blob: 028e36d27ca49a625a260437b7f0dcb07b176eb9 [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 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530567 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 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;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530640 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
641 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530643 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800645 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 break;
647 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530648 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
649 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
650 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800652 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 return eHAL_STATUS_FAILURE;
654 }
655 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 return (status);
657}
658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659eHalStatus csrRoamClose(tpAniSirGlobal pMac)
660{
661 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
663 {
664 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
665 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530666 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
667 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
668 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
669 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 return (eHAL_STATUS_SUCCESS);
671}
672
Jeff Johnson295189b2012-06-20 16:38:30 -0700673eHalStatus csrRoamStart(tpAniSirGlobal pMac)
674{
675 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 return (eHAL_STATUS_SUCCESS);
677}
678
Jeff Johnson295189b2012-06-20 16:38:30 -0700679void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
680{
681 csrRoamStopRoamingTimer(pMac, sessionId);
682 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
683 csrRoamDeregStatisticsReq(pMac);
684}
Jeff Johnson295189b2012-06-20 16:38:30 -0700685eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
686{
687 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800688 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 {
690 status = eHAL_STATUS_SUCCESS;
691 *pState = pMac->roam.roamSession[sessionId].connectState;
692 }
693 return (status);
694}
695
Jeff Johnson295189b2012-06-20 16:38:30 -0700696eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
697{
698 eHalStatus status = eHAL_STATUS_FAILURE;
699 tANI_U32 size = 0;
700 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700701
702 if(!pSession)
703 {
704 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
705 return eHAL_STATUS_FAILURE;
706 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
708 if(pProfile)
709 {
710 if(pSession->pConnectBssDesc)
711 {
712 do
713 {
714 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
715 if(size)
716 {
717 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
718 if(HAL_STATUS_SUCCESS(status))
719 {
720 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
721 }
722 else
723 break;
724 }
725 else
726 {
727 pProfile->pBssDesc = NULL;
728 }
729 pProfile->AuthType = pSession->connectedProfile.AuthType;
730 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
731 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
732 pProfile->BSSType = pSession->connectedProfile.BSSType;
733 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
734 pProfile->CBMode = pSession->connectedProfile.CBMode;
735 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
736 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
737#ifdef WLAN_FEATURE_VOWIFI_11R
738 if (pSession->connectedProfile.MDID.mdiePresent)
739 {
740 pProfile->MDID.mdiePresent = 1;
741 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
742 }
743 else
744 {
745 pProfile->MDID.mdiePresent = 0;
746 pProfile->MDID.mobilityDomain = 0;
747 }
748#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700749#ifdef FEATURE_WLAN_CCX
750 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
752 {
753 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
754 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
755 pProfile->ccxCckmInfo.reassoc_req_num=
756 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
757 pProfile->ccxCckmInfo.krk_plumbed =
758 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
759 }
760#endif
761 }while(0);
762 }
763 }
764
765 return (status);
766}
767
Jeff Johnson295189b2012-06-20 16:38:30 -0700768eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
769{
770 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700771
772 if((csrIsConnStateConnected(pMac, sessionId)) ||
773 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 {
775 if(pProfile)
776 {
777 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
778 }
779 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 return (status);
781}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700782
Jeff Johnson295189b2012-06-20 16:38:30 -0700783eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
784{
785 eHalStatus status = eHAL_STATUS_SUCCESS;
786
787 if(pProfile->pBssDesc)
788 {
789 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
790 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700791 if(pProfile->pAddIEAssoc)
792 {
793 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
794 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
796 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
797 return (status);
798}
799
Jeff Johnson295189b2012-06-20 16:38:30 -0700800static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
801{
802 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 if( pConnectedInfo->pbFrames )
804 {
805 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
806 pConnectedInfo->pbFrames = NULL;
807 }
808 pConnectedInfo->nBeaconLength = 0;
809 pConnectedInfo->nAssocReqLength = 0;
810 pConnectedInfo->nAssocRspLength = 0;
811 pConnectedInfo->staId = 0;
812#ifdef WLAN_FEATURE_VOWIFI_11R
813 pConnectedInfo->nRICRspLength = 0;
814#endif
815#ifdef FEATURE_WLAN_CCX
816 pConnectedInfo->nTspecIeLength = 0;
817#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 return ( status );
819}
820
Jeff Johnson295189b2012-06-20 16:38:30 -0700821
822
Jeff Johnsone7245742012-09-05 17:12:55 -0700823
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700824void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
825{
826 csrReinitPreauthCmd(pMac, pCommand);
827 csrReleaseCommand( pMac, pCommand );
828}
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
831{
832 csrReinitRoamCmd(pMac, pCommand);
833 csrReleaseCommand( pMac, pCommand );
834}
835
Jeff Johnson295189b2012-06-20 16:38:30 -0700836void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
837{
838 csrReinitScanCmd(pMac, pCommand);
839 csrReleaseCommand( pMac, pCommand );
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
843{
844 csrReinitWmStatusChangeCmd(pMac, pCommand);
845 csrReleaseCommand( pMac, pCommand );
846}
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
849{
850 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
851}
852
Jeff Johnson295189b2012-06-20 16:38:30 -0700853void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
854{
855 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
856}
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
859{
860 csrReinitSetKeyCmd(pMac, pCommand);
861 csrReleaseCommand( pMac, pCommand );
862}
Jeff Johnson295189b2012-06-20 16:38:30 -0700863void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
864{
865 csrReinitRemoveKeyCmd(pMac, pCommand);
866 csrReleaseCommand( pMac, pCommand );
867}
Jeff Johnson295189b2012-06-20 16:38:30 -0700868void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
869{
870
871 if( eSmeCsrCommandMask & pCommand->command )
872 {
873 switch (pCommand->command)
874 {
875 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800876 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800877 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700878 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 if (NULL != pCommand->u.scanCmd.callback)
880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800881 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
883 }
884 csrReleaseCommandScan( pMac, pCommand );
885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 case eSmeCommandRoam:
887 csrReleaseCommandRoam( pMac, pCommand );
888 break;
889
890 case eSmeCommandWmStatusChange:
891 csrReleaseCommandWmStatusChange( pMac, pCommand );
892 break;
893
894 case eSmeCommandSetKey:
895 csrReleaseCommandSetKey( pMac, pCommand );
896 break;
897
898 case eSmeCommandRemoveKey:
899 csrReleaseCommandRemoveKey( pMac, pCommand );
900 break;
901
902 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800903 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 csrReleaseCommand( pMac, pCommand );
905 break;
906 }
907 }
908}
909
Jeff Johnson295189b2012-06-20 16:38:30 -0700910void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
911{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800912 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 if(pMac->roam.curSubState[sessionId] == NewSubstate)
915 {
916 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700917 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 pMac->roam.curSubState[sessionId] = NewSubstate;
919}
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
922{
923 eCsrRoamState PreviousState;
924
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800925 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700926
927 PreviousState = pMac->roam.curState[sessionId];
928
929 if ( NewRoamState != pMac->roam.curState[sessionId] )
930 {
931 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
932 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
933 {
934 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
935 }
936
937 pMac->roam.curState[sessionId] = NewRoamState;
938 }
939 return( PreviousState );
940}
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
943{
944 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 if(catOffset)
946 {
947 pMac->roam.configParam.bCatRssiOffset = catOffset;
948 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
949 {
950 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
951 }
952 }
953}
954
Jeff Johnson295189b2012-06-20 16:38:30 -0700955static void initConfigParam(tpAniSirGlobal pMac)
956{
957 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
959 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
960 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700961
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
963 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
964 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
965 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
966 pMac->roam.configParam.HeartbeatThresh24 = 40;
967 pMac->roam.configParam.HeartbeatThresh50 = 40;
968 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
969 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
970 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700971 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 pMac->roam.configParam.RTSThreshold = 2346;
973 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
974 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
975 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
976 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
977 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
978 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
979 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
980 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
981 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
982 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
983 {
984 pMac->roam.configParam.BssPreferValue[i] = i;
985 }
986 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
987 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
988 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
989 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
991 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
992 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
993 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
994 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
995 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800996 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
997 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700998 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700999#ifdef WLAN_AP_STA_CONCURRENCY
1000 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1001 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1002 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1003 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1004 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001005 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1006 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001007#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1009 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1010 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1011 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001012#ifdef WLAN_FEATURE_VOWIFI_11R
1013 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1014#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001015#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1016 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1017 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1018 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1019 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1020 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1021 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1022 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1023 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1024 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1025 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1026 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001027 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001028#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001029#ifdef WLAN_FEATURE_11AC
1030 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1031#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001032
1033 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1034 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001035
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001036 //Remove this code once SLM_Sessionization is supported
1037 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001038 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
Jeff Johnsone7245742012-09-05 17:12:55 -07001040}
Jeff Johnson295189b2012-06-20 16:38:30 -07001041eCsrBand csrGetCurrentBand(tHalHandle hHal)
1042{
1043 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1044 return pMac->roam.configParam.bandCapability;
1045}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001046
1047#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1048tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
1049{
1050 /* Get country code from CFG */
1051 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
1052 tANI_U8 i = 0;
1053 v_BOOL_t retVal = FALSE;
1054 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1055 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1056
1057 /* Compare against KR valid list */
1058 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1059 (NULL != pCountryValidChannelList))
1060 {
1061 for (i = 0; i <(*pNumChannels); i++)
1062 {
1063 if (channel == pCountryValidChannelList[i])
1064 {
1065 retVal = TRUE;
1066 break;
1067 }
1068 }
1069 }
1070 else
1071 {
1072 retVal = csrRoamIsChannelValid(pMac, channel);
1073 }
1074
1075 return retVal;
1076}
1077
1078void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1079{
1080 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1081 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1082}
1083
1084/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001085 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001086*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001087eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001088{
1089 eHalStatus status = eHAL_STATUS_SUCCESS;
1090 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1091
1092 /* Free up the memory first (if required) */
1093 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1094 {
1095 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1096 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001097 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001098 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001099 return status;
1100}
1101
1102
1103
1104/*
1105 This function flushes the roam scan cache and creates fresh cache
1106 based on the input channel list
1107*/
1108eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1109 const tANI_U8 *pChannelList,
1110 const tANI_U8 numChannels)
1111{
1112 eHalStatus status = eHAL_STATUS_SUCCESS;
1113 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1114
Srinivas Girigowdade697412013-02-14 16:31:48 -08001115 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1116
1117 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1118 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1119
1120 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1121 {
1122 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1123 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1124 return eHAL_STATUS_RESOURCES;
1125 }
1126
1127 /* Update the roam global structure */
1128 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1129 pChannelList,
1130 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1131 return status;
1132}
1133
1134/* This function modifies the bgscan channel list set via config ini or
1135 runtime, whenever the band changes.
1136 if the band is auto, then no operation is performed on the channel list
1137 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1138 if the band is 5G, then make sure channel list contains only 5G valid channels
1139*/
1140eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1141 eCsrBand eBand)
1142{
1143 eHalStatus status = eHAL_STATUS_SUCCESS;
1144 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1145 tANI_U8 outNumChannels = 0;
1146 tANI_U8 inNumChannels = 0;
1147 tANI_U8 *inPtr = NULL;
1148 tANI_U8 i = 0;
1149 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1150
1151 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1152
1153 {
1154 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1155 "No update required for channel list "
1156 "either cfg.ini channel list is not set up or "
1157 "auto band (Band %d)", eBand);
1158 return status;
1159 }
1160
1161 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1162 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1163 if (eCSR_BAND_24 == eBand)
1164 {
1165 for (i = 0; i < inNumChannels; i++)
1166 {
1167 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1168 {
1169 ChannelList[outNumChannels++] = inPtr[i];
1170 }
1171 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001172 csrFlushBgScanRoamChannelList(pMac);
1173 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001174 }
1175 else if (eCSR_BAND_5G == eBand)
1176 {
1177 for (i = 0; i < inNumChannels; i++)
1178 {
1179 /* Add 5G Non-DFS channel */
1180 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1181 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1182 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1183 {
1184 ChannelList[outNumChannels++] = inPtr[i];
1185 }
1186 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001187 csrFlushBgScanRoamChannelList(pMac);
1188 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001189 }
1190 else if (eCSR_BAND_ALL == eBand)
1191 {
1192 for (i = 0; i < inNumChannels; i++)
1193 {
1194 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1195 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1196 {
1197 ChannelList[outNumChannels++] = inPtr[i];
1198 }
1199 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001200 csrFlushBgScanRoamChannelList(pMac);
1201 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001202 }
1203 else
1204 {
1205 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1206 "Invalid band, No operation carried out (Band %d)", eBand);
1207 status = eHAL_STATUS_INVALID_PARAMETER;
1208 }
1209
1210 return status;
1211}
1212
1213/*
1214 This function initializes the valid channel list based on country code
1215*/
1216eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1217 tANI_U8 Revision)
1218{
1219 eHalStatus status = eHAL_STATUS_SUCCESS;
1220 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001221 tANI_U8 **pOutChannelList = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001222 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1223 const tANI_U8 *pChannelList = NULL;
1224
1225 if (SME_KR_3 == Revision)
1226 {
1227 pChannelList = KR_3;
1228 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1229 }
1230 else if (SME_KR_24 == Revision)
1231 {
1232 pChannelList = KR_24;
1233 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1234 }
1235 else if (SME_KR_25 == Revision)
1236 {
1237 pChannelList = KR_25;
1238 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1239 }
1240 else
1241 return eHAL_STATUS_INVALID_PARAMETER;
1242
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001243 /* Free any existing channel list */
1244 vos_mem_free(*pOutChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001245
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001246 *pOutChannelList = vos_mem_malloc(*pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001247
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001248 if (NULL == *pOutChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001249 {
1250 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1251 *pNumChannels = 0;
1252 return eHAL_STATUS_RESOURCES;
1253 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001254 /* Update the roam global structure */
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001255 palCopyMemory(pMac->hHdd, *pOutChannelList, pChannelList, *pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001256 return status;
1257}
1258
1259#endif
1260
Jeff Johnson295189b2012-06-20 16:38:30 -07001261eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1262{
1263 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1264 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1266 (eBand == eCSR_BAND_24))
1267 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001268 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001270 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001271 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 pMac->roam.configParam.uCfgDot11Mode, eBand);
1273 return eHAL_STATUS_INVALID_PARAMETER;
1274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1276 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1277 (eBand == eCSR_BAND_5G))
1278 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001279 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001281 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001282 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 pMac->roam.configParam.uCfgDot11Mode, eBand);
1284 return eHAL_STATUS_INVALID_PARAMETER;
1285 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001287 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001288 pMac->roam.configParam.eBand = eBand;
1289 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001291#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1292 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1293#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 status = csrInitGetChannels( pMac );
1295 if (eHAL_STATUS_SUCCESS == status)
1296 csrInitChannelList( hHal );
1297 return status;
1298}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001299
1300
Jeff Johnsone7245742012-09-05 17:12:55 -07001301/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1302 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1303 * Ideally we should have kept the ini value and enum value same and representing the same
1304 * cb values as in 11n standard i.e.
1305 * Set to 1 (SCA) if the secondary channel is above the primary channel
1306 * Set to 3 (SCB) if the secondary channel is below the primary channel
1307 * Set to 0 (SCN) if no secondary channel is present
1308 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1309 * 0 - secondary none
1310 * 1 - secondary LOW
1311 * 2 - secondary HIGH
1312 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1313 * The enum values are as follows:
1314 * PHY_SINGLE_CHANNEL_CENTERED = 0
1315 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1316 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1317 */
1318ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1319{
1320
1321 ePhyChanBondState phyCbState;
1322 switch (cbIniValue) {
1323 // secondary none
1324 case 0:
1325 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1326 break;
1327 // secondary LOW
1328 case 1:
1329 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1330 break;
1331 // secondary HIGH
1332 case 2:
1333 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1334 break;
1335#ifdef WLAN_FEATURE_11AC
1336 case 3:
1337 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1338 break;
1339 case 4:
1340 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1341 break;
1342 case 5:
1343 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1344 break;
1345 case 6:
1346 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1347 break;
1348 case 7:
1349 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1350 break;
1351 case 8:
1352 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1353 break;
1354 case 9:
1355 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1356 break;
1357#endif
1358 default:
1359 // If an invalid value is passed, disable CHANNEL BONDING
1360 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1361 break;
1362 }
1363 return phyCbState;
1364}
1365
1366v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1367{
1368
1369 v_U32_t cbIniValue;
1370 switch (phyCbState) {
1371 // secondary none
1372 case PHY_SINGLE_CHANNEL_CENTERED:
1373 cbIniValue = 0;
1374 break;
1375 // secondary LOW
1376 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1377 cbIniValue = 1;
1378 break;
1379 // secondary HIGH
1380 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1381 cbIniValue = 2;
1382 break;
1383#ifdef WLAN_FEATURE_11AC
1384 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1385 cbIniValue = 3;
1386 break;
1387 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1388 cbIniValue = 4;
1389 break;
1390 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1391 cbIniValue = 5;
1392 break;
1393 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1394 cbIniValue = 6;
1395 break;
1396 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1397 cbIniValue = 7;
1398 break;
1399 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1400 cbIniValue = 8;
1401 break;
1402 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1403 cbIniValue = 9;
1404 break;
1405#endif
1406 default:
1407 // return some invalid value
1408 cbIniValue = 10;
1409 break;
1410 }
1411 return cbIniValue;
1412}
Jeff Johnson295189b2012-06-20 16:38:30 -07001413
1414eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1415{
1416 eHalStatus status = eHAL_STATUS_SUCCESS;
1417
1418 if(pParam)
1419 {
1420 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1421 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1422 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1423 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1424 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1425 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1426
1427 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001428 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1429
Jeff Johnsone7245742012-09-05 17:12:55 -07001430 /* channelBondingMode5GHz plays a dual role right now
1431 * 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
1432 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1433 */
1434 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001436 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001437 }
1438 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1439 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001441 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001442 }
1443 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1445 pMac->roam.configParam.phyMode = pParam->phyMode;
1446 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1447 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1448 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1449 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1450 pMac->roam.configParam.TxRate = pParam->TxRate;
1451 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1452 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1453 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1454 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1455 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001456 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 //if HDD passed down non zero values then only update,
1458 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001459 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 {
1461 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1462 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001463 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 {
1465 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1466 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001467 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 {
1469 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1470 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001471 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 {
1473 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1474 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001475 if (pParam->nActiveMaxChnTimeBtc)
1476 {
1477 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1478 }
1479 if (pParam->nActiveMinChnTimeBtc)
1480 {
1481 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1482 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001483#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001484 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001485 {
1486 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1487 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001488 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001489 {
1490 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1491 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001492 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001493 {
1494 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1495 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001496 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001497 {
1498 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1499 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001500 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001501 {
1502 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1503 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001504 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001505 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001506 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1507 }
1508 if (pParam->nNumP2PChanCombinedConc)
1509 {
1510 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001511 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001512#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001514 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 {
1516 //Change the unit from second to microsecond
1517 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1519 {
1520 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1521 }
1522 else
1523 {
1524 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1525 }
1526 }
1527 else
1528 {
1529 pMac->roam.configParam.impsSleepTime = 0;
1530 }
1531 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1533 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 //if HDD passed down non zero values for age params, then only update,
1535 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001536 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 {
1538 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 if(pParam->scanAgeTimeNCNPS)
1541 {
1542 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 if(pParam->scanAgeTimeNCPS)
1545 {
1546 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 if(pParam->scanAgeTimeCNPS)
1549 {
1550 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1551 }
1552 if(pParam->scanAgeTimeCPS)
1553 {
1554 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1555 }
1556
1557 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1558 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1559 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1560 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1561 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1562 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1564 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1566 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1567 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1568 //Assign this before calling CsrInit11dInfo
1569 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 if( csrIs11dSupported( pMac ) )
1571 {
1572 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1573 }
1574 else
1575 {
1576 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1577 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001578
1579 /* Initialize the power + channel information if 11h is enabled.
1580 If 11d is enabled this information has already been initialized */
1581 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1582 {
1583 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1584 }
1585
1586
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301587#ifdef WLAN_FEATURE_VOWIFI_11R
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001589 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001590#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001591#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001593 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001594 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001595 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001596 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001597 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001598 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001599 pMac->roam.configParam.nProbes = pParam->nProbes;
1600 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001601#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001602#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1603 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001604 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001605#endif
1606#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001607 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1608#endif
1609
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301610#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001613#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1614 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001615 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1616 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1617 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1618 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1619 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1620 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1621 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1622 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 {
1624 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001625 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 -07001626 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1627 {
1628 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1629 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001630 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 }
1632#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1634 pMac->scan.fValidateList = pParam->fValidateList;
1635 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1636 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001637 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1640 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1641 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1642 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1643 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1644 * single session
1645 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001646 //Remove this code once SLM_Sessionization is supported
1647 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001648 pMac->roam.configParam.doBMPSWorkaround = 0;
1649
Jeff Johnsone7245742012-09-05 17:12:55 -07001650#ifdef WLAN_FEATURE_11AC
1651 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001652 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001653 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001654 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001655#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001656 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni4f087d22013-07-29 16:32:26 -07001657 pMac->roam.configParam.enableOxygenNwk = pParam->enableOxygenNwk;
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 }
1659
1660 return status;
1661}
1662
Jeff Johnson295189b2012-06-20 16:38:30 -07001663eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1664{
1665 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 if(pParam)
1667 {
1668 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1669 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1670 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1671 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1672 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1673 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001674 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1675 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1677 pParam->phyMode = pMac->roam.configParam.phyMode;
1678 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1679 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1680 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1681 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1682 pParam->TxRate = pMac->roam.configParam.TxRate;
1683 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1684 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1685 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1686 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1687 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1689 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1690 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1691 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001692 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1693 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1694 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001695#ifdef WLAN_AP_STA_CONCURRENCY
1696 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1697 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1698 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1699 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1700 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001701 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1702 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 //Change the unit from microsecond to second
1705 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1706 pParam->eBand = pMac->roam.configParam.eBand;
1707 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1708 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1709 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1710 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1711 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1712 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1713 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1714 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1715 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1716 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1717 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1718 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1719 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1721 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1722 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1723 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1725 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1726 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1727 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1728 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001729 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001730 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001731 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001732 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001733
1734#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1735 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1736#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001737#ifdef WLAN_FEATURE_11AC
1738 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001739 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001740 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001741#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001742#ifdef WLAN_FEATURE_VOWIFI_11R
1743 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1744#endif
1745#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1746 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1747 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1748 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1749 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1750 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001751 pParam->nProbes = pMac->roam.configParam.nProbes;
1752 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001753#endif
1754#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1755 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1756 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1757#endif
1758#ifdef FEATURE_WLAN_LFR
1759 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1760#endif
1761
1762#ifdef FEATURE_WLAN_CCX
1763 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1764#endif
1765#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1766 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1767 {
1768 int i;
1769 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1770 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1771 {
1772 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1773 }
1774 smsLog( pMac, LOG1, "");
1775 }
1776#endif
1777
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001778 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001779 pParam->enableOxygenNwk = pMac->roam.configParam.enableOxygenNwk;
1780
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 csrSetChannels(pMac, pParam);
1782
1783 status = eHAL_STATUS_SUCCESS;
1784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 return (status);
1786}
1787
Jeff Johnson295189b2012-06-20 16:38:30 -07001788eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1789{
1790 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1791 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1792 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1793 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 do
1795 {
1796 if(eCSR_BAND_24 == eBand)
1797 {
1798 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1799 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1800 }
1801 if(eCSR_BAND_5G == eBand)
1802 {
1803 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1804 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1805 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1806 )
1807 {
1808 break;
1809 }
1810 }
1811 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1812 {
1813 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1814 }
1815 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1816 {
1817 newPhyMode = eCSR_DOT11_MODE_AUTO;
1818 }
1819 else
1820 {
1821 //Check for dual band and higher capability first
1822 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1823 {
1824 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1825 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1826 }
1827 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1828 {
1829 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1830 if(eCSR_BAND_24 == eBand) break;
1831 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1832 eBand = eCSR_BAND_5G;
1833 }
1834 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1835 {
1836 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1837 if(eCSR_BAND_5G == eBand) break;
1838 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1839 eBand = eCSR_BAND_24;
1840 }
1841 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1842 {
1843 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1844 if(eCSR_BAND_5G == eBand) break;
1845 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1846 eBand = eCSR_BAND_24;
1847 }
1848 else if(eCSR_DOT11_MODE_11n & phyMode)
1849 {
1850 newPhyMode = eCSR_DOT11_MODE_11n;
1851 }
1852 else if(eCSR_DOT11_MODE_abg & phyMode)
1853 {
1854 newPhyMode = eCSR_DOT11_MODE_abg;
1855 }
1856 else if(eCSR_DOT11_MODE_11a & phyMode)
1857 {
1858 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1859 {
1860 if(eCSR_BAND_ALL == eBand)
1861 {
1862 newPhyMode = eCSR_DOT11_MODE_abg;
1863 }
1864 else
1865 {
1866 //bad setting
1867 break;
1868 }
1869 }
1870 else
1871 {
1872 newPhyMode = eCSR_DOT11_MODE_11a;
1873 eBand = eCSR_BAND_5G;
1874 }
1875 }
1876 else if(eCSR_DOT11_MODE_11g & phyMode)
1877 {
1878 newPhyMode = eCSR_DOT11_MODE_11g;
1879 eBand = eCSR_BAND_24;
1880 }
1881 else if(eCSR_DOT11_MODE_11b & phyMode)
1882 {
1883 newPhyMode = eCSR_DOT11_MODE_11b;
1884 eBand = eCSR_BAND_24;
1885 }
1886 else
1887 {
1888 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001889 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 newPhyMode = eCSR_DOT11_MODE_AUTO;
1891 }
1892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 //Done validating
1894 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 //Now we need to check whether a restart is needed.
1896 if(eBand != pMac->roam.configParam.eBand)
1897 {
1898 fRestartNeeded = eANI_BOOLEAN_TRUE;
1899 break;
1900 }
1901 if(newPhyMode != pMac->roam.configParam.phyMode)
1902 {
1903 fRestartNeeded = eANI_BOOLEAN_TRUE;
1904 break;
1905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 if(HAL_STATUS_SUCCESS(status))
1908 {
1909 pMac->roam.configParam.eBand = eBand;
1910 pMac->roam.configParam.phyMode = newPhyMode;
1911 if(pfRestartNeeded)
1912 {
1913 *pfRestartNeeded = fRestartNeeded;
1914 }
1915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 return (status);
1917}
1918
Jeff Johnson295189b2012-06-20 16:38:30 -07001919void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1920{
1921 tANI_U8 Index;
1922 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 // for dual band NICs, don't need to trim the channel list....
1924 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1925 {
1926 // 2.4 GHz band operation requires the channel list to be trimmed to
1927 // the 2.4 GHz channels only...
1928 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1929 {
1930 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1931 Index++ )
1932 {
1933 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1934 {
1935 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1936 cChannels++;
1937 }
1938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1940 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1941 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1942 // only if we need to.
1943 //
1944 // The amount of memory to clear is the number of channesl that we trimmed
1945 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1946
1947 if ( pChannelList->numChannels > cChannels )
1948 {
1949 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1950 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1951
1952 }
1953
1954 pChannelList->numChannels = cChannels;
1955 }
1956 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1957 {
1958 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1959 {
1960 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1961 {
1962 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1963 cChannels++;
1964 }
1965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1967 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1968 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1969 // only if we need to.
1970 //
1971 // The amount of memory to clear is the number of channesl that we trimmed
1972 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1973 if ( pChannelList->numChannels > cChannels )
1974 {
1975 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1976 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1977 }
1978
1979 pChannelList->numChannels = cChannels;
1980 }
1981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001982}
Jeff Johnson295189b2012-06-20 16:38:30 -07001983#define INFRA_AP_DEFAULT_CHANNEL 6
1984eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1985{
1986 tANI_U8 index= 0;
1987 eHalStatus status = eHAL_STATUS_FAILURE;
1988 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1989 {
1990 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1991 status = eHAL_STATUS_SUCCESS;
1992 break;
1993 }
1994 }
1995 return status;
1996}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001997
1998eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1999{
2000 eHalStatus status = eHAL_STATUS_SUCCESS;
2001 tANI_U8 num20MHzChannelsFound = 0;
2002 VOS_STATUS vosStatus;
2003 tANI_U8 num40MHzChannelsFound = 0;
2004 tANI_U8 Index = 0;
2005 tANI_U8 channelList = 0;
2006
2007 // Updating the defaultpower Table for changed Domain Id
2008 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2009 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2010
2011 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2012 {
2013 smsLog( pMac, LOGE, FL("failed to get channels"));
2014 status = eHAL_STATUS_FAILURE;
2015 }
2016 else
2017 {
2018 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2019 {
2020 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2021 }
2022
2023 // Move the only 5GHZ channel list to the global data,
2024 // As 2.4GHZ list coming from the AP for the changed domain
2025 // structure -- this will be used as the scan list
2026 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
2027 {
2028 // If Channel is 5GHz just break the for loop
2029 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
2030 break;
2031 }
2032 // Update the 5G channels from nv.bin
2033 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2034 {
2035 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
2036 {
Krunal Sonia75019a2013-05-01 01:08:22 -07002037 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
2038 {
2039 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
2040 channelList++;
2041 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002042 }
2043 }
2044
2045 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
2046 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
2047 // Filling the remaining index as Zero Just for causion
2048 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
2049 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
2050 }
2051 return status;
2052}
2053
2054eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
2055{
2056 eHalStatus status = eHAL_STATUS_SUCCESS;
2057 tANI_U8 num20MHzChannelsFound = 0;
2058 VOS_STATUS vosStatus;
2059 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302060 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002061 tANI_U8 num40MHzChannelsFound = 0;
2062 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
2063 tANI_U8 channelList = 0;
2064
2065 // Read the scan channel list (including the power limit) from EEPROM
2066 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2067 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2068
2069 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2070 {
2071 smsLog( pMac, LOGE, FL("failed to get channels \n"));
2072 status = eHAL_STATUS_FAILURE;
2073 }
2074 else
2075 {
2076 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2077 {
2078 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2079 }
2080
2081 // Move the 2.4GHZ channel list only to the global data,
2082 // As 5GHz list been provided by AP as part of 11d IE
2083 // structure -- this will be used as the scan list
2084 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
2085 {
2086 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
2087 {
2088 // First taking the 5GHz channel list backup
2089 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2090 nuum5GchannelListBackup++;
2091 }
2092 }
2093 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302094 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002095 {
2096 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302097 {
2098 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2099 numChan++;
2100 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002101 }
2102 // Restoring the Backed up 5 GHZ channels
2103 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2104 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302105 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002106 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302107 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2108 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002109 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002110 }
2111
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302112 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2113 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002114 }
2115 return (status);
2116}
2117
Jeff Johnson295189b2012-06-20 16:38:30 -07002118eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2119{
2120 eHalStatus status = eHAL_STATUS_SUCCESS;
2121 tANI_U8 num20MHzChannelsFound = 0;
2122 VOS_STATUS vosStatus;
2123 tANI_U8 Index = 0;
2124 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002125
Jeff Johnson295189b2012-06-20 16:38:30 -07002126
2127 //TODO: this interface changed to include the 40MHz channel list
2128 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2129 // Read the scan channel list (including the power limit) from EEPROM
2130 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2131 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2132 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002134 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 status = eHAL_STATUS_FAILURE;
2136 }
2137 else
2138 {
2139 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2140 {
2141 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2142 }
2143 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2144 // Move the channel list to the global data
2145 // structure -- this will be used as the scan list
2146 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2147 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
2150 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2151 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2152 {
2153 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2154 }
2155 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2156 {
2157 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2158 }
2159 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 return (status);
2162}
2163
Jeff Johnson295189b2012-06-20 16:38:30 -07002164eHalStatus csrInitChannelList( tHalHandle hHal )
2165{
2166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2167 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2169 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002170 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2171 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002173 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002174
2175 return (status);
2176}
Jeff Johnson295189b2012-06-20 16:38:30 -07002177eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2178 tCsrUpdateConfigParam *pUpdateConfigParam)
2179{
2180 eHalStatus status = eHAL_STATUS_FAILURE;
2181 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2183 status = CsrInit11dInfo(pMac, ps11dinfo);
2184 return status;
2185}
2186
Jeff Johnson295189b2012-06-20 16:38:30 -07002187static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2188{
2189 eHalStatus status = eHAL_STATUS_FAILURE;
2190 tANI_U8 index;
2191 tANI_U32 count=0;
2192 tSirMacChanInfo *pChanInfo;
2193 tSirMacChanInfo *pChanInfoStart;
2194 tANI_BOOLEAN applyConfig = TRUE;
2195
2196 if(!ps11dinfo)
2197 {
2198 return (status);
2199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2201 {
2202 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2203 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2204 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2205 if(!HAL_STATUS_SUCCESS(status)) return (status);
2206 }
2207 else
2208 {
2209 //No change
2210 return (eHAL_STATUS_SUCCESS);
2211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 //legacy maintenance
2213 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2214 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2215 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 //Tush: at csropen get this initialized with default, during csr reset if this
2217 // already set with some value no need initilaize with default again
2218 if(0 == pMac->scan.countryCodeCurrent[0])
2219 {
2220 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2221 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2222 if(!HAL_STATUS_SUCCESS(status)) return (status);
2223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 // need to add the max power channel list
2225 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2226 {
2227 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2228 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002229 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2230 {
2231 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2232 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2233 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2234 pChanInfo++;
2235 count++;
2236 }
2237 if(count)
2238 {
2239 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2240 }
2241 palFreeMemory(pMac->hHdd, pChanInfoStart);
2242 }
2243 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2244 if( HAL_STATUS_SUCCESS(status) )
2245 {
2246 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2247 {
2248 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2249 {
2250 applyConfig = FALSE;
2251 }
2252 }
2253
2254 if(TRUE == applyConfig)
2255 {
2256 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002257 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002258 }
2259
2260 }
2261 return (status);
2262}
2263/* Initialize the Channel + Power List in the local cache and in the CFG */
2264eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2265{
2266 tANI_U8 index;
2267 tANI_U32 count=0;
2268 tSirMacChanInfo *pChanInfo;
2269 tSirMacChanInfo *pChanInfoStart;
2270
2271 if(!ps11dinfo || !pMac)
2272 {
2273 return eHAL_STATUS_FAILURE;
2274 }
2275
2276 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2277 {
2278 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2279 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280
2281 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2282 {
2283 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2284 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2285 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2286 pChanInfo++;
2287 count++;
2288 }
2289 if(count)
2290 {
2291 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2292 }
2293 palFreeMemory(pMac->hHdd, pChanInfoStart);
2294 }
2295
Jeff Johnsone7245742012-09-05 17:12:55 -07002296 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002297}
2298
2299//pCommand may be NULL
2300//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2301void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2302{
2303 tListElem *pEntry, *pNextEntry;
2304 tSmeCmd *pDupCommand;
2305 tDblLinkList localList;
2306
2307 vos_mem_zero(&localList, sizeof(tDblLinkList));
2308 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2309 {
2310 smsLog(pMac, LOGE, FL(" failed to open list"));
2311 return;
2312 }
2313 csrLLLock( &pMac->sme.smeCmdPendingList );
2314 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2315 while( pEntry )
2316 {
2317 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2318 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 // Remove the previous command if..
2320 // - the new roam command is for the same RoamReason...
2321 // - the new roam command is a NewProfileList.
2322 // - the new roam command is a Forced Dissoc
2323 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2324 if (
2325 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2326 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002327 /* This peermac check is requried for Softap/GO scenarios
2328 * For STA scenario below OR check will suffice as pCommand will
2329 * always be NULL for STA scenarios
2330 */
2331 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2333 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2334 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2335 ||
2336 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002337 ( (sessionId == pDupCommand->sessionId) &&
2338 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 ((eCsrForcedDisassoc == eRoamReason) ||
2340 (eCsrHddIssued == eRoamReason))
2341 )
2342 )
2343 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002344 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 // Remove the 'stale' roam command from the pending list...
2346 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2347 {
2348 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2349 }
2350 }
2351 pEntry = pNextEntry;
2352 }
2353 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2354
2355 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2356 {
2357 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2358 //Tell caller that the command is cancelled
2359 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2360 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2361 csrReleaseCommandRoam(pMac, pDupCommand);
2362 }
2363 csrLLClose(&localList);
2364}
Jeff Johnson295189b2012-06-20 16:38:30 -07002365eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2366 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2367{
2368 eHalStatus status = eHAL_STATUS_SUCCESS;
2369#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2370 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2371#endif
2372 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2374 {
2375 pSession = CSR_GET_SESSION( pMac, sessionId );
2376 }
2377 else
2378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002379 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 VOS_ASSERT(0);
2381 return eHAL_STATUS_FAILURE;
2382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002385 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002387 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2388 /*
2389 * Decrement bRefAssocStartCnt for FT reassoc failure.
2390 * Reason: For FT reassoc failures, we first call
2391 * csrRoamCallCallback before notifying a failed roam
2392 * completion through csrRoamComplete. The latter in
2393 * turn calls csrRoamProcessResults which tries to
2394 * once again call csrRoamCallCallback if bRefAssocStartCnt
2395 * is non-zero. Since this is redundant for FT reassoc
2396 * failure, decrement bRefAssocStartCnt.
2397 */
2398 pSession->bRefAssocStartCnt--;
2399 }
2400
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 if ( (pSession == NULL) ||
2402 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002404 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 return eHAL_STATUS_FAILURE;
2406 }
2407
2408 if(NULL != pSession->callback)
2409 {
2410 if( pRoamInfo )
2411 {
2412 pRoamInfo->sessionId = (tANI_U8)sessionId;
2413 }
2414
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302415 /* avoid holding the global lock when making the roaming callback, original change came
2416 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2417 is possible on other OS ports where the callback may need to take locks to protect
2418 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2420 that may actually depend on the lock being held */
2421 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2422 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2423 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2424 }
2425 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2426 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2427#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2428 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2429 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2430 {
2431 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2432 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2433 if(NULL != pRoamInfo->pBssDesc)
2434 {
2435 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2436 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2439 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2440 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2441 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2442 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2443 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2446 {
2447 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2448 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2449 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 if(eCSR_ROAM_RESULT_FORCED == u2)
2452 {
2453 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2454 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2455 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2458 {
2459 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2460 connectionStatus.reason = eCSR_REASON_DISASSOC;
2461 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2464 {
2465 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2466 connectionStatus.reason = eCSR_REASON_DEAUTH;
2467 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002469#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2470
2471 return (status);
2472}
Jeff Johnson295189b2012-06-20 16:38:30 -07002473// Returns whether handoff is currently in progress or not
2474tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2475{
2476#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2477 return csrNeighborRoamIsHandoffInProgress(pMac);
2478#else
2479 return eANI_BOOLEAN_FALSE;
2480#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002481}
Jeff Johnson295189b2012-06-20 16:38:30 -07002482eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2483 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2484{
2485 eHalStatus status = eHAL_STATUS_SUCCESS;
2486 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2487 tANI_U16 reasonCode;
2488 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002489
2490 if(!pSession)
2491 {
2492 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2493 return eHAL_STATUS_FAILURE;
2494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002495
2496 //Restore AC weight in case we change it
2497 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2498 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002499 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 -07002500 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2501 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2502 }
2503
2504 if ( fMICFailure )
2505 {
2506 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2507 }
2508 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2509 {
2510 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002511 }
2512 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 {
2514 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002516#ifdef WLAN_FEATURE_VOWIFI_11R
2517 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2518 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2519 {
2520 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2521 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002522 }
2523 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002524#endif
2525 if(pSession->pConnectBssDesc)
2526 {
2527 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2528 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002529
Jeff Johnson295189b2012-06-20 16:38:30 -07002530
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002531 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2532 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2533 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2534
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2536
2537 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2538
2539 if(HAL_STATUS_SUCCESS(status))
2540 {
2541 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002542#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2543 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2544 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2545 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002546 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2548 }
2549#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002550 }
2551 else
2552 {
2553 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2554 }
2555
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 return (status);
2557}
Jeff Johnson295189b2012-06-20 16:38:30 -07002558
Jeff Johnson295189b2012-06-20 16:38:30 -07002559/* ---------------------------------------------------------------------------
2560 \fn csrRoamIssueDisassociateStaCmd
2561 \brief csr function that HDD calls to disassociate a associated station
2562 \param sessionId - session Id for Soft AP
2563 \param pPeerMacAddr - MAC of associated station to delete
2564 \param reason - reason code, be one of the tSirMacReasonCodes
2565 \return eHalStatus
2566 ---------------------------------------------------------------------------*/
2567eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2568 tANI_U32 sessionId,
2569 tANI_U8 *pPeerMacAddr,
2570 tANI_U32 reason)
2571{
2572 eHalStatus status = eHAL_STATUS_SUCCESS;
2573 tSmeCmd *pCommand;
2574
2575 do
2576 {
2577 pCommand = csrGetCommandBuffer( pMac );
2578 if ( !pCommand )
2579 {
2580 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2581 status = eHAL_STATUS_RESOURCES;
2582 break;
2583 }
2584 pCommand->command = eSmeCommandRoam;
2585 pCommand->sessionId = (tANI_U8)sessionId;
2586 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2587 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2588 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2589 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2590 if( !HAL_STATUS_SUCCESS( status ) )
2591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002592 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 csrReleaseCommandRoam( pMac, pCommand );
2594 }
2595 }while(0);
2596
2597 return status;
2598}
2599
2600
Jeff Johnson295189b2012-06-20 16:38:30 -07002601/* ---------------------------------------------------------------------------
2602 \fn csrRoamIssueDeauthSta
2603 \brief csr function that HDD calls to delete a associated station
2604 \param sessionId - session Id for Soft AP
2605 \param pPeerMacAddr - MAC of associated station to delete
2606 \param reason - reason code, be one of the tSirMacReasonCodes
2607 \return eHalStatus
2608 ---------------------------------------------------------------------------*/
2609eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2610 tANI_U32 sessionId,
2611 tANI_U8 *pPeerMacAddr,
2612 tANI_U32 reason)
2613{
2614 eHalStatus status = eHAL_STATUS_SUCCESS;
2615 tSmeCmd *pCommand;
2616
2617 do
2618 {
2619 pCommand = csrGetCommandBuffer( pMac );
2620 if ( !pCommand )
2621 {
2622 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2623 status = eHAL_STATUS_RESOURCES;
2624 break;
2625 }
2626 pCommand->command = eSmeCommandRoam;
2627 pCommand->sessionId = (tANI_U8)sessionId;
2628 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2629 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2630 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2631 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2632 if( !HAL_STATUS_SUCCESS( status ) )
2633 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002634 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 csrReleaseCommandRoam( pMac, pCommand );
2636 }
2637 }while(0);
2638
2639 return status;
2640}
Jeff Johnson295189b2012-06-20 16:38:30 -07002641eHalStatus
2642csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2643 tANI_BOOLEAN bEnable )
2644{
2645 eHalStatus status = eHAL_STATUS_FAILURE;
2646 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2647 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 if (!pSession)
2649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002650 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 return (status);
2652 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 if (pSession->pConnectBssDesc)
2654 {
2655 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2656 }
2657 else
2658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002659 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 return (status);
2661 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002662 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 -07002663 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302664 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2666 return (status);
2667}
Jeff Johnson295189b2012-06-20 16:38:30 -07002668eHalStatus
2669csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2670 VOS_MODULE_ID modId, void *pUsrContext,
2671 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2672{
2673 eHalStatus status = eHAL_STATUS_SUCCESS;
2674 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2675 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 if (!pSession)
2677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002678 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 return (status);
2680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 if(pSession->pConnectBssDesc)
2682 {
2683 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2684 }
2685 else
2686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002687 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 return (status);
2689 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002690 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2692 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2694 return (status);
2695}
Jeff Johnson295189b2012-06-20 16:38:30 -07002696eHalStatus
2697csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2698 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2699{
2700 eHalStatus status = eHAL_STATUS_SUCCESS;
2701 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2702 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2703
2704 if (!pSession)
2705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002706 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 return (status);
2708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 if(pSession->pConnectBssDesc)
2710 {
2711 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2712 }
2713 else
2714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002715 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 return (status);
2717 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002718 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2720 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2721
2722 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2723
2724 return (status);
2725}
Jeff Johnson295189b2012-06-20 16:38:30 -07002726eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2727{
2728 eHalStatus status = eHAL_STATUS_SUCCESS;
2729 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2730 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002731
2732 if (!pSession)
2733 {
2734 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2735 return eHAL_STATUS_FAILURE;
2736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002737
2738 if(pSession->pConnectBssDesc)
2739 {
2740 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2741 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002742 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2744 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2746
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302747 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002748 if(!HAL_STATUS_SUCCESS(status))
2749 {
2750 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2751 }
2752
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 return (status);
2754}
2755
Jeff Johnson295189b2012-06-20 16:38:30 -07002756eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2757{
2758 eHalStatus status = eHAL_STATUS_SUCCESS;
2759 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2760 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002761
2762 if(!pSession)
2763 {
2764 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2765 return eHAL_STATUS_FAILURE;
2766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002767
2768 // If no BSS description was found in this connection (happens with start IBSS), then
2769 // nix the BSS description that we keep around for the connected BSS) and get out...
2770 if(NULL == pBssDesc)
2771 {
2772 csrFreeConnectBssDesc(pMac, sessionId);
2773 }
2774 else
2775 {
2776 size = pBssDesc->length + sizeof( pBssDesc->length );
2777 if(NULL != pSession->pConnectBssDesc)
2778 {
2779 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2780 {
2781 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2782 csrFreeConnectBssDesc(pMac, sessionId);
2783 }
2784 }
2785 if(NULL == pSession->pConnectBssDesc)
2786 {
2787 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2788 }
2789 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2790 {
2791 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2792 }
2793 }
2794
2795 return (status);
2796}
2797
Jeff Johnson295189b2012-06-20 16:38:30 -07002798eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2799 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2800 tDot11fBeaconIEs *pIes)
2801{
2802 eHalStatus status = eHAL_STATUS_SUCCESS;
2803 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302805 if (pIes == NULL)
2806 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002807
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 do
2809 {
2810 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2811 //get qos
2812 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2813 //get SSID
2814 if(pIes->SSID.present)
2815 {
2816 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2817 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2818 }
2819 else
2820 pBssConfig->SSID.length = 0;
2821 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002823 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 //Return failed if profile doesn't have an SSID either.
2825 if(pProfile->SSIDs.numOfSSIDs == 0)
2826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002827 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 status = eHAL_STATUS_FAILURE;
2829 break;
2830 }
2831 }
2832 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2833 {
2834 pBssConfig->eBand = eCSR_BAND_5G;
2835 }
2836 else
2837 {
2838 pBssConfig->eBand = eCSR_BAND_24;
2839 }
2840 //phymode
2841 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2842 {
2843 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2844 }
2845 else
2846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002847 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 //force it
2849 if(eCSR_BAND_24 == pBssConfig->eBand)
2850 {
2851 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2852 }
2853 else
2854 {
2855 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2856 }
2857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 //Qos
2859 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2860 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2861 {
2862 //Joining BSS is not 11n capable and WMM is disabled on client.
2863 //Disable QoS and WMM
2864 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2865 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302866
2867 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302868 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302869 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2870 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2871 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2872 {
2873 //Joining BSS is 11n capable and WMM is disabled on AP.
2874 //Assume all HT AP's are QOS AP's and enable WMM
2875 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2876 }
2877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 //auth type
2879 switch( pProfile->negotiatedAuthType )
2880 {
2881 default:
2882 case eCSR_AUTH_TYPE_WPA:
2883 case eCSR_AUTH_TYPE_WPA_PSK:
2884 case eCSR_AUTH_TYPE_WPA_NONE:
2885 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2886 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2887 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 case eCSR_AUTH_TYPE_SHARED_KEY:
2889 pBssConfig->authType = eSIR_SHARED_KEY;
2890 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 case eCSR_AUTH_TYPE_AUTOSWITCH:
2892 pBssConfig->authType = eSIR_AUTO_SWITCH;
2893 break;
2894 }
2895 //short slot time
2896 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2897 {
2898 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2899 }
2900 else
2901 {
2902 pBssConfig->uShortSlotTime = 0;
2903 }
2904 if(pBssConfig->BssCap.ibss)
2905 {
2906 //We don't support 11h on IBSS
2907 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2908 }
2909 else
2910 {
2911 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2912 }
2913 //power constraint
2914 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2915 //heartbeat
2916 if ( CSR_IS_11A_BSS( pBssDesc ) )
2917 {
2918 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2919 }
2920 else
2921 {
2922 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2923 }
2924 //Join timeout
2925 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002926 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 if ( pBssDesc->beaconInterval )
2928 {
2929 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002930 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 }
2932 else
2933 {
2934 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2935 }
2936 //validate CB
2937 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2938 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 return (status);
2940}
2941
Jeff Johnson295189b2012-06-20 16:38:30 -07002942static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2943 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2944{
2945 eHalStatus status = eHAL_STATUS_SUCCESS;
2946 tANI_U8 operationChannel = 0;
2947 tANI_U8 qAPisEnabled = FALSE;
2948 //SSID
2949 pBssConfig->SSID.length = 0;
2950 if(pProfile->SSIDs.numOfSSIDs)
2951 {
2952 //only use the first one
2953 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2954 }
2955 else
2956 {
2957 //SSID must present
2958 return eHAL_STATUS_FAILURE;
2959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 //Settomg up the capabilities
2961 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2962 {
2963 pBssConfig->BssCap.ibss = 1;
2964 }
2965 else
2966 {
2967 pBssConfig->BssCap.ess = 1;
2968 }
2969 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2970 {
2971 pBssConfig->BssCap.privacy = 1;
2972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 pBssConfig->eBand = pMac->roam.configParam.eBand;
2974 //phymode
2975 if(pProfile->ChannelInfo.ChannelList)
2976 {
2977 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2980 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 //QOS
2982 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 if ( pBssConfig->BssCap.ess == 1 )
2984 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 /*For Softap case enable WMM*/
2986 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2987 qAPisEnabled = TRUE;
2988 }
2989 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2991 qAPisEnabled = TRUE;
2992 } else {
2993 qAPisEnabled = FALSE;
2994 }
2995 } else {
2996 qAPisEnabled = TRUE;
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2999 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3000 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3001 )
3002 {
3003 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3004 } else {
3005 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3006 }
3007
3008 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003009 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 {
3011 default:
3012 case eCSR_AUTH_TYPE_WPA:
3013 case eCSR_AUTH_TYPE_WPA_PSK:
3014 case eCSR_AUTH_TYPE_WPA_NONE:
3015 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3016 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3017 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 case eCSR_AUTH_TYPE_SHARED_KEY:
3019 pBssConfig->authType = eSIR_SHARED_KEY;
3020 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 case eCSR_AUTH_TYPE_AUTOSWITCH:
3022 pBssConfig->authType = eSIR_AUTO_SWITCH;
3023 break;
3024 }
3025 //short slot time
3026 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3027 {
3028 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3029 }
3030 else
3031 {
3032 pBssConfig->uShortSlotTime = 0;
3033 }
3034 //power constraint. We don't support 11h on IBSS
3035 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3036 pBssConfig->uPowerLimit = 0;
3037 //heartbeat
3038 if ( eCSR_BAND_5G == pBssConfig->eBand )
3039 {
3040 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3041 }
3042 else
3043 {
3044 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3045 }
3046 //Join timeout
3047 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003048
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 return (status);
3050}
Jeff Johnson295189b2012-06-20 16:38:30 -07003051static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3052{
3053 eHalStatus status = eHAL_STATUS_FAILURE;
3054 tDot11fBeaconIEs *pIes = NULL;
3055
3056 do
3057 {
3058 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3059 {
3060 //err msg
3061 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003062 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 break;
3064 }
3065 //check if the AP is QAP & it supports APSD
3066 if( CSR_IS_QOS_BSS(pIes) )
3067 {
3068 return eHAL_STATUS_SUCCESS;
3069 }
3070 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 return status;
3072}
3073
Jeff Johnson295189b2012-06-20 16:38:30 -07003074void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3075{
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3077 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3078 // See !!Note: below in this function...
3079 tANI_U32 PrivacyEnabled = 0;
3080 tANI_U32 RsnEnabled = 0;
3081 tANI_U32 WepDefaultKeyId = 0;
3082 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3083 tANI_U32 Key0Length = 0;
3084 tANI_U32 Key1Length = 0;
3085 tANI_U32 Key2Length = 0;
3086 tANI_U32 Key3Length = 0;
3087
3088 // Reserve for the biggest key
3089 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3090 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3091 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3092 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3093
3094 switch ( pProfile->negotiatedUCEncryptionType )
3095 {
3096 case eCSR_ENCRYPT_TYPE_NONE:
3097
3098 // for NO encryption, turn off Privacy and Rsn.
3099 PrivacyEnabled = 0;
3100 RsnEnabled = 0;
3101
3102 // WEP key length and Wep Default Key ID don't matter in this case....
3103
3104 // clear out the WEP keys that may be hanging around.
3105 Key0Length = 0;
3106 Key1Length = 0;
3107 Key2Length = 0;
3108 Key3Length = 0;
3109
3110 break;
3111
3112 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303113 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003114
3115 // Privacy is ON. NO RSN for Wep40 static key.
3116 PrivacyEnabled = 1;
3117 RsnEnabled = 0;
3118
3119 // Set the Wep default key ID.
3120 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 // Wep key size if 5 bytes (40 bits).
3122 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3123
3124 // set encryption keys in the CFG database or clear those that are not present in this profile.
3125 if ( pProfile->Keys.KeyLength[0] )
3126 {
3127 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3128 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3129 }
3130 else
3131 {
3132 Key0Length = 0;
3133 }
3134
3135 if ( pProfile->Keys.KeyLength[1] )
3136 {
3137 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3138 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3139 }
3140 else
3141 {
3142 Key1Length = 0;
3143 }
3144
3145 if ( pProfile->Keys.KeyLength[2] )
3146 {
3147 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3148 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3149 }
3150 else
3151 {
3152 Key2Length = 0;
3153 }
3154
3155 if ( pProfile->Keys.KeyLength[3] )
3156 {
3157 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3158 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3159 }
3160 else
3161 {
3162 Key3Length = 0;
3163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 break;
3165
3166 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303167 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003168
3169 // Privacy is ON. NO RSN for Wep40 static key.
3170 PrivacyEnabled = 1;
3171 RsnEnabled = 0;
3172
3173 // Set the Wep default key ID.
3174 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3175
3176 // Wep key size if 13 bytes (104 bits).
3177 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3178
3179 // set encryption keys in the CFG database or clear those that are not present in this profile.
3180 if ( pProfile->Keys.KeyLength[0] )
3181 {
3182 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3183 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3184 }
3185 else
3186 {
3187 Key0Length = 0;
3188 }
3189
3190 if ( pProfile->Keys.KeyLength[1] )
3191 {
3192 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3193 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3194 }
3195 else
3196 {
3197 Key1Length = 0;
3198 }
3199
3200 if ( pProfile->Keys.KeyLength[2] )
3201 {
3202 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3203 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3204 }
3205 else
3206 {
3207 Key2Length = 0;
3208 }
3209
3210 if ( pProfile->Keys.KeyLength[3] )
3211 {
3212 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3213 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3214 }
3215 else
3216 {
3217 Key3Length = 0;
3218 }
3219
3220 break;
3221
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 case eCSR_ENCRYPT_TYPE_TKIP:
3223 case eCSR_ENCRYPT_TYPE_AES:
3224#ifdef FEATURE_WLAN_WAPI
3225 case eCSR_ENCRYPT_TYPE_WPI:
3226#endif /* FEATURE_WLAN_WAPI */
3227 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3228 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3229 PrivacyEnabled = (0 != fPrivacy);
3230
3231 // turn on RSN enabled for WPA associations
3232 RsnEnabled = 1;
3233
3234 // WEP key length and Wep Default Key ID don't matter in this case....
3235
3236 // clear out the static WEP keys that may be hanging around.
3237 Key0Length = 0;
3238 Key1Length = 0;
3239 Key2Length = 0;
3240 Key3Length = 0;
3241
3242 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 default:
3244 PrivacyEnabled = 0;
3245 RsnEnabled = 0;
3246 break;
3247 }
3248
3249 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3250 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3251 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3252 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3253 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3254 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3255 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3256 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3257}
3258
Jeff Johnson295189b2012-06-20 16:38:30 -07003259static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3260{
3261 tANI_U32 len = 0;
3262 if(pSSID->length <= WNI_CFG_SSID_LEN)
3263 {
3264 len = pSSID->length;
3265 }
3266 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3267}
3268
Jeff Johnson295189b2012-06-20 16:38:30 -07003269eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3270{
3271 eHalStatus status = eHAL_STATUS_SUCCESS;
3272 tANI_U32 QoSEnabled;
3273 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 // set the CFG enable/disable variables based on the qosType being configured...
3275 switch( qosType )
3276 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3278 QoSEnabled = FALSE;
3279 WmeEnabled = TRUE;
3280 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3282 QoSEnabled = FALSE;
3283 WmeEnabled = TRUE;
3284 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3286 QoSEnabled = FALSE;
3287 WmeEnabled = TRUE;
3288 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3290 QoSEnabled = TRUE;
3291 WmeEnabled = FALSE;
3292 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 case eCSR_MEDIUM_ACCESS_11e_HCF:
3294 QoSEnabled = TRUE;
3295 WmeEnabled = FALSE;
3296 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 default:
3298 case eCSR_MEDIUM_ACCESS_DCF:
3299 QoSEnabled = FALSE;
3300 WmeEnabled = FALSE;
3301 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 }
3303 //save the WMM setting for later use
3304 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3306 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 return (status);
3308}
Jeff Johnson295189b2012-06-20 16:38:30 -07003309static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3310 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3311{
3312 eHalStatus status = eHAL_STATUS_FAILURE;
3313 int i;
3314 eCsrCfgDot11Mode cfgDot11Mode;
3315 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3317 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003319
3320 if( NULL != pIes )
3321 {
3322 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 // Originally, we thought that for 11a networks, the 11a rates are always
3324 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3325 // appear in the Operational Rate set. Consequently, in either case, we
3326 // would blindly put the rates we support into our Operational Rate set
3327 // (including the basic rates, which we have already verified are
3328 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 // However, it turns out that this is not always the case. Some AP's
3330 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3331 // too. Now, we're a little more careful:
3332 pDstRate = pOpRateSet->rate;
3333 if(pIes->SuppRates.present)
3334 {
3335 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3336 {
3337 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3338 {
3339 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003340 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 }
3342 }
3343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3345 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3346 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3347 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3348 {
3349 // If there are Extended Rates in the beacon, we will reflect those
3350 // extended rates that we support in out Extended Operational Rate
3351 // set:
3352 pDstRate = pExRateSet->rate;
3353 if(pIes->ExtSuppRates.present)
3354 {
3355 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3356 {
3357 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3358 {
3359 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3360 pExRateSet->numRates++;
3361 }
3362 }
3363 }
3364 }
3365 }//Parsing BSSDesc
3366 else
3367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003368 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 }
3370 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3371 return status;
3372}
3373
3374static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3375 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3376{
3377 int i;
3378 tANI_U8 *pDstRate;
3379 eCsrCfgDot11Mode cfgDot11Mode;
3380 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3381 tANI_U32 OperationalRatesLength = 0;
3382 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3383 tANI_U32 ExtendedOperationalRatesLength = 0;
3384 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3385 tANI_U32 ProprietaryOperationalRatesLength = 0;
3386 tANI_U32 PropRatesEnable = 0;
3387 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3388 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 if( NULL != pIes )
3391 {
3392 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 // Originally, we thought that for 11a networks, the 11a rates are always
3394 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3395 // appear in the Operational Rate set. Consequently, in either case, we
3396 // would blindly put the rates we support into our Operational Rate set
3397 // (including the basic rates, which we have already verified are
3398 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 // However, it turns out that this is not always the case. Some AP's
3400 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3401 // too. Now, we're a little more careful:
3402 pDstRate = OperationalRates;
3403 if(pIes->SuppRates.present)
3404 {
3405 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3406 {
3407 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3408 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3409 {
3410 *pDstRate++ = pIes->SuppRates.rates[ i ];
3411 OperationalRatesLength++;
3412 }
3413 }
3414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3416 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3417 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3418 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3419 {
3420 // If there are Extended Rates in the beacon, we will reflect those
3421 // extended rates that we support in out Extended Operational Rate
3422 // set:
3423 pDstRate = ExtendedOperationalRates;
3424 if(pIes->ExtSuppRates.present)
3425 {
3426 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3427 {
3428 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3429 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3430 {
3431 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3432 ExtendedOperationalRatesLength++;
3433 }
3434 }
3435 }
3436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 // Enable proprietary MAC features if peer node is Airgo node and STA
3438 // user wants to use them
3439 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3440 {
3441 PropRatesEnable = 1;
3442 }
3443 else
3444 {
3445 PropRatesEnable = 0;
3446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 // For ANI network companions, we need to populate the proprietary rate
3448 // set with any proprietary rates we found in the beacon, only if user
3449 // allows them...
3450 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3451 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3452 {
3453 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3454 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3455 {
3456 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3457 }
3458 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3459 }
3460 else {
3461 // No proprietary modes...
3462 ProprietaryOperationalRatesLength = 0;
3463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 /* Get MCS Rate */
3465 pDstRate = MCSRateIdxSet;
3466 if ( pIes->HTCaps.present )
3467 {
3468 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3469 {
3470 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3471 {
3472 MCSRateLength++;
3473 *pDstRate++ = i;
3474 }
3475 }
3476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 // Set the operational rate set CFG variables...
3478 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3479 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3480 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3481 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3482 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3483 ProprietaryOperationalRates,
3484 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3485 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3486 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3487 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3488 }//Parsing BSSDesc
3489 else
3490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003491 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 }
3493}
3494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3496 tCsrRoamProfile *pProfile )
3497{
3498 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3499 { 8,
3500 { SIR_MAC_RATE_6,
3501 SIR_MAC_RATE_9,
3502 SIR_MAC_RATE_12,
3503 SIR_MAC_RATE_18,
3504 SIR_MAC_RATE_24,
3505 SIR_MAC_RATE_36,
3506 SIR_MAC_RATE_48,
3507 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3509 { 4,
3510 { SIR_MAC_RATE_1,
3511 SIR_MAC_RATE_2,
3512 SIR_MAC_RATE_5_5,
3513 SIR_MAC_RATE_11 } } };
3514
3515
3516 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3517 { SIR_MAC_RATE_72,
3518 SIR_MAC_RATE_96,
3519 SIR_MAC_RATE_108 } };
3520 eCsrCfgDot11Mode cfgDot11Mode;
3521 eCsrBand eBand;
3522 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3523 tANI_U32 OperationalRatesLength = 0;
3524 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3525 tANI_U32 ExtendedOperationalRatesLength = 0;
3526 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3527 tANI_U32 ProprietaryOperationalRatesLength = 0;
3528 tANI_U32 PropRatesEnable = 0;
3529 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 if(pProfile->ChannelInfo.ChannelList)
3531 {
3532 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3536 // networks, the 11b rates appear in the Operational Rate set. In either case,
3537 // we can blindly put the rates we support into our Operational Rate set
3538 // (including the basic rates, which we have already verified are supported
3539 // earlier in the roaming decision).
3540 if ( eCSR_BAND_5G == eBand )
3541 {
3542 // 11a rates into the Operational Rate Set.
3543 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3544 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3545 palCopyMemory( pMac->hHdd, OperationalRates,
3546 DefaultSupportedRates11a.supportedRateSet.rate,
3547 OperationalRatesLength );
3548
3549 // Nothing in the Extended rate set.
3550 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 // populate proprietary rates if user allows them
3552 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3553 {
3554 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3555 sizeof(*DefaultSupportedPropRates.propRate);
3556 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3557 DefaultSupportedPropRates.propRate,
3558 ProprietaryOperationalRatesLength );
3559 }
3560 else
3561 {
3562 // No proprietary modes
3563 ProprietaryOperationalRatesLength = 0;
3564 }
3565 }
3566 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3567 {
3568 // 11b rates into the Operational Rate Set.
3569 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3570 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3571 palCopyMemory( pMac->hHdd, OperationalRates,
3572 DefaultSupportedRates11b.supportedRateSet.rate,
3573 OperationalRatesLength );
3574 // Nothing in the Extended rate set.
3575 ExtendedOperationalRatesLength = 0;
3576 // No proprietary modes
3577 ProprietaryOperationalRatesLength = 0;
3578 }
3579 else
3580 {
3581 // 11G
3582
3583 // 11b rates into the Operational Rate Set.
3584 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3585 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3586 palCopyMemory( pMac->hHdd, OperationalRates,
3587 DefaultSupportedRates11b.supportedRateSet.rate,
3588 OperationalRatesLength );
3589
3590 // 11a rates go in the Extended rate set.
3591 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3592 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3593 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3594 DefaultSupportedRates11a.supportedRateSet.rate,
3595 ExtendedOperationalRatesLength );
3596
3597 // populate proprietary rates if user allows them
3598 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3599 {
3600 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3601 sizeof(*DefaultSupportedPropRates.propRate);
3602 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3603 DefaultSupportedPropRates.propRate,
3604 ProprietaryOperationalRatesLength );
3605 }
3606 else
3607 {
3608 // No proprietary modes
3609 ProprietaryOperationalRatesLength = 0;
3610 }
3611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3613 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3614 {
3615 PropRatesEnable = 1;
3616 }
3617 else
3618 {
3619 PropRatesEnable = 0;
3620 }
3621
3622 // Set the operational rate set CFG variables...
3623 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3624 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3625 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3626 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3627 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3628 ProprietaryOperationalRates,
3629 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3630 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003631}
Jeff Johnson295189b2012-06-20 16:38:30 -07003632void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3633{
3634 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003635
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3637 tANI_U32 sessionId;
3638 tSmeCmd *pCommand = NULL;
3639
3640 if(NULL == pEntry)
3641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003642 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 return;
3644 }
3645 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3646 sessionId = pCommand->sessionId;
3647
3648 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3649 {
3650 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3651 }
3652}
3653
Jeff Johnson295189b2012-06-20 16:38:30 -07003654//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3655tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3656{
3657 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3658 {
3659 return (WNI_CFG_PHY_MODE_11B);
3660 }
3661 else
3662 {
3663 if(eCSR_BAND_24 == band)
3664 return (WNI_CFG_PHY_MODE_11G);
3665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 return (WNI_CFG_PHY_MODE_11A);
3667}
Jeff Johnson295189b2012-06-20 16:38:30 -07003668
Jeff Johnsone7245742012-09-05 17:12:55 -07003669
3670#ifdef WLAN_FEATURE_11AC
3671ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3672{
3673 switch ( aniCBMode )
3674 {
3675 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3676 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3677 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3678 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3679 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3680 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3681 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3682 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3683 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003684 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003685 return PHY_SINGLE_CHANNEL_CENTERED;
3686 }
3687}
3688#endif
3689
Jeff Johnson295189b2012-06-20 16:38:30 -07003690//pIes may be NULL
3691eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3692 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3693 tDot11fBeaconIEs *pIes)
3694{
3695 eHalStatus status = eHAL_STATUS_SUCCESS;
3696 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3697 tANI_U8 channel = 0;
3698 //Make sure we have the domain info for the BSS we try to connect to.
3699 //Do we need to worry about sequence for OSs that are not Windows??
3700 if(pBssDesc)
3701 {
3702 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3703 {
3704 //Make sure the 11d info from this BSSDesc can be applied
3705 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3706 csrApplyCountryInformation( pMac, TRUE );
3707 }
Kiran4a17ebe2013-01-31 10:43:43 -08003708 if ((csrIs11dSupported (pMac)) && pIes)
3709 {
3710 if (!pIes->Country.present)
3711 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 //Qos
3715 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3716 //SSID
3717 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3718 //fragment threshold
3719 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3720 //RTS threshold
3721 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3722
3723 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3724
3725 //Auth type
3726 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3727 //encryption type
3728 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3729 //short slot time
3730 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 //11d
3732 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3733 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3734 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 /*//11h
3736 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3737 */
3738 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3739 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003740
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003741 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 {
3743 channel = pProfile->operationChannel;
3744 }
3745 else
3746 {
3747 if(pBssDesc)
3748 {
3749 channel = pBssDesc->channelId;
3750 }
3751 }
3752 if(0 != channel)
3753 {
3754 if(CSR_IS_CHANNEL_24GHZ(channel))
3755 {//for now if we are on 2.4 Ghz, CB will be always disabled
3756 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3757 }
3758 else
3759 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003760 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 }
3762 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003763#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003764 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3765 // in function csrConvertCBIniValueToPhyCBState()
3766 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3767 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003768 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003769 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003770 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003771 }
3772 else
3773 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003774 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003775 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003776 }
3777 else
3778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3780 //Rate
3781 //Fixed Rate
3782 if(pBssDesc)
3783 {
3784 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3785 }
3786 else
3787 {
3788 csrSetCfgRateSetFromProfile(pMac, pProfile);
3789 }
3790 //Make this the last CFG to set. The callback will trigger a join_req
3791 //Join time out
3792 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3793
3794 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 return (status);
3796}
3797
Jeff Johnson295189b2012-06-20 16:38:30 -07003798eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3799 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3800{
3801 eHalStatus status;
3802 tBssConfigParam *pBssConfig;
3803 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003804
3805 if(!pSession)
3806 {
3807 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3808 return eHAL_STATUS_FAILURE;
3809 }
3810
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3812 if(HAL_STATUS_SUCCESS(status))
3813 {
3814 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3815 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3816 if(HAL_STATUS_SUCCESS(status))
3817 {
3818 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003819 /* This will allow to pass cbMode during join req */
3820 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 //For IBSS, we need to prepare some more information
3822 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 )
3825 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003826 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 }
3828 // If we are in an IBSS, then stop the IBSS...
3829 ////Not worry about WDS connection for now
3830 if ( csrIsConnStateIbss( pMac, sessionId ) )
3831 {
3832 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3833 }
3834 else
3835 {
3836 // if we are in an Infrastructure association....
3837 if ( csrIsConnStateInfra( pMac, sessionId ) )
3838 {
3839 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3840 // across SSIDs (roaming to a new SSID)... //
3841 //Not worry about WDS connection for now
3842 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3843 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3844 {
3845 // then we need to disassociate from the Infrastructure network...
3846 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3847 }
3848 else
3849 {
3850 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3851 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3852 if ( pBssDesc )
3853 {
3854 // Set parameters for this Bss.
3855 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3856 }
3857 }
3858 }
3859 else
3860 {
3861 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3862 // Nothing to stop.
3863 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 )
3866 {
3867 // Set parameters for this Bss.
3868 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3869 }
3870 }
3871 }
3872 }//Success getting BSS config info
3873 palFreeMemory(pMac->hHdd, pBssConfig);
3874 }//Allocate memory
3875
3876 return (status);
3877}
3878
Jeff Johnson295189b2012-06-20 16:38:30 -07003879eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3880 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3881{
3882 eCsrJoinState eRoamState = eCsrContinueRoaming;
3883 eHalStatus status;
3884 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3885 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3886 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003887
3888 if(!pSession)
3889 {
3890 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3891 return (eCsrStopRoaming);
3892 }
3893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 if( CSR_IS_WDS_STA( pProfile ) )
3895 {
3896 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3897 if( !HAL_STATUS_SUCCESS( status ) )
3898 {
3899 eRoamState = eCsrStopRoaming;
3900 }
3901 }
3902 else
3903 {
3904 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3905 {
3906 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3907 return (eCsrStopRoaming);
3908 }
3909 if ( csrIsInfraBssDesc( pBssDesc ) )
3910 {
3911 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3912 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3913 // have changed and handle the changes (without disturbing the current association).
3914
3915 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3916 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3917 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3918 )
3919 {
3920 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3921 // with Authenticating first. To force this, stop the current association (Disassociate) and
3922 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3923 // a new Association.
3924 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003926 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3928 {
3929 eRoamState = eCsrReassocToSelfNoCapChange;
3930 }
3931 else
3932 {
3933 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 //The key changes
3935 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3936 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3937 if(HAL_STATUS_SUCCESS(status))
3938 {
3939 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003940 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 //Reapply the config including Keys so reassoc is happening.
3942 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3943 if(!HAL_STATUS_SUCCESS(status))
3944 {
3945 eRoamState = eCsrStopRoaming;
3946 }
3947 }
3948 else
3949 {
3950 eRoamState = eCsrStopRoaming;
3951 }
3952 }//same profile
3953 }
3954 else
3955 {
3956 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3957 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003959 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 eRoamState = eCsrStopRoaming;
3961 }
3962 }
3963 }
3964 else
3965 {
3966 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3967 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3968 // work much better.
3969 //
3970 //
3971 // stop the existing network before attempting to join the new network...
3972 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3973 {
3974 eRoamState = eCsrStopRoaming;
3975 }
3976 }
3977 }//Infra
3978 else
3979 {
3980 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3981 {
3982 eRoamState = eCsrStopRoaming;
3983 }
3984 }
3985 if( pIesLocal && !pScanResult->pvIes )
3986 {
3987 palFreeMemory(pMac->hHdd, pIesLocal);
3988 }
3989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 return( eRoamState );
3991}
3992
Jeff Johnson295189b2012-06-20 16:38:30 -07003993eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3994 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3995{
3996 eHalStatus status = eHAL_STATUS_SUCCESS;
3997 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3999 roamInfo.pBssDesc = pBssDesc;
4000 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4001 return (status);
4002}
Jeff Johnson295189b2012-06-20 16:38:30 -07004003//In case no matching BSS is found, use whatever default we can find
4004static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4005{
4006 //Need to get all negotiated types in place first
4007 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004008 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 {
4010 default:
4011 case eCSR_AUTH_TYPE_WPA:
4012 case eCSR_AUTH_TYPE_WPA_PSK:
4013 case eCSR_AUTH_TYPE_WPA_NONE:
4014 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4015 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4016 break;
4017
4018 case eCSR_AUTH_TYPE_SHARED_KEY:
4019 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4020 break;
4021
4022 case eCSR_AUTH_TYPE_AUTOSWITCH:
4023 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4024 break;
4025 }
4026 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4027 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4028 //In this case, the multicast encryption needs to follow the uncast ones.
4029 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4030 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4031}
4032
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004033
4034static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4035{
4036 switch(pCommand->u.roamCmd.roamReason)
4037 {
4038 case eCsrLostLink1:
4039 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4040 break;
4041 case eCsrLostLink2:
4042 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4043 break;
4044 case eCsrLostLink3:
4045 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4046 break;
4047 default:
4048 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4049 pCommand->u.roamCmd.roamReason);
4050 break;
4051 }
4052}
4053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4055{
4056 eHalStatus status;
4057 tCsrScanResult *pScanResult = NULL;
4058 eCsrJoinState eRoamState = eCsrStopRoaming;
4059 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4060 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4061 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4062#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4063 v_U8_t acm_mask = 0;
4064#endif
4065 tANI_U32 sessionId = pCommand->sessionId;
4066 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4067 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4068 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004069
4070 if(!pSession)
4071 {
4072 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4073 return (eCsrStopRoaming);
4074 }
4075
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 do
4077 {
4078 // Check for Cardbus eject condition, before trying to Roam to any BSS
4079 //***if( !balIsCardPresent(pAdapter) ) break;
4080
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004081 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4082 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 if(NULL != pBSSList)
4084 {
4085 // When handling AP's capability change, continue to associate to
4086 // same BSS and make sure pRoamBssEntry is not Null.
4087 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4088 {
4089 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4090 {
4091 //Try the first BSS
4092 pCommand->u.roamCmd.pLastRoamBss = NULL;
4093 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4094 }
4095 else
4096 {
4097 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4098 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4099 {
4100 //Done with all the BSSs
4101 //In this case, will tell HDD the completion
4102 break;
4103 }
4104 else
4105 {
4106 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004107 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4109 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4110 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4111 pRoamInfo = &roamInfo;
4112 }
4113 }
4114 while(pCommand->u.roamCmd.pRoamBssEntry)
4115 {
4116 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 /*If concurrency enabled take the concurrent connected channel first. */
4118 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004119 if (vos_concurrent_sessions_running() &&
4120 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 {
4122 concurrentChannel =
4123 csrGetConcurrentOperationChannel(pMac);
4124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004125 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 if ((concurrentChannel) &&
4127 (concurrentChannel ==
4128 pScanResult->Result.BssDescriptor.channelId))
4129 {
4130 //make this 0 because we do not want the
4131 //below check to pass as we don't want to
4132 //connect on other channel
4133 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4134 FL("Concurrent channel match =%d"),
4135 concurrentChannel);
4136 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 }
4138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004139
4140 if (!concurrentChannel)
4141 {
4142
4143 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4144 sessionId, &pScanResult->Result.BssDescriptor,
4145 pCommand->u.roamCmd.roamId)))
4146 {
4147 //Ok to roam this
4148 break;
4149 }
4150 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004151 else
4152 {
4153 eRoamState = eCsrStopRoamingDueToConcurrency;
4154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4156 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4157 {
4158 //Done with all the BSSs
4159 fDone = eANI_BOOLEAN_TRUE;
4160 break;
4161 }
4162 }
4163 if(fDone)
4164 {
4165 break;
4166 }
4167 }
4168 }
4169 //We have something to roam, tell HDD when it is infra.
4170 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4171 //For WDS, the indication is eCSR_ROAM_WDS_IND
4172 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4173 {
4174 if(pRoamInfo)
4175 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004176 if(pSession->bRefAssocStartCnt)
4177 {
4178 pSession->bRefAssocStartCnt--;
4179 //Complete the last association attemp because a new one is about to be tried
4180 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4181 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004183 }
4184 }
4185 /* If the roaming has stopped, not to continue the roaming command*/
4186 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4187 {
4188 //No need to complete roaming here as it already completes
4189 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4190 pCommand->u.roamCmd.roamReason);
4191 eRoamState = eCsrStopRoaming;
4192 csrSetAbortRoamingCommand(pMac, pCommand);
4193 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 }
4195 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4196 if(pScanResult)
4197 {
4198 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4200 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004201 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 fDone = eANI_BOOLEAN_TRUE;
4203 eRoamState = eCsrStopRoaming;
4204 break;
4205 }
4206 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4207 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4208 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4209 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4210 CSR_IS_QOS_BSS(pIesLocal) &&
4211 CSR_IS_UAPSD_BSS(pIesLocal) )
4212 {
4213#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4215 pIesLocal);
4216 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4217#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 }
4219 else
4220 {
4221 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4222 }
4223 if( pIesLocal && !pScanResult->Result.pvIes)
4224 {
4225 palFreeMemory(pMac->hHdd, pIesLocal);
4226 }
4227 }
4228 else
4229 {
4230 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4231 }
4232 roamInfo.pProfile = pProfile;
4233 pSession->bRefAssocStartCnt++;
4234 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4235 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4238 {
4239 // If this is a start IBSS profile, then we need to start the IBSS.
4240 if ( CSR_IS_START_IBSS(pProfile) )
4241 {
4242 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 // Attempt to start this IBSS...
4244 csrRoamAssignDefaultParam( pMac, pCommand );
4245 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4246 if(HAL_STATUS_SUCCESS(status))
4247 {
4248 if ( fSameIbss )
4249 {
4250 eRoamState = eCsrStartIbssSameIbss;
4251 }
4252 else
4253 {
4254 eRoamState = eCsrContinueRoaming;
4255 }
4256 }
4257 else
4258 {
4259 //it somehow fail need to stop
4260 eRoamState = eCsrStopRoaming;
4261 }
4262 break;
4263 }
4264 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 )
4267 {
4268 // Attempt to start this WDS...
4269 csrRoamAssignDefaultParam( pMac, pCommand );
4270 /* For AP WDS, we dont have any BSSDescription */
4271 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4272 if(HAL_STATUS_SUCCESS(status))
4273 {
4274 eRoamState = eCsrContinueRoaming;
4275 }
4276 else
4277 {
4278 //it somehow fail need to stop
4279 eRoamState = eCsrStopRoaming;
4280 }
4281 }
4282 else
4283 {
4284 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004285 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 eRoamState = eCsrStopRoaming;
4287 break;
4288 }
4289 }
4290 else //We have BSS
4291 {
4292 //Need to assign these value because they are used in csrIsSameProfile
4293 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4294 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4295 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4296 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4297 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4298 {
4299 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4300 {
4301 eRoamState = eCsrStartIbssSameIbss;
4302 break;
4303 }
4304 }
4305 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4306 {
4307 //trying to connect to the one already connected
4308 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4309 eRoamState = eCsrReassocToSelfNoCapChange;
4310 break;
4311 }
4312 // Attempt to Join this Bss...
4313 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4314 break;
4315 }
4316
4317 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4319 {
4320 //Need to indicate association_completion if association_start has been done
4321 if(pSession->bRefAssocStartCnt > 0)
4322 {
4323 pSession->bRefAssocStartCnt--;
4324 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004325 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4327 eCSR_ROAM_ASSOCIATION_COMPLETION,
4328 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4329 }
4330 }
4331
4332 return( eRoamState );
4333}
4334
Jeff Johnson295189b2012-06-20 16:38:30 -07004335static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4336{
4337 eHalStatus status = eHAL_STATUS_SUCCESS;
4338 eCsrJoinState RoamState;
4339 tANI_U32 sessionId = pCommand->sessionId;
4340
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 //***if( hddIsRadioStateOn( pAdapter ) )
4342 {
4343 // Attept to join a Bss...
4344 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004347 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 {
4349 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 // and if connected in Infrastructure mode...
4351 if ( csrIsConnStateInfra(pMac, sessionId) )
4352 {
4353 //... then we need to issue a disassociation
4354 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4355 if(!HAL_STATUS_SUCCESS(status))
4356 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004357 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 //roam command is completed by caller in the failed case
4359 fComplete = eANI_BOOLEAN_TRUE;
4360 }
4361 }
4362 else if( csrIsConnStateIbss(pMac, sessionId) )
4363 {
4364 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4365 if(!HAL_STATUS_SUCCESS(status))
4366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004367 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 //roam command is completed by caller in the failed case
4369 fComplete = eANI_BOOLEAN_TRUE;
4370 }
4371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4373 {
4374 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4375 if(!HAL_STATUS_SUCCESS(status))
4376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004377 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 //roam command is completed by caller in the failed case
4379 fComplete = eANI_BOOLEAN_TRUE;
4380 }
4381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 else
4383 {
4384 fComplete = eANI_BOOLEAN_TRUE;
4385 }
4386 if(fComplete)
4387 {
4388 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004389 if(eCsrStopRoamingDueToConcurrency == RoamState)
4390 {
4391 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4392 }
4393 else
4394 {
4395 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 }
4398 }
4399 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4400 {
4401 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4402 }
4403 else if ( eCsrStartIbssSameIbss == RoamState )
4404 {
4405 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4406 }
4407 }//hddIsRadioStateOn
4408
4409 return status;
4410}
Jeff Johnson295189b2012-06-20 16:38:30 -07004411eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4412{
4413 tANI_U32 sessionId;
4414 tCsrRoamSession *pSession;
4415 tCsrScanResult *pScanResult = NULL;
4416 tSirBssDescription *pBssDesc = NULL;
4417 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 sessionId = pCommand->sessionId;
4419 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004420
4421 if(!pSession)
4422 {
4423 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4424 return eHAL_STATUS_FAILURE;
4425 }
4426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4428 {
4429 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004430 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4432 return eHAL_STATUS_FAILURE;
4433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 if (pCommand->u.roamCmd.pRoamBssEntry)
4435 {
4436 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4437 pBssDesc = &pScanResult->Result.BssDescriptor;
4438 }
4439 else
4440 {
4441 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004442 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4444 return eHAL_STATUS_FAILURE;
4445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4447 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4448 return status;
4449}
4450
Jeff Johnson295189b2012-06-20 16:38:30 -07004451eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4452{
4453 eHalStatus status = eHAL_STATUS_SUCCESS;
4454 tCsrRoamInfo roamInfo;
4455 tANI_U32 sessionId = pCommand->sessionId;
4456 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004457
4458 if(!pSession)
4459 {
4460 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4461 return eHAL_STATUS_FAILURE;
4462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004463
4464 switch ( pCommand->u.roamCmd.roamReason )
4465 {
4466 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004468 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 case eCsrSmeIssuedDisassocForHandoff:
4471 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4472#if 0 // TODO : Confirm this change
4473 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4474#else
4475 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4476#endif
4477
4478 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004481 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004485 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 case eCsrHddIssuedReassocToSameAP:
4488 case eCsrSmeIssuedReassocToSameAP:
4489 {
4490 tDot11fBeaconIEs *pIes = NULL;
4491
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 if( pSession->pConnectBssDesc )
4493 {
4494 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4495 if(!HAL_STATUS_SUCCESS(status) )
4496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004497 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 }
4499 else
4500 {
4501 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4502 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4503 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4505 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4506 pSession->bRefAssocStartCnt++;
4507 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4508 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4509
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004510 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004511 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4512 &pCommand->u.roamCmd.roamProfile );
4513 if(!HAL_STATUS_SUCCESS(status))
4514 {
4515 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004516 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004517 }
4518
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 palFreeMemory(pMac->hHdd, pIes);
4520 pIes = NULL;
4521 }
4522 }
4523 break;
4524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004526 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4528 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004531 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4533 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004534
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 case eCsrStopBss:
4536 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4537 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4538 break;
4539
4540 case eCsrForcedDisassocSta:
4541 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4542 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4543 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4544 pCommand->u.roamCmd.reason);
4545 break;
4546
4547 case eCsrForcedDeauthSta:
4548 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4549 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4550 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4551 pCommand->u.roamCmd.reason);
4552 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004553
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004554 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004555 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004556 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4557 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004558 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560 default:
4561 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4562
4563 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4564 {
4565 //Remember the roaming profile
4566 csrFreeRoamProfile(pMac, sessionId);
4567 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4568 {
4569 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4570 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4571 }
4572 }
4573
4574 //At this point, original uapsd_mask is saved in pCurRoamProfile
4575 //uapsd_mask in the pCommand may change from this point on.
4576
4577 // Attempt to roam with the new scan results (if we need to..)
4578 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004579 if(!HAL_STATUS_SUCCESS(status))
4580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004581 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 break;
4584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 return (status);
4586}
4587
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004588void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4589{
4590 pCommand->u.roamCmd.pLastRoamBss = NULL;
4591 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4592 //Because u.roamCmd is union and share with scanCmd and StatusChange
4593 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4594}
4595
Jeff Johnson295189b2012-06-20 16:38:30 -07004596void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4597{
4598 if(pCommand->u.roamCmd.fReleaseBssList)
4599 {
4600 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4601 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4602 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4603 }
4604 if(pCommand->u.roamCmd.fReleaseProfile)
4605 {
4606 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4607 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4608 }
4609 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4610 //Because u.roamCmd is union and share with scanCmd and StatusChange
4611 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4612}
4613
Jeff Johnson295189b2012-06-20 16:38:30 -07004614void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4615{
4616 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4617}
Jeff Johnson295189b2012-06-20 16:38:30 -07004618void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4619{
4620 tListElem *pEntry;
4621 tSmeCmd *pCommand;
4622 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004623 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4625 if ( pEntry )
4626 {
4627 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 // If the head of the queue is Active and it is a ROAM command, remove
4629 // and put this on the Free queue.
4630 if ( eSmeCommandRoam == pCommand->command )
4631 {
4632 //we need to process the result first before removing it from active list because state changes
4633 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4634 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4635 if( fReleaseCommand )
4636 {
4637 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4638 {
4639 csrReleaseCommandRoam( pMac, pCommand );
4640 }
4641 else
4642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004643 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004644 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 }
4646 }
4647 else
4648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004649 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004650 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 }
4652 }
4653 else
4654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004655 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 }
4657 }
4658 else
4659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004660 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 if( fReleaseCommand )
4663 {
4664 smeProcessPendingQueue( pMac );
4665 }
4666}
4667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4669{
4670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004671 if(!pSession)
4672 {
4673 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4674 return;
4675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4677 pSession->NumPmkidCandidate = 0;
4678}
Jeff Johnson295189b2012-06-20 16:38:30 -07004679#ifdef FEATURE_WLAN_WAPI
4680void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4681{
4682 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004683 if(!pSession)
4684 {
4685 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4686 return;
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4689 pSession->NumBkidCandidate = 0;
4690}
4691#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004692extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4693
Jeff Johnson295189b2012-06-20 16:38:30 -07004694static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4695 tSirBssDescription *pSirBssDesc,
4696 tDot11fBeaconIEs *pIes)
4697{
4698 eHalStatus status = eHAL_STATUS_SUCCESS;
4699 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4700 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004701
4702 if(!pSession)
4703 {
4704 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4705 return eHAL_STATUS_FAILURE;
4706 }
4707
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 if((eCSR_AUTH_TYPE_WPA == authType) ||
4709 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4710 (eCSR_AUTH_TYPE_RSN == authType) ||
4711 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4712#if defined WLAN_FEATURE_VOWIFI_11R
4713 ||
4714 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4715 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4716#endif /* FEATURE_WLAN_WAPI */
4717#ifdef FEATURE_WLAN_WAPI
4718 ||
4719 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4720 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4721#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004722#ifdef WLAN_FEATURE_11W
4723 ||
4724 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4725#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 )
4727 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004730 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 }
4732 if( pIesLocal )
4733 {
4734 tANI_U32 nIeLen;
4735 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 if((eCSR_AUTH_TYPE_RSN == authType) ||
4737#if defined WLAN_FEATURE_VOWIFI_11R
4738 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4739 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4740#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004741#if defined WLAN_FEATURE_11W
4742 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4745 {
4746 if(pIesLocal->RSN.present)
4747 {
4748 //Calculate the actual length
4749 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4750 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4751 + 2 //akm_suite_count
4752 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4753 + 2; //reserved
4754 if( pIesLocal->RSN.pmkid_count )
4755 {
4756 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4757 }
4758 //nIeLen doesn't count EID and length fields
4759 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4760 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004761 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4763 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4764 //copy upto akm_suites
4765 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004766 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4767 pIeBuf += sizeof(pIesLocal->RSN.version);
4768 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4769 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4770 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4771 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 if( pIesLocal->RSN.pwise_cipher_suite_count )
4773 {
4774 //copy pwise_cipher_suites
4775 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4776 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4777 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4778 }
4779 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4780 pIeBuf += 2;
4781 if( pIesLocal->RSN.akm_suite_count )
4782 {
4783 //copy akm_suites
4784 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4785 pIesLocal->RSN.akm_suite_count * 4);
4786 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4787 }
4788 //copy the rest
4789 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4790 pIesLocal->RSN.akm_suite_count * 4,
4791 2 + pIesLocal->RSN.pmkid_count * 4);
4792 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4793 }
4794 }
4795 }
4796 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4797 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4798 {
4799 if(pIesLocal->WPA.present)
4800 {
4801 //Calculate the actual length
4802 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4803 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4804 + 2 //auth_suite_count
4805 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4806 // The WPA capabilities follows the Auth Suite (two octects)--
4807 // this field is optional, and we always "send" zero, so just
4808 // remove it. This is consistent with our assumptions in the
4809 // frames compiler; c.f. bug 15234:
4810 //nIeLen doesn't count EID and length fields
4811 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4812 {
4813 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4814 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4815 pIeBuf = pSession->pWpaRsnRspIE + 2;
4816 //Copy WPA OUI
4817 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4818 pIeBuf += 4;
4819 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4820 pIesLocal->WPA.unicast_cipher_count * 4);
4821 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4822 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4823 pIesLocal->WPA.auth_suite_count * 4);
4824 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4825 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4826 }
4827 }
4828 }
4829#ifdef FEATURE_WLAN_WAPI
4830 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4831 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4832 {
4833 if(pIesLocal->WAPI.present)
4834 {
4835 //Calculate the actual length
4836 nIeLen = 4 //version + akm_suite_count
4837 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4838 + 2 //pwise_cipher_suite_count
4839 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4840 + 6; //gp_cipher_suite + preauth + reserved
4841 if( pIesLocal->WAPI.bkid_count )
4842 {
4843 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4844 }
4845
4846 //nIeLen doesn't count EID and length fields
4847 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4848 {
4849 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4850 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4851 pIeBuf = pSession->pWapiRspIE + 2;
4852 //copy upto akm_suite_count
lukez3c809222013-05-03 10:23:02 -07004853 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 pIeBuf += 4;
4855 if( pIesLocal->WAPI.akm_suite_count )
4856 {
4857 //copy akm_suites
4858 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4859 pIesLocal->WAPI.akm_suite_count * 4);
4860 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4861 }
4862 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4863 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4865 {
4866 //copy pwise_cipher_suites
4867 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4868 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4869 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4870 }
lukez3c809222013-05-03 10:23:02 -07004871 //gp_cipher_suite
4872 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite, 4);
4873 //preauth + reserved
4874 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite + 4, 2);
4875 //bkid_count
4876 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
4877
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 pIeBuf += 8;
4879 if( pIesLocal->WAPI.bkid_count )
4880 {
4881 //copy akm_suites
4882 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4883 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4884 }
4885 pSession->nWapiRspIeLength = nIeLen + 2;
4886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 }
4888 }
4889#endif /* FEATURE_WLAN_WAPI */
4890 if( !pIes )
4891 {
4892 //locally allocated
4893 palFreeMemory(pMac->hHdd, pIesLocal);
4894 }
4895 }
4896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 return (status);
4898}
4899
Jeff Johnson295189b2012-06-20 16:38:30 -07004900static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4901{
4902 v_U8_t bACWeights[WLANTL_MAX_AC];
4903 v_U8_t paramBk, paramBe, paramVi, paramVo;
4904 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4906 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4907 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4908 //This doesn't address the case where the lower AC needs a real higher weight
4909 if( pIEs->WMMParams.present )
4910 {
4911 //no change to the lowest ones
4912 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4913 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4914 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4915 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4916 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4917 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4918 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4919 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4920 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4921 {
4922 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4923 fWeightChange = VOS_TRUE;
4924 }
4925 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4926 {
4927 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4928 fWeightChange = VOS_TRUE;
4929 }
4930 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4931 {
4932 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4933 fWeightChange = VOS_TRUE;
4934 }
4935 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4936 {
4937 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4938 fWeightChange = VOS_TRUE;
4939 }
4940 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4941 {
4942 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4943 fWeightChange = VOS_TRUE;
4944 }
4945 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4946 {
4947 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4948 fWeightChange = VOS_TRUE;
4949 }
4950 if(fWeightChange)
4951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004952 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 bACWeights[2], bACWeights[3]);
4954 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4955 }
4956 }
4957}
Jeff Johnson295189b2012-06-20 16:38:30 -07004958#ifdef WLAN_FEATURE_VOWIFI_11R
4959//Returns whether the current association is a 11r assoc or not
4960tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4961{
4962#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4963 return csrNeighborRoamIs11rAssoc(pMac);
4964#else
4965 return eANI_BOOLEAN_FALSE;
4966#endif
4967}
4968#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004969#ifdef FEATURE_WLAN_CCX
4970//Returns whether the current association is a CCX assoc or not
4971tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4972{
4973#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4974 return csrNeighborRoamIsCCXAssoc(pMac);
4975#else
4976 return eANI_BOOLEAN_FALSE;
4977#endif
4978}
4979#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004980#ifdef FEATURE_WLAN_LFR
4981//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304982tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004983{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304984 tCsrRoamSession *pSession = NULL;
4985
4986 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4987 {
4988 pSession = CSR_GET_SESSION( pMac, sessionId );
4989 if (NULL != pSession->pCurRoamProfile)
4990 {
4991 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4992 {
4993 return eANI_BOOLEAN_FALSE;
4994 }
4995 }
4996 }
4997
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004998#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4999 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5000 {
5001 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5002 }
5003 else
5004#endif
5005 {
5006 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005007 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005008 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005009}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005010
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005011#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5012//Returns whether "FW based BG scan" is currently enabled...or not
5013tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5014{
5015 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5016}
5017#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005018#endif
5019
Jeff Johnson295189b2012-06-20 16:38:30 -07005020//Return true means the command can be release, else not
5021static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5022 eCsrRoamCompleteResult Result, void *Context )
5023{
5024 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5025 tSirBssDescription *pSirBssDesc = NULL;
5026 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5027 tCsrScanResult *pScanResult = NULL;
5028 tCsrRoamInfo roamInfo;
5029 sme_QosAssocInfo assocInfo;
5030 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5031 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5032 tDot11fBeaconIEs *pIes = NULL;
5033 tANI_U32 sessionId = pCommand->sessionId;
5034 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5035 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5036 eRoamCmdStatus roamStatus;
5037 eCsrRoamResult roamResult;
5038 eHalStatus status;
5039 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005041
Jeff Johnson32d95a32012-09-10 13:15:23 -07005042 if(!pSession)
5043 {
5044 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5045 return eANI_BOOLEAN_FALSE;
5046 }
5047
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005048 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 switch( Result )
5050 {
5051 case eCsrJoinSuccess:
5052 // reset the IDLE timer
5053 // !!
5054 // !! fall through to the next CASE statement here is intentional !!
5055 // !!
5056 case eCsrReassocSuccess:
5057 if(eCsrReassocSuccess == Result)
5058 {
5059 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5060 }
5061 else
5062 {
5063 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5064 }
5065 // Success Join Response from LIM. Tell NDIS we are connected and save the
5066 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005067 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5069 //always free the memory here
5070 if(pSession->pWpaRsnRspIE)
5071 {
5072 pSession->nWpaRsnRspIeLength = 0;
5073 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
5074 pSession->pWpaRsnRspIE = NULL;
5075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005076#ifdef FEATURE_WLAN_WAPI
5077 if(pSession->pWapiRspIE)
5078 {
5079 pSession->nWapiRspIeLength = 0;
5080 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
5081 pSession->pWapiRspIE = NULL;
5082 }
5083#endif /* FEATURE_WLAN_WAPI */
5084#ifdef FEATURE_WLAN_BTAMP_UT_RF
5085 //Reset counter so no join retry is needed.
5086 pSession->maxRetryCount = 0;
5087 csrRoamStopJoinRetryTimer(pMac, sessionId);
5088#endif
5089 /* This creates problem since we have not saved the connected profile.
5090 So moving this after saving the profile
5091 */
5092 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5093 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5094 {
5095 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5096 }
5097 else
5098 {
5099 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 //Use the last connected bssdesc for reassoc-ing to the same AP.
5102 //NOTE: What to do when reassoc to a different AP???
5103 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5104 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5105 {
5106 pSirBssDesc = pSession->pConnectBssDesc;
5107 if(pSirBssDesc)
5108 {
5109 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5110 }
5111 }
5112 else
5113 {
5114
5115 if(pCommand->u.roamCmd.pRoamBssEntry)
5116 {
5117 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5118 if(pScanResult != NULL)
5119 {
5120 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5121 //this can be NULL
5122 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5123 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5124 }
5125 }
5126 }
5127 if( pSirBssDesc )
5128 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5131 //Save WPA/RSN IE
5132 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5133#ifdef FEATURE_WLAN_CCX
5134 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5135#endif
5136
5137 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5138 // substate change.
5139 // Moving even save profile above so that below mentioned conditon is also met.
5140 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5141 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5143 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5144 // will be dropped for the security context may not be set properly.
5145 //
5146 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5147 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5148 //
5149 // this reordering was done on titan_prod_usb branch and is being replicated here.
5150 //
5151
5152 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5153 !pProfile->bWPSAssociation)
5154 {
5155 // Issue the set Context request to LIM to establish the Unicast STA context
5156 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5157 pProfile->negotiatedUCEncryptionType,
5158 pSirBssDesc, &(pSirBssDesc->bssId),
5159 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005161 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5163 }
5164 // Issue the set Context request to LIM to establish the Broadcast STA context
5165 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5166 pSirBssDesc, &BroadcastMac,
5167 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5168 }
5169 else
5170 {
5171 //Need to wait for supplicant authtication
5172 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 //Set the subestate to WaitForKey in case authentiation is needed
5174 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5175
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 if(pProfile->bWPSAssociation)
5177 {
5178 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5179 }
5180 else
5181 {
5182 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5183 }
5184
5185 //Save sessionId in case of timeout
5186 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5187 //This time should be long enough for the rest of the process plus setting key
5188 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5189 {
5190 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005191 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5193 }
5194 }
5195
5196 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5197 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 if(Context)
5199 {
5200 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5201 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5203 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5204#ifdef WLAN_FEATURE_VOWIFI_11R
5205 len += pJoinRsp->parsedRicRspLen;
5206#endif /* WLAN_FEATURE_VOWIFI_11R */
5207#ifdef FEATURE_WLAN_CCX
5208 len += pJoinRsp->tspecIeLen;
5209#endif
5210 if(len)
5211 {
5212 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5213 (void **)&pSession->connectedInfo.pbFrames, len)))
5214 {
5215 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5216 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5217 {
5218 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5219 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5220 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5221#ifdef WLAN_FEATURE_VOWIFI_11R
5222 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5223#endif /* WLAN_FEATURE_VOWIFI_11R */
5224#ifdef FEATURE_WLAN_CCX
5225 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5226#endif
5227 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5228 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5229 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5230 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5231 }
5232 else
5233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005234 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005235 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5237 pSession->connectedInfo.pbFrames = NULL;
5238 }
5239 }
5240 }
5241 if(pCommand->u.roamCmd.fReassoc)
5242 {
5243 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5244 }
5245 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5246 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5247 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5248 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5249 }
5250 else
5251 {
5252 if(pCommand->u.roamCmd.fReassoc)
5253 {
5254 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5255 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5256 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5257 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5258 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5259 }
5260 }
5261#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5262 // Indicate SME-QOS with reassoc success event, only after
5263 // copying the frames
5264 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5265#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 roamInfo.pBssDesc = pSirBssDesc;
5267 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5268 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5269#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5270 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5271#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5272 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5274 //It may be better to let QoS do this????
5275 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005277 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5279 pmcStartUapsd( pMac, NULL, NULL );
5280 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305281 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5283 if( pSession->bRefAssocStartCnt > 0 )
5284 {
5285 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005286 //Remove this code once SLM_Sessionization is supported
5287 //BMPS_WORKAROUND_NOT_NEEDED
5288 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005289 {
5290 pMac->roam.configParam.doBMPSWorkaround = 1;
5291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5293 }
5294
5295 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 // reset the PMKID candidate list
5297 csrResetPMKIDCandidateList( pMac, sessionId );
5298 //Update TL's AC weight base on the current EDCA parameters
5299 //These parameters may change in the course of the connection, that sictuation
5300 //is not taken care here. This change is mainly to address a WIFI WMM test where
5301 //BE has a equal or higher TX priority than VI.
5302 //We only do this for infra link
5303 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5304 {
5305 csrCheckAndUpdateACWeight(pMac, pIes);
5306 }
5307#ifdef FEATURE_WLAN_WAPI
5308 // reset the BKID candidate list
5309 csrResetBKIDCandidateList( pMac, sessionId );
5310#endif /* FEATURE_WLAN_WAPI */
5311 }
5312 else
5313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005314 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 csrScanCancelIdleScan(pMac);
5317 //Not to signal link up because keys are yet to be set.
5318 //The linkup function will overwrite the sub-state that we need to keep at this point.
5319 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5320 {
5321 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5324 //enough to let security and DHCP handshake succeed before entry into BMPS
5325 if (pmcShouldBmpsTimerRun(pMac))
5326 {
5327 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5328 != eHAL_STATUS_SUCCESS)
5329 {
5330 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5331 }
5332 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 break;
5335
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 case eCsrStartBssSuccess:
5337 // on the StartBss Response, LIM is returning the Bss Description that we
5338 // are beaconing. Add this Bss Description to our scan results and
5339 // chain the Profile to this Bss Description. On a Start BSS, there was no
5340 // detected Bss description (no partner) so we issued the Start Bss to
5341 // start the Ibss without any Bss description. Lim was kind enough to return
5342 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005343 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5347 if( CSR_IS_IBSS( pProfile ) )
5348 {
5349 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 else if (CSR_IS_INFRA_AP(pProfile))
5352 {
5353 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 else
5356 {
5357 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5358 }
5359 if( !CSR_IS_WDS_STA( pProfile ) )
5360 {
5361 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005365 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 roamInfo.pBssDesc = pSirBssDesc;
5367 //We need to associate_complete it first, becasue Associate_start already indicated.
5368 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5369 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5370 break;
5371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005374 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 }
5376 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5377 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5378 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5379 if(pSirBssDesc)
5380 {
5381 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5382 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5383 }
5384 //We are doen with the IEs so free it
5385 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005386#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5387 {
5388 vos_log_ibss_pkt_type *pIbssLog;
5389 tANI_U32 bi;
5390
5391 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5392 if(pIbssLog)
5393 {
5394 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5395 {
5396 //We start the IBSS (didn't find any matched IBSS out there)
5397 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5398 }
5399 else
5400 {
5401 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5402 }
5403 if(pSirBssDesc)
5404 {
5405 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5406 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5407 }
5408 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5409 {
5410 //***U8 is not enough for beacon interval
5411 pIbssLog->beaconInterval = (v_U8_t)bi;
5412 }
5413 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5414 }
5415 }
5416#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5417 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5418 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5420 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5422 csrRoamIssueSetContextReq( pMac, sessionId,
5423 pProfile->negotiatedMCEncryptionType,
5424 pSirBssDesc, &BroadcastMac,
5425 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5426 }
5427 }
5428 else
5429 {
5430 //Keep the state to eCSR_ROAMING_STATE_JOINING
5431 //Need to send join_req.
5432 if(pCommand->u.roamCmd.pRoamBssEntry)
5433 {
5434 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5435 {
5436 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5437 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5438 // Set the roaming substate to 'join attempt'...
5439 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005440 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 }
5442 }
5443 else
5444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005445 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 VOS_ASSERT( 0 );
5447 }
5448 }
5449 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5450 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5451 //trigger the connection start indication in Vista
5452 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5453 {
5454 roamStatus = eCSR_ROAM_IBSS_IND;
5455 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5456 if( CSR_IS_WDS( pProfile ) )
5457 {
5458 roamStatus = eCSR_ROAM_WDS_IND;
5459 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if( CSR_IS_INFRA_AP( pProfile ) )
5462 {
5463 roamStatus = eCSR_ROAM_INFRA_IND;
5464 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005466
5467 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5468 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5469 //trigger the connection start indication in Vista
5470 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5471 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5472 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5473 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5474 {
5475 //We start the IBSS (didn't find any matched IBSS out there)
5476 roamInfo.pBssDesc = pSirBssDesc;
5477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005479 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005480 //Remove this code once SLM_Sessionization is supported
5481 //BMPS_WORKAROUND_NOT_NEEDED
5482 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005483 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005484 {
5485 pMac->roam.configParam.doBMPSWorkaround = 1;
5486 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005487
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5489 }
5490
5491 csrScanCancelIdleScan(pMac);
5492 //Only use this timer for ibss. BAP has its own timer for WDS
5493 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5494 {
5495 //start the join IBSS timer
5496 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5497 pSession->ibss_join_pending = TRUE;
5498 }
5499 if( HAL_STATUS_SUCCESS( status ) )
5500 {
5501 //Already sent join_req for the WDS station
5502 fReleaseCommand = eANI_BOOLEAN_FALSE;
5503 }
5504 else if( CSR_IS_WDS_STA( pProfile ) )
5505 {
5506 //need to send stop BSS because we fail to send join_req
5507 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5508 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5509 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 case eCsrStartBssFailure:
5513#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5514 {
5515 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5517 if(pIbssLog)
5518 {
5519 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5520 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5521 }
5522 }
5523#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 roamStatus = eCSR_ROAM_IBSS_IND;
5525 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5526 if( CSR_IS_WDS( pProfile ) )
5527 {
5528 roamStatus = eCSR_ROAM_WDS_IND;
5529 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 if( CSR_IS_INFRA_AP( pProfile ) )
5532 {
5533 roamStatus = eCSR_ROAM_INFRA_IND;
5534 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 if(Context)
5537 {
5538 pSirBssDesc = (tSirBssDescription *)Context;
5539 }
5540 else
5541 {
5542 pSirBssDesc = NULL;
5543 }
5544 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5545 roamInfo.pBssDesc = pSirBssDesc;
5546 //We need to associate_complete it first, becasue Associate_start already indicated.
5547 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5548 csrSetDefaultDot11Mode( pMac );
5549 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 case eCsrSilentlyStopRoaming:
5551 // We are here because we try to start the same IBSS
5552 //No message to PE
5553 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005554 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5556 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5557 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5558 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5559 if( roamInfo.pBssDesc )
5560 {
5561 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5562 }
5563 //Since there is no change in the current state, simply pass back no result otherwise
5564 //HDD may be mistakenly mark to disconnected state.
5565 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5566 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 case eCsrSilentlyStopRoamingSaveState:
5569 //We are here because we try to connect to the same AP
5570 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005571 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5573
5574 //to aviod resetting the substate to NONE
5575 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5576 //No need to change substate to wai_for_key because there is no state change
5577 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5578 if( roamInfo.pBssDesc )
5579 {
5580 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5583 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5584 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5585 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5586 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5587 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5588 roamInfo.staId = pSession->connectedInfo.staId;
5589 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 pSession->bRefAssocStartCnt--;
5592 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5593 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5594 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5595 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 case eCsrReassocFailure:
5597#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5598 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5599#endif
5600 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005601 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 csrFreeConnectBssDesc(pMac, sessionId);
5603 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5604 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5605 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5606 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5607 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5608 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5609 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5610 eCSR_ROAM_WDS_IND,
5611 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5612 //Need to issue stop_bss
5613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 case eCsrJoinFailure:
5615 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005616 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 default:
5618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005619 smsLog(pMac, LOGW, FL("receives no association indication"));
5620 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005621 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5623 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5624 {
5625 //do not free for the other profiles as we need to send down stop BSS later
5626 csrFreeConnectBssDesc(pMac, sessionId);
5627 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5628 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5629 csrSetDefaultDot11Mode( pMac );
5630 }
5631
5632 switch( pCommand->u.roamCmd.roamReason )
5633 {
5634 // If this transition is because of an 802.11 OID, then we transition
5635 // back to INIT state so we sit waiting for more OIDs to be issued and
5636 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005637 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 case eCsrSmeIssuedAssocToSimilarAP:
5639 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005640 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5642 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5643 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5644 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5645 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005646 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5647
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 /* Defeaturize this later if needed */
5649#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5650 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5651 if (csrRoamIsHandoffInProgress(pMac))
5652 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 /* Should indicate neighbor roam algorithm about the connect failure here */
5654 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 if(pSession->bRefAssocStartCnt > 0)
5658 {
5659 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005660 if(eCsrJoinFailureDueToConcurrency == Result)
5661 {
5662 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5663 eCSR_ROAM_ASSOCIATION_COMPLETION,
5664 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5665 }
5666 else
5667 {
5668 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 eCSR_ROAM_ASSOCIATION_COMPLETION,
5670 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005673 else
5674 {
5675 /* bRefAssocStartCnt is not incremented when
5676 * eRoamState == eCsrStopRoamingDueToConcurrency
5677 * in csrRoamJoinNextBss API. so handle this in
5678 * else case by sending assoc failure
5679 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005680 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005681 pCommand->u.scanCmd.roamId,
5682 eCSR_ROAM_ASSOCIATION_FAILURE,
5683 eCSR_ROAM_RESULT_FAILURE);
5684 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005685 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005686#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5687 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5688#endif
5689 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5690 csrScanStartIdleScan(pMac);
5691#ifdef FEATURE_WLAN_BTAMP_UT_RF
5692 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5693 //BT activity and not able to recevie WLAN traffic. Retry the join
5694 if( CSR_IS_WDS_STA(pProfile) )
5695 {
5696 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5697 }
5698#endif
5699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 case eCsrHddIssuedReassocToSameAP:
5701 case eCsrSmeIssuedReassocToSameAP:
5702 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5703
5704 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5705#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5706 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5707#endif
5708 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5709 csrScanStartIdleScan(pMac);
5710 break;
5711 case eCsrForcedDisassoc:
5712 case eCsrForcedDeauth:
5713 case eCsrSmeIssuedIbssJoinFailure:
5714 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5715
5716 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5717 {
5718 // Notify HDD that IBSS join failed
5719 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5720 }
5721 else
5722 {
5723 csrRoamCallCallback(pMac, sessionId, NULL,
5724 pCommand->u.roamCmd.roamId,
5725 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5726 }
5727#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5728 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5729#endif
5730 csrRoamLinkDown(pMac, sessionId);
5731 csrScanStartIdleScan(pMac);
5732 break;
5733 case eCsrForcedIbssLeave:
5734 csrRoamCallCallback(pMac, sessionId, NULL,
5735 pCommand->u.roamCmd.roamId,
5736 eCSR_ROAM_IBSS_LEAVE,
5737 eCSR_ROAM_RESULT_IBSS_STOP);
5738 break;
5739 case eCsrForcedDisassocMICFailure:
5740 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5741
5742 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5743#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5744 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5745#endif
5746 csrScanStartIdleScan(pMac);
5747 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 case eCsrStopBss:
5749 csrRoamCallCallback(pMac, sessionId, NULL,
5750 pCommand->u.roamCmd.roamId,
5751 eCSR_ROAM_INFRA_IND,
5752 eCSR_ROAM_RESULT_INFRA_STOPPED);
5753 break;
5754 case eCsrForcedDisassocSta:
5755 case eCsrForcedDeauthSta:
5756 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5757 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5758 {
5759 pSession = CSR_GET_SESSION(pMac, sessionId);
5760 if (!pSession)
5761 break;
5762
5763 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5764 {
5765 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5766 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5767 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5768 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5769 roamInfo.statusCode = eSIR_SME_SUCCESS;
5770 status = csrRoamCallCallback(pMac, sessionId,
5771 &roamInfo, pCommand->u.roamCmd.roamId,
5772 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5773 }
5774 }
5775 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 case eCsrLostLink1:
5777 // if lost link roam1 failed, then issue lost link Scan2 ...
5778 csrScanRequestLostLink2(pMac, sessionId);
5779 break;
5780 case eCsrLostLink2:
5781 // if lost link roam2 failed, then issue lost link scan3 ...
5782 csrScanRequestLostLink3(pMac, sessionId);
5783 break;
5784 case eCsrLostLink3:
5785 default:
5786 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5787
5788 //We are done with one round of lostlink roaming here
5789 csrScanHandleFailedLostlink3(pMac, sessionId);
5790 break;
5791 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 break;
5793 }
5794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 return ( fReleaseCommand );
5796}
5797
Jeff Johnson295189b2012-06-20 16:38:30 -07005798eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5799{
5800 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 return (status);
5802}
5803
Jeff Johnson295189b2012-06-20 16:38:30 -07005804eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5805{
5806 eHalStatus status = eHAL_STATUS_SUCCESS;
5807 tANI_U32 size = 0;
5808
5809 do
5810 {
5811 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5812 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5813 {
5814 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5815 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5816 if(!HAL_STATUS_SUCCESS(status))
5817 {
5818 break;
5819 }
5820 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5821 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5822 }
5823 if(pSrcProfile->SSIDs.numOfSSIDs)
5824 {
5825 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5826 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5827 if(!HAL_STATUS_SUCCESS(status))
5828 {
5829 break;
5830 }
5831 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5832 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5833 }
5834 if(pSrcProfile->nWPAReqIELength)
5835 {
5836 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5837 if(!HAL_STATUS_SUCCESS(status))
5838 {
5839 break;
5840 }
5841 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5842 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5843 }
5844 if(pSrcProfile->nRSNReqIELength)
5845 {
5846 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5847 if(!HAL_STATUS_SUCCESS(status))
5848 {
5849 break;
5850 }
5851 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5852 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5853 }
5854#ifdef FEATURE_WLAN_WAPI
5855 if(pSrcProfile->nWAPIReqIELength)
5856 {
5857 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5858 if(!HAL_STATUS_SUCCESS(status))
5859 {
5860 break;
5861 }
5862 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5863 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5864 }
5865#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 if(pSrcProfile->nAddIEScanLength)
5867 {
5868 status = palAllocateMemory(pMac->hHdd,
5869 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5870 if(!HAL_STATUS_SUCCESS(status))
5871 {
5872 break;
5873 }
5874 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5875 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5876 pSrcProfile->nAddIEScanLength);
5877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 if(pSrcProfile->nAddIEAssocLength)
5879 {
5880 status = palAllocateMemory(pMac->hHdd,
5881 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5882 if(!HAL_STATUS_SUCCESS(status))
5883 {
5884 break;
5885 }
5886 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5887 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5888 pSrcProfile->nAddIEAssocLength);
5889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 if(pSrcProfile->ChannelInfo.ChannelList)
5891 {
5892 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5893 if(!HAL_STATUS_SUCCESS(status))
5894 {
5895 break;
5896 }
5897 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5898 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 pDstProfile->AuthType = pSrcProfile->AuthType;
5901 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5902 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5903 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5904 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5905 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005906#ifdef WLAN_FEATURE_11W
5907 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5908 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5909 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 pDstProfile->BSSType = pSrcProfile->BSSType;
5912 pDstProfile->phyMode = pSrcProfile->phyMode;
5913 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5914
5915#ifdef FEATURE_WLAN_WAPI
5916 if(csrIsProfileWapi(pSrcProfile))
5917 {
5918 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5919 {
5920 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5921 }
5922 }
5923#endif /* FEATURE_WLAN_WAPI */
5924 pDstProfile->CBMode = pSrcProfile->CBMode;
5925 /*Save the WPS info*/
5926 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5927 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 pDstProfile->privacy = pSrcProfile->privacy;
5930 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5931 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5932 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5933 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5934 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5935 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5936 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5937 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5938 pDstProfile->wps_state = pSrcProfile->wps_state;
5939 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005941#ifdef WLAN_FEATURE_VOWIFI_11R
5942 if (pSrcProfile->MDID.mdiePresent)
5943 {
5944 pDstProfile->MDID.mdiePresent = 1;
5945 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5946 }
5947#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 }while(0);
5949
5950 if(!HAL_STATUS_SUCCESS(status))
5951 {
5952 csrReleaseProfile(pMac, pDstProfile);
5953 pDstProfile = NULL;
5954 }
5955
5956 return (status);
5957}
Jeff Johnson295189b2012-06-20 16:38:30 -07005958eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5959{
5960 eHalStatus status = eHAL_STATUS_SUCCESS;
5961 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5962 do
5963 {
5964 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5965 if(pSrcProfile->bssid)
5966 {
5967 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5968 if(!HAL_STATUS_SUCCESS(status))
5969 {
5970 break;
5971 }
5972 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5973 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5974 }
5975 if(pSrcProfile->SSID.ssId)
5976 {
5977 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5978 if(!HAL_STATUS_SUCCESS(status))
5979 {
5980 break;
5981 }
5982 pDstProfile->SSIDs.numOfSSIDs = 1;
5983 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5984 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5985 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5986 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005987 if(pSrcProfile->nAddIEAssocLength)
5988 {
5989 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5990 if(!HAL_STATUS_SUCCESS(status))
5991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005992 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005993 break;
5994 }
5995 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5996 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5997 pSrcProfile->nAddIEAssocLength);
5998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
6000 if(!HAL_STATUS_SUCCESS(status))
6001 {
6002 break;
6003 }
6004 pDstProfile->ChannelInfo.numOfChannels = 1;
6005 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 pDstProfile->AuthType.numEntries = 1;
6007 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6008 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6009 pDstProfile->EncryptionType.numEntries = 1;
6010 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6011 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6012 pDstProfile->mcEncryptionType.numEntries = 1;
6013 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6014 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6015 pDstProfile->BSSType = pSrcProfile->BSSType;
6016 pDstProfile->CBMode = pSrcProfile->CBMode;
6017 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
6018#ifdef WLAN_FEATURE_VOWIFI_11R
6019 if (pSrcProfile->MDID.mdiePresent)
6020 {
6021 pDstProfile->MDID.mdiePresent = 1;
6022 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6023 }
6024#endif
6025
6026 }while(0);
6027
6028 if(!HAL_STATUS_SUCCESS(status))
6029 {
6030 csrReleaseProfile(pMac, pDstProfile);
6031 pDstProfile = NULL;
6032 }
6033
6034 return (status);
6035}
6036
Jeff Johnson295189b2012-06-20 16:38:30 -07006037eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6038 tScanResultHandle hBSSList,
6039 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6040 tANI_BOOLEAN fClearScan)
6041{
6042 eHalStatus status = eHAL_STATUS_SUCCESS;
6043 tSmeCmd *pCommand;
6044
6045 pCommand = csrGetCommandBuffer(pMac);
6046 if(NULL == pCommand)
6047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006048 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 status = eHAL_STATUS_RESOURCES;
6050 }
6051 else
6052 {
6053 if( fClearScan )
6054 {
6055 csrScanCancelIdleScan(pMac);
6056 csrScanAbortMacScanNotForConnect(pMac);
6057 }
6058 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6059 if(NULL == pProfile)
6060 {
6061 //We can roam now
6062 //Since pProfile is NULL, we need to build our own profile, set everything to default
6063 //We can only support open and no encryption
6064 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6065 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6066 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6067 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6068 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6069 }
6070 else
6071 {
6072 //make a copy of the profile
6073 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6074 if(HAL_STATUS_SUCCESS(status))
6075 {
6076 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6077 }
6078 }
6079 pCommand->command = eSmeCommandRoam;
6080 pCommand->sessionId = (tANI_U8)sessionId;
6081 pCommand->u.roamCmd.hBSSList = hBSSList;
6082 pCommand->u.roamCmd.roamId = roamId;
6083 pCommand->u.roamCmd.roamReason = reason;
6084 //We need to free the BssList when the command is done
6085 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6086 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6088 FL("CSR PERSONA=%d"),
6089 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6091 if( !HAL_STATUS_SUCCESS( status ) )
6092 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006093 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 csrReleaseCommandRoam( pMac, pCommand );
6095 }
6096 }
6097
6098 return (status);
6099}
Jeff Johnson295189b2012-06-20 16:38:30 -07006100eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6101 tCsrRoamModifyProfileFields *pMmodProfileFields,
6102 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6103{
6104 eHalStatus status = eHAL_STATUS_SUCCESS;
6105 tSmeCmd *pCommand;
6106
6107 pCommand = csrGetCommandBuffer(pMac);
6108 if(NULL == pCommand)
6109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006110 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 status = eHAL_STATUS_RESOURCES;
6112 }
6113 else
6114 {
6115 csrScanCancelIdleScan(pMac);
6116 csrScanAbortMacScanNotForConnect(pMac);
6117 if(pProfile)
6118 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 //This is likely trying to reassoc to different profile
6120 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6121 //make a copy of the profile
6122 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6123 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 }
6125 else
6126 {
6127 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6128 //how to update WPA/WPA2 info in roamProfile??
6129 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 if(HAL_STATUS_SUCCESS(status))
6132 {
6133 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6134 }
6135 pCommand->command = eSmeCommandRoam;
6136 pCommand->sessionId = (tANI_U8)sessionId;
6137 pCommand->u.roamCmd.roamId = roamId;
6138 pCommand->u.roamCmd.roamReason = reason;
6139 //We need to free the BssList when the command is done
6140 //For reassoc there is no BSS list, so the boolean set to false
6141 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6142 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6143 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6145 if( !HAL_STATUS_SUCCESS( status ) )
6146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006147 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6149 csrReleaseCommandRoam( pMac, pCommand );
6150 }
6151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 return (status);
6153}
6154
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006155eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6156 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306157// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006158{
6159 eHalStatus status = eHAL_STATUS_SUCCESS;
6160 tSmeCmd *pCommand;
6161
6162 pCommand = csrGetCommandBuffer(pMac);
6163 if(NULL == pCommand)
6164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006165 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006166 status = eHAL_STATUS_RESOURCES;
6167 }
6168 else
6169 {
6170 if(pBssDescription)
6171 {
6172 //copy over the parameters we need later
6173 pCommand->command = eSmeCommandRoam;
6174 pCommand->sessionId = (tANI_U8)sessionId;
6175 pCommand->u.roamCmd.roamReason = reason;
6176 //this is the important parameter
6177 //in this case we are using this field for the "next" BSS
6178 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6179 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6180 if( !HAL_STATUS_SUCCESS( status ) )
6181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006182 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006183 csrReleaseCommandPreauth( pMac, pCommand );
6184 }
6185 }
6186 else
6187 {
6188 //Return failure
6189 status = eHAL_STATUS_RESOURCES;
6190 }
6191 }
6192 return (status);
6193}
6194
6195eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6196{
6197 tListElem *pEntry;
6198 tSmeCmd *pCommand;
6199 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6200 if ( pEntry )
6201 {
6202 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6203 if ( (eSmeCommandRoam == pCommand->command) &&
6204 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6205 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006206 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006207 pCommand->command, pCommand->u.roamCmd.roamReason);
6208 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6209 csrReleaseCommandPreauth( pMac, pCommand );
6210 }
6211 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006212 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006213 pCommand->command, pCommand->u.roamCmd.roamReason);
6214 }
6215 }
6216 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006217 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006218 }
6219 smeProcessPendingQueue( pMac );
6220 return eHAL_STATUS_SUCCESS;
6221}
6222
Jeff Johnson295189b2012-06-20 16:38:30 -07006223eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6224 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6225{
6226 eHalStatus status = eHAL_STATUS_FAILURE;
6227 tScanResultHandle hBSSList;
6228 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6230 if(HAL_STATUS_SUCCESS(status))
6231 {
6232 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6233 if(pRoamId)
6234 {
6235 *pRoamId = roamId;
6236 }
6237 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6238 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6239 if(!HAL_STATUS_SUCCESS(status))
6240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006241 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 csrScanResultPurge(pMac, hBSSList);
6243 }
6244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 return (status);
6246}
6247
Jeff Johnson295189b2012-06-20 16:38:30 -07006248eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6249 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6250{
6251 eHalStatus status = eHAL_STATUS_SUCCESS;
6252 tScanResultHandle hBSSList;
6253 tCsrScanResultFilter *pScanFilter;
6254 tANI_U32 roamId = 0;
6255 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 if (NULL == pProfile)
6258 {
6259 smsLog(pMac, LOGP, FL("No profile specified"));
6260 return eHAL_STATUS_FAILURE;
6261 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006262 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 if( CSR_IS_WDS( pProfile ) &&
6265 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006267 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006268 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 return status;
6270 }
6271 csrRoamCancelRoaming(pMac, sessionId);
6272 csrScanRemoveFreshScanCommand(pMac, sessionId);
6273 csrScanCancelIdleScan(pMac);
6274 //Only abort the scan if it is not used for other roam/connect purpose
6275 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6277 {
6278 csrScanDisable(pMac);
6279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6281 //Check whether ssid changes
6282 if(csrIsConnStateConnected(pMac, sessionId))
6283 {
6284 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6285 {
6286 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6287 }
6288 }
6289#ifdef FEATURE_WLAN_BTAMP_UT_RF
6290 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6291#endif
6292 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006294 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6296 if(pRoamId)
6297 {
6298 roamId = *pRoamId;
6299 }
6300 if(!HAL_STATUS_SUCCESS(status))
6301 {
6302 fCallCallback = eANI_BOOLEAN_TRUE;
6303 }
6304 }
6305 else
6306 {
6307 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6308 if(HAL_STATUS_SUCCESS(status))
6309 {
6310 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6311 //Try to connect to any BSS
6312 if(NULL == pProfile)
6313 {
6314 //No encryption
6315 pScanFilter->EncryptionType.numEntries = 1;
6316 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6317 }//we don't have a profile
6318 else
6319 {
6320 //Here is the profile we need to connect to
6321 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6322 }//We have a profile
6323 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6324 if(pRoamId)
6325 {
6326 *pRoamId = roamId;
6327 }
6328
6329 if(HAL_STATUS_SUCCESS(status))
6330 {
6331 /*Save the WPS info*/
6332 if(NULL != pProfile)
6333 {
6334 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6335 }
6336 else
6337 {
6338 pScanFilter->bWPSAssociation = 0;
6339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 do
6341 {
6342 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 )
6345 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006346 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6348 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6349 if(!HAL_STATUS_SUCCESS(status))
6350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006351 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 fCallCallback = eANI_BOOLEAN_TRUE;
6353 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006354 else
6355 {
6356 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 break;
6359 }
6360 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006361 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 if(HAL_STATUS_SUCCESS(status))
6363 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6365 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6366 if(!HAL_STATUS_SUCCESS(status))
6367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006368 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 csrScanResultPurge(pMac, hBSSList);
6370 fCallCallback = eANI_BOOLEAN_TRUE;
6371 }
6372 }//Have scan result
6373 else if(NULL != pProfile)
6374 {
6375 //Check whether it is for start ibss
6376 if(CSR_IS_START_IBSS(pProfile))
6377 {
6378 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6379 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6380 if(!HAL_STATUS_SUCCESS(status))
6381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006382 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 fCallCallback = eANI_BOOLEAN_TRUE;
6384 }
6385 }
6386 else
6387 {
6388 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006389 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 if(!HAL_STATUS_SUCCESS(status))
6391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006392 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 fCallCallback = eANI_BOOLEAN_TRUE;
6394 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006395 else
6396 {
6397 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 }
6400 }
6401 else
6402 {
6403 fCallCallback = eANI_BOOLEAN_TRUE;
6404 }
6405 } while (0);
6406 if(NULL != pProfile)
6407 {
6408 //we need to free memory for filter if profile exists
6409 csrFreeScanFilter(pMac, pScanFilter);
6410 }
6411 }//Got the scan filter from profile
6412
6413 palFreeMemory(pMac->hHdd, pScanFilter);
6414 }//allocated memory for pScanFilter
6415 }//No Bsslist coming in
6416 //tell the caller if we fail to trigger a join request
6417 if( fCallCallback )
6418 {
6419 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6420 }
6421
6422 return (status);
6423}
Jeff Johnson295189b2012-06-20 16:38:30 -07006424eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6425 tCsrRoamModifyProfileFields modProfileFields,
6426 tANI_U32 *pRoamId)
6427{
6428 eHalStatus status = eHAL_STATUS_SUCCESS;
6429 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6430 tANI_U32 roamId = 0;
6431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 if (NULL == pProfile)
6433 {
6434 smsLog(pMac, LOGP, FL("No profile specified"));
6435 return eHAL_STATUS_FAILURE;
6436 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006437 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 -07006438 csrRoamCancelRoaming(pMac, sessionId);
6439 csrScanRemoveFreshScanCommand(pMac, sessionId);
6440 csrScanCancelIdleScan(pMac);
6441 csrScanAbortMacScanNotForConnect(pMac);
6442 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 if(csrIsConnStateConnected(pMac, sessionId))
6444 {
6445 if(pProfile)
6446 {
6447 if(pProfile->SSIDs.numOfSSIDs &&
6448 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6449 {
6450 fCallCallback = eANI_BOOLEAN_FALSE;
6451 }
6452 else
6453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006454 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 }
6456 }
6457 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6458 &pSession->connectedProfile.modifyProfileFields,
6459 sizeof(tCsrRoamModifyProfileFields)))
6460 {
6461 fCallCallback = eANI_BOOLEAN_FALSE;
6462 }
6463 else
6464 {
6465 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006466 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 }
6468 }
6469 else
6470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006471 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 if(!fCallCallback)
6474 {
6475 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6476 if(pRoamId)
6477 {
6478 *pRoamId = roamId;
6479 }
6480
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6482 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 }
6484 else
6485 {
6486 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6487 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 return status;
6490}
Jeff Johnson295189b2012-06-20 16:38:30 -07006491eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6492{
6493 eHalStatus status = eHAL_STATUS_FAILURE;
6494 tScanResultHandle hBSSList = NULL;
6495 tCsrScanResultFilter *pScanFilter = NULL;
6496 tANI_U32 roamId;
6497 tCsrRoamProfile *pProfile = NULL;
6498 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006499
6500 if(!pSession)
6501 {
6502 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6503 return eHAL_STATUS_FAILURE;
6504 }
6505
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 do
6507 {
6508 if(pSession->pCurRoamProfile)
6509 {
6510 csrScanCancelIdleScan(pMac);
6511 csrScanAbortMacScanNotForConnect(pMac);
6512 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6513 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6514 if(!HAL_STATUS_SUCCESS(status))
6515 break;
6516 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6517 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6518 if(!HAL_STATUS_SUCCESS(status))
6519 break;
6520 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6521 if(!HAL_STATUS_SUCCESS(status))
6522 {
6523 break;
6524 }
6525 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6526 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6527 if(!HAL_STATUS_SUCCESS(status))
6528 {
6529 break;
6530 }
6531 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6532 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6533 if(HAL_STATUS_SUCCESS(status))
6534 {
6535 //we want to put the last connected BSS to the very beginning, if possible
6536 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6537 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6538 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6539 if(!HAL_STATUS_SUCCESS(status))
6540 {
6541 csrScanResultPurge(pMac, hBSSList);
6542 break;
6543 }
6544 }
6545 else
6546 {
6547 //Do a scan on this profile
6548 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006549 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 if(!HAL_STATUS_SUCCESS(status))
6551 {
6552 break;
6553 }
6554 }
6555 }//We have a profile
6556 else
6557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006558 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 break;
6560 }
6561 }while(0);
6562 if(pScanFilter)
6563 {
6564 csrFreeScanFilter(pMac, pScanFilter);
6565 palFreeMemory(pMac->hHdd, pScanFilter);
6566 }
6567 if(NULL != pProfile)
6568 {
6569 csrReleaseProfile(pMac, pProfile);
6570 palFreeMemory(pMac->hHdd, pProfile);
6571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 return (status);
6573}
Jeff Johnson295189b2012-06-20 16:38:30 -07006574eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6575{
6576 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 if(csrIsConnStateConnected(pMac, sessionId))
6578 {
6579 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6580 if(HAL_STATUS_SUCCESS(status))
6581 {
6582 status = csrRoamJoinLastProfile(pMac, sessionId);
6583 }
6584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 return (status);
6586}
6587
Jeff Johnson295189b2012-06-20 16:38:30 -07006588eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6589{
6590 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006591 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 csrRoamCancelRoaming(pMac, sessionId);
6593 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6594 if(csrIsConnStateDisconnected(pMac, sessionId))
6595 {
6596 status = csrRoamJoinLastProfile(pMac, sessionId);
6597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 return (status);
6599}
6600
Jeff Johnson295189b2012-06-20 16:38:30 -07006601eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6602{
6603 eHalStatus status = eHAL_STATUS_SUCCESS;
6604 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6605 eCsrRoamSubState NewSubstate;
6606 tANI_U32 sessionId = pCommand->sessionId;
6607
6608 // change state to 'Roaming'...
6609 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6610
6611 if ( csrIsConnStateIbss( pMac, sessionId ) )
6612 {
6613 // If we are in an IBSS, then stop the IBSS...
6614 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6615 fComplete = (!HAL_STATUS_SUCCESS(status));
6616 }
6617 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006619 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 -07006620 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6621 //Restore AC weight in case we change it
6622 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6623 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6624 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6625 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6626 {
6627 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6628 }
6629 if( fDisassoc )
6630 {
6631 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6632 }
6633 else
6634 {
6635 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6636 }
6637 fComplete = (!HAL_STATUS_SUCCESS(status));
6638 }
6639 else if ( csrIsConnStateWds( pMac, sessionId ) )
6640 {
6641 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6642 {
6643 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6644 fComplete = (!HAL_STATUS_SUCCESS(status));
6645 }
6646 //This has to be WDS station
6647 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6648 {
6649
6650 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6651 if( fDisassoc )
6652 {
6653 status = csrRoamIssueDisassociate( pMac, sessionId,
6654 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6655 fComplete = (!HAL_STATUS_SUCCESS(status));
6656 }
6657 }
6658 } else {
6659 // we got a dis-assoc request while not connected to any peer
6660 // just complete the command
6661 fComplete = eANI_BOOLEAN_TRUE;
6662 status = eHAL_STATUS_FAILURE;
6663 }
6664 if(fComplete)
6665 {
6666 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6667 }
6668
6669 if(HAL_STATUS_SUCCESS(status))
6670 {
6671 if ( csrIsConnStateInfra( pMac, sessionId ) )
6672 {
6673 //Set the state to disconnect here
6674 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6675 }
6676 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006677 else
6678 {
6679 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 return (status);
6682}
6683
Jeff Johnson295189b2012-06-20 16:38:30 -07006684/* This is been removed from latest code base */
6685/*
6686static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6687{
6688 eHalStatus status;
6689 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6691 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 return ( status );
6693}
6694*/
6695
Jeff Johnson295189b2012-06-20 16:38:30 -07006696eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6697{
6698 eHalStatus status = eHAL_STATUS_SUCCESS;
6699 tSmeCmd *pCommand;
6700 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 do
6702 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006703 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 pCommand = csrGetCommandBuffer( pMac );
6705 if ( !pCommand )
6706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006707 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 status = eHAL_STATUS_RESOURCES;
6709 break;
6710 }
6711 //Change the substate in case it is wait-for-key
6712 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6713 {
6714 csrRoamStopWaitForKeyTimer( pMac );
6715 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6716 }
6717 pCommand->command = eSmeCommandRoam;
6718 pCommand->sessionId = (tANI_U8)sessionId;
6719 switch ( reason )
6720 {
6721 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6722 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6723 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 case eCSR_DISCONNECT_REASON_DEAUTH:
6725 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 case eCSR_DISCONNECT_REASON_HANDOFF:
6728 fHighPriority = eANI_BOOLEAN_TRUE;
6729 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6730 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6732 case eCSR_DISCONNECT_REASON_DISASSOC:
6733 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6734 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6736 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6739 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6740 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 default:
6742 break;
6743 }
6744 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6745 if( !HAL_STATUS_SUCCESS( status ) )
6746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006747 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 csrReleaseCommandRoam( pMac, pCommand );
6749 }
6750 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 return( status );
6752}
6753
Jeff Johnson295189b2012-06-20 16:38:30 -07006754eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6755{
6756 eHalStatus status = eHAL_STATUS_SUCCESS;
6757 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 pCommand = csrGetCommandBuffer( pMac );
6759 if ( NULL != pCommand )
6760 {
6761 //Change the substate in case it is wait-for-key
6762 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6763 {
6764 csrRoamStopWaitForKeyTimer( pMac );
6765 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6766 }
6767 pCommand->command = eSmeCommandRoam;
6768 pCommand->sessionId = (tANI_U8)sessionId;
6769 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6770 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6771 if( !HAL_STATUS_SUCCESS( status ) )
6772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006773 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 csrReleaseCommandRoam( pMac, pCommand );
6775 }
6776 }
6777 else
6778 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006779 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 status = eHAL_STATUS_RESOURCES;
6781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 return ( status );
6783}
6784
Jeff Johnson295189b2012-06-20 16:38:30 -07006785eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6786{
6787 eHalStatus status = eHAL_STATUS_SUCCESS;
6788 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006789
6790 if(!pSession)
6791 {
6792 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6793 return eHAL_STATUS_FAILURE;
6794 }
6795
Jeff Johnson295189b2012-06-20 16:38:30 -07006796#ifdef FEATURE_WLAN_BTAMP_UT_RF
6797 //Stop te retry
6798 pSession->maxRetryCount = 0;
6799 csrRoamStopJoinRetryTimer(pMac, sessionId);
6800#endif
6801 //Not to call cancel roaming here
6802 //Only issue disconnect when necessary
6803 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6804 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6805 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6806
6807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006808 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 return (status);
6812}
6813
Jeff Johnson295189b2012-06-20 16:38:30 -07006814eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6815{
6816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006817
6818 if(!pSession)
6819 {
6820 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6821 return eHAL_STATUS_FAILURE;
6822 }
6823
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 csrRoamCancelRoaming(pMac, sessionId);
6825 pSession->ibss_join_pending = FALSE;
6826 csrRoamStopIbssJoinTimer(pMac, sessionId);
6827 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6828
6829 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6830}
6831
Jeff Johnson295189b2012-06-20 16:38:30 -07006832eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6833 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6834{
6835 eHalStatus status = eHAL_STATUS_SUCCESS;
6836 tDot11fBeaconIEs *pIesTemp = pIes;
6837 tANI_U8 index;
6838 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6839 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006840
6841 if(!pSession)
6842 {
6843 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6844 return eHAL_STATUS_FAILURE;
6845 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006846
6847 if(pConnectProfile->pAddIEAssoc)
6848 {
6849 palFreeMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc);
6850 pConnectProfile->pAddIEAssoc = NULL;
6851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6853 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6854 pConnectProfile->AuthInfo = pProfile->AuthType;
6855 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6856 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6857 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6858 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6859 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6860 pConnectProfile->BSSType = pProfile->BSSType;
6861 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6862 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006863 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6864
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006866
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006867 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6868 if(pProfile->nAddIEAssocLength)
6869 {
6870 status = palAllocateMemory(pMac->hHdd,
6871 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6872 if(!HAL_STATUS_SUCCESS(status))
6873 {
6874 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6875 return eHAL_STATUS_FAILURE;
6876 }
6877 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6878 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6879 pProfile->nAddIEAssocLength);
6880 }
6881
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 //Save bssid
6883 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6884#ifdef WLAN_FEATURE_VOWIFI_11R
6885 if (pSirBssDesc->mdiePresent)
6886 {
6887 pConnectProfile->MDID.mdiePresent = 1;
6888 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6889 }
6890#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006891 if( NULL == pIesTemp )
6892 {
6893 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006895#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006896 if ((csrIsProfileCCX(pProfile) ||
6897 ((pIesTemp->CCXVersion.present)
6898 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6899 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6900 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6901 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006902#ifdef WLAN_FEATURE_11W
6903 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6904#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306905 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006906 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 {
6908 pConnectProfile->isCCXAssoc = 1;
6909 }
6910#endif
6911 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 if(HAL_STATUS_SUCCESS(status))
6913 {
6914 if(pIesTemp->SSID.present)
6915 {
6916 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6917 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6918 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6919 }
6920
6921 //Save the bss desc
6922 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306923
6924 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306926 //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 -07006927 pConnectProfile->qap = TRUE;
6928 }
6929 else
6930 {
6931 pConnectProfile->qap = FALSE;
6932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 if ( NULL == pIes )
6934 {
6935 //Free memory if it allocated locally
6936 palFreeMemory(pMac->hHdd, pIesTemp);
6937 }
6938 }
6939 //Save Qos connection
6940 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6941
6942 if(!HAL_STATUS_SUCCESS(status))
6943 {
6944 csrFreeConnectBssDesc(pMac, sessionId);
6945 }
6946 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6947 {
6948 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6949 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6950 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6951 {
6952 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6953 break;
6954 }
6955 pConnectProfile->handoffPermitted = FALSE;
6956 }
6957
6958 return (status);
6959}
6960
Jeff Johnson295189b2012-06-20 16:38:30 -07006961static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6962{
6963 tListElem *pEntry = NULL;
6964 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 //The head of the active list is the request we sent
6966 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6967 if(pEntry)
6968 {
6969 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6972 {
6973 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6974 {
6975#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6976 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6977#endif
6978 }
6979 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6980 }
6981 else
6982 {
6983 tANI_U32 roamId = 0;
6984 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006985 if(!pSession)
6986 {
6987 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6988 return;
6989 }
6990
Jeff Johnson295189b2012-06-20 16:38:30 -07006991
6992 //The head of the active list is the request we sent
6993 //Try to get back the same profile and roam again
6994 if(pCommand)
6995 {
6996 roamId = pCommand->u.roamCmd.roamId;
6997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6999 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007000 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007001#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7002 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7003 if (csrRoamIsHandoffInProgress(pMac))
7004 {
7005 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7006 /* Should indicate neighbor roam algorithm about the connect failure here */
7007 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7008 }
7009#endif
7010 if (pCommand)
7011 {
7012 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7013 {
7014 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7015 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7016 csrRoamReissueRoamCommand(pMac);
7017 }
7018 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7019 {
7020 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7021 }
7022 else
7023 {
7024 csrRoam(pMac, pCommand);
7025 }
7026 }
7027 else
7028 {
7029 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7030 }
7031 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7032}
7033
Jeff Johnson295189b2012-06-20 16:38:30 -07007034eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7035 tDot11fBeaconIEs *pIes,
7036 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7037{
7038 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007039 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
7041 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
7042
7043 // Set the roaming substate to 'join attempt'...
7044 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007046 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 return (status);
7048}
7049
Jeff Johnson295189b2012-06-20 16:38:30 -07007050static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7051 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7052{
7053 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 // Set the roaming substate to 'join attempt'...
7055 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7056
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007057 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007058
7059 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007060 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007061}
7062
Jeff Johnson295189b2012-06-20 16:38:30 -07007063void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7064{
7065 tListElem *pEntry;
7066 tSmeCmd *pCommand;
7067 tCsrRoamInfo roamInfo;
7068 tANI_U32 sessionId;
7069 tCsrRoamSession *pSession;
7070
7071 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7072 if(pEntry)
7073 {
7074 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7075 if ( eSmeCommandRoam == pCommand->command )
7076 {
7077 sessionId = pCommand->sessionId;
7078 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007079
7080 if(!pSession)
7081 {
7082 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7083 return;
7084 }
7085
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 if( pCommand->u.roamCmd.fStopWds )
7087 {
7088 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7089 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7090 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7091 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7094 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7095 eCSR_ROAM_WDS_IND,
7096 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007097 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7098 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7099 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7100 eCSR_ROAM_INFRA_IND,
7101 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7102 }
7103
Jeff Johnson295189b2012-06-20 16:38:30 -07007104
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007107 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7109 }
7110 }
7111 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007113 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7115 }
7116 }
7117 else
7118 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007119 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 }
7121 }
7122 else
7123 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007124 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 }
7126}
7127
Jeff Johnson295189b2012-06-20 16:38:30 -07007128tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7129{
7130 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7131 tListElem *pEntry;
7132 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 //alwasy lock active list before locking pending list
7134 csrLLLock( &pMac->sme.smeCmdActiveList );
7135 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7136 if(pEntry)
7137 {
7138 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7139 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7140 {
7141 fRet = eANI_BOOLEAN_TRUE;
7142 }
7143 }
7144 if(eANI_BOOLEAN_FALSE == fRet)
7145 {
7146 csrLLLock(&pMac->sme.smeCmdPendingList);
7147 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7148 while(pEntry)
7149 {
7150 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7151 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7152 {
7153 fRet = eANI_BOOLEAN_TRUE;
7154 break;
7155 }
7156 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7157 }
7158 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7159 }
7160 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 return (fRet);
7162}
7163
Jeff Johnson295189b2012-06-20 16:38:30 -07007164tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7165{
7166 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7167 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7169 {
7170 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7171 {
7172 break;
7173 }
7174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 return ( fRet );
7176}
7177
Jeff Johnson295189b2012-06-20 16:38:30 -07007178tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7179{
7180 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 //alwasy lock active list before locking pending list
7182 csrLLLock( &pMac->sme.smeCmdActiveList );
7183 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7184 if(eANI_BOOLEAN_FALSE == fRet)
7185 {
7186 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7187 }
7188 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 return (fRet);
7190}
7191
Jeff Johnson295189b2012-06-20 16:38:30 -07007192tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7193{
7194 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7195 tListElem *pEntry;
7196 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 //alwasy lock active list before locking pending list
7198 csrLLLock( &pMac->sme.smeCmdActiveList );
7199 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7200 if( pEntry )
7201 {
7202 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7203 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7204 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7205 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7206 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7207 {
7208 fRet = eANI_BOOLEAN_TRUE;
7209 }
7210 }
7211 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 return (fRet);
7213}
Jeff Johnson295189b2012-06-20 16:38:30 -07007214eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7215{
7216 eHalStatus status = eHAL_STATUS_SUCCESS;
7217 tSmeCmd *pCommand = NULL;
7218 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7219 tANI_BOOLEAN fRemoveCmd = FALSE;
7220 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 // Delete the old assoc command. All is setup for reassoc to be serialized
7222 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7223 if ( pEntry )
7224 {
7225 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7226 if ( !pCommand )
7227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007228 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 return eHAL_STATUS_RESOURCES;
7230 }
7231 if ( eSmeCommandRoam == pCommand->command )
7232 {
7233 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7234 {
7235 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7236 }
7237 else
7238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007239 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 }
7241 if (fRemoveCmd == FALSE)
7242 {
7243 // Implies we did not get the serialized assoc command we
7244 // were expecting
7245 pCommand = NULL;
7246 }
7247 }
7248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 if(NULL == pCommand)
7250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007251 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 return eHAL_STATUS_RESOURCES;
7253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 do
7255 {
7256 //Change the substate in case it is wait-for-key
7257 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7258 {
7259 csrRoamStopWaitForKeyTimer( pMac );
7260 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7261 }
7262 pCommand->command = eSmeCommandRoam;
7263 pCommand->sessionId = (tANI_U8)sessionId;
7264 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7266 if( !HAL_STATUS_SUCCESS( status ) )
7267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007268 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 csrReleaseCommandRoam( pMac, pCommand );
7270 }
7271 } while( 0 );
7272
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 return( status );
7274}
7275static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7276{
7277 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7278 tCsrScanResult *pScanResult = NULL;
7279 tSirBssDescription *pBssDesc = NULL;
7280 tSmeCmd *pCommand = NULL;
7281 tANI_U32 sessionId;
7282 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 if(NULL == pEntry)
7284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007285 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 return;
7287 }
7288 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7289 sessionId = pCommand->sessionId;
7290 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007291
7292 if(!pSession)
7293 {
7294 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7295 return;
7296 }
7297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7299 {
7300 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007301 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7303 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007304 /* If the roaming has stopped, not to continue the roaming command*/
7305 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7306 {
7307 //No need to complete roaming here as it already completes
7308 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7309 pCommand->u.roamCmd.roamReason);
7310 csrSetAbortRoamingCommand( pMac, pCommand );
7311 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 else
7314 {
7315 if ( CCM_IS_RESULT_SUCCESS(result) )
7316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007317 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 // Successfully set the configuration parameters for the new Bss. Attempt to
7319 // join the roaming Bss.
7320 if(pCommand->u.roamCmd.pRoamBssEntry)
7321 {
7322 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7323 pBssDesc = &pScanResult->Result.BssDescriptor;
7324 }
7325 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7326 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 )
7329 {
7330 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7331 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7332 pBssDesc, pCommand->u.roamCmd.roamId )))
7333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007334 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 //We need to complete the command
7336 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7337 }
7338 }
7339 else
7340 {
7341 if (!pCommand->u.roamCmd.pRoamBssEntry)
7342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007343 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 //We need to complete the command
7345 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7346 return;
7347 }
7348 // If we are roaming TO an Infrastructure BSS...
7349 VOS_ASSERT(pScanResult != NULL);
7350 if ( csrIsInfraBssDesc( pBssDesc ) )
7351 {
7352 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7354 {
7355 // ..and currently in an Infrastructure connection....
7356 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7357 {
7358 // ...and the SSIDs are equal, then we Reassoc.
7359 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7360 pIesLocal ) )
7361 // ..and currently in an infrastructure connection
7362 {
7363 // then issue a Reassoc.
7364 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7365 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7366 &pCommand->u.roamCmd.roamProfile );
7367 }
7368 else
7369 {
7370
7371 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7372 // previously associated AP.
7373 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7374 pIesLocal,
7375 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7376 {
7377 //try something else
7378 csrRoam( pMac, pCommand );
7379 }
7380 }
7381 }
7382 else
7383 {
7384 eHalStatus status = eHAL_STATUS_SUCCESS;
7385
7386 /* We need to come with other way to figure out that this is because of HO in BMP
7387 The below API will be only available for Android as it uses a different HO algorithm */
7388 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7389 * use join request */
7390#ifdef WLAN_FEATURE_VOWIFI_11R
7391 if (csrRoamIsHandoffInProgress(pMac) &&
7392 csrRoamIs11rAssoc(pMac))
7393 {
7394 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7395 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7396 }
7397 else
7398#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007399#ifdef FEATURE_WLAN_CCX
7400 if (csrRoamIsHandoffInProgress(pMac) &&
7401 csrRoamIsCCXAssoc(pMac))
7402 {
7403 // Now serialize the reassoc command.
7404 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7405 }
7406 else
7407#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007408#ifdef FEATURE_WLAN_LFR
7409 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307410 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007411 {
7412 // Now serialize the reassoc command.
7413 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7414 }
7415 else
7416#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 // else we are not connected and attempting to Join. Issue the
7418 // Join request.
7419 {
7420 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7421 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7422 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7423 }
7424 if(!HAL_STATUS_SUCCESS(status))
7425 {
7426 //try something else
7427 csrRoam( pMac, pCommand );
7428 }
7429 }
7430 if( !pScanResult->Result.pvIes )
7431 {
7432 //Locally allocated
7433 palFreeMemory(pMac->hHdd, pIesLocal);
7434 }
7435 }
7436 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7437 else
7438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007439 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 }
7441 }//else
7442 }//if ( WNI_CFG_SUCCESS == result )
7443 else
7444 {
7445 // In the event the configuration failed, for infra let the roam processor
7446 //attempt to join something else...
7447 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7448 {
7449 csrRoam(pMac, pCommand);
7450 }
7451 else
7452 {
7453 //We need to complete the command
7454 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7455 {
7456 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7457 }
7458 else
7459 {
7460 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7461 }
7462 }
7463 }
7464 }//we have active entry
7465}
7466
Jeff Johnson295189b2012-06-20 16:38:30 -07007467static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7468{
7469 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007470 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007471 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007473 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7475 // join the new one...
7476 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7478 }
7479 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007480 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 /***profHandleLostLinkAfterReset(pAdapter);
7482 // In the event the authenticate fails, let the roam processor attempt to join something else...
7483 roamRoam( pAdapter );***/
7484 }
7485}
7486
Jeff Johnson295189b2012-06-20 16:38:30 -07007487static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7488{
7489 eCsrRoamCompleteResult result;
7490 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7491 tCsrRoamInfo roamInfo;
7492 tANI_U32 roamId = 0;
7493
7494 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007496 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 /* Defeaturize this part later if needed */
7499#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7500 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7501 * we need the response contents while processing the result in csrRoamProcessResults() */
7502 if (csrRoamIsHandoffInProgress(pMac))
7503 {
7504 /* Need to dig more on indicating events to SME QoS module */
7505 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7506 csrRoamComplete( pMac, result, pSmeJoinRsp);
7507 }
7508 else
7509#endif
7510 {
7511 csrRoamComplete( pMac, result, NULL );
7512 }
7513 }
7514 /* Should we handle this similar to handling the join failure? Is it ok
7515 * to call csrRoamComplete() with state as CsrJoinFailure */
7516 else
7517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007518 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 result = eCsrReassocFailure;
7520#ifdef WLAN_FEATURE_VOWIFI_11R
7521 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7522 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7523 {
7524 // Inform HDD to turn off FT flag in HDD
7525 if (pNeighborRoamInfo)
7526 {
7527 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7528 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7529 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007530 /*
7531 * Since the above callback sends a disconnect
7532 * to HDD, we should clean-up our state
7533 * machine as well to be in sync with the upper
7534 * layers. There is no need to send a disassoc
7535 * since: 1) we will never reassoc to the current
7536 * AP in LFR, and 2) there is no need to issue a
7537 * disassoc to the AP with which we were trying
7538 * to reassoc.
7539 */
7540 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7541 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 }
7543 }
7544#endif
7545 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7546 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7547 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7548 //The disassoc rsp message will remove the command from active list
7549 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7550 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7551 {
7552 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7553 }
7554 }
7555}
7556
Jeff Johnson295189b2012-06-20 16:38:30 -07007557static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7558{
Jeff Johnson295189b2012-06-20 16:38:30 -07007559#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7560 {
7561 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007562 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7563 if(pIbssLog)
7564 {
7565 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7566 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7567 {
7568 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7569 }
7570 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7571 }
7572 }
7573#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7575 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7576 {
7577 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7578 }
7579 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7580 {
7581 csrRoamReissueRoamCommand(pMac);
7582 }
7583}
7584
Jeff Johnson295189b2012-06-20 16:38:30 -07007585void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7586{
7587 tSirResultCodes statusCode;
7588#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7589 tScanResultHandle hBSSList;
7590 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7591 eHalStatus status;
7592 tCsrRoamInfo roamInfo;
7593 tCsrScanResultFilter *pScanFilter = NULL;
7594 tANI_U32 roamId = 0;
7595 tCsrRoamProfile *pCurRoamProfile = NULL;
7596 tListElem *pEntry = NULL;
7597 tSmeCmd *pCommand = NULL;
7598#endif
7599 tANI_U32 sessionId;
7600 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007601
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 tSirSmeDisassocRsp SmeDisassocRsp;
7603
7604 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7605 sessionId = SmeDisassocRsp.sessionId;
7606 statusCode = SmeDisassocRsp.statusCode;
7607
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007608 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
7610 if ( csrIsConnStateInfra( pMac, sessionId ) )
7611 {
7612 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007615
7616 if(!pSession)
7617 {
7618 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7619 return;
7620 }
7621
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7623 {
7624 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7625 }
7626 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7627 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7628 {
7629 if ( eSIR_SME_SUCCESS == statusCode )
7630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007631 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7633 }
7634 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007638 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007639#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007640 /*
7641 * First ensure if the roam profile is in the scan cache.
7642 * If not, post a reassoc failure and disconnect.
7643 */
7644 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7645 if(HAL_STATUS_SUCCESS(status))
7646 {
7647 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7648 status = csrRoamPrepareFilterFromProfile(pMac,
7649 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7650 if(!HAL_STATUS_SUCCESS(status))
7651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007652 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007653 __func__, status);
7654 goto POST_ROAM_FAILURE;
7655 }
7656 else
7657 {
7658 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7659 if (!HAL_STATUS_SUCCESS(status))
7660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007661 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007662 __func__, status);
7663 goto POST_ROAM_FAILURE;
7664 }
7665 }
7666 }
7667 else
7668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007669 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007670 __func__, status);
7671 goto POST_ROAM_FAILURE;
7672 }
7673
7674 /*
7675 * After ensuring that the roam profile is in the scan result list,
7676 * dequeue the command from the active list.
7677 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7679 if ( pEntry )
7680 {
7681 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007682 /* If the head of the queue is Active and it is a ROAM command, remove
7683 * and put this on the Free queue.
7684 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 if ( eSmeCommandRoam == pCommand->command )
7686 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007687
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007688 /*
7689 * we need to process the result first before removing it from active list
7690 * because state changes still happening insides roamQProcessRoamResults so
7691 * no other roam command should be issued.
7692 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7694 if(pCommand->u.roamCmd.fReleaseProfile)
7695 {
7696 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7697 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 else
7702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007703 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007704 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 }
7706 }
7707 else
7708 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007709 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 }
7711 }
7712 else
7713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007714 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007716
7717 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7719
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007720 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7721 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7722 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007723
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007724 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7725 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007726
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007727 /* Copy the connected profile to apply the same for this connection as well */
7728 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7729 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007731 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7732 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7733 //make sure to put it at the head of the cmd queue
7734 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7735 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7736 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7737
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 if(!HAL_STATUS_SUCCESS(status))
7739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007740 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007741 __func__, status);
7742 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 }
7744
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007745 /* Notify sub-modules like QoS etc. that handoff happening */
7746 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007747 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007748 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007749 csrFreeScanFilter(pMac, pScanFilter);
7750 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007751 return;
7752 }
7753
7754POST_ROAM_FAILURE:
7755 if (pScanFilter)
7756 {
7757 csrFreeScanFilter(pMac, pScanFilter);
7758 palFreeMemory( pMac->hHdd, pScanFilter );
7759 }
7760 if (pCurRoamProfile)
7761 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7762
7763 /* Inform the upper layers that the reassoc failed */
7764 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7765 csrRoamCallCallback(pMac, sessionId,
7766 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7767
7768 /*
7769 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7770 * Upon success, we would re-enter this routine after receiving the disassoc
7771 * response and will fall into the reassoc fail sub-state. And, eventually
7772 * call csrRoamComplete which would remove the roam command from SME active
7773 * queue.
7774 */
7775 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7776 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007778 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007779 __func__, status);
7780 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007782#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007783
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7785 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7786 {
7787 // Disassoc due to Reassoc failure falls into this codepath....
7788 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7789 }
7790 else
7791 {
7792 if ( eSIR_SME_SUCCESS == statusCode )
7793 {
7794 // Successfully disassociated from the 'old' Bss...
7795 //
7796 // We get Disassociate response in three conditions.
7797 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7798 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7799 // Infrastructure network.
7800 // - Third is where we are doing an Infra to Infra roam between networks with different
7801 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7802
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007803 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 }
7805 else
7806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007807 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 }
7809 //We are not done yet. Get the data and continue roaming
7810 csrRoamReissueRoamCommand(pMac);
7811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007812}
7813
Jeff Johnson295189b2012-06-20 16:38:30 -07007814static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7815{
7816 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007818 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7820 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7821 {
7822 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7823 }
7824 else
7825 {
7826 if ( eSIR_SME_SUCCESS == statusCode )
7827 {
7828 // Successfully deauth from the 'old' Bss...
7829 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007830 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 }
7832 else
7833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007834 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 }
7836 //We are not done yet. Get the data and continue roaming
7837 csrRoamReissueRoamCommand(pMac);
7838 }
7839}
7840
Jeff Johnson295189b2012-06-20 16:38:30 -07007841static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7842{
7843 eCsrRoamCompleteResult result;
7844
7845 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007847 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 result = eCsrStartBssSuccess;
7849 }
7850 else
7851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007852 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 //Let csrRoamComplete decide what to do
7854 result = eCsrStartBssFailure;
7855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007857}
7858
Jeff Johnson295189b2012-06-20 16:38:30 -07007859/*
7860 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7861 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7862 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7863 For the messages where sender allocates memory for specific structures, then it can be
7864 cast accordingly.
7865*/
7866void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7867{
7868 tSirSmeRsp *pSmeRsp;
7869 tSmeIbssPeerInd *pIbssPeerInd;
7870 tCsrRoamInfo roamInfo;
7871 // TODO Session Id need to be acquired in this function
7872 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007874 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 pSmeRsp->messageType, pSmeRsp->messageType,
7876 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 pSmeRsp->messageType = (pSmeRsp->messageType);
7878 pSmeRsp->length = (pSmeRsp->length);
7879 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 switch (pSmeRsp->messageType)
7881 {
7882
7883 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7884 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7885 {
7886 //We sent a JOIN_REQ
7887 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7888 }
7889 break;
7890
7891 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7892 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7893 {
7894 //We sent a AUTH_REQ
7895 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7896 }
7897 break;
7898
7899 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7900 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7901 {
7902 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7903 }
7904 break;
7905
7906 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7907 {
7908 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7909 }
7910 break;
7911
7912 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7913 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7914 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7915 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7916 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7917 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7918//HO
7919 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007921 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7923 }
7924 break;
7925
7926 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7927 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7928 {
7929 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7930 }
7931 break;
7932
7933 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7934 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7935 {
7936 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7937 }
7938 break;
7939
7940 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7941 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7942 {
7943 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7947 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7948 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007949 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7951 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7952 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7953 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7954 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7955 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7956 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7957 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7958 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007960 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 pSmeRsp->messageType, pSmeRsp->messageType,
7962 pMac->roam.curSubState[pSmeRsp->sessionId] );
7963
7964 //If we are connected, check the link status change
7965 if(!csrIsConnStateDisconnected(pMac, sessionId))
7966 {
7967 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7968 }
7969 break;
7970 }
7971}
7972
Jeff Johnson295189b2012-06-20 16:38:30 -07007973void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7974{
7975 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976 switch (pSirMsg->messageType)
7977 {
7978 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007979 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 csrRoamStatsRspProcessor( pMac, pSirMsg );
7981 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7983 {
7984 tCsrRoamSession *pSession;
7985 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7986 tCsrRoamInfo roamInfo;
7987 tCsrRoamInfo *pRoamInfo = NULL;
7988 tANI_U32 sessionId;
7989 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007990 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7992 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7994 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7995 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007996
7997 if(!pSession)
7998 {
7999 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8000 return;
8001 }
8002
Jeff Johnson295189b2012-06-20 16:38:30 -07008003 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8004 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8006 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8007 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8009 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
8011 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8014 {
8015 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8016 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8017 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8018 }
8019 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8020 {
8021 vos_sleep( 100 );
8022 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8023 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8024 }
8025
Jeff Johnson295189b2012-06-20 16:38:30 -07008026 }
8027 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 default:
8029 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8030 break;
8031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008032}
8033
Jeff Johnson295189b2012-06-20 16:38:30 -07008034eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8035 tSirBssDescription *pBssDescription,
8036 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8037 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8038 tANI_U8 keyId, tANI_U16 keyLength,
8039 tANI_U8 *pKey, tANI_U8 paeRole )
8040{
8041 eHalStatus status = eHAL_STATUS_SUCCESS;
8042 tAniEdType edType;
8043
8044 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8045 {
8046 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8047 }
8048
8049 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8050
8051 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8052 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8053 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8054 addKey )
8055 {
8056 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 setKey.encType = EncryptType;
8058 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
8059 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
8060 setKey.paeRole = paeRole; //0 for supplicant
8061 setKey.keyId = keyId; // Kye index
8062 setKey.keyLength = keyLength;
8063 if( keyLength )
8064 {
8065 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
8066 }
8067 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 return (status);
8070}
8071
Jeff Johnson295189b2012-06-20 16:38:30 -07008072static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8073 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8074{
8075 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8076 tSmeCmd *pCommand = NULL;
8077#ifdef FEATURE_WLAN_CCX
8078 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8079#endif /* FEATURE_WLAN_CCX */
8080
8081 do
8082 {
8083 pCommand = csrGetCommandBuffer(pMac);
8084 if(NULL == pCommand)
8085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008086 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 status = eHAL_STATUS_RESOURCES;
8088 break;
8089 }
8090 pCommand->command = eSmeCommandSetKey;
8091 pCommand->sessionId = (tANI_U8)sessionId;
8092 // validate the key length, Adjust if too long...
8093 // for static WEP the keys are not set thru' SetContextReq
8094 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8095 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8096 {
8097 //KeyLength maybe 0 for static WEP
8098 if( pSetKey->keyLength )
8099 {
8100 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008102 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008103 break;
8104 }
8105
8106 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
8107 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
8108 }
8109 }
8110 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8111 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8112 {
8113 //KeyLength maybe 0 for static WEP
8114 if( pSetKey->keyLength )
8115 {
8116 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8117 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008118 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 break;
8120 }
8121
8122 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8123 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8124 }
8125 }
8126 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8127 {
8128 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8129 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008130 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 break;
8132 }
8133 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8134 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8135 }
8136 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8137 {
8138 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8139 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008140 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 break;
8142 }
8143 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8144 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8145 }
8146#ifdef FEATURE_WLAN_WAPI
8147 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8148 {
8149 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008151 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 break;
8153 }
8154 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8155 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8156 }
8157#endif /* FEATURE_WLAN_WAPI */
8158#ifdef FEATURE_WLAN_CCX
8159 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8160 {
8161 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008163 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 break;
8165 }
8166 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8167 pSession->ccxCckmInfo.reassoc_req_num=1;
8168 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8169 status = eHAL_STATUS_SUCCESS;
8170 break;
8171 }
8172#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008173
Jeff Johnson295189b2012-06-20 16:38:30 -07008174#ifdef WLAN_FEATURE_11W
8175 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008176 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008178 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008180 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 break;
8182 }
8183 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008184 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 }
8186#endif
8187 status = eHAL_STATUS_SUCCESS;
8188 pCommand->u.setKeyCmd.roamId = roamId;
8189 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8190 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8191 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8192 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8193 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8194 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8195 //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
8196
8197 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8198 if( !HAL_STATUS_SUCCESS( status ) )
8199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008200 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 }
8202 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 // Free the command if there has been a failure, or it is a
8204 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008205 if ( ( NULL != pCommand ) &&
8206 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008207#ifdef FEATURE_WLAN_CCX
8208 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8209#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008210 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 {
8212 csrReleaseCommandSetKey( pMac, pCommand );
8213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 return( status );
8215}
8216
Jeff Johnson295189b2012-06-20 16:38:30 -07008217eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8218 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8219{
8220 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8221 tSmeCmd *pCommand = NULL;
8222 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 do
8224 {
8225 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008227 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 status = eHAL_STATUS_CSR_WRONG_STATE;
8229 break;
8230 }
8231 pCommand = csrGetCommandBuffer(pMac);
8232 if(NULL == pCommand)
8233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008234 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 status = eHAL_STATUS_RESOURCES;
8236 break;
8237 }
8238 pCommand->command = eSmeCommandRemoveKey;
8239 pCommand->sessionId = (tANI_U8)sessionId;
8240 pCommand->u.removeKeyCmd.roamId = roamId;
8241 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8242 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8243 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8244 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8245 {
8246 //in this case, put it to the end of the Q incase there is a set key pending.
8247 fImediate = eANI_BOOLEAN_FALSE;
8248 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008249 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 pRemoveKey->encType, pRemoveKey->keyId,
8251 pCommand->u.removeKeyCmd.peerMac[0],
8252 pCommand->u.removeKeyCmd.peerMac[1],
8253 pCommand->u.removeKeyCmd.peerMac[2],
8254 pCommand->u.removeKeyCmd.peerMac[3],
8255 pCommand->u.removeKeyCmd.peerMac[4],
8256 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8258 if( !HAL_STATUS_SUCCESS( status ) )
8259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008260 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 break;
8262 }
8263 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008264 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8265 {
8266 csrReleaseCommandRemoveKey( pMac, pCommand );
8267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 return (status );
8269}
8270
Jeff Johnson295189b2012-06-20 16:38:30 -07008271eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8272{
8273 eHalStatus status;
8274 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8275 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8276 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8277 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008278#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8279 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8280 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008281 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008282 {
8283 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8284 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8285 {
8286 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8287 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8288 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8289 }
8290 else
8291 {
8292 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8293 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8294 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8295 }
8296 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
lukez3c809222013-05-03 10:23:02 -07008297 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 {
8299 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 //It has to be static WEP here
8301 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8302 {
8303 setKeyEvent.keyId = (v_U8_t)defKeyId;
8304 }
8305 }
8306 else
8307 {
8308 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8309 }
8310 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8311 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8312 }
8313#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 if( csrIsSetKeyAllowed(pMac, sessionId) )
8315 {
8316 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8317 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8318 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8319 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8320 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8321 pCommand->u.setKeyCmd.keyRsc);
8322 }
8323 else
8324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008325 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 //Set this status so the error handling take care of the case.
8327 status = eHAL_STATUS_CSR_WRONG_STATE;
8328 }
8329 if( !HAL_STATUS_SUCCESS(status) )
8330 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008331 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008333#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008334 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 {
8336 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8337 {
8338 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8339 }
8340 else
8341 {
8342 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8343 }
8344 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8345 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8346 }
8347#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 return ( status );
8350}
8351
Jeff Johnson295189b2012-06-20 16:38:30 -07008352eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8353{
8354 eHalStatus status;
8355 tpSirSmeRemoveKeyReq pMsg = NULL;
8356 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8357 tANI_U8 *p;
8358 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008359#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8360 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8361 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8363 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8364 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8365 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8366 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8367 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8368 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8369 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8370#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008371 if( csrIsSetKeyAllowed(pMac, sessionId) )
8372 {
8373 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8374 }
8375 else
8376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008377 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 //Set the error status so error handling kicks in below
8379 status = eHAL_STATUS_CSR_WRONG_STATE;
8380 }
8381 if( HAL_STATUS_SUCCESS( status ) )
8382 {
8383 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8384 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8385 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 pMsg->sessionId = (tANI_U8)sessionId;
8387 pMsg->transactionId = 0;
8388 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8389 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8390 // bssId - copy from session Info
8391 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8392 p += sizeof(tSirMacAddr);
8393 // peerMacAddr
8394 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8395 p += sizeof(tSirMacAddr);
8396 // edType
8397 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8398 p++;
8399 // weptype
8400 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8401 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8402 {
8403 *p = (tANI_U8)eSIR_WEP_STATIC;
8404 }
8405 else
8406 {
8407 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8408 }
8409 p++;
8410 //keyid
8411 *p = pCommand->u.removeKeyCmd.keyId;
8412 p++;
8413 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 status = palSendMBMessage(pMac->hHdd, pMsg);
8415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 if( !HAL_STATUS_SUCCESS( status ) )
8417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008418 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008419#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8420 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008421 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8423#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 return ( status );
8427}
8428
Jeff Johnson295189b2012-06-20 16:38:30 -07008429eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8430{
8431 eHalStatus status;
8432
8433 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8434 {
8435 status = eHAL_STATUS_CSR_WRONG_STATE;
8436 }
8437 else
8438 {
8439 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 return ( status );
8442}
8443
Jeff Johnson295189b2012-06-20 16:38:30 -07008444/*
8445 Prepare a filter base on a profile for parsing the scan results.
8446 Upon successful return, caller MUST call csrFreeScanFilter on
8447 pScanFilter when it is done with the filter.
8448*/
8449eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8450 tCsrScanResultFilter *pScanFilter)
8451{
8452 eHalStatus status = eHAL_STATUS_SUCCESS;
8453 tANI_U32 size = 0;
8454 tANI_U8 index = 0;
8455
8456 do
8457 {
8458 if(pProfile->BSSIDs.numOfBSSIDs)
8459 {
8460 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8461 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8462 if(!HAL_STATUS_SUCCESS(status))
8463 {
8464 break;
8465 }
8466 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8467 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8468 }
8469 if(pProfile->SSIDs.numOfSSIDs)
8470 {
8471 if( !CSR_IS_WDS_STA( pProfile ) )
8472 {
8473 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8474 }
8475 else
8476 {
8477 //For WDS station
8478 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8479 pScanFilter->SSIDs.numOfSSIDs = 1;
8480 }
8481 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8482 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8483 if(!HAL_STATUS_SUCCESS(status))
8484 {
8485 break;
8486 }
8487 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8488 }
8489 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8490 {
8491 pScanFilter->ChannelInfo.numOfChannels = 0;
8492 pScanFilter->ChannelInfo.ChannelList = NULL;
8493 }
8494 else if(pProfile->ChannelInfo.numOfChannels)
8495 {
8496 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8497 pScanFilter->ChannelInfo.numOfChannels = 0;
8498 if(HAL_STATUS_SUCCESS(status))
8499 {
8500 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8501 {
8502 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8503 {
8504 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8505 = pProfile->ChannelInfo.ChannelList[index];
8506 pScanFilter->ChannelInfo.numOfChannels++;
8507 }
8508 else
8509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008510 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 }
8513 }
8514 else
8515 {
8516 break;
8517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 }
8519 else
8520 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008521 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 status = eHAL_STATUS_FAILURE;
8523 break;
8524 }
8525 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8526 pScanFilter->authType = pProfile->AuthType;
8527 pScanFilter->EncryptionType = pProfile->EncryptionType;
8528 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8529 pScanFilter->BSSType = pProfile->BSSType;
8530 pScanFilter->phyMode = pProfile->phyMode;
8531#ifdef FEATURE_WLAN_WAPI
8532 //check if user asked for WAPI with 11n or auto mode, in that case modify
8533 //the phymode to 11g
8534 if(csrIsProfileWapi(pProfile))
8535 {
8536 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8537 {
8538 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8539 }
8540 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8541 {
8542 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8543 }
8544 if(!pScanFilter->phyMode)
8545 {
8546 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8547 }
8548 }
8549#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 /*Save the WPS info*/
8551 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 if( pProfile->countryCode[0] )
8553 {
8554 //This causes the matching function to use countryCode as one of the criteria.
8555 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8556 WNI_CFG_COUNTRY_CODE_LEN );
8557 }
8558#ifdef WLAN_FEATURE_VOWIFI_11R
8559 if (pProfile->MDID.mdiePresent)
8560 {
8561 pScanFilter->MDID.mdiePresent = 1;
8562 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8563 }
8564#endif
8565
8566 }while(0);
8567
8568 if(!HAL_STATUS_SUCCESS(status))
8569 {
8570 csrFreeScanFilter(pMac, pScanFilter);
8571 }
8572
8573 return(status);
8574}
8575
Jeff Johnson295189b2012-06-20 16:38:30 -07008576tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8577 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8578{
8579 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8580 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008581 do
8582 {
8583 // Validate the type is ok...
8584 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8585 pCommand = csrGetCommandBuffer( pMac );
8586 if ( !pCommand )
8587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008588 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 break;
8590 }
8591 //Change the substate in case it is waiting for key
8592 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8593 {
8594 csrRoamStopWaitForKeyTimer( pMac );
8595 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8596 }
8597 pCommand->command = eSmeCommandWmStatusChange;
8598 pCommand->sessionId = (tANI_U8)sessionId;
8599 pCommand->u.wmStatusChangeCmd.Type = Type;
8600 if ( eCsrDisassociated == Type )
8601 {
8602 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8603 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8604 }
8605 else
8606 {
8607 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8608 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8609 }
8610 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8611 {
8612 fCommandQueued = eANI_BOOLEAN_TRUE;
8613 }
8614 else
8615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008616 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 csrReleaseCommandWmStatusChange( pMac, pCommand );
8618 }
8619
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8621 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 return( fCommandQueued );
8624}
8625
Jeff Johnson295189b2012-06-20 16:38:30 -07008626static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8627{
8628 v_S7_t rssi = 0;
8629 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8630 if(pGetRssiReq)
8631 {
8632 if(NULL != pGetRssiReq->pVosContext)
8633 {
8634 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8635 }
8636 else
8637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008638 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 return;
8640 }
8641
8642 if(NULL != pGetRssiReq->rssiCallback)
8643 {
8644 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8645 }
8646 else
8647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008648 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 return;
8650 }
8651 }
8652 else
8653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008654 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 }
8656 return;
8657}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008658#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8659void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8660{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008661 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8662
Jeff Johnson36d483b2013-04-08 11:08:53 -07008663 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008664 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008665 /* Get roam Rssi request is backed up and passed back to the response,
8666 Extract the request message to fetch callback */
8667 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8668 v_S7_t rssi = pRoamRssiRsp->rssi;
8669
8670 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008671 {
8672 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8673 reqBkp->rssiCallback = NULL;
8674 vos_mem_free(reqBkp);
8675 }
8676 else
8677 {
8678 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8679 if (NULL != reqBkp)
8680 {
8681 vos_mem_free(reqBkp);
8682 }
8683 }
8684 }
8685 else
8686 {
8687 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8688 }
8689 return;
8690}
8691#endif
8692
Jeff Johnsone7245742012-09-05 17:12:55 -07008693static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8694{
8695 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8696 if(pTlRssiInd)
8697 {
8698 if(NULL != pTlRssiInd->tlCallback)
8699 {
8700 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008701 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008702 }
8703 else
8704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008705 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008706 }
8707 }
8708 else
8709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008710 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008711 }
8712 return;
8713}
Jeff Johnson295189b2012-06-20 16:38:30 -07008714
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308715eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8716{
8717 tpSirResetAPCapsChange pMsg;
8718 tANI_U16 len;
8719 eHalStatus status = eHAL_STATUS_SUCCESS;
8720
8721 /* Create the message and send to lim */
8722 len = sizeof(tSirResetAPCapsChange);
8723 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8724 if (HAL_STATUS_SUCCESS(status))
8725 {
8726 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8727 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8728 pMsg->length = len;
8729 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8730 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8731 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8732 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8733 status = palSendMBMessage(pMac->hHdd, pMsg);
8734 }
8735 else
8736 {
8737 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8738 }
8739 return status;
8740}
8741
Jeff Johnson295189b2012-06-20 16:38:30 -07008742void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8743{
8744 tSirSmeAssocInd *pAssocInd;
8745 tSirSmeDisassocInd *pDisassocInd;
8746 tSirSmeDeauthInd *pDeauthInd;
8747 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8748 tSirSmeNewBssInfo *pNewBss;
8749 tSmeIbssPeerInd *pIbssPeerInd;
8750 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8751 tSirSmeApNewCaps *pApNewCaps;
8752 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8753 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8754 tCsrRoamInfo *pRoamInfo = NULL;
8755 tCsrRoamInfo roamInfo;
8756 eHalStatus status;
8757 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8758 tCsrRoamSession *pSession = NULL;
8759 tpSirSmeSwitchChannelInd pSwitchChnInd;
8760 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008761 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 pSirMsg->messageType = (pSirMsg->messageType);
8763 pSirMsg->length = (pSirMsg->length);
8764 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 switch( pSirMsg->messageType )
8767 {
8768 case eWNI_SME_ASSOC_IND:
8769 {
8770 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008771 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8773 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8774 if( HAL_STATUS_SUCCESS( status ) )
8775 {
8776 pSession = CSR_GET_SESSION(pMac, sessionId);
8777
Jeff Johnson32d95a32012-09-10 13:15:23 -07008778 if(!pSession)
8779 {
8780 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8781 return;
8782 }
8783
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 pRoamInfo = &roamInfo;
8785
8786 // Required for indicating the frames to upper layer
8787 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8788 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8789
8790 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8791 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8792 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8793 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8794
8795 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8796 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8797 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8798
8799 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8800 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8802 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8804 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8807 {
8808 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8809 {
8810 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8811 pSession->pConnectBssDesc,
8812 &(pRoamInfo->peerMac),
8813 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8814 pRoamInfo->fAuthRequired = FALSE;
8815 }
8816 else
8817 {
8818 pRoamInfo->fAuthRequired = TRUE;
8819 }
8820 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8821 if (!HAL_STATUS_SUCCESS(status))
8822 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 /* Send Association completion message to PE */
8825 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8826
8827 /* send a message to CSR itself just to avoid the EAPOL frames going
8828 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8830 {
8831 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8834 {
8835 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8836 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8837 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 }
8840 }
8841 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008843 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008844 // Check if AP dis-associated us because of MIC failure. If so,
8845 // then we need to take action immediately and not wait till the
8846 // the WmStatusChange requests is pushed and processed
8847 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8848 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8849 if( HAL_STATUS_SUCCESS( status ) )
8850 {
8851 // If we are in neighbor preauth done state then on receiving
8852 // disassoc or deauth we dont roam instead we just disassoc
8853 // from current ap and then go to disconnected state
8854 // This happens for CCX and 11r FT connections ONLY.
8855#ifdef WLAN_FEATURE_VOWIFI_11R
8856 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8857 {
8858 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8859 }
8860#endif
8861#ifdef FEATURE_WLAN_CCX
8862 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8863 {
8864 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8865 }
8866#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008867#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308868 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008869 {
8870 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8871 }
8872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 pSession = CSR_GET_SESSION( pMac, sessionId );
8874
Jeff Johnson32d95a32012-09-10 13:15:23 -07008875 if(!pSession)
8876 {
8877 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8878 return;
8879 }
8880
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 if ( csrIsConnStateInfra( pMac, sessionId ) )
8882 {
8883 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008885#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8886 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8887#endif
8888 csrRoamLinkDown(pMac, sessionId);
8889 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8891 {
8892
8893 pRoamInfo = &roamInfo;
8894
8895 pRoamInfo->statusCode = pDisassocInd->statusCode;
8896 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8897
8898 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8899
8900 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8901 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8902
8903 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008904
8905 /*
8906 * STA/P2P client got disassociated so remove any pending deauth
8907 * commands in sme pending list
8908 */
8909 pCommand.command = eSmeCommandRoam;
8910 pCommand.sessionId = (tANI_U8)sessionId;
8911 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8912 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8913 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 }
8916 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008918 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8920 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8921 if( HAL_STATUS_SUCCESS( status ) )
8922 {
8923 // If we are in neighbor preauth done state then on receiving
8924 // disassoc or deauth we dont roam instead we just disassoc
8925 // from current ap and then go to disconnected state
8926 // This happens for CCX and 11r FT connections ONLY.
8927#ifdef WLAN_FEATURE_VOWIFI_11R
8928 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8929 {
8930 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8931 }
8932#endif
8933#ifdef FEATURE_WLAN_CCX
8934 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8935 {
8936 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8937 }
8938#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008939#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308940 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008941 {
8942 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8943 }
8944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 pSession = CSR_GET_SESSION( pMac, sessionId );
8946
Jeff Johnson32d95a32012-09-10 13:15:23 -07008947 if(!pSession)
8948 {
8949 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8950 return;
8951 }
8952
Jeff Johnson295189b2012-06-20 16:38:30 -07008953 if ( csrIsConnStateInfra( pMac, sessionId ) )
8954 {
8955 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008957#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8958 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8959#endif
8960 csrRoamLinkDown(pMac, sessionId);
8961 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8963 {
8964
8965 pRoamInfo = &roamInfo;
8966
8967 pRoamInfo->statusCode = pDeauthInd->statusCode;
8968 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8969
8970 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8971
8972 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8973 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8974
8975 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008977 }
8978 break;
8979
8980 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 -08008981 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8983 //Update with the new channel id.
8984 //The channel id is hidden in the statusCode.
8985 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8986 if( HAL_STATUS_SUCCESS( status ) )
8987 {
8988 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008989 if(!pSession)
8990 {
8991 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8992 return;
8993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8995 if(pSession->pConnectBssDesc)
8996 {
8997 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8998 }
8999 }
9000 break;
9001
9002 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009003 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009004 {
9005 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9006 sessionId = pDeauthRsp->sessionId;
9007 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9008 {
9009 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009010 if(!pSession)
9011 {
9012 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9013 return;
9014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9016 {
9017 pRoamInfo = &roamInfo;
9018 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9019 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
9020 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9021 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9022 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9023 }
9024 }
9025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 break;
9027
9028 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009029 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009030 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 {
9032 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9033 sessionId = pDisassocRsp->sessionId;
9034 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9035 {
9036 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009037 if(!pSession)
9038 {
9039 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9040 return;
9041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9043 {
9044 pRoamInfo = &roamInfo;
9045 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9046 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
9047 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9048 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9049 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9050 }
9051 }
9052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 case eWNI_SME_MIC_FAILURE_IND:
9055 {
9056 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9057 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9058 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07009059#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9060 {
lukez3c809222013-05-03 10:23:02 -07009061 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009063 if(!pSession)
9064 {
9065 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9066 return;
9067 }
lukez3c809222013-05-03 10:23:02 -07009068
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
9070 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9071 secEvent.encryptionModeMulticast =
9072 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9073 secEvent.encryptionModeUnicast =
9074 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9075 secEvent.authMode =
9076 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9077 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
9078 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9079 }
9080#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9082 if( HAL_STATUS_SUCCESS( status ) )
9083 {
9084 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9085 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9086 pRoamInfo = &roamInfo;
9087 if(pMicInd->info.multicast)
9088 {
9089 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9090 }
9091 else
9092 {
9093 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9094 }
9095 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9096 }
9097 }
9098 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009099 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9100 {
9101 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9102 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009103 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009104
9105 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9106 if( HAL_STATUS_SUCCESS( status ) )
9107 {
9108 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9109 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9110 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9111 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9112 }
9113 }
9114 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009115
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9117 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9118 switch( pStatusChangeMsg->statusChangeCode )
9119 {
9120 case eSIR_SME_IBSS_ACTIVE:
9121 sessionId = csrFindIbssSession( pMac );
9122 if( CSR_SESSION_ID_INVALID != sessionId )
9123 {
9124 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009125 if(!pSession)
9126 {
9127 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9128 return;
9129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9131 if(pSession->pConnectBssDesc)
9132 {
9133 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9134 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9135 pRoamInfo = &roamInfo;
9136 }
9137 else
9138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009139 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 }
9141 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9142 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9143 }
9144 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009145 case eSIR_SME_IBSS_INACTIVE:
9146 sessionId = csrFindIbssSession( pMac );
9147 if( CSR_SESSION_ID_INVALID != sessionId )
9148 {
9149 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009150 if(!pSession)
9151 {
9152 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9153 return;
9154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9156 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9157 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9158 }
9159 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9161 sessionId = csrFindIbssSession( pMac );
9162 if( CSR_SESSION_ID_INVALID != sessionId )
9163 {
9164 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009165 if(!pSession)
9166 {
9167 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9168 return;
9169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 // update the connection state information
9171 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009172#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9173 {
9174 vos_log_ibss_pkt_type *pIbssLog;
9175 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009176 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9177 if(pIbssLog)
9178 {
9179 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9180 if(pNewBss)
9181 {
9182 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9183 if(pNewBss->ssId.length)
9184 {
9185 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9186 }
9187 pIbssLog->operatingChannel = pNewBss->channelNumber;
9188 }
9189 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9190 {
9191 //***U8 is not enough for beacon interval
9192 pIbssLog->beaconInterval = (v_U8_t)bi;
9193 }
9194 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9195 }
9196 }
9197#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009199
9200 if ((eCSR_ENCRYPT_TYPE_NONE ==
9201 pSession->connectedProfile.EncryptionType ))
9202 {
9203 csrRoamIssueSetContextReq( pMac, sessionId,
9204 pSession->connectedProfile.EncryptionType,
9205 pSession->pConnectBssDesc,
9206 &Broadcastaddr,
9207 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9210 roamStatus = eCSR_ROAM_IBSS_IND;
9211 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9212 pRoamInfo = &roamInfo;
9213 //This BSSID is th ereal BSSID, let's save it
9214 if(pSession->pConnectBssDesc)
9215 {
9216 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9217 }
9218 // Stop the join IBSS timer in case of join, for
9219 // genuine merge do nothing
9220 if(pSession->ibss_join_pending)
9221 {
9222 pSession->ibss_join_pending = FALSE;
9223 csrRoamStopIbssJoinTimer(pMac, sessionId);
9224 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9225 }
9226 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009227 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 // detection by LIM that the capabilities of the associated AP have changed.
9230 case eSIR_SME_AP_CAPS_CHANGED:
9231 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009232 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9234 if( HAL_STATUS_SUCCESS( status ) )
9235 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009236 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9237 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309238 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009239 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9240 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9241 )
9242 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309243 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9244 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009245 }
9246 else
9247 {
9248 smsLog(pMac, LOGW,
9249 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009250 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009251 pMac->roam.curState[sessionId],
9252 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309253 /* We ignore the caps change event if CSR is not in full connected state.
9254 * Send one event to PE to reset limSentCapsChangeNtf
9255 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9256 * otherwise lim cannot send any CAPS change events to SME */
9257 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 }
9260 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309261
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 default:
9263 roamStatus = eCSR_ROAM_FAILED;
9264 result = eCSR_ROAM_RESULT_NONE;
9265 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 } // end switch on statusChangeCode
9267 if(eCSR_ROAM_RESULT_NONE != result)
9268 {
9269 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9270 }
9271 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 case eWNI_SME_IBSS_NEW_PEER_IND:
9273 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009274#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9275 {
9276 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009277 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9278 if(pIbssLog)
9279 {
9280 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9281 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9282 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9283 }
9284 }
9285#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 sessionId = csrFindIbssSession( pMac );
9287 if( CSR_SESSION_ID_INVALID != sessionId )
9288 {
9289 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009290
9291 if(!pSession)
9292 {
9293 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9294 return;
9295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9297 if(pSession->pConnectBssDesc)
9298 {
9299 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9300 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9301 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9302 {
9303 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9304 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9305 if(HAL_STATUS_SUCCESS(status))
9306 {
9307 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9308 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9309 roamInfo.nBeaconLength);
9310 }
9311 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9312 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9313 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9314 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9315 pSession->pConnectBssDesc->length);
9316 if(HAL_STATUS_SUCCESS(status))
9317 {
9318 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9319 pSession->pConnectBssDesc->length);
9320 }
9321 if(HAL_STATUS_SUCCESS(status))
9322 {
9323 pRoamInfo = &roamInfo;
9324 }
9325 else
9326 {
9327 if(roamInfo.pbFrames)
9328 {
9329 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9330 }
9331 if(roamInfo.pBssDesc)
9332 {
9333 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9334 }
9335 }
9336 }
9337 else
9338 {
9339 pRoamInfo = &roamInfo;
9340 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009341 if ((eCSR_ENCRYPT_TYPE_NONE ==
9342 pSession->connectedProfile.EncryptionType ))
9343 {
9344 csrRoamIssueSetContextReq( pMac, sessionId,
9345 pSession->connectedProfile.EncryptionType,
9346 pSession->pConnectBssDesc,
9347 &(pIbssPeerInd->peerAddr),
9348 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 }
9351 else
9352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009353 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 }
9355 //send up the sec type for the new peer
9356 if (pRoamInfo)
9357 {
9358 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9359 }
9360 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9361 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9362 if(pRoamInfo)
9363 {
9364 if(roamInfo.pbFrames)
9365 {
9366 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9367 }
9368 if(roamInfo.pBssDesc)
9369 {
9370 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9371 }
9372 }
9373 }
9374 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9376 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9377 sessionId = csrFindIbssSession( pMac );
9378 if( CSR_SESSION_ID_INVALID != sessionId )
9379 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009380#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9381 {
9382 vos_log_ibss_pkt_type *pIbssLog;
9383
9384 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9385 if(pIbssLog)
9386 {
9387 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9388 if(pIbssPeerInd)
9389 {
9390 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9391 }
9392 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9393 }
9394 }
9395#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009396 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009397 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9398 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9399 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9400 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9401 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9402 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9403 }
9404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 case eWNI_SME_SETCONTEXT_RSP:
9406 {
9407 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9408 tListElem *pEntry;
9409 tSmeCmd *pCommand;
9410
9411 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9412 if ( pEntry )
9413 {
9414 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9415 if ( eSmeCommandSetKey == pCommand->command )
9416 {
9417 sessionId = pCommand->sessionId;
9418 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009419
9420 if(!pSession)
9421 {
9422 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9423 return;
9424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009425
9426#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9427 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9428 {
9429 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9430 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9431 if( pRsp->peerMacAddr[0] & 0x01 )
9432 {
9433 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9434 }
9435 else
9436 {
9437 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9438 }
9439 setKeyEvent.encryptionModeMulticast =
9440 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9441 setKeyEvent.encryptionModeUnicast =
9442 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9443 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9444 setKeyEvent.authMode =
9445 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009446 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 {
9448 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9449 }
9450 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9451 }
9452#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9453 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9454 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009455 csrRoamStopWaitForKeyTimer( pMac );
9456
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 //We are done with authentication, whethere succeed or not
9458 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 //We do it here because this linkup function is not called after association
9460 //when a key needs to be set.
9461 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9462 {
9463 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9464 }
9465 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009466 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 {
9468 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009469 //Make sure we install the GTK before indicating to HDD as authenticated
9470 //This is to prevent broadcast packets go out after PTK and before GTK.
9471 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9472 sizeof(tSirMacAddr) ) )
9473 {
Yathish9f22e662012-12-10 14:21:35 -08009474#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9475 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9476 {
9477 tpSirSetActiveModeSetBncFilterReq pMsg;
9478 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9479 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9480 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9481 pMsg->seesionId = sessionId;
9482 status = palSendMBMessage(pMac->hHdd, pMsg );
9483 }
9484#endif
9485 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009486 }
9487 else
9488 {
9489 result = eCSR_ROAM_RESULT_NONE;
9490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 pRoamInfo = &roamInfo;
9492 }
9493 else
9494 {
9495 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009496 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9498 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9499 }
9500 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9501 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9503 // can go ahead and initiate the TSPEC if any are pending
9504 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009505#ifdef FEATURE_WLAN_CCX
9506 //Send Adjacent AP repot to new AP.
9507 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9508 pSession->isPrevApInfoValid &&
9509 pSession->connectedProfile.isCCXAssoc)
9510 {
9511#ifdef WLAN_FEATURE_VOWIFI
9512 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9513#endif
9514 pSession->isPrevApInfoValid = FALSE;
9515 }
9516#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9518 {
9519 csrReleaseCommandSetKey( pMac, pCommand );
9520 }
9521 }
9522 else
9523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009524 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 }
9526 }
9527 else
9528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009529 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 smeProcessPendingQueue( pMac );
9532 }
9533 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 case eWNI_SME_REMOVEKEY_RSP:
9535 {
9536 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9537 tListElem *pEntry;
9538 tSmeCmd *pCommand;
9539
9540 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9541 if ( pEntry )
9542 {
9543 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9544 if ( eSmeCommandRemoveKey == pCommand->command )
9545 {
9546 sessionId = pCommand->sessionId;
9547 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009548
9549 if(!pSession)
9550 {
9551 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9552 return;
9553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009554#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9555 {
9556 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9557 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9558 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9559 removeKeyEvent.encryptionModeMulticast =
9560 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9561 removeKeyEvent.encryptionModeUnicast =
9562 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9563 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9564 removeKeyEvent.authMode =
9565 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009566 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 {
9568 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9569 }
9570 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9571 }
9572#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009573 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 {
9575 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9576 result = eCSR_ROAM_RESULT_NONE;
9577 pRoamInfo = &roamInfo;
9578 }
9579 else
9580 {
9581 result = eCSR_ROAM_RESULT_FAILURE;
9582 }
9583 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9584 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9585 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9586 {
9587 csrReleaseCommandRemoveKey( pMac, pCommand );
9588 }
9589 }
9590 else
9591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009592 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 }
9594 }
9595 else
9596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009597 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 smeProcessPendingQueue( pMac );
9600 }
9601 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009603 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 csrRoamStatsRspProcessor( pMac, pSirMsg );
9605 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009606#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9607 case eWNI_SME_GET_ROAM_RSSI_RSP:
9608 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9609 csrRoamRssiRspProcessor( pMac, pSirMsg );
9610 break;
9611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009613 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 csrUpdateRssi( pMac, pSirMsg );
9615 break;
9616
Jeff Johnson295189b2012-06-20 16:38:30 -07009617#ifdef WLAN_FEATURE_VOWIFI_11R
9618 case eWNI_SME_FT_PRE_AUTH_RSP:
9619 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9620 break;
9621#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9623 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009624 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 -07009625 sessionId = pSmeMaxAssocInd->sessionId;
9626 roamInfo.sessionId = sessionId;
9627 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9628 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9629 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9630 break;
9631
9632 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009633 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 btampEstablishLogLinkHdlr( pSirMsg );
9635 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009636 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009637 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009638 csrRoamRssiIndHdlr( pMac, pSirMsg );
9639 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009640#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9641 case eWNI_SME_CANDIDATE_FOUND_IND:
9642 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9643 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9644 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009645 case eWNI_SME_HANDOFF_REQ:
9646 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9647 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9648 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009649#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009650
9651 default:
9652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009654}
9655
Jeff Johnson295189b2012-06-20 16:38:30 -07009656void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9657 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9658{
9659 if(pSession)
9660 {
9661 if(pSession->bRefAssocStartCnt)
9662 {
9663 pSession->bRefAssocStartCnt--;
9664 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9665 //Need to call association_completion because there is an assoc_start pending.
9666 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9667 eCSR_ROAM_ASSOCIATION_COMPLETION,
9668 eCSR_ROAM_RESULT_FAILURE);
9669 }
9670 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9671 }
9672 else
9673 {
9674 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9675 }
9676}
9677
9678
9679eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9680{
9681 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9683 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9684 {
9685 status = csrScanRequestLostLink1( pMac, sessionId );
9686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 return(status);
9688}
9689
Jeff Johnson295189b2012-06-20 16:38:30 -07009690//return a boolean to indicate whether roaming completed or continue.
9691tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9692 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9693{
9694 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9695 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9696 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9697 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009698 if(!pSession)
9699 {
9700 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9701 return eANI_BOOLEAN_FALSE;
9702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 //Check whether time is up
9704 if(pSession->fCancelRoaming || fForce ||
9705 ((curTime - pSession->roamingStartTime) > roamTime) ||
9706 eCsrReassocRoaming == pSession->roamingReason ||
9707 eCsrDynamicRoaming == pSession->roamingReason)
9708 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009709 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9711 {
9712 //roaming is cancelled, tell HDD to indicate disconnect
9713 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9714 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9715 //to be eSIR_BEACON_MISSED
9716 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9717 {
9718 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9719 }
9720 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9721 {
9722 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9723 }
9724 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9725 {
9726 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9727 }
9728 else
9729 {
9730 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9731 }
9732 }
9733 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9734 pSession->roamingReason = eCsrNotRoaming;
9735 }
9736 else
9737 {
9738 pSession->roamResult = roamResult;
9739 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9740 {
9741 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9742 pSession->roamingReason = eCsrNotRoaming;
9743 }
9744 else
9745 {
9746 fCompleted = eANI_BOOLEAN_FALSE;
9747 }
9748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 return(fCompleted);
9750}
9751
Jeff Johnson295189b2012-06-20 16:38:30 -07009752void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9753{
9754 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009755
9756 if(!pSession)
9757 {
9758 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9759 return;
9760 }
9761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 if(CSR_IS_ROAMING(pSession))
9763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009764 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9766 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9767 {
9768 //No need to do anything in here because the handler takes care of it
9769 }
9770 else
9771 {
9772 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9773 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9774 //Roaming is stopped after here
9775 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9776 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9777 csrScanAbortMacScan(pMac);
9778 csrRoamStopRoamingTimer(pMac, sessionId);
9779 }
9780 }
9781}
9782
Jeff Johnson295189b2012-06-20 16:38:30 -07009783void csrRoamRoamingTimerHandler(void *pv)
9784{
9785 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9786 tpAniSirGlobal pMac = pInfo->pMac;
9787 tANI_U32 sessionId = pInfo->sessionId;
9788 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009789
9790 if(!pSession)
9791 {
9792 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9793 return;
9794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009795
9796 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9797 {
9798 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9799 {
9800 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9801 pSession->roamingReason = eCsrNotRoaming;
9802 }
9803 }
9804}
9805
Jeff Johnson295189b2012-06-20 16:38:30 -07009806eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9807{
9808 eHalStatus status;
9809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009810
9811 if(!pSession)
9812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009813 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009814 return eHAL_STATUS_FAILURE;
9815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009816
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009817 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309819 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009820
9821 return (status);
9822}
9823
Jeff Johnson295189b2012-06-20 16:38:30 -07009824eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9825{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309826 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -07009827}
9828
Jeff Johnson295189b2012-06-20 16:38:30 -07009829void csrRoamWaitForKeyTimeOutHandler(void *pv)
9830{
9831 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9832 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009833 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9834
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009835 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009836 pMac->roam.neighborRoamInfo.neighborRoamState,
9837 pMac->roam.curSubState[pInfo->sessionId]);
9838
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9840 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009841#ifdef FEATURE_WLAN_LFR
9842 if (csrNeighborRoamIsHandoffInProgress(pMac))
9843 {
9844 /*
9845 * Enable heartbeat timer when hand-off is in progress
9846 * and Key Wait timer expired.
9847 */
9848 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009849 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009850 pMac->roam.configParam.HeartbeatThresh24);
9851 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9852 pMac->roam.configParam.HeartbeatThresh24,
9853 NULL, eANI_BOOLEAN_FALSE);
9854 }
9855#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009856 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 //Change the substate so command queue is unblocked.
9858 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009859 if (pSession)
9860 {
9861 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9862 {
9863 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9864 smeProcessPendingQueue(pMac);
9865 }
9866 else
9867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009868 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009869 __func__);
9870 }
9871 }
9872 else
9873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009874 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 }
9877
9878}
9879
Jeff Johnson295189b2012-06-20 16:38:30 -07009880eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9881{
9882 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009883#ifdef FEATURE_WLAN_LFR
9884 if (csrNeighborRoamIsHandoffInProgress(pMac))
9885 {
9886 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009887 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009888 __func__,
9889 pMac->roam.neighborRoamInfo.neighborRoamState,
9890 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9891 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9892 }
9893#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009894 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309895 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009896
9897 return (status);
9898}
9899
Jeff Johnson295189b2012-06-20 16:38:30 -07009900eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9901{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009902 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009903 pMac->roam.neighborRoamInfo.neighborRoamState,
9904 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9905#ifdef FEATURE_WLAN_LFR
9906 if (csrNeighborRoamIsHandoffInProgress(pMac))
9907 {
9908 /*
9909 * Enable heartbeat timer when hand-off is in progress
9910 * and Key Wait timer got stopped for some reason
9911 */
9912 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009913 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009914 pMac->roam.configParam.HeartbeatThresh24);
9915 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9916 pMac->roam.configParam.HeartbeatThresh24,
9917 NULL, eANI_BOOLEAN_FALSE);
9918 }
9919#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309920 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009921}
9922
Jeff Johnson295189b2012-06-20 16:38:30 -07009923void csrRoamIbssJoinTimerHandler(void *pv)
9924{
9925 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9926 tpAniSirGlobal pMac = pInfo->pMac;
9927 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9928 tANI_U32 sessionId = pInfo->sessionId;
9929 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009930
9931 if(!pSession)
9932 {
9933 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9934 return;
9935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009936
9937 pSession->ibss_join_pending = FALSE;
9938 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9939 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9940 // Send an IBSS stop request to PE
9941 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009942}
Jeff Johnson295189b2012-06-20 16:38:30 -07009943eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9944{
9945 eHalStatus status;
9946 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009947
9948 if(!pSession)
9949 {
9950 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9951 return eHAL_STATUS_FAILURE;
9952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009953
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009954 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309956 status = vos_timer_start(&pSession->hTimerIbssJoining, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009957
9958 return (status);
9959}
Jeff Johnson295189b2012-06-20 16:38:30 -07009960eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9961{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309962 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerIbssJoining));
Jeff Johnson295189b2012-06-20 16:38:30 -07009963}
Jeff Johnson295189b2012-06-20 16:38:30 -07009964void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9965 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9966{
9967 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9968 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009969 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9970 /* To silence the KW tool Null chaeck is added */
9971 if(!pSession)
9972 {
9973 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9974 return;
9975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009976
9977 if(pCommand)
9978 {
9979 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9983 {
9984 //if success, force roaming completion
9985 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9986 }
9987 else
9988 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009989 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009990 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9992 }
9993}
9994
Jeff Johnson295189b2012-06-20 16:38:30 -07009995eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9996{
9997 eHalStatus status = eHAL_STATUS_SUCCESS;
9998 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9999 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10000 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10001 tCsrRoamInfo *pRoamInfo = NULL;
10002 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010003 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010005 /* To silence the KW tool Null chaeck is added */
10006 if(!pSession)
10007 {
10008 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10009 return eHAL_STATUS_FAILURE;
10010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010012 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010013 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10014 if ( eWNI_SME_DISASSOC_IND == type )
10015 {
10016 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10017 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10018 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010019 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 }
10021 else if ( eWNI_SME_DEAUTH_IND == type )
10022 {
10023 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10024 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10025 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010026 /* Convert into proper reason code */
10027 pSession->joinFailStatusCode.reasonCode =
10028 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010029 0 : pDeauthIndMsg->reasonCode;
10030 /* cfg layer expects 0 as reason code if
10031 the driver dosent know the reason code
10032 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 }
10034 else
10035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010036 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010038 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 }
10040
10041 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 {
10044 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10045 }
10046
10047 if ( eWNI_SME_DISASSOC_IND == type )
10048 {
10049 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10050 }
10051 else if ( eWNI_SME_DEAUTH_IND == type )
10052 {
10053 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 if(!HAL_STATUS_SUCCESS(status))
10056 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010057 //If fail to send confirmation to PE, not to trigger roaming
10058 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 }
10060
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010061 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10063 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10064 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 if( eWNI_SME_DISASSOC_IND == type)
10066 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010067 //staMacAddr
10068 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10069 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 else if( eWNI_SME_DEAUTH_IND == type )
10072 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010073 //staMacAddr
10074 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10075 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10076 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010077 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010078
10079 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10080 that we are roaming. But if we cannot possibly roam, or if we are unable to
10081 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 if(fToRoam)
10083 {
10084 //Only remove the connected BSS in infrastructure mode
10085 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10086 //Not to do anying for lostlink with WDS
10087 if( pMac->roam.configParam.nRoamingTime )
10088 {
10089 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10090 ( eWNI_SME_DEAUTH_IND == type ) ?
10091 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10092 {
10093 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10094 //For IBSS, we need to give some more info to HDD
10095 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10096 {
10097 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10098 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10099 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10100 }
10101 else
10102 {
10103 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10104 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010105 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10107 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10108 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10109 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10110 }
10111 else
10112 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010113 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010114 fToRoam = eANI_BOOLEAN_FALSE;
10115 }
10116 }
10117 else
10118 {
10119 //We are told not to roam, indicate lostlink
10120 fToRoam = eANI_BOOLEAN_FALSE;
10121 }
10122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 if(!fToRoam)
10124 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010125 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010126 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010127 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010128 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10129 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10130 * csrRoamCheckForLinkStatusChange API.
10131 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010132 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10133 }
10134
10135 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 Still enable idle scan for polling in case concurrent sessions are running */
10137 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10138 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010139 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 }
10141 }
10142
10143 return (status);
10144}
10145
Jeff Johnson295189b2012-06-20 16:38:30 -070010146eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10147{
10148 eHalStatus status = eHAL_STATUS_SUCCESS;
10149 tListElem *pEntry = NULL;
10150 tSmeCmd *pCommand = NULL;
10151 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010152
10153 if(!pSession)
10154 {
10155 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10156 return eHAL_STATUS_FAILURE;
10157 }
10158
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 //Only remove the connected BSS in infrastructure mode
10161 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10162 if(pMac->roam.configParam.nRoamingTime)
10163 {
10164 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10165 {
10166 //before starting the lost link logic release the roam command for handoff
10167 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10168 if(pEntry)
10169 {
10170 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10171 }
10172 if(pCommand)
10173 {
10174 if (( eSmeCommandRoam == pCommand->command ) &&
10175 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10176 {
10177 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10178 {
10179 csrReleaseCommandRoam( pMac, pCommand );
10180 }
10181 }
10182 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010183 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 }
10185 }
10186 else
10187 {
10188 //We are told not to roam, indicate lostlink
10189 status = eHAL_STATUS_FAILURE;
10190 }
10191
10192 return (status);
10193}
Jeff Johnson295189b2012-06-20 16:38:30 -070010194void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10195{
10196 tListElem *pEntry;
10197 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10199 if ( pEntry )
10200 {
10201 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10202 if ( eSmeCommandWmStatusChange == pCommand->command )
10203 {
10204 // Nothing to process in a Lost Link completion.... It just kicks off a
10205 // roaming sequence.
10206 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10207 {
10208 csrReleaseCommandWmStatusChange( pMac, pCommand );
10209 }
10210 else
10211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010212 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 }
10214
10215 }
10216 else
10217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010218 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 }
10220 }
10221 else
10222 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010223 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 smeProcessPendingQueue( pMac );
10226}
10227
Jeff Johnson295189b2012-06-20 16:38:30 -070010228void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10229{
10230 eHalStatus status = eHAL_STATUS_FAILURE;
10231 tSirSmeRsp *pSirSmeMsg;
10232 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010233
10234 if(!pSession)
10235 {
10236 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10237 return;
10238 }
10239
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 switch ( pCommand->u.wmStatusChangeCmd.Type )
10241 {
10242 case eCsrDisassociated:
10243 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10244 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10245 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 case eCsrDeauthenticated:
10247 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10248 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10249 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010251 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 break;
10253 }
10254 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10255 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10256 {
10257 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10258 {
10259 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010260 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 }
10262 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010263 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10264 // command here since there is nothing else to do.
10265 csrRoamWmStatusChangeComplete( pMac );
10266}
10267
Jeff Johnson295189b2012-06-20 16:38:30 -070010268//This function returns band and mode information.
10269//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10270//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010271static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10272 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010273{
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10275 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10276 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010277 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010278
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 //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 -070010280 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10281 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10282 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10283 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010284 {
10285 switch( pMac->roam.configParam.uCfgDot11Mode )
10286 {
10287 case eCSR_CFG_DOT11_MODE_11A:
10288 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10289 eBand = eCSR_BAND_5G;
10290 break;
10291 case eCSR_CFG_DOT11_MODE_11B:
10292 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10293 eBand = eCSR_BAND_24;
10294 break;
10295 case eCSR_CFG_DOT11_MODE_11G:
10296 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10297 eBand = eCSR_BAND_24;
10298 break;
10299 case eCSR_CFG_DOT11_MODE_11N:
10300 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010301 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10302 break;
10303#ifdef WLAN_FEATURE_11AC
10304 case eCSR_CFG_DOT11_MODE_11AC:
10305 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10306 {
10307 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10308 eBand = eCSR_BAND_5G;
10309 }
10310 else
10311 {
10312 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10313 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10314 }
10315 break;
10316 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10317 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10318 {
10319 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10320 eBand = eCSR_BAND_5G;
10321 }
10322 else
10323 {
10324 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10325 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10326 }
10327 break;
10328#endif
10329 case eCSR_CFG_DOT11_MODE_AUTO:
10330 eBand = pMac->roam.configParam.eBand;
10331 if (eCSR_BAND_24 == eBand)
10332 {
10333 // WiFi tests require IBSS networks to start in 11b mode
10334 // without any change to the default parameter settings
10335 // on the adapter. We use ACU to start an IBSS through
10336 // creation of a startIBSS profile. This startIBSS profile
10337 // has Auto MACProtocol and the adapter property setting
10338 // for dot11Mode is also AUTO. So in this case, let's
10339 // start the IBSS network in 11b mode instead of 11g mode.
10340 // So this is for Auto=profile->MacProtocol && Auto=Global.
10341 // dot11Mode && profile->channel is < 14, then start the IBSS
10342 // in b mode.
10343 //
10344 // Note: we used to have this start as an 11g IBSS for best
10345 // performance... now to specify that the user will have to
10346 // set the do11Mode in the property page to 11g to force it.
10347 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10348 }
10349 else
10350 {
10351#ifdef WLAN_FEATURE_11AC
10352 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10353 {
10354 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10355 eBand = eCSR_BAND_5G;
10356 }
10357 else
10358 {
10359 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10360 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10361 }
10362#else
10363 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10364 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10365#endif
10366 }
10367 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 default:
10369 // Global dot11 Mode setting is 11a/b/g.
10370 // use the channel number to determine the Mode setting.
10371 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10372 {
10373 eBand = pMac->roam.configParam.eBand;
10374 if(eCSR_BAND_24 == eBand)
10375 {
10376 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10377 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10378 }
10379 else
10380 {
10381 //prefer 5GHz
10382 eBand = eCSR_BAND_5G;
10383 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10384 }
10385 }
10386 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10387 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010388 // WiFi tests require IBSS networks to start in 11b mode
10389 // without any change to the default parameter settings
10390 // on the adapter. We use ACU to start an IBSS through
10391 // creation of a startIBSS profile. This startIBSS profile
10392 // has Auto MACProtocol and the adapter property setting
10393 // for dot11Mode is also AUTO. So in this case, let's
10394 // start the IBSS network in 11b mode instead of 11g mode.
10395 // So this is for Auto=profile->MacProtocol && Auto=Global.
10396 // dot11Mode && profile->channel is < 14, then start the IBSS
10397 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010399 // Note: we used to have this start as an 11g IBSS for best
10400 // performance... now to specify that the user will have to
10401 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010402 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10403 eBand = eCSR_BAND_24;
10404 }
10405 else
10406 {
10407 // else, it's a 5.0GHz channel. Set mode to 11a.
10408 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10409 eBand = eCSR_BAND_5G;
10410 }
10411 break;
10412 }//switch
10413 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10414 else
10415 {
10416 //dot11 mode is set, lets pick the band
10417 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10418 {
10419 // channel is Auto also.
10420 eBand = pMac->roam.configParam.eBand;
10421 if(eCSR_BAND_ALL == eBand)
10422 {
10423 //prefer 5GHz
10424 eBand = eCSR_BAND_5G;
10425 }
10426 }
10427 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10428 {
10429 eBand = eCSR_BAND_24;
10430 }
10431 else
10432 {
10433 eBand = eCSR_BAND_5G;
10434 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 if(pBand)
10437 {
10438 *pBand = eBand;
10439 }
10440
10441 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010442 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10444 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010445
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010446 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10447 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 -070010448 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010449#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010450 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010451#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010452 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10453 {
10454 //We cannot do 11n here
10455 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10456 {
10457 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10458 }
10459 else
10460 {
10461 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10462 }
10463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 return( cfgDot11Mode );
10465}
10466
Jeff Johnson295189b2012-06-20 16:38:30 -070010467eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10468{
10469 eHalStatus status;
10470 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010471
10472 if(!pSession)
10473 {
10474 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10475 return eHAL_STATUS_FAILURE;
10476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010477
10478#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10479 {
10480 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10482 if(pIbssLog)
10483 {
10484 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10485 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10486 }
10487 }
10488#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 pSession->ibss_join_pending = FALSE;
10490 csrRoamStopIbssJoinTimer(pMac, sessionId );
10491 // Set the roaming substate to 'stop Bss request'...
10492 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10493
10494 // attempt to stop the Bss (reason code is ignored...)
10495 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010496 if(!HAL_STATUS_SUCCESS(status))
10497 {
10498 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10499 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010500 return (status);
10501}
10502
Jeff Johnson295189b2012-06-20 16:38:30 -070010503//pNumChan is a caller allocated space with the sizeof pChannels
10504eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10505{
10506
10507 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10508 (tANI_U8 *)pChannels,
10509 pNumChan));
10510}
10511
Kiran4a17ebe2013-01-31 10:43:43 -080010512tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10513{
10514 tANI_U32 cfgLength = 0;
10515 tANI_U16 cfgId = 0;
10516 tPowerdBm maxTxPwr = 0;
10517 tANI_U8 *pCountryInfo = NULL;
10518 eHalStatus status;
10519 tANI_U8 count = 0;
10520 tANI_U8 firstChannel;
10521 tANI_U8 maxChannels;
10522
10523 if (CSR_IS_CHANNEL_5GHZ(channel))
10524 {
10525 cfgId = WNI_CFG_MAX_TX_POWER_5;
10526 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10527 }
10528 else if (CSR_IS_CHANNEL_24GHZ(channel))
10529 {
10530 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10531 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10532 }
10533 else
10534 return maxTxPwr;
10535
10536 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10537 if (status != eHAL_STATUS_SUCCESS)
10538 {
10539 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10540 FL("%s: palAllocateMemory() failed, status = %d"),
10541 __FUNCTION__, status);
10542 goto error;
10543 }
10544 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10545 if (status != eHAL_STATUS_SUCCESS)
10546 {
10547 goto error;
10548 }
10549 /* Identify the channel and maxtxpower */
10550 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10551 {
10552 firstChannel = pCountryInfo[count++];
10553 maxChannels = pCountryInfo[count++];
10554 maxTxPwr = pCountryInfo[count++];
10555
10556 if ((channel >= firstChannel) &&
10557 (channel < (firstChannel + maxChannels)))
10558 {
10559 break;
10560 }
10561 }
10562
10563error:
10564 if (NULL != pCountryInfo)
10565 palFreeMemory(pMac->hHdd, pCountryInfo);
10566
10567 return maxTxPwr;
10568}
10569
10570
Jeff Johnson295189b2012-06-20 16:38:30 -070010571tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10572{
10573 tANI_BOOLEAN fValid = FALSE;
10574 tANI_U32 idxValidChannels;
10575 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10576
10577 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10578 {
10579 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10580 {
10581 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10582 {
10583 fValid = TRUE;
10584 break;
10585 }
10586 }
10587 }
10588 pMac->roam.numValidChannels = len;
10589 return fValid;
10590}
10591
Jeff Johnson295189b2012-06-20 16:38:30 -070010592tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10593{
10594 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10595 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10597 {
10598 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10599 {
10600 fValid = eANI_BOOLEAN_TRUE;
10601 break;
10602 }
10603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 return (fValid);
10605}
10606
Jeff Johnson295189b2012-06-20 16:38:30 -070010607//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010608 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010609{
Jeff Johnsone7245742012-09-05 17:12:55 -070010610 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 tANI_U8 centerChn;
10612 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10614 {
10615 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10616 }
10617 else
10618 {
10619 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10620 }
10621 //Figure what the other side's CB mode
10622 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10623 {
10624 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10625 {
10626 if(pIes->HTInfo.present)
10627 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010628 /* This is called during INFRA STA/CLIENT and should use the merged value of
10629 * supported channel width and recommended tx width as per standard
10630 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010631 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010632 pIes->HTCaps.supportedChannelWidthSet,
10633 pIes->HTInfo.recommendedTxWidthSet,
10634 pIes->HTInfo.secondaryChannelOffset);
10635
10636 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10637 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010638 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010639 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10640 switch (eRet) {
10641 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10642 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10643 break;
10644 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10645 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10646 break;
10647 case PHY_SINGLE_CHANNEL_CENTERED:
10648 default:
10649 centerChn = primaryChn;
10650 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010651 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010652 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010654 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010655 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 }
10657 }
10658 }
10659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 return eRet;
10661}
Jeff Johnson295189b2012-06-20 16:38:30 -070010662tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10663{
10664 tANI_BOOLEAN fFound = FALSE;
10665 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10667 {
10668 if( pCipherList->encryptionType[idx] == encryptionType )
10669 {
10670 fFound = TRUE;
10671 break;
10672 }
10673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 return fFound;
10675}
Jeff Johnson295189b2012-06-20 16:38:30 -070010676tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10677{
10678 tANI_BOOLEAN fFound = FALSE;
10679 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010680 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10681 {
10682 if( pAuthList->authType[idx] == authType )
10683 {
10684 fFound = TRUE;
10685 break;
10686 }
10687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 return fFound;
10689}
Jeff Johnson295189b2012-06-20 16:38:30 -070010690tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10691{
10692 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10693 tCsrScanResultFilter *pScanFilter = NULL;
10694 eHalStatus status = eHAL_STATUS_SUCCESS;
10695
10696 if(pProfile1 && pProfile2)
10697 {
10698 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10699 if(HAL_STATUS_SUCCESS(status))
10700 {
10701 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10702 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10703 if(HAL_STATUS_SUCCESS(status))
10704 {
10705 fCheck = eANI_BOOLEAN_FALSE;
10706 do
10707 {
10708 tANI_U32 i;
10709 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10710 {
10711 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10712 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10713 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10714 if ( fCheck ) break;
10715 }
10716 if(!fCheck)
10717 {
10718 break;
10719 }
10720 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10721 || pProfile2->BSSType != pProfile1->BSSType
10722 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10723 )
10724 {
10725 fCheck = eANI_BOOLEAN_FALSE;
10726 break;
10727 }
10728#ifdef WLAN_FEATURE_VOWIFI_11R
10729 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10730 {
10731 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10732 {
10733 fCheck = eANI_BOOLEAN_FALSE;
10734 break;
10735 }
10736 }
10737#endif
10738 //Match found
10739 fCheck = eANI_BOOLEAN_TRUE;
10740 }while(0);
10741 csrFreeScanFilter(pMac, pScanFilter);
10742 }
10743 palFreeMemory(pMac->hHdd, pScanFilter);
10744 }
10745 }
10746
10747 return (fCheck);
10748}
10749
Jeff Johnson295189b2012-06-20 16:38:30 -070010750tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10751{
10752 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10753 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 do
10755 {
10756 //Only check for static WEP
10757 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10758 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10759 {
10760 fCheck = eANI_BOOLEAN_TRUE;
10761 break;
10762 }
10763 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10764 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10765 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10766 {
10767 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10768 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10769 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10770 {
10771 break;
10772 }
10773 }
10774 if( i == CSR_MAX_NUM_KEY)
10775 {
10776 fCheck = eANI_BOOLEAN_TRUE;
10777 }
10778 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 return (fCheck);
10780}
10781
Jeff Johnson295189b2012-06-20 16:38:30 -070010782//IBSS
10783
Jeff Johnson295189b2012-06-20 16:38:30 -070010784tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10785{
10786 tANI_U8 channel = 0;
10787 tANI_U32 idx;
10788 tANI_U32 idxValidChannels;
10789 tANI_BOOLEAN fFound = FALSE;
10790 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10791
10792 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10793 {
10794 channel = pMac->roam.configParam.AdHocChannel5G;
10795 if(!csrRoamIsChannelValid(pMac, channel))
10796 {
10797 channel = 0;
10798 }
10799 }
10800 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10801 {
10802 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10803 {
10804 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10805 {
10806 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10807 {
10808 fFound = TRUE;
10809 channel = csrStartIbssChannels50[ idx ];
10810 }
10811 }
10812 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010813 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10814 if (!fFound)
10815 {
10816 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10817 {
10818 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10819 {
10820 channel = csrStartIbssChannels50[ idx ];
10821 break;
10822 }
10823 }
10824 }
10825 }//if
10826
10827 return( channel );
10828}
10829
Jeff Johnson295189b2012-06-20 16:38:30 -070010830tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10831{
10832 tANI_U8 channel = 1;
10833 tANI_U32 idx;
10834 tANI_U32 idxValidChannels;
10835 tANI_BOOLEAN fFound = FALSE;
10836 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10837
10838 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10839 {
10840 channel = pMac->roam.configParam.AdHocChannel24;
10841 if(!csrRoamIsChannelValid(pMac, channel))
10842 {
10843 channel = 0;
10844 }
10845 }
10846
10847 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10848 {
10849 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10850 {
10851 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10852 {
10853 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10854 {
10855 fFound = TRUE;
10856 channel = csrStartIbssChannels24[ idx ];
10857 }
10858 }
10859 }
10860 }
10861
10862 return( channel );
10863}
10864
Jeff Johnson295189b2012-06-20 16:38:30 -070010865static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10866 tCsrRoamStartBssParams *pParam )
10867{
10868 eCsrCfgDot11Mode cfgDot11Mode;
10869 eCsrBand eBand;
10870 tANI_U8 channel = 0;
10871 tSirNwType nwType;
10872 tANI_U8 operationChannel = 0;
10873
10874 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10875 {
10876 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10877 }
10878
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010880
Jeff Johnson295189b2012-06-20 16:38:30 -070010881 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10882 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10883 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10884 )
10885 {
10886 /* This should never happen */
10887 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010888 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 pProfile->csrPersona);
10890 VOS_ASSERT(0);
10891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 switch( cfgDot11Mode )
10893 {
10894 case eCSR_CFG_DOT11_MODE_11G:
10895 nwType = eSIR_11G_NW_TYPE;
10896 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 case eCSR_CFG_DOT11_MODE_11B:
10898 nwType = eSIR_11B_NW_TYPE;
10899 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 case eCSR_CFG_DOT11_MODE_11A:
10901 nwType = eSIR_11A_NW_TYPE;
10902 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 default:
10904 case eCSR_CFG_DOT11_MODE_11N:
10905 case eCSR_CFG_DOT11_MODE_TAURUS:
10906 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10907 if(eCSR_BAND_24 == eBand)
10908 {
10909 nwType = eSIR_11G_NW_TYPE;
10910 }
10911 else
10912 {
10913 nwType = eSIR_11A_NW_TYPE;
10914 }
10915 break;
10916 }
10917
10918 pParam->extendedRateSet.numRates = 0;
10919
10920 switch ( nwType )
10921 {
10922 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010923 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 case eSIR_11A_NW_TYPE:
10925
10926 pParam->operationalRateSet.numRates = 8;
10927
10928 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10929 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10930 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10931 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10932 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10933 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10934 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10935 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10936
10937 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10938 {
10939 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10940 if( 0 == channel &&
10941 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10942 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10943 )
10944 {
10945 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10946 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10947 nwType = eSIR_11B_NW_TYPE;
10948 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10949 pParam->operationalRateSet.numRates = 4;
10950 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10951 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10952 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10953 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10954 }
10955 }
10956 else
10957 {
10958 channel = operationChannel;
10959 }
10960 break;
10961
10962 case eSIR_11B_NW_TYPE:
10963 pParam->operationalRateSet.numRates = 4;
10964 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10965 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10966 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10967 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010968 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10969 {
10970 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10971 }
10972 else
10973 {
10974 channel = operationChannel;
10975 }
10976
10977 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010978 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 /* For P2P Client and P2P GO, disable 11b rates */
10980 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10981 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10982 )
10983 {
10984 pParam->operationalRateSet.numRates = 8;
10985
10986 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10987 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10988 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10989 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10990 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10991 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10992 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10993 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10994 }
10995 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010996 {
10997 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10999 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11000 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11001 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11002
11003 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11005 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11006 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11007 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11008 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11009 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11010 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11011 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11012 }
11013
11014 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11015 {
11016 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11017 }
11018 else
11019 {
11020 channel = operationChannel;
11021 }
11022
11023 break;
11024 }
11025 pParam->operationChn = channel;
11026 pParam->sirNwType = nwType;
11027}
11028
Jeff Johnson295189b2012-06-20 16:38:30 -070011029static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11030 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11031{
11032
11033 if( pParam )
11034 {
11035 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011036 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011037 pParam->operationChn = pBssDesc->channelId;
11038 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
11039
11040 if( pIes )
11041 {
11042 if(pIes->SuppRates.present)
11043 {
11044 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11045 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011047 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 -070011048 pIes->SuppRates.num_rates);
11049 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11050 }
11051 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11052 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
11053 }
11054 if( pIes->SSID.present )
11055 {
11056 pParam->ssId.length = pIes->SSID.num_ssid;
11057 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
11058 }
11059 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 }
11061 else
11062 {
11063 pParam->ssId.length = 0;
11064 pParam->operationalRateSet.numRates = 0;
11065 }
11066 }
11067}
11068
Jeff Johnson295189b2012-06-20 16:38:30 -070011069static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11070{
11071 tANI_U8 MaxRate = 0;
11072 tANI_U32 i;
11073 tANI_U8 *pRate;
11074
11075 pRate = pSirRateSet->rate;
11076 for ( i = 0; i < pSirRateSet->numRates; i++ )
11077 {
11078 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11079 }
11080
11081 // Save the max rate in the connected state information...
11082
11083 // modify LastRates variable as well
11084
11085 return;
11086}
11087
Jeff Johnson295189b2012-06-20 16:38:30 -070011088eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11089 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11090{
11091 eHalStatus status = eHAL_STATUS_SUCCESS;
11092 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 // Set the roaming substate to 'Start BSS attempt'...
11094 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011095#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11096 //Need to figure out whether we need to log WDS???
11097 if( CSR_IS_IBSS( pProfile ) )
11098 {
11099 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11101 if(pIbssLog)
11102 {
11103 if(pBssDesc)
11104 {
11105 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
11106 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
11107 }
11108 else
11109 {
11110 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11111 }
11112 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11113 pParam->ssId.length);
11114 if(pProfile->ChannelInfo.numOfChannels == 0)
11115 {
11116 pIbssLog->channelSetting = AUTO_PICK;
11117 }
11118 else
11119 {
11120 pIbssLog->channelSetting = SPECIFIED;
11121 }
11122 pIbssLog->operatingChannel = pParam->operationChn;
11123 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11124 }
11125 }
11126#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11127 //Put RSN information in for Starting BSS
11128 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11129 pParam->pRSNIE = pProfile->pRSNReqIE;
11130
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 pParam->privacy = pProfile->privacy;
11132 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11133 pParam->authType = pProfile->csr80211AuthType;
11134 pParam->beaconInterval = pProfile->beaconInterval;
11135 pParam->dtimPeriod = pProfile->dtimPeriod;
11136 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11137 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11138 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11139 {
11140 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11141 {
11142 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11143 }
11144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011145 pParam->protEnabled = pProfile->protEnabled;
11146 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11147 pParam->ht_protection = pProfile->cfg_protection;
11148 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011149
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11151 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 pParam->bssPersona = pProfile->csrPersona;
11153 // When starting an IBSS, start on the channel from the Profile.
11154 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011155 return (status);
11156}
11157
Jeff Johnson295189b2012-06-20 16:38:30 -070011158static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011159 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011160{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011161 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011162 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011164
11165 if(!pSession)
11166 {
11167 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11168 return;
11169 }
11170
Jeff Johnson295189b2012-06-20 16:38:30 -070011171 if( pBssDesc )
11172 {
11173 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11174 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11175 //The following code has to be do after that.
11176 //For WDS station, use selfMac as the self BSSID
11177 if( CSR_IS_WDS_STA( pProfile ) )
11178 {
11179 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11180 }
11181 }
11182 else
11183 {
11184 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011185 //Use the first SSID
11186 if(pProfile->SSIDs.numOfSSIDs)
11187 {
11188 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11189 }
11190 //For WDS station, use selfMac as the self BSSID
11191 if( CSR_IS_WDS_STA( pProfile ) )
11192 {
11193 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11194 }
11195 //Use the first BSSID
11196 else if( pProfile->BSSIDs.numOfBSSIDs )
11197 {
11198 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11199 }
11200 else
11201 {
11202 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11203 }
11204 }
11205 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 //Set operating channel in pProfile which will be used
11207 //in csrRoamSetBssConfigCfg() to determine channel bonding
11208 //mode and will be configured in CFG later
11209 pProfile->operationChannel = Channel;
11210
11211 if(Channel == 0)
11212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011213 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 }
11215 else
11216 {
11217
11218 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011219 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011220 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011221 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011222 {
11223 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11224 }
11225 else
11226 {
11227 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11228 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011229 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011230 pBssConfig->cbMode = cbMode;
11231 pSession->bssParams.cbMode = cbMode;
11232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 }
11234}
11235
Jeff Johnson295189b2012-06-20 16:38:30 -070011236static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11237 tANI_BOOLEAN *pfSameIbss )
11238{
11239 eHalStatus status = eHAL_STATUS_SUCCESS;
11240 tANI_BOOLEAN fSameIbss = FALSE;
11241
11242 if ( csrIsConnStateIbss( pMac, sessionId ) )
11243 {
11244 // Check if any profile parameter has changed ? If any profile parameter
11245 // has changed then stop old BSS and start a new one with new parameters
11246 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11247 {
11248 fSameIbss = TRUE;
11249 }
11250 else
11251 {
11252 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11253 }
11254 }
11255 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11256 {
11257 // Disassociate from the connected Infrastructure network...
11258 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11259 }
11260 else
11261 {
11262 tBssConfigParam *pBssConfig;
11263
11264 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11265 if(HAL_STATUS_SUCCESS(status))
11266 {
11267 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11268 // there is no Bss description before we start an IBSS so we need to adopt
11269 // all Bss configuration parameters from the Profile.
11270 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11271 if(HAL_STATUS_SUCCESS(status))
11272 {
11273 //save dotMode
11274 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11275 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011276 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11278 }
11279
11280 palFreeMemory(pMac->hHdd, pBssConfig);
11281 }//Allocate memory
11282 }
11283
11284 if(pfSameIbss)
11285 {
11286 *pfSameIbss = fSameIbss;
11287 }
11288 return( status );
11289}
11290
Jeff Johnson295189b2012-06-20 16:38:30 -070011291static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11292 tSirSmeNewBssInfo *pNewBss )
11293{
11294 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011295
11296 if(!pSession)
11297 {
11298 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11299 return;
11300 }
11301
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 if( pNewBss )
11303 {
11304 // Set the operating channel.
11305 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11306 // move the BSSId from the BSS description into the connected state information.
11307 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11308 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 return;
11311}
11312
Jeff Johnson295189b2012-06-20 16:38:30 -070011313#ifdef FEATURE_WLAN_WAPI
11314eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11315 tANI_U32 numItems )
11316{
11317 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11318 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011319 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011321 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 return status;
11323 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011324 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 pSession = CSR_GET_SESSION( pMac, sessionId );
11326 if(numItems <= CSR_MAX_BKID_ALLOWED)
11327 {
11328 status = eHAL_STATUS_SUCCESS;
11329 //numItems may be 0 to clear the cache
11330 pSession->NumBkidCache = (tANI_U16)numItems;
11331 if(numItems && pBKIDCache)
11332 {
11333 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11334 sizeof(tBkidCacheInfo) * numItems );
11335 }
11336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011337 return (status);
11338}
Jeff Johnson295189b2012-06-20 16:38:30 -070011339eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11340 tBkidCacheInfo *pBkidCache)
11341{
11342 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11343 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011346 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 return status;
11348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 pSession = CSR_GET_SESSION( pMac, sessionId );
11350 if(pNum && pBkidCache)
11351 {
11352 if(pSession->NumBkidCache == 0)
11353 {
11354 *pNum = 0;
11355 status = eHAL_STATUS_SUCCESS;
11356 }
11357 else if(*pNum >= pSession->NumBkidCache)
11358 {
11359 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11360 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011361 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 -070011362 pSession->NumBkidCache);
11363 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11364 }
11365 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11366 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11367 *pNum = pSession->NumBkidCache;
11368 status = eHAL_STATUS_SUCCESS;
11369 }
11370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011372}
Jeff Johnson295189b2012-06-20 16:38:30 -070011373tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11374{
11375 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011376}
11377#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011378eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11379 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11380{
11381 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11382 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011383
11384 if(!pSession)
11385 {
11386 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11387 return eHAL_STATUS_FAILURE;
11388 }
11389
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011390 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11392 {
11393#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11394 {
11395 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11396 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11397 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11398 secEvent.encryptionModeMulticast =
11399 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11400 secEvent.encryptionModeUnicast =
11401 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11402 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11403 secEvent.authMode =
11404 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11405 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11406 }
11407#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 status = eHAL_STATUS_SUCCESS;
11409 //numItems may be 0 to clear the cache
11410 pSession->NumPmkidCache = (tANI_U16)numItems;
11411 if(numItems && pPMKIDCache)
11412 {
11413 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11414 sizeof(tPmkidCacheInfo) * numItems );
11415 }
11416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 return (status);
11418}
11419
Jeff Johnson295189b2012-06-20 16:38:30 -070011420tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11421{
11422 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11423}
11424
Jeff Johnson295189b2012-06-20 16:38:30 -070011425eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11426{
11427 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11428 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011429
11430 if(!pSession)
11431 {
11432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11433 return eHAL_STATUS_FAILURE;
11434 }
11435
Jeff Johnson295189b2012-06-20 16:38:30 -070011436 if(pNum && pPmkidCache)
11437 {
11438 if(pSession->NumPmkidCache == 0)
11439 {
11440 *pNum = 0;
11441 status = eHAL_STATUS_SUCCESS;
11442 }
11443 else if(*pNum >= pSession->NumPmkidCache)
11444 {
11445 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011447 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 -070011448 pSession->NumPmkidCache);
11449 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11450 }
11451 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11452 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11453 *pNum = pSession->NumPmkidCache;
11454 status = eHAL_STATUS_SUCCESS;
11455 }
11456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 return (status);
11458}
11459
Jeff Johnson295189b2012-06-20 16:38:30 -070011460eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11461{
11462 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11463 tANI_U32 len;
11464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011465
11466 if(!pSession)
11467 {
11468 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11469 return eHAL_STATUS_FAILURE;
11470 }
11471
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 if(pLen)
11473 {
11474 len = *pLen;
11475 *pLen = pSession->nWpaRsnReqIeLength;
11476 if(pBuf)
11477 {
11478 if(len >= pSession->nWpaRsnReqIeLength)
11479 {
11480 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11481 }
11482 }
11483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 return (status);
11485}
11486
Jeff Johnson295189b2012-06-20 16:38:30 -070011487eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11488{
11489 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11490 tANI_U32 len;
11491 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011492
11493 if(!pSession)
11494 {
11495 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11496 return eHAL_STATUS_FAILURE;
11497 }
11498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 if(pLen)
11500 {
11501 len = *pLen;
11502 *pLen = pSession->nWpaRsnRspIeLength;
11503 if(pBuf)
11504 {
11505 if(len >= pSession->nWpaRsnRspIeLength)
11506 {
11507 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11508 }
11509 }
11510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 return (status);
11512}
Jeff Johnson295189b2012-06-20 16:38:30 -070011513#ifdef FEATURE_WLAN_WAPI
11514eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11515{
11516 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11517 tANI_U32 len;
11518 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011519
11520 if(!pSession)
11521 {
11522 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11523 return eHAL_STATUS_FAILURE;
11524 }
11525
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 if(pLen)
11527 {
11528 len = *pLen;
11529 *pLen = pSession->nWapiReqIeLength;
11530 if(pBuf)
11531 {
11532 if(len >= pSession->nWapiReqIeLength)
11533 {
11534 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11535 }
11536 }
11537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 return (status);
11539}
Jeff Johnson295189b2012-06-20 16:38:30 -070011540eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11541{
11542 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11543 tANI_U32 len;
11544 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011545
11546 if(!pSession)
11547 {
11548 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11549 return eHAL_STATUS_FAILURE;
11550 }
11551
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 if(pLen)
11553 {
11554 len = *pLen;
11555 *pLen = pSession->nWapiRspIeLength;
11556 if(pBuf)
11557 {
11558 if(len >= pSession->nWapiRspIeLength)
11559 {
11560 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11561 }
11562 }
11563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 return (status);
11565}
11566#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011567eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11568{
11569 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011571
11572 if(!pSession)
11573 {
11574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11575 return (retStatus);
11576 }
11577
Jeff Johnson295189b2012-06-20 16:38:30 -070011578 if(CSR_IS_ROAMING(pSession))
11579 {
11580 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11581 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11582 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011583 return (retStatus);
11584}
11585
Jeff Johnson295189b2012-06-20 16:38:30 -070011586//This function remove the connected BSS from te cached scan result
11587eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11588 tCsrRoamConnectedProfile *pConnProfile)
11589{
11590 eHalStatus status = eHAL_STATUS_FAILURE;
11591 tCsrScanResultFilter *pScanFilter = NULL;
11592 tListElem *pEntry;
11593 tCsrScanResult *pResult;
11594 tDot11fBeaconIEs *pIes;
11595 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11597 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11598 {
11599 do
11600 {
11601 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11602 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11603 if(!HAL_STATUS_SUCCESS(status)) break;
11604 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11605 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11606 if(!HAL_STATUS_SUCCESS(status)) break;
11607 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11608 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11609 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11610 {
11611 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11612 if(!HAL_STATUS_SUCCESS(status)) break;
11613 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11614 }
11615 pScanFilter->authType.numEntries = 1;
11616 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11617 pScanFilter->BSSType = pConnProfile->BSSType;
11618 pScanFilter->EncryptionType.numEntries = 1;
11619 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11620 pScanFilter->mcEncryptionType.numEntries = 1;
11621 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11622 //We ignore the channel for now, BSSID should be enough
11623 pScanFilter->ChannelInfo.numOfChannels = 0;
11624 //Also ignore the following fields
11625 pScanFilter->uapsd_mask = 0;
11626 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11627 pScanFilter->countryCode[0] = 0;
11628 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 csrLLLock(&pMac->scan.scanResultList);
11630 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11631 while( pEntry )
11632 {
11633 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11634 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11635 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11636 pScanFilter, NULL, NULL, NULL, &pIes);
11637 //Release the IEs allocated by csrMatchBSS is needed
11638 if( !pResult->Result.pvIes )
11639 {
11640 //need to free the IEs since it is allocated by csrMatchBSS
11641 palFreeMemory(pMac->hHdd, pIes);
11642 }
11643 if(fMatch)
11644 {
11645 //We found the one
11646 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11647 {
11648 //Free the memory
11649 csrFreeScanResultEntry( pMac, pResult );
11650 }
11651 break;
11652 }
11653 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11654 }//while
11655 csrLLUnlock(&pMac->scan.scanResultList);
11656 }while(0);
11657 if(pScanFilter)
11658 {
11659 csrFreeScanFilter(pMac, pScanFilter);
11660 palFreeMemory(pMac->hHdd, pScanFilter);
11661 }
11662 }
11663 return (status);
11664}
11665
Jeff Johnson295189b2012-06-20 16:38:30 -070011666//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011667eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11668{
11669 eHalStatus status = eHAL_STATUS_SUCCESS;
11670 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11672 {
11673 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11674 {
11675 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11676 {
11677 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011678 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 status = eHAL_STATUS_CSR_WRONG_STATE;
11680 break;
11681 }
11682 if( csrIsConnStateInfra( pMac, sessionId ) )
11683 {
11684 if( chnId &&
11685 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011687 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11689 status = eHAL_STATUS_CSR_WRONG_STATE;
11690 break;
11691 }
11692 }
11693 }
11694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 return ( status );
11696}
11697
Jeff Johnson295189b2012-06-20 16:38:30 -070011698static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11699{
11700 eHalStatus status = eHAL_STATUS_SUCCESS;
11701 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11702 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011703
11704 if(!pSession)
11705 {
11706 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11707 return eHAL_STATUS_FAILURE;
11708 }
11709
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 if ( csrIsConnStateIbss( pMac, sessionId ) )
11711 {
11712 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11713 }
11714 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11715 {
11716 // Disassociate from the connected Infrastructure network...
11717 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11718 }
11719 else
11720 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11722 //Otherwise we need to add code to handle the
11723 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11724 //send stop_bss to PE, before we can continue.
11725 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11727 /* Assume HDD provide bssid in profile */
11728 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11729 // there is no Bss description before we start an WDS so we need
11730 // to adopt all Bss configuration parameters from the Profile.
11731 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11732 if(HAL_STATUS_SUCCESS(status))
11733 {
11734 //Save profile for late use
11735 csrFreeRoamProfile( pMac, sessionId );
11736 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11737 (void **)&pSession->pCurRoamProfile,
11738 sizeof(tCsrRoamProfile))))
11739 {
11740 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11741 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011744 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011745 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11746 }
11747 }
11748
11749 return( status );
11750}
11751
Jeff Johnson295189b2012-06-20 16:38:30 -070011752////////////////////Mail box
11753
Jeff Johnson295189b2012-06-20 16:38:30 -070011754//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11755//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11756static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11757 tSirBssDescription *pBssDescription,
11758 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11759{
11760 tCsrChannelSet channelGroup;
11761 tSirMacCapabilityInfo *pAP_capabilityInfo;
11762 tAniBool fTmp;
11763 tANI_BOOLEAN found = FALSE;
11764 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011765 tANI_S8 pwrLimit = 0;
11766 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11768 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11769 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11770 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 // 802.11h
11772 //We can do this because it is in HOST CPU order for now.
11773 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011774 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11775 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11776 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 fTmp = (tAniBool)pal_cpu_to_be32(1);
11778 }
11779 else
11780 fTmp = (tAniBool)0;
11781
11782 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11783 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11784 pBuf += sizeof(tAniBool);
11785 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011786 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 // This is required for 11k test VoWiFi Ent: Test 2.
11788 // We need the power capabilities for Assoc Req.
11789 // This macro is provided by the halPhyCfg.h. We pick our
11790 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011791 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11792 if (0 != pwrLimit)
11793 {
11794 *pBuf++ = pwrLimit;
11795 }
11796 else
11797 {
11798 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 size = sizeof(pMac->roam.validChannelList);
11801 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11802 {
11803 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11804 for ( i = 0; i < size; i++)
11805 {
11806 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11807
11808 }
11809 }
11810 else
11811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011812 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011813 *pBuf++ = 0; //tSirSupChnl->numChnl
11814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 //Check whether it is ok to enter UAPSD
11816#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11817 if( btcIsReadyForUapsd(pMac) )
11818#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11819 {
11820 *pBuf++ = uapsdMask;
11821 }
11822#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11823 else
11824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011825 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 *pBuf++ = 0;
11827 }
11828#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11829
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 // move the entire BssDescription into the join request.
11831 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11832 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11834}
11835
Jeff Johnson295189b2012-06-20 16:38:30 -070011836/*
11837 * The communication between HDD and LIM is thru mailbox (MB).
11838 * Both sides will access the data structure "tSirSmeJoinReq".
11839 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11840 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11841 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11842 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11843 */
11844eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011845 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011846{
11847 eHalStatus status = eHAL_STATUS_SUCCESS;
11848 tSirSmeJoinReq *pMsg;
11849 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011850 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 tANI_U16 msgLen, wTmp, ieLen;
11852 tSirMacRateSet OpRateSet;
11853 tSirMacRateSet ExRateSet;
11854 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11855 tANI_U32 dwTmp;
11856 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011857 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011858
11859 if(!pSession)
11860 {
11861 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11862 return eHAL_STATUS_FAILURE;
11863 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011864 /* To satisfy klockworks */
11865 if (NULL == pBssDescription)
11866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011867 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011868 return eHAL_STATUS_FAILURE;
11869 }
11870
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 do {
11872 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11873 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011874 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011875 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11876 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11877 // IE fields, but the length field in the bssDescription needs to be interpreted to
11878 // determine length of the IE fields.
11879 //
11880 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11881 // add in the length from the bssDescription (then add the size of the 'length' field
11882 // itself because that is NOT included in the length field).
11883 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11884 pBssDescription->length + sizeof( pBssDescription->length ) +
11885 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 -070011886 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11887 if ( !HAL_STATUS_SUCCESS(status) ) break;
11888 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011889 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 pMsg->length = pal_cpu_to_be16(msgLen);
11891 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 // sessionId
11893 *pBuf = (tANI_U8)sessionId;
11894 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011895 // transactionId
11896 *pBuf = 0;
11897 *( pBuf + 1 ) = 0;
11898 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 // ssId
11900 if( pIes->SSID.present && pIes->SSID.num_ssid )
11901 {
11902 // ssId len
11903 *pBuf = pIes->SSID.num_ssid;
11904 pBuf++;
11905 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11906 pBuf += pIes->SSID.num_ssid;
11907 }
11908 else
11909 {
11910 *pBuf = 0;
11911 pBuf++;
11912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 // selfMacAddr
11914 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11915 pBuf += sizeof(tSirMacAddr);
11916 // bsstype
11917 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11918 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11919 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11920 pBuf += sizeof(tSirBssType);
11921 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011922 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11923 if (pBssDescription->channelId <= 14 &&
11924 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11925 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11926 {
11927 //Need to disable VHT operation in 2.4 GHz band
11928 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11929 }
11930 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 //Persona
11933 *pBuf = (tANI_U8)pProfile->csrPersona;
11934 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011935 //CBMode
11936 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11937 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011938
11939 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011940 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11941
Jeff Johnson295189b2012-06-20 16:38:30 -070011942 // uapsdPerAcBitmask
11943 *pBuf = pProfile->uapsd_mask;
11944 pBuf++;
11945
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011946
11947
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011949 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 {
11951 // OperationalRateSet
11952 if (OpRateSet.numRates) {
11953 *pBuf++ = OpRateSet.numRates;
11954 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11955 pBuf += OpRateSet.numRates;
11956 } else *pBuf++ = 0;
11957 // ExtendedRateSet
11958 if (ExRateSet.numRates) {
11959 *pBuf++ = ExRateSet.numRates;
11960 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11961 pBuf += ExRateSet.numRates;
11962 } else *pBuf++ = 0;
11963 }
11964 else
11965 {
11966 *pBuf++ = 0;
11967 *pBuf++ = 0;
11968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011969 // rsnIE
11970 if ( csrIsProfileWpa( pProfile ) )
11971 {
11972 // Insert the Wpa IE into the join request
11973 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11974 (tCsrWpaIe *)( wpaRsnIE ) );
11975 }
11976 else if( csrIsProfileRSN( pProfile ) )
11977 {
11978 // Insert the RSN IE into the join request
11979 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11980 (tCsrRSNIe *)( wpaRsnIE ) );
11981 }
11982#ifdef FEATURE_WLAN_WAPI
11983 else if( csrIsProfileWapi( pProfile ) )
11984 {
11985 // Insert the WAPI IE into the join request
11986 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11987 (tCsrWapiIe *)( wpaRsnIE ) );
11988 }
11989#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 else
11991 {
11992 ieLen = 0;
11993 }
11994 //remember the IE for future use
11995 if( ieLen )
11996 {
11997 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011999 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 -070012000 ieLen = DOT11F_IE_RSN_MAX_LEN;
12001 }
12002#ifdef FEATURE_WLAN_WAPI
12003 if( csrIsProfileWapi( pProfile ) )
12004 {
12005 //Check whether we need to allocate more memory
12006 if(ieLen > pSession->nWapiReqIeLength)
12007 {
12008 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12009 {
12010 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12011 }
12012 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
12013 if(!HAL_STATUS_SUCCESS(status)) break;
12014 }
12015 pSession->nWapiReqIeLength = ieLen;
12016 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
12017 wTmp = pal_cpu_to_be16( ieLen );
12018 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12019 pBuf += sizeof(tANI_U16);
12020 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12021 pBuf += ieLen;
12022 }
12023 else//should be WPA/WPA2 otherwise
12024#endif /* FEATURE_WLAN_WAPI */
12025 {
12026 //Check whether we need to allocate more memory
12027 if(ieLen > pSession->nWpaRsnReqIeLength)
12028 {
12029 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12030 {
12031 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12032 }
12033 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
12034 if(!HAL_STATUS_SUCCESS(status)) break;
12035 }
12036 pSession->nWpaRsnReqIeLength = ieLen;
12037 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
12038 wTmp = pal_cpu_to_be16( ieLen );
12039 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12040 pBuf += sizeof(tANI_U16);
12041 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12042 pBuf += ieLen;
12043 }
12044 }
12045 else
12046 {
12047 //free whatever old info
12048 pSession->nWpaRsnReqIeLength = 0;
12049 if(pSession->pWpaRsnReqIE)
12050 {
12051 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12052 pSession->pWpaRsnReqIE = NULL;
12053 }
12054#ifdef FEATURE_WLAN_WAPI
12055 pSession->nWapiReqIeLength = 0;
12056 if(pSession->pWapiReqIE)
12057 {
12058 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12059 pSession->pWapiReqIE = NULL;
12060 }
12061#endif /* FEATURE_WLAN_WAPI */
12062 //length is two bytes
12063 *pBuf = 0;
12064 *(pBuf + 1) = 0;
12065 pBuf += 2;
12066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012067#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012068 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012070 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 //length is two bytes
12072 *pBuf = 0;
12073 *(pBuf + 1) = 0;
12074 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012075 }
12076 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012078 // cckmIE
12079 if( csrIsProfileCCX( pProfile ) )
12080 {
12081 // Insert the CCKM IE into the join request
12082 ieLen = csrConstructCcxCckmIe( pMac,
12083 pSession,
12084 pProfile,
12085 pBssDescription,
12086 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 pSession->nWpaRsnReqIeLength,
12088 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012089 }
12090 else
12091 {
12092 ieLen = 0;
12093 }
12094 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12095 if( ieLen )
12096 {
12097 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12098 wTmp = pal_cpu_to_be16( ieLen );
12099 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12100 pBuf += sizeof(tANI_U16);
12101 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12102 pBuf += ieLen;
12103 }
12104 else
12105 {
12106 //Indicate you have no CCKM IE
12107 //length is two bytes
12108 *pBuf = 0;
12109 *(pBuf + 1) = 0;
12110 pBuf += 2;
12111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 }
12113#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 // addIEScan
12115 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12116 {
12117 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 if(ieLen > pSession->nAddIEScanLength)
12119 {
12120 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12121 {
12122 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12123 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012124 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012125 (void **)&pSession->pAddIEScan, ieLen);
12126 if(!HAL_STATUS_SUCCESS(status)) break;
12127 }
12128 pSession->nAddIEScanLength = ieLen;
12129 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12130 pProfile->pAddIEScan, ieLen);
12131 wTmp = pal_cpu_to_be16( ieLen );
12132 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12133 pBuf += sizeof(tANI_U16);
12134 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12135 pBuf += ieLen;
12136 }
12137 else
12138 {
12139 pSession->nAddIEScanLength = 0;
12140 if(pSession->pAddIEScan)
12141 {
12142 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12143 pSession->pAddIEScan = NULL;
12144 }
12145 *pBuf = 0;
12146 *(pBuf + 1) = 0;
12147 pBuf += 2;
12148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 // addIEAssoc
12150 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12151 {
12152 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 if(ieLen > pSession->nAddIEAssocLength)
12154 {
12155 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12156 {
12157 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12158 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012159 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 (void **)&pSession->pAddIEAssoc, ieLen);
12161 if(!HAL_STATUS_SUCCESS(status)) break;
12162 }
12163 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012164 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 pProfile->pAddIEAssoc, ieLen);
12166 wTmp = pal_cpu_to_be16( ieLen );
12167 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12168 pBuf += sizeof(tANI_U16);
12169 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12170 pBuf += ieLen;
12171 }
12172 else
12173 {
12174 pSession->nAddIEAssocLength = 0;
12175 if(pSession->pAddIEAssoc)
12176 {
12177 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12178 pSession->pAddIEAssoc = NULL;
12179 }
12180 *pBuf = 0;
12181 *(pBuf + 1) = 0;
12182 pBuf += 2;
12183 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012184
12185 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012187 //Unmask any AC in reassoc that is ACM-set
12188 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12189 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012191 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12192 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012193#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012194 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012195#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012196 uapsd_mask &= ~(acm_mask);
12197 }
12198 else
12199 {
12200 uapsd_mask = 0;
12201 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 }
12203 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012204
Jeff Johnson295189b2012-06-20 16:38:30 -070012205 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12206 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012207 pBuf += sizeof(tANI_U32);
12208
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12210 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012211 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012212#ifdef WLAN_FEATURE_11W
12213 //MgmtEncryption
12214 if (pProfile->MFPEnabled)
12215 {
12216 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12217 }
12218 else
12219 {
12220 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12221 }
12222 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12223 pBuf += sizeof(tANI_U32);
12224#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012225#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012226 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012227 if (csrIsProfile11r( pProfile )
12228#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012229 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12230 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012231#endif
12232 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012233 {
12234 // is11Rconnection;
12235 dwTmp = pal_cpu_to_be32(TRUE);
12236 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12237 pBuf += sizeof(tAniBool);
12238 }
12239 else
12240 {
12241 // is11Rconnection;
12242 dwTmp = pal_cpu_to_be32(FALSE);
12243 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12244 pBuf += sizeof(tAniBool);
12245 }
12246#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012247#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012248
12249 // isCCXFeatureIniEnabled
12250 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12251 {
12252 dwTmp = pal_cpu_to_be32(TRUE);
12253 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12254 pBuf += sizeof(tAniBool);
12255 }
12256 else
12257 {
12258 dwTmp = pal_cpu_to_be32(FALSE);
12259 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12260 pBuf += sizeof(tAniBool);
12261 }
12262
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012263 /* A profile can not be both CCX and 11R. But an 802.11R AP
12264 * may be advertising support for CCX as well. So if we are
12265 * associating Open or explicitly CCX then we will get CCX.
12266 * If we are associating explictly 11R only then we will get
12267 * 11R.
12268 */
12269 if ((csrIsProfileCCX(pProfile) ||
12270 ((pIes->CCXVersion.present)
12271 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012272 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12273 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12274 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012275#ifdef WLAN_FEATURE_11W
12276 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12277#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012278 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012279 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12280 {
12281 // isCCXconnection;
12282 dwTmp = pal_cpu_to_be32(TRUE);
12283 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12284 pBuf += sizeof(tAniBool);
12285 }
12286 else
12287 {
12288 //isCCXconnection;
12289 dwTmp = pal_cpu_to_be32(FALSE);
12290 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12291 pBuf += sizeof(tAniBool);
12292 }
12293
12294 if (eWNI_SME_JOIN_REQ == messageType)
12295 {
12296 tCCXTspecInfo ccxTspec;
12297 // CCX-Tspec IEs in the ASSOC request is presently not supported
12298 // so nullify the TSPEC parameters
12299 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12300 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12301 pBuf += sizeof(tCCXTspecInfo);
12302 }
12303 else if (eWNI_SME_REASSOC_REQ == messageType)
12304 {
12305 if ((csrIsProfileCCX(pProfile) ||
12306 ((pIes->CCXVersion.present)
12307 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012308 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12309 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12310 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012311#ifdef WLAN_FEATURE_11W
12312 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12313#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012314 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012315 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 {
12317 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 // CCX Tspec information
12319 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12320 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12321 *pBuf = ccxTspec.numTspecs;
12322 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 // Copy the TSPEC information only if present
12324 if (ccxTspec.numTspecs) {
12325 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12326 }
12327 pBuf += sizeof(ccxTspec.tspec);
12328 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012329 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 tCCXTspecInfo ccxTspec;
12332 // CCX-Tspec IEs in the ASSOC request is presently not supported
12333 // so nullify the TSPEC parameters
12334 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12335 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12336 pBuf += sizeof(tCCXTspecInfo);
12337 }
12338 }
12339#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012340#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012342 if (pMac->roam.configParam.isFastTransitionEnabled
12343#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012344 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012345#endif
12346 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012348 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012350 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012351 }
12352 else
12353 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012354 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012356 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012357 }
12358#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012359#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012360 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012361 {
12362 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012363 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012364 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012365 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012366 }
12367 else
12368 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012369 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012370 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012371 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012372 }
12373#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012374
12375 // txLdpcIniFeatureEnabled
12376 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12377 pBuf++;
12378
Kiran4a17ebe2013-01-31 10:43:43 -080012379 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12380 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12381 {
12382 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12383 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12384 csrApplyPower2Current(pMac);
12385 }
12386
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012387#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012388 // txBFIniFeatureEnabled
12389 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12390 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012391
12392 // txBFCsnValue
12393 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12394 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012395#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012396 //BssDesc
12397 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12398 (tANI_U8)pProfile->uapsd_mask);
12399 status = palSendMBMessage(pMac->hHdd, pMsg );
12400 if(!HAL_STATUS_SUCCESS(status))
12401 {
12402 break;
12403 }
12404 else
12405 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012406#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012407 if (eWNI_SME_JOIN_REQ == messageType)
12408 {
12409 //Tush-QoS: notify QoS module that join happening
12410 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12411 }
12412 else if (eWNI_SME_REASSOC_REQ == messageType)
12413 {
12414 //Tush-QoS: notify QoS module that reassoc happening
12415 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012417#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012420 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012421}
12422
Jeff Johnson295189b2012-06-20 16:38:30 -070012423//
12424eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12425{
12426 eHalStatus status = eHAL_STATUS_SUCCESS;
12427 tSirSmeDisassocReq *pMsg;
12428 tANI_U8 *pBuf;
12429 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12431 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12432 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 do {
12434 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12435 if ( !HAL_STATUS_SUCCESS(status) ) break;
12436 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12437 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12438 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 pBuf = &pMsg->sessionId;
12440 // sessionId
12441 *pBuf++ = (tANI_U8)sessionId;
12442 // transactionId
12443 *pBuf = 0;
12444 *( pBuf + 1 ) = 0;
12445 pBuf += sizeof(tANI_U16);
12446
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012447 if ( (pSession->pCurRoamProfile != NULL) &&
12448 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12449 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 {
12451 // Set the bssid address before sending the message to LIM
12452 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12453 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 // Set the peer MAC address before sending the message to LIM
12455 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12456 pBuf = pBuf + sizeof ( tSirMacAddr );
12457 }
12458 else
12459 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 // Set the peer MAC address before sending the message to LIM
12461 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12462 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12464 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 if(!HAL_STATUS_SUCCESS(status))
12467 {
12468 palFreeMemory(pMac->hHdd, pMsg);
12469 break;
12470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 // reasonCode
12472 wTmp = pal_cpu_to_be16(reasonCode);
12473 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12474 if(!HAL_STATUS_SUCCESS(status))
12475 {
12476 palFreeMemory(pMac->hHdd, pMsg);
12477 break;
12478 }
12479 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12481 Here we should not send the disassoc over the air to the AP */
12482 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12483#ifdef WLAN_FEATURE_VOWIFI_11R
12484 && csrRoamIs11rAssoc(pMac)
12485#endif
12486 )
12487 {
12488 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12489 }
12490 pBuf += sizeof(tANI_U8);
12491 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 return( status );
12494}
Jeff Johnson295189b2012-06-20 16:38:30 -070012495eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12496{
12497 eHalStatus status = eHAL_STATUS_SUCCESS;
12498 tSirSmeTkipCntrMeasReq *pMsg;
12499 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 do
12501 {
12502 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12503 if ( !HAL_STATUS_SUCCESS(status) ) break;
12504 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12505 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12506 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012507 pBuf = &pMsg->sessionId;
12508 // sessionId
12509 *pBuf++ = (tANI_U8)sessionId;
12510 // transactionId
12511 *pBuf = 0;
12512 *( pBuf + 1 ) = 0;
12513 pBuf += sizeof(tANI_U16);
12514 // bssid
12515 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12516 pBuf = pBuf + sizeof ( tSirMacAddr );
12517 // bEnable
12518 *pBuf = (tANI_BOOLEAN)bEnable;
12519 if(!HAL_STATUS_SUCCESS(status))
12520 {
12521 palFreeMemory(pMac->hHdd, pMsg);
12522 break;
12523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012525 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 return( status );
12527}
Jeff Johnson295189b2012-06-20 16:38:30 -070012528eHalStatus
12529csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12530 VOS_MODULE_ID modId, tSirMacAddr bssId,
12531 void *pUsrContext, void *pfnSapEventCallback,
12532 tANI_U8 *pAssocStasBuf )
12533{
12534 eHalStatus status = eHAL_STATUS_SUCCESS;
12535 tSirSmeGetAssocSTAsReq *pMsg;
12536 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12537 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012538 do
12539 {
12540 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12541 if (!HAL_STATUS_SUCCESS(status)) break;
12542 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12543 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 pBuf = (tANI_U8 *)&pMsg->bssId;
12545 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 // bssId
12547 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12548 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012549 // modId
12550 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12551 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12552 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 // pUsrContext
12554 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12555 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12556 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 // pfnSapEventCallback
12558 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12559 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12560 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 // pAssocStasBuf
12562 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12563 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12564 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 status = palSendMBMessage( pMac->hHdd, pMsg );
12567 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 return( status );
12569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012570eHalStatus
12571csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12572 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12573 {
12574 eHalStatus status = eHAL_STATUS_SUCCESS;
12575 tSirSmeGetWPSPBCSessionsReq *pMsg;
12576 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12577 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 do
12579 {
12580 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12581 if (!HAL_STATUS_SUCCESS(status)) break;
12582 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12583 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070012585 VOS_ASSERT(pBuf);
12586
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 // pUsrContext
12589 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12590 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12591 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 // pSapEventCallback
12593 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12594 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12595 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 // bssId
12597 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12598 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 // MAC Address of STA in WPS session
12600 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12601 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 return( status );
12606}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012607
12608eHalStatus
12609csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12610{
12611 tpSirChangeBIParams pMsg;
12612 tANI_U16 len = 0;
12613 eHalStatus status = eHAL_STATUS_SUCCESS;
12614 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12615
12616 if(!pSession)
12617 {
12618 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12619 return eHAL_STATUS_FAILURE;
12620 }
12621
12622 //NO need to update the Beacon Params if update beacon parameter flag is not set
12623 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12624 return eHAL_STATUS_SUCCESS;
12625
12626 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12627
12628 /* Create the message and send to lim */
12629 len = sizeof(tSirChangeBIParams);
12630 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12631 if(HAL_STATUS_SUCCESS(status))
12632 {
12633 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12634 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12635 pMsg->length = len;
12636
12637 // bssId
12638 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012639 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 -080012640 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12641 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12642 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012643 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012644 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12645 status = palSendMBMessage(pMac->hHdd, pMsg);
12646 }
12647 return status;
12648}
12649
Jeff Johnson295189b2012-06-20 16:38:30 -070012650eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12651{
12652 eHalStatus status = eHAL_STATUS_SUCCESS;
12653 tSirSmeDeauthReq *pMsg;
12654 tANI_U8 *pBuf;
12655 tANI_U16 wTmp;
12656 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12657 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12658 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 do {
12660 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12661 if ( !HAL_STATUS_SUCCESS(status) ) break;
12662 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12663 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12664 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12665 //sessionId
12666 pBuf = &pMsg->sessionId;
12667 *pBuf++ = (tANI_U8)sessionId;
12668
12669 //tansactionId
12670 *pBuf = 0;
12671 *(pBuf + 1 ) = 0;
12672 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12676 // Set the BSSID before sending the message to LIM
12677 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12678 pBuf = pBuf + sizeof(tSirMacAddr);
12679 }
12680 else
12681 {
12682 // Set the BSSID before sending the message to LIM
12683 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12684 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 }
12686 if(!HAL_STATUS_SUCCESS(status))
12687 {
12688 palFreeMemory(pMac->hHdd, pMsg);
12689 break;
12690 }
12691 // Set the peer MAC address before sending the message to LIM
12692 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12693 pBuf = pBuf + sizeof(tSirMacAddr);
12694 if(!HAL_STATUS_SUCCESS(status))
12695 {
12696 palFreeMemory(pMac->hHdd, pMsg);
12697 break;
12698 }
12699 wTmp = pal_cpu_to_be16(reasonCode);
12700 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12701 if(!HAL_STATUS_SUCCESS(status))
12702 {
12703 palFreeMemory(pMac->hHdd, pMsg);
12704 break;
12705 }
12706 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 return( status );
12709}
12710
Jeff Johnson295189b2012-06-20 16:38:30 -070012711eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12712{
12713 eHalStatus status = eHAL_STATUS_SUCCESS;
12714 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 do {
12716 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12717 if ( !HAL_STATUS_SUCCESS(status) ) break;
12718 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12719 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12720 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12721 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12722 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12723 if(!HAL_STATUS_SUCCESS(status))
12724 {
12725 palFreeMemory(pMac->hHdd, pMsg);
12726 break;
12727 }
12728//To test reconn
12729 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12730 if(!HAL_STATUS_SUCCESS(status))
12731 {
12732 palFreeMemory(pMac->hHdd, pMsg);
12733 break;
12734 }
12735//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 return( status );
12739}
12740
Jeff Johnson295189b2012-06-20 16:38:30 -070012741eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12742{
12743 eHalStatus status = eHAL_STATUS_SUCCESS;
12744 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 do {
12746 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12747 if ( !HAL_STATUS_SUCCESS(status) ) break;
12748 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12749 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12750 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12751 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12752 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12753 if(!HAL_STATUS_SUCCESS(status))
12754 {
12755 palFreeMemory(pMac->hHdd, pMsg);
12756 break;
12757 }
12758 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12759 if(!HAL_STATUS_SUCCESS(status))
12760 {
12761 palFreeMemory(pMac->hHdd, pMsg);
12762 break;
12763 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 return( status );
12767}
Jeff Johnson295189b2012-06-20 16:38:30 -070012768eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12769{
12770 eHalStatus status = eHAL_STATUS_SUCCESS;
12771 tSirSmeAssocCnf *pMsg;
12772 tANI_U8 *pBuf;
12773 tSirResultCodes statusCode;
12774 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 do {
12776 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12777 if ( !HAL_STATUS_SUCCESS(status) ) break;
12778 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12779 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12780 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 pBuf = (tANI_U8 *)&pMsg->statusCode;
12782 if(HAL_STATUS_SUCCESS(Halstatus))
12783 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12784 else
12785 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12786 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12787 pBuf += sizeof(tSirResultCodes);
12788 // bssId
12789 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12790 pBuf += sizeof (tSirMacAddr);
12791 // peerMacAddr
12792 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12793 pBuf += sizeof (tSirMacAddr);
12794 // aid
12795 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12796 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12797 pBuf += sizeof (tANI_U16);
12798 // alternateBssId
12799 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12800 pBuf += sizeof (tSirMacAddr);
12801 // alternateChannelId
12802 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 status = palSendMBMessage( pMac->hHdd, pMsg );
12804 if(!HAL_STATUS_SUCCESS(status))
12805 {
12806 //pMsg is freed by palSendMBMessage
12807 break;
12808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 return( status );
12811}
Jeff Johnson295189b2012-06-20 16:38:30 -070012812eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12813 tpSirSmeAssocInd pAssocInd,
12814 eHalStatus Halstatus,
12815 tANI_U8 sessionId)
12816{
12817 tSirMsgQ msgQ;
12818 eHalStatus status = eHAL_STATUS_SUCCESS;
12819 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12820 tANI_U8 *pBuf;
12821 tSirResultCodes statusCode;
12822 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 do {
12824 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12825 if ( !HAL_STATUS_SUCCESS(status) ) break;
12826 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012827
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12829 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12830
12831 pMsg->sessionId = sessionId;
12832
12833 pBuf = (tANI_U8 *)&pMsg->statusCode;
12834 if(HAL_STATUS_SUCCESS(Halstatus))
12835 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12836 else
12837 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12838 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12839 pBuf += sizeof(tSirResultCodes);
12840 // bssId
12841 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12842 pBuf += sizeof (tSirMacAddr);
12843 // peerMacAddr
12844 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12845 pBuf += sizeof (tSirMacAddr);
12846 // StaId
12847 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12848 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12849 pBuf += sizeof (tANI_U16);
12850 // alternateBssId
12851 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12852 pBuf += sizeof (tSirMacAddr);
12853 // alternateChannelId
12854 *pBuf = 11;
12855 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012856 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 //Wmm
12858 *pBuf = pAssocInd->wmmEnabledSta;
12859 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 //RSN IE
12861 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12862 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 //Additional IE
12864 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12865 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 //reassocReq
12867 *pBuf = pAssocInd->reassocReq;
12868 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12870 msgQ.bodyptr = pMsg;
12871 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 return( status );
12875}
Jeff Johnson295189b2012-06-20 16:38:30 -070012876
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012877eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12879 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12880 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12881 tANI_U8 *pKeyRsc )
12882{
12883 tSirSmeSetContextReq *pMsg;
12884 tANI_U16 msgLen;
12885 eHalStatus status = eHAL_STATUS_FAILURE;
12886 tAniEdType tmpEdType;
12887 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012888 tANI_U8 *pBuf = NULL;
12889 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12894 // key set. Since we only support upto one key, we always allocate memory for 1 key
12895 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12896 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12897 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12898 ( sizeof( pMsg->keyMaterial.key ) );
12899
12900 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12901 if ( !HAL_STATUS_SUCCESS(status) ) break;
12902 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12903 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12904 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 //sessionId
12906 pBuf = &pMsg->sessionId;
12907 *pBuf = (tANI_U8)sessionId;
12908 pBuf++;
12909 // transactionId
12910 *pBuf = 0;
12911 *(pBuf + 1) = 0;
12912 pBuf += sizeof(tANI_U16);
12913 // peerMacAddr
12914 palCopyMemory( pMac->hHdd, pBuf,
12915 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12916
12917 pBuf += sizeof(tSirMacAddr);
12918
12919 // bssId
12920 palCopyMemory( pMac->hHdd, pBuf,
12921 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12922
12923 pBuf += sizeof(tSirMacAddr);
12924
12925 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12927 // in the tSirKeyMaterial keyMaterial; field).
12928 //
12929 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12930 // shorter than this max size. Is LIM interpreting this ok ?
12931 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 -070012932 // set pMsg->keyMaterial.edType
12933 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12934 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12935 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 // set the pMsg->keyMaterial.numKeys field
12937 *p = numKeys;
12938 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 // set pSirKey->keyId = keyId;
12940 *p = keyId;
12941 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 // set pSirKey->unicast = (tANI_U8)fUnicast;
12943 *p = (tANI_U8)fUnicast;
12944 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 // set pSirKey->keyDirection = aniKeyDirection;
12946 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12947 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12948 p += sizeof(tAniKeyDirection);
12949 // pSirKey->keyRsc = ;;
12950 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12951 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 // set pSirKey->paeRole
12953 *p = paeRole; // 0 is Supplicant
12954 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 // set pSirKey->keyLength = keyLength;
12956 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 if ( keyLength && pKey )
12958 {
12959 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12960 if(keyLength == 16)
12961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012962 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 -070012963 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12964 pKey[5], pKey[6], pKey[7], pKey[8],
12965 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12966 }
12967 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 return( status );
12971}
12972
Jeff Johnson295189b2012-06-20 16:38:30 -070012973eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12974 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12975{
12976 eHalStatus status;
12977 tSirSmeStartBssReq *pMsg;
12978 tANI_U8 *pBuf = NULL;
12979 tANI_U8 *wTmpBuf = NULL;
12980 tANI_U16 msgLen, wTmp;
12981 tANI_U32 dwTmp;
12982 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012983 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012986
12987 if(!pSession)
12988 {
12989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12990 return eHAL_STATUS_FAILURE;
12991 }
12992
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 do {
12994 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12995 pSession->joinFailStatusCode.reasonCode = 0;
12996 msgLen = sizeof(tSirSmeStartBssReq);
12997 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12998 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 palZeroMemory(pMac->hHdd, pMsg, msgLen);
13000 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013002 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 //sessionId
13004 *pBuf = (tANI_U8)sessionId;
13005 pBuf++;
13006 // transactionId
13007 *pBuf = 0;
13008 *(pBuf + 1) = 0;
13009 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 // bssid
13011 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
13012 pBuf += sizeof(tSirMacAddr);
13013 // selfMacAddr
13014 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
13015 pBuf += sizeof(tSirMacAddr);
13016 // beaconInterval
13017 if( pBssDesc && pBssDesc->beaconInterval )
13018 {
13019 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13020 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 else if(pParam->beaconInterval)
13022 {
13023 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13024 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 else
13026 {
13027 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13028 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013029 if(csrIsconcurrentsessionValid (pMac, sessionId,
13030 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013031 == eHAL_STATUS_SUCCESS )
13032 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013033 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013034 pParam->bssPersona);
13035 //Update the beacon Interval
13036 pParam->beaconInterval = wTmp;
13037 }
13038 else
13039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013040 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013041 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070013042 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070013043 return status;
13044 }
13045
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13047 pBuf += sizeof(tANI_U16);
13048 // dot11mode
13049 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13050 pBuf += 1;
13051 // bssType
13052 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
13053 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
13054 pBuf += sizeof(tSirBssType);
13055 // ssId
13056 if( pParam->ssId.length )
13057 {
13058 // ssId len
13059 *pBuf = pParam->ssId.length;
13060 pBuf++;
13061 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
13062 pBuf += pParam->ssId.length;
13063 }
13064 else
13065 {
13066 *pBuf = 0;
13067 pBuf++;
13068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 // set the channel Id
13070 *pBuf = pParam->operationChn;
13071 pBuf++;
13072 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013073 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
13074 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
13075 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013076
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 // Set privacy
13078 *pBuf = pParam->privacy;
13079 pBuf++;
13080
13081 //Set Uapsd
13082 *pBuf = pParam->ApUapsdEnable;
13083 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 //Set SSID hidden
13085 *pBuf = pParam->ssidHidden;
13086 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13088 pBuf++;
13089
13090 //Ht protection Enable/Disable
13091 *pBuf = (tANI_U8)pParam->protEnabled;
13092 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 //Enable Beacons to Receive for OBSS protection Enable/Disable
13094 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13095 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 //set cfg related to protection
13097 wTmp = pal_cpu_to_be16( pParam->ht_protection );
13098 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13099 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 // Set Auth type
13101 authType = pal_cpu_to_be32(pParam->authType);
13102 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
13103 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 // Set DTIM
13105 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
13106 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
13107 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 // Set wps_state
13109 *pBuf = pParam->wps_state;
13110 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013111 //Persona
13112 *pBuf = (tANI_U8)pParam->bssPersona;
13113 pBuf++;
13114
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013115 //txLdpcIniFeatureEnabled
13116 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13117 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013118
13119 // prop IE enabled in .ini file
13120 *pBuf = (tANI_U8)pMac->roam.configParam.enableOxygenNwk;
13121 pBuf++;
13122
13123 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013124 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13125 {
13126 status = eHAL_STATUS_INVALID_PARAMETER;
13127 palFreeMemory( pMac->hHdd, pMsg );
13128 break;
13129 }
13130 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
13131 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
13132 pBuf += sizeof(tANI_U16);
13133 if( wTmp )
13134 {
13135 wTmp = pParam->nRSNIELength;
13136 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13137 pBuf += wTmp;
13138 }
13139 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13140 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13141 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13143 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13145 pBuf += pParam->operationalRateSet.numRates ;
13146 *pBuf++ = pParam->extendedRateSet.numRates;
13147 if(0 != pParam->extendedRateSet.numRates)
13148 {
13149 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13150 pBuf += pParam->extendedRateSet.numRates;
13151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013152 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13153 pMsg->length = pal_cpu_to_be16(msgLen);
13154
13155 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013157 return( status );
13158}
13159
Jeff Johnson295189b2012-06-20 16:38:30 -070013160eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13161{
13162 eHalStatus status = eHAL_STATUS_FAILURE;
13163 tSirSmeStopBssReq *pMsg;
13164 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13165 tANI_U8 *pBuf;
13166 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013167
13168 if(!pSession)
13169 {
13170 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13171 return eHAL_STATUS_FAILURE;
13172 }
13173
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 do {
13175 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13176 if ( !HAL_STATUS_SUCCESS(status) ) break;
13177 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13178 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13179 pBuf = &pMsg->sessionId;
13180 //sessionId
13181 *pBuf = (tANI_U8)sessionId;
13182 pBuf++;
13183 // transactionId
13184 *pBuf = 0;
13185 pBuf += sizeof(tANI_U16);
13186 //reason code
13187 *pBuf = 0;
13188 pBuf += sizeof(tSirResultCodes);
13189 // bssid
13190 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13191 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13192 {
13193 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13194 }
13195 else
13196 {
13197 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13198 }
13199 pBuf += sizeof(tSirMacAddr);
13200 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13201 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 status = palSendMBMessage( pMac->hHdd, pMsg );
13203#if 0
13204 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13205 if ( !HAL_STATUS_SUCCESS(status) ) break;
13206 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13207 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13208 pMsg->reasonCode = 0;
13209 // bssid
13210 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13211 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13212 {
13213 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13214 }
13215 else
13216 {
13217 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13218 }
13219 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13220 pMsg->transactionId = 0;
13221 pMsg->sessionId = (tANI_U8)sessionId;
13222 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13223 status = palSendMBMessage( pMac->hHdd, pMsg );
13224#endif
13225 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 return( status );
13227}
13228
Jeff Johnson295189b2012-06-20 16:38:30 -070013229eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13230 tCsrRoamModifyProfileFields *pModProfileFields,
13231 tANI_U32 *pRoamId, v_BOOL_t fForce)
13232{
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 eHalStatus status = eHAL_STATUS_FAILURE;
13234 tANI_U32 roamId = 0;
13235 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 if((csrIsConnStateConnected(pMac, sessionId)) &&
13237 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13238 &pSession->connectedProfile.modifyProfileFields,
13239 sizeof(tCsrRoamModifyProfileFields)))) )
13240 {
13241 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13242 if(pRoamId)
13243 {
13244 *pRoamId = roamId;
13245 }
13246
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13248 eCsrSmeIssuedReassocToSameAP, roamId,
13249 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 return status;
13252}
Jeff Johnson295189b2012-06-20 16:38:30 -070013253static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13254{
13255 eHalStatus status = eHAL_STATUS_SUCCESS;
13256 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13258 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13259 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13260 return (status);
13261}
Jeff Johnson295189b2012-06-20 16:38:30 -070013262eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13263{
13264 eHalStatus status = eHAL_STATUS_SUCCESS;
13265 tListElem *pEntry = NULL;
13266 tSmeCmd *pCommand = NULL;
13267 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 do
13269 {
13270 if(pMsg == NULL)
13271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013272 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 status = eHAL_STATUS_FAILURE;
13274 break;
13275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13277 if(pEntry)
13278 {
13279 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13280 if(eSmeCommandAddStaSession == pCommand->command)
13281 {
13282 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013283 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 //Remove this command out of the active list
13287 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13288 {
13289 //Now put this command back on the avilable command list
13290 csrReleaseCommand(pMac, pCommand);
13291 }
13292 smeProcessPendingQueue( pMac );
13293 }
13294 else
13295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013296 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 -070013297 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 status = eHAL_STATUS_FAILURE;
13299 break;
13300 }
13301 }
13302 else
13303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013304 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 -070013305 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 status = eHAL_STATUS_FAILURE;
13307 break;
13308 }
13309 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013311}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013312eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13313 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013314{
13315 tSirSmeAddStaSelfReq *pMsg;
13316 tANI_U16 msgLen;
13317 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013319 msgLen = sizeof(tSirSmeAddStaSelfReq);
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13321 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13324 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 // self station address
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013326 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr,
13327 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13328
13329 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13330
13331 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 pMsg->selfMacAddr[0],
13333 pMsg->selfMacAddr[1],
13334 pMsg->selfMacAddr[2],
13335 pMsg->selfMacAddr[3],
13336 pMsg->selfMacAddr[4],
13337 pMsg->selfMacAddr[5]);
13338 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 return( status );
13341}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013342eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13343 tANI_U32 sessionId,
13344 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013345{
13346 eHalStatus status = eHAL_STATUS_SUCCESS;
13347 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 pCommand = csrGetCommandBuffer(pMac);
13349 if(NULL == pCommand)
13350 {
13351 status = eHAL_STATUS_RESOURCES;
13352 }
13353 else
13354 {
13355 pCommand->command = eSmeCommandAddStaSession;
13356 pCommand->sessionId = (tANI_U8)sessionId;
13357 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013358 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13360 if( !HAL_STATUS_SUCCESS( status ) )
13361 {
13362 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013363 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 }
13365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 return (status);
13367}
Jeff Johnson295189b2012-06-20 16:38:30 -070013368eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13369{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013370 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013371}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013372eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13373 csrRoamCompleteCallback callback,
13374 void *pContext, tANI_U8 *pSelfMacAddr,
13375 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013376{
13377 eHalStatus status = eHAL_STATUS_SUCCESS;
13378 tANI_U32 i;
13379 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 *pbSessionId = CSR_SESSION_ID_INVALID;
13381 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13382 {
13383 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13384 {
13385 pSession = CSR_GET_SESSION( pMac, i );
13386 status = eHAL_STATUS_SUCCESS;
13387 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13388 pSession->sessionId = (tANI_U8)i;
13389 pSession->callback = callback;
13390 pSession->pContext = pContext;
13391 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13392 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013393 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13394 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013396 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013398 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 break;
13400 }
13401#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013402 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13403 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013405 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013407 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 break;
13409 }
13410#endif
13411 pSession->ibssJoinTimerInfo.pMac = pMac;
13412 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013413 status = vos_timer_init(&pSession->hTimerIbssJoining, VOS_TIMER_TYPE_SW,
13414 csrRoamIbssJoinTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 &pSession->ibssJoinTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013416 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013418 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 break;
13420 }
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013421 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 break;
13423 }
13424 }
13425 if( CSR_ROAM_SESSION_MAX == i )
13426 {
13427 //No session is available
13428 status = eHAL_STATUS_RESOURCES;
13429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 return ( status );
13431}
Jeff Johnson295189b2012-06-20 16:38:30 -070013432eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13433{
13434 eHalStatus status = eHAL_STATUS_SUCCESS;
13435 tListElem *pEntry = NULL;
13436 tSmeCmd *pCommand = NULL;
13437 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 do
13439 {
13440 if(pMsg == NULL)
13441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013442 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 status = eHAL_STATUS_FAILURE;
13444 break;
13445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13447 if(pEntry)
13448 {
13449 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13450 if(eSmeCommandDelStaSession == pCommand->command)
13451 {
13452 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013454 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 //This session is done.
13456 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 if(pCommand->u.delStaSessionCmd.callback)
13458 {
13459
13460 status = sme_ReleaseGlobalLock( &pMac->sme );
13461 if ( HAL_STATUS_SUCCESS( status ) )
13462 {
13463 pCommand->u.delStaSessionCmd.callback(
13464 pCommand->u.delStaSessionCmd.pContext);
13465 status = sme_AcquireGlobalLock( &pMac->sme );
13466 if (! HAL_STATUS_SUCCESS( status ) )
13467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013468 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 return status;
13470 }
13471 }
13472 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013473 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 }
13475 }
13476
13477 //Remove this command out of the active list
13478 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13479 {
13480 //Now put this command back on the avilable command list
13481 csrReleaseCommand(pMac, pCommand);
13482 }
13483 smeProcessPendingQueue( pMac );
13484 }
13485 else
13486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013487 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 -070013488 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 status = eHAL_STATUS_FAILURE;
13490 break;
13491 }
13492 }
13493 else
13494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013495 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 -070013496 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 status = eHAL_STATUS_FAILURE;
13498 break;
13499 }
13500 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013502}
Jeff Johnson295189b2012-06-20 16:38:30 -070013503eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13504{
13505 tSirSmeDelStaSelfReq *pMsg;
13506 tANI_U16 msgLen;
13507 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013508 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13510 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13512 if ( !HAL_STATUS_SUCCESS(status) ) break;
13513
13514 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13516 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 // self station address
13518 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013519 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 return( status );
13522}
Jeff Johnson295189b2012-06-20 16:38:30 -070013523eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13524 tSirMacAddr sessionMacAddr,
13525 csrRoamSessionCloseCallback callback,
13526 void *pContext)
13527{
13528 eHalStatus status = eHAL_STATUS_SUCCESS;
13529 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 pCommand = csrGetCommandBuffer(pMac);
13531 if(NULL == pCommand)
13532 {
13533 status = eHAL_STATUS_RESOURCES;
13534 }
13535 else
13536 {
13537 pCommand->command = eSmeCommandDelStaSession;
13538 pCommand->sessionId = (tANI_U8)sessionId;
13539 pCommand->u.delStaSessionCmd.callback = callback;
13540 pCommand->u.delStaSessionCmd.pContext = pContext;
13541 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13543 if( !HAL_STATUS_SUCCESS( status ) )
13544 {
13545 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013546 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 }
13548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 return (status);
13550}
Jeff Johnson295189b2012-06-20 16:38:30 -070013551eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13552{
13553 return csrSendMBDelSelfStaReqMsg( pMac,
13554 pCommand->u.delStaSessionCmd.selfMacAddr );
13555}
Jeff Johnson295189b2012-06-20 16:38:30 -070013556static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13557{
13558 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13559 tListElem *pEntry, *pNext;
13560 tSmeCmd *pCommand;
13561 tDblLinkList localList;
13562
13563 vos_mem_zero(&localList, sizeof(tDblLinkList));
13564 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13565 {
13566 smsLog(pMac, LOGE, FL(" failed to open list"));
13567 return;
13568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 csrLLLock(pList);
13570 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13571 while(pEntry != NULL)
13572 {
13573 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13574 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13575 if(pCommand->sessionId == sessionId)
13576 {
13577 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13578 {
13579 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13580 }
13581 }
13582 pEntry = pNext;
13583 }
13584 csrLLUnlock(pList);
13585
13586 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13587 {
13588 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13589 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13590 }
13591 csrLLClose(&localList);
13592}
13593
Jeff Johnson295189b2012-06-20 16:38:30 -070013594void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13595{
13596 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13597 {
13598 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 csrRoamStop(pMac, sessionId);
13600 csrFreeConnectBssDesc(pMac, sessionId);
13601 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13602 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013603 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070013604#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013605 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013606#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013607 vos_timer_destroy(&pSession->hTimerIbssJoining);
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 purgeSmeSessionCmdList(pMac, sessionId);
13609 purgeCsrSessionCmdList(pMac, sessionId);
13610 csrInitSession(pMac, sessionId);
13611 }
13612}
13613
Jeff Johnson295189b2012-06-20 16:38:30 -070013614eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13615 tANI_BOOLEAN fSync,
13616 csrRoamSessionCloseCallback callback,
13617 void *pContext )
13618{
13619 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13621 {
13622 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13623 if(fSync)
13624 {
13625 csrCleanupSession(pMac, sessionId);
13626 }
13627 else
13628 {
13629 purgeSmeSessionCmdList(pMac, sessionId);
13630 purgeCsrSessionCmdList(pMac, sessionId);
13631 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13632 pSession->selfMacAddr, callback, pContext);
13633 }
13634 }
13635 else
13636 {
13637 status = eHAL_STATUS_INVALID_PARAMETER;
13638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 return ( status );
13640}
13641
Jeff Johnson295189b2012-06-20 16:38:30 -070013642static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13643{
13644 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013645
13646 if(!pSession)
13647 {
13648 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13649 return;
13650 }
13651
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13653 pSession->sessionId = CSR_SESSION_ID_INVALID;
13654 pSession->callback = NULL;
13655 pSession->pContext = NULL;
13656 pSession->ibss_join_pending = FALSE;
13657 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13658 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13659 csrFreeRoamProfile( pMac, sessionId );
13660 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13661 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13662 csrFreeConnectBssDesc(pMac, sessionId);
13663 csrScanEnable(pMac);
13664 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13665 if(pSession->pWpaRsnReqIE)
13666 {
13667 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13668 pSession->pWpaRsnReqIE = NULL;
13669 }
13670 pSession->nWpaRsnReqIeLength = 0;
13671 if(pSession->pWpaRsnRspIE)
13672 {
13673 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13674 pSession->pWpaRsnRspIE = NULL;
13675 }
13676 pSession->nWpaRsnRspIeLength = 0;
13677#ifdef FEATURE_WLAN_WAPI
13678 if(pSession->pWapiReqIE)
13679 {
13680 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13681 pSession->pWapiReqIE = NULL;
13682 }
13683 pSession->nWapiReqIeLength = 0;
13684 if(pSession->pWapiRspIE)
13685 {
13686 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13687 pSession->pWapiRspIE = NULL;
13688 }
13689 pSession->nWapiRspIeLength = 0;
13690#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 if(pSession->pAddIEScan)
13692 {
13693 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13694 pSession->pAddIEScan = NULL;
13695 }
13696 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 if(pSession->pAddIEAssoc)
13698 {
13699 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13700 pSession->pAddIEAssoc = NULL;
13701}
13702 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013703}
13704
Jeff Johnson295189b2012-06-20 16:38:30 -070013705eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13706{
13707 eHalStatus status = eHAL_STATUS_FAILURE;
13708 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13710 {
13711 if( CSR_IS_SESSION_VALID( pMac, i ) )
13712 {
13713 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13714 {
13715 //Found it
13716 status = eHAL_STATUS_SUCCESS;
13717 *pSessionId = i;
13718 break;
13719 }
13720 }
13721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 return( status );
13723}
13724
Jeff Johnson295189b2012-06-20 16:38:30 -070013725//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13726//session because for IBSS, the bssid changes.
13727static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13728{
13729 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13730 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13732 {
13733 if( CSR_IS_SESSION_VALID( pMac, i ) )
13734 {
13735 pSession = CSR_GET_SESSION( pMac, i );
13736 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13737 {
13738 //Found it
13739 nRet = i;
13740 break;
13741 }
13742 }
13743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 return (nRet);
13745}
Jeff Johnson295189b2012-06-20 16:38:30 -070013746static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13747{
13748 /* Update the current BSS info in ho control block based on connected
13749 profile info from pmac global structure */
13750
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013751 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13753 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 /* Check for user misconfig of RSSI trigger threshold */
13755 pMac->roam.configParam.vccRssiThreshold =
13756 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13757 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13758 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 /* Check for user misconfig of UL MAC Loss trigger threshold */
13760 pMac->roam.configParam.vccUlMacLossThreshold =
13761 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13762 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13764 {
13765 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 /* Indicate the neighbor roal algorithm about the connect indication */
13767 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13768 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13769 }
13770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013771}
13772
Jeff Johnson295189b2012-06-20 16:38:30 -070013773static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13774{
13775 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013776
13777 if(!pSession)
13778 {
13779 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13780 return;
13781 }
13782
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 //Only to handle the case for Handover on infra link
13784 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13785 {
13786 return;
13787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13789 csrRoamDeregStatisticsReq(pMac);
13790 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13791#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13792 /* Indicate the neighbor roal algorithm about the disconnect indication */
13793 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13794#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013795
13796 //Remove this code once SLM_Sessionization is supported
13797 //BMPS_WORKAROUND_NOT_NEEDED
13798 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013799 csrIsInfraApStarted( pMac ) &&
13800 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013801 {
13802 pMac->roam.configParam.doBMPSWorkaround = 0;
13803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013804}
13805
Jeff Johnson295189b2012-06-20 16:38:30 -070013806void csrRoamTlStatsTimerHandler(void *pv)
13807{
13808 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13809 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13811
Jeff Johnsone7245742012-09-05 17:12:55 -070013812 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13813
Jeff Johnson295189b2012-06-20 16:38:30 -070013814#if 0
13815 // TODO Persession .???
13816 //req TL for stats
13817 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013819 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 }
13821 else
13822 {
13823 //save in SME
13824 csrRoamSaveStatsFromTl(pMac, tlStats);
13825 }
13826#endif
13827 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13828 {
13829 if(pMac->roam.tlStatsReqInfo.periodicity)
13830 {
13831 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013832 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13833 pMac->roam.tlStatsReqInfo.periodicity);
13834 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013836 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 return;
13838 }
13839 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13840 }
13841 }
13842}
Jeff Johnson295189b2012-06-20 16:38:30 -070013843void csrRoamPeStatsTimerHandler(void *pv)
13844{
13845 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13846 eHalStatus status;
13847 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13848 VOS_STATUS vosStatus;
13849 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013850 pPeStatsReqListEntry->timerRunning = FALSE;
13851 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13852 {
13853 // If we entered here, meaning the timer could not be successfully
13854 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13855
13856 /* Destroy the timer */
13857 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13858 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13859 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013860 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 }
13862
13863 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013864 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 pPeStatsReqListEntry = NULL;
13866 }
13867 else
13868 {
13869 if(!pPeStatsReqListEntry->rspPending)
13870 {
13871 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13872 pPeStatsReqListEntry->staId);
13873 if(!HAL_STATUS_SUCCESS(status))
13874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013875 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 }
13877 else
13878 {
13879 pPeStatsReqListEntry->rspPending = TRUE;
13880 }
13881 }
13882
13883 //send down a req
13884 if(pPeStatsReqListEntry->periodicity &&
13885 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13886 {
13887 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13888 if(ePMC_FULL_POWER == powerState)
13889 {
13890 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13891 {
13892 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13893 }
13894 }
13895 else
13896 {
13897 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13898 {
13899 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13900 }
13901 }
13902 //start timer
13903 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13904 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13905 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013906 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 return;
13908 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 pPeStatsReqListEntry->timerRunning = TRUE;
13910
13911 }
13912
13913 }
13914}
Jeff Johnson295189b2012-06-20 16:38:30 -070013915void csrRoamStatsClientTimerHandler(void *pv)
13916{
13917 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13919 {
13920#if 0
13921 // TODO Stats fix for multisession
13922 //start the timer
13923 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13924
13925 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013927 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 }
13929#endif
13930 }
13931#if 0
13932 //send up the stats report
13933 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13934 pStaEntry->staId, pStaEntry->pContext);
13935#endif
13936}
13937
13938
13939
Jeff Johnson295189b2012-06-20 16:38:30 -070013940eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13941{
13942 tAniGetPEStatsReq *pMsg;
13943 eHalStatus status = eHAL_STATUS_SUCCESS;
13944 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13945 if ( !HAL_STATUS_SUCCESS(status) )
13946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013947 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 return status;
13949 }
13950 // need to initiate a stats request to PE
13951 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13952 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13953 pMsg->staId = staId;
13954 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 if(!HAL_STATUS_SUCCESS(status))
13957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013958 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 return status;
13961}
Jeff Johnson295189b2012-06-20 16:38:30 -070013962void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13963{
13964 tAniGetPEStatsRsp *pSmeStatsRsp;
13965 eHalStatus status = eHAL_STATUS_FAILURE;
13966 tListElem *pEntry = NULL;
13967 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13968 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13969 tANI_U32 tempMask = 0;
13970 tANI_U8 counter = 0;
13971 tANI_U8 *pStats = NULL;
13972 tANI_U32 length = 0;
13973 v_PVOID_t pvosGCtx;
13974 v_S7_t rssi = 0;
13975 tANI_U32 *pRssi = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013976 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13978 if(pSmeStatsRsp->rc)
13979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013980 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 goto post_update;
13982 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 tempMask = pSmeStatsRsp->statsMask;
13984 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 /* subtract all statistics from this length, and after processing the entire
13986 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13987 * in this 'stats' message.
13988 */
13989 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 //new stats info from PE, fill up the stats strucutres in PMAC
13991 while(tempMask)
13992 {
13993 if(tempMask & 1)
13994 {
13995 switch(counter)
13996 {
13997 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013998 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14000 pStats, sizeof(tCsrSummaryStatsInfo));
14001 if(!HAL_STATUS_SUCCESS(status))
14002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014003 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 }
14005 pStats += sizeof(tCsrSummaryStatsInfo);
14006 length -= sizeof(tCsrSummaryStatsInfo);
14007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014009 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14011 pStats, sizeof(tCsrGlobalClassAStatsInfo));
14012 if(!HAL_STATUS_SUCCESS(status))
14013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014014 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 }
14016 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14017 length -= sizeof(tCsrGlobalClassAStatsInfo);
14018 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014020 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14022 pStats, sizeof(tCsrGlobalClassBStatsInfo));
14023 if(!HAL_STATUS_SUCCESS(status))
14024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014025 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 }
14027 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14028 length -= sizeof(tCsrGlobalClassBStatsInfo);
14029 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014031 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14033 pStats, sizeof(tCsrGlobalClassCStatsInfo));
14034 if(!HAL_STATUS_SUCCESS(status))
14035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014036 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 }
14038 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14039 length -= sizeof(tCsrGlobalClassCStatsInfo);
14040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014042 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14044 {
14045 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14046 pStats, sizeof(tCsrPerStaStatsInfo));
14047 }
14048 else
14049 {
14050 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014051 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 VOS_ASSERT( 0 );
14053 }
14054 if(!HAL_STATUS_SUCCESS(status))
14055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014056 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014057 }
14058 pStats += sizeof(tCsrPerStaStatsInfo);
14059 length -= sizeof(tCsrPerStaStatsInfo);
14060 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014062 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 }
14065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 tempMask >>=1;
14067 counter++;
14068 }
14069 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14070 if (length != 0)
14071 {
14072 pRssi = (tANI_U32*)pStats;
14073 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014074 pStats += sizeof(tANI_U32);
14075 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 }
14077 else
14078 {
14079 /* If riva is not sending rssi, continue to use the hack */
14080 rssi = RSSI_HACK_BMPS;
14081 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014082
Jeff Johnson295189b2012-06-20 16:38:30 -070014083 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014084
14085 if (length != 0)
14086 {
14087 linkCapacity = *(tANI_U32*)pStats;
14088 }
14089 else
14090 {
14091 linkCapacity = 0;
14092 }
14093
14094 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014095post_update:
14096 //make sure to update the pe stats req list
14097 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14098 if(pEntry)
14099 {
14100 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14101 pPeStaEntry->rspPending = FALSE;
14102
14103 }
14104 //check the one timer cases
14105 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14106 if(pEntry)
14107 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 if(pTempStaEntry->timerExpired)
14110 {
14111 //send up the stats report
14112 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14113 pTempStaEntry->staId, pTempStaEntry->pContext);
14114 //also remove from the client list
14115 csrRoamRemoveStatListEntry(pMac, pEntry);
14116 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 }
14118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014119}
Jeff Johnson295189b2012-06-20 16:38:30 -070014120tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14121{
14122 tListElem *pEntry = NULL;
14123 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 if(!pEntry)
14126 {
14127 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014128 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 return NULL;
14130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 while( pEntry )
14132 {
14133 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 if(pTempStaEntry->statsMask == statsMask)
14135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014136 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 break;
14138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014139 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014141 return pEntry;
14142}
14143
Jeff Johnson295189b2012-06-20 16:38:30 -070014144tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14145 tANI_BOOLEAN update)
14146{
14147 tListElem *pEntry;
14148 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014149 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 if(!pEntry)
14151 {
14152 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014153 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014154 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 return NULL;
14156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014157 while( pEntry )
14158 {
14159 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14161 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014163 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 if(update)
14165 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014166 pTempStaEntry->periodicity = pStaEntry->periodicity;
14167 pTempStaEntry->callback = pStaEntry->callback;
14168 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 }
14170 break;
14171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 return pEntry;
14175}
Jeff Johnson295189b2012-06-20 16:38:30 -070014176tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14177{
14178 tListElem *pEntry;
14179 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 if(!pEntry)
14182 {
14183 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014184 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014185 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 return NULL;
14187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 while( pEntry )
14189 {
14190 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014193 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 break;
14195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014198 return pEntry;
14199}
Jeff Johnson295189b2012-06-20 16:38:30 -070014200eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14201 csrRoamLinkQualityIndCallback callback,
14202 void *pContext)
14203{
14204 pMac->roam.linkQualityIndInfo.callback = callback;
14205 pMac->roam.linkQualityIndInfo.context = pContext;
14206 if( NULL == callback )
14207 {
14208 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14209 }
14210 else
14211 {
14212 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014213 /* do we need to invoke the callback to notify client of initial value ?? */
14214 }
14215 return eHAL_STATUS_SUCCESS;
14216}
Jeff Johnson295189b2012-06-20 16:38:30 -070014217void csrRoamVccTrigger(tpAniSirGlobal pMac)
14218{
14219 eCsrRoamLinkQualityInd newVccLinkQuality;
14220 tANI_U32 ul_mac_loss = 0;
14221 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14223 /*-------------------------------------------------------------------------
14224 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 Check for a change in link quality and notify client if necessary
14226 -------------------------------------------------------------------------*/
14227 ul_mac_loss_trigger_threshold =
14228 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014230 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014234 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14236 }
14237 else
14238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014239 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014240 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14243 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14245 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014246 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014249 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 newVccLinkQuality );
14251
14252 /* we now invoke the callback once to notify client of initial value */
14253 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14254 pMac->roam.linkQualityIndInfo.context );
14255 //event: EVENT_WLAN_VCC
14256 }
14257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 pMac->roam.vccLinkQuality = newVccLinkQuality;
14259
Jeff Johnson295189b2012-06-20 16:38:30 -070014260}
Jeff Johnson295189b2012-06-20 16:38:30 -070014261VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14262 v_U8_t rssiNotification,
14263 void * context)
14264{
14265 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14266 eCsrRoamLinkQualityInd newVccLinkQuality;
14267 // TODO : Session info unavailable
14268 tANI_U32 sessionId = 0;
14269 VOS_STATUS status = VOS_STATUS_SUCCESS;
14270 /*-------------------------------------------------------------------------
14271 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 Check for a change in link quality and notify client if necessary
14273 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014274 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014275 pMac->roam.configParam.vccRssiThreshold);
14276 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014278 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014279 return VOS_STATUS_SUCCESS;
14280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014283 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14285 }
14286 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014288 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14290 }
14291 else
14292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014293 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 //Set to this so the code below won't do anything
14295 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 VOS_ASSERT(0);
14297 }
14298
Jeff Johnson295189b2012-06-20 16:38:30 -070014299 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014301 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014304 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014305 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 /* we now invoke the callback once to notify client of initial value */
14307 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14308 pMac->roam.linkQualityIndInfo.context );
14309 //event: EVENT_WLAN_VCC
14310 }
14311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014312 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 return status;
14314}
Jeff Johnson295189b2012-06-20 16:38:30 -070014315tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14316 tDblLinkList *pStaList,
14317 tCsrStatsClientReqInfo *pStaEntry)
14318{
14319 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014321 //if same entity requested for same set of stats with different periodicity &
14322 // callback update it
14323 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14324 {
14325
14326 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14327 if (!HAL_STATUS_SUCCESS(status))
14328 {
14329 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014330 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 return NULL;
14332 }
14333
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 pNewStaEntry->callback = pStaEntry->callback;
14335 pNewStaEntry->pContext = pStaEntry->pContext;
14336 pNewStaEntry->periodicity = pStaEntry->periodicity;
14337 pNewStaEntry->requesterId = pStaEntry->requesterId;
14338 pNewStaEntry->statsMask = pStaEntry->statsMask;
14339 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14340 pNewStaEntry->pMac = pStaEntry->pMac;
14341 pNewStaEntry->staId = pStaEntry->staId;
14342 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14343
14344 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14345 }
14346 return pNewStaEntry;
14347}
14348
Jeff Johnson295189b2012-06-20 16:38:30 -070014349tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14350 tDblLinkList *pStaList,
14351 tCsrPeStatsReqInfo *pStaEntry)
14352{
14353 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014354 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14356 if (!HAL_STATUS_SUCCESS(status))
14357 {
14358 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014359 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 return NULL;
14361 }
14362
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14364 pNewStaEntry->numClient = pStaEntry->numClient;
14365 pNewStaEntry->periodicity = pStaEntry->periodicity;
14366 pNewStaEntry->statsMask = pStaEntry->statsMask;
14367 pNewStaEntry->pMac = pStaEntry->pMac;
14368 pNewStaEntry->staId = pStaEntry->staId;
14369 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14370 pNewStaEntry->rspPending = pStaEntry->rspPending;
14371
14372 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 return pNewStaEntry;
14374}
Jeff Johnson295189b2012-06-20 16:38:30 -070014375eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14376 tCsrRssiCallback callback,
14377 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14378{
14379 eHalStatus status = eHAL_STATUS_SUCCESS;
14380 vos_msg_t msg;
14381 tANI_U32 sessionId;
14382
14383 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014384 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014385 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14386 if ( !HAL_STATUS_SUCCESS(status) )
14387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014388 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014389 return status;
14390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014391 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14392
14393 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14394 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14395 pMsg->sessionId = sessionId;
14396 pMsg->staId = staId;
14397 pMsg->rssiCallback = callback;
14398 pMsg->pDevContext = pContext;
14399 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 msg.type = eWNI_SME_GET_RSSI_REQ;
14401 msg.bodyptr = pMsg;
14402 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014405 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014406 palFreeMemory(pMac->hHdd, (void *)pMsg);
14407 status = eHAL_STATUS_FAILURE;
14408 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014409 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 return status;
14411}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014412
14413#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14414eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14415 tCsrRssiCallback callback,
14416 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14417{
14418 eHalStatus status = eHAL_STATUS_SUCCESS;
14419 tAniGetRssiReq *pMsg;
14420
14421 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14422 if ( !HAL_STATUS_SUCCESS(status) )
14423 {
14424 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14425 return status;
14426 }
14427 // need to initiate a stats request to PE
14428 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14429 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14430 pMsg->staId = staId;
14431 pMsg->rssiCallback = callback;
14432 pMsg->pDevContext = pContext;
14433 pMsg->pVosContext = pVosContext;
14434 status = palSendMBMessage(pMac->hHdd, pMsg );
14435 if(!HAL_STATUS_SUCCESS(status))
14436 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014437 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14438 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014439 status = eHAL_STATUS_FAILURE;
14440 }
14441 return status;
14442}
14443#endif
14444
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053014445/* ---------------------------------------------------------------------------
14446 \fn csrGetTLSTAState
14447 \helper function to get teh TL STA State whenever the function is called.
14448
14449 \param staId - The staID to be passed to the TL
14450 to get the relevant TL STA State
14451 \return the state as tANI_U16
14452 ---------------------------------------------------------------------------*/
14453tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
14454{
14455 WLANTL_STAStateType tlSTAState;
14456 tlSTAState = WLANTL_STA_INIT;
14457
14458 //request TL for STA State
14459 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
14460 {
14461 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
14462 }
14463
14464 return tlSTAState;
14465}
14466
Jeff Johnson295189b2012-06-20 16:38:30 -070014467eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14468 tANI_U32 statsMask,
14469 tCsrStatsCallback callback,
14470 tANI_U32 periodicity, tANI_BOOLEAN cache,
14471 tANI_U8 staId, void *pContext)
14472{
14473 tCsrStatsClientReqInfo staEntry;
14474 tCsrStatsClientReqInfo *pStaEntry = NULL;
14475 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14476 tListElem *pEntry = NULL;
14477 tANI_BOOLEAN found = FALSE;
14478 eHalStatus status = eHAL_STATUS_SUCCESS;
14479 tANI_BOOLEAN insertInClientList = FALSE;
14480 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014481 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014482
14483 if( csrIsAllSessionDisconnected(pMac) )
14484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014485 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 return eHAL_STATUS_FAILURE;
14487 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 if((!statsMask) && (!callback))
14489 {
14490 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014491 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 return eHAL_STATUS_FAILURE;
14493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 //for the search list method for deregister
14495 staEntry.requesterId = requesterId;
14496 staEntry.statsMask = statsMask;
14497 //requester wants to deregister or just an error
14498 if((statsMask) && (!callback))
14499 {
14500 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14501 if(!pEntry)
14502 {
14503 //msg
14504 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014505 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 return eHAL_STATUS_FAILURE;
14507 }
14508 else
14509 {
14510 //clean up & return
14511 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014512 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014514 pStaEntry->pPeStaEntry->numClient--;
14515 //check if we need to delete the entry from peStatsReqList too
14516 if(!pStaEntry->pPeStaEntry->numClient)
14517 {
14518 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014521
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 //check if we need to stop the tl stats timer too
14523 pMac->roam.tlStatsReqInfo.numClient--;
14524 if(!pMac->roam.tlStatsReqInfo.numClient)
14525 {
14526 if(pMac->roam.tlStatsReqInfo.timerRunning)
14527 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014528 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14529 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014531 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 return eHAL_STATUS_FAILURE;
14533 }
14534 }
14535 pMac->roam.tlStatsReqInfo.periodicity = 0;
14536 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14537 }
14538 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 // Destroy the vos timer...
14540 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14541 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014543 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 csrRoamRemoveStatListEntry(pMac, pEntry);
14546 pStaEntry = NULL;
14547 return eHAL_STATUS_SUCCESS;
14548 }
14549 }
14550
14551 if(cache && !periodicity)
14552 {
14553 //return the cached stats
14554 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14555 }
14556 else
14557 {
14558 //add the request in the client req list
14559 staEntry.callback = callback;
14560 staEntry.pContext = pContext;
14561 staEntry.periodicity = periodicity;
14562 staEntry.pPeStaEntry = NULL;
14563 staEntry.staId = staId;
14564 staEntry.pMac = pMac;
14565 staEntry.timerExpired = FALSE;
14566
14567
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 //if periodic report requested with non cached result from PE/TL
14569 if(periodicity)
14570 {
14571
14572 //if looking for stats from PE
14573 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14574 {
14575
14576 //check if same request made already & waiting for rsp
14577 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14578 periodicity, &found, staId);
14579 if(!pPeStaEntry)
14580 {
14581 //bail out, maxed out on number of req for PE
14582 return eHAL_STATUS_FAILURE;
14583 }
14584 else
14585 {
14586 staEntry.pPeStaEntry = pPeStaEntry;
14587 }
14588
14589 }
14590 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14591 if(statsMask & (1 << eCsrGlobalClassDStats))
14592 {
14593 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014595 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 }
14597 else
14598 {
14599
14600 //update periodicity
14601 if(pMac->roam.tlStatsReqInfo.periodicity)
14602 {
14603 pMac->roam.tlStatsReqInfo.periodicity =
14604 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14605 }
14606 else
14607 {
14608 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14609 }
14610 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14611 {
14612 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14613 }
14614
14615 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14616 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014617 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14618 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014619 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014620 //req TL for class D stats
14621 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014623 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014624 }
14625 else
14626 {
14627 //save in SME
14628 csrRoamSaveStatsFromTl(pMac, pTlStats);
14629 }
14630 vos_mem_free(pTlStats);
14631 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 }
14633 else
14634 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014635 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014637
Jeff Johnson295189b2012-06-20 16:38:30 -070014638 if(pMac->roam.tlStatsReqInfo.periodicity)
14639 {
14640 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014641 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14642 pMac->roam.tlStatsReqInfo.periodicity);
14643 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014645 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014646 return eHAL_STATUS_FAILURE;
14647 }
14648 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14649 }
14650 }
14651 }
14652 pMac->roam.tlStatsReqInfo.numClient++;
14653 }
14654
14655 insertInClientList = TRUE;
14656 }
14657 //if one time report requested with non cached result from PE/TL
14658 else if(!cache && !periodicity)
14659 {
14660 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14661 {
14662 //send down a req
14663 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14664 if(!HAL_STATUS_SUCCESS(status))
14665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014666 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014667 }
14668 //so that when the stats rsp comes back from PE we respond to upper layer
14669 //right away
14670 staEntry.timerExpired = TRUE;
14671 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014672 }
14673 if(statsMask & (1 << eCsrGlobalClassDStats))
14674 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014675 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14676 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014677 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014678 //req TL for class D stats
14679 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14680 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014681 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014682 }
14683 else
14684 {
14685 //save in SME
14686 csrRoamSaveStatsFromTl(pMac, pTlStats);
14687 }
14688 vos_mem_free(pTlStats);
14689 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014690 }
14691 else
14692 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014693 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014695
14696 }
14697 //if looking for stats from TL only
14698 if(!insertInClientList)
14699 {
14700 //return the stats
14701 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014704 if(insertInClientList)
14705 {
14706 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14707 if(!pStaEntry)
14708 {
14709 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014710 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 return eHAL_STATUS_FAILURE;
14712 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014713 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 //Init & start timer if needed
14715 if(periodicity)
14716 {
14717 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14718 csrRoamStatsClientTimerHandler, pStaEntry );
14719 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014721 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 return eHAL_STATUS_FAILURE;
14723 }
14724 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14725 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014727 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 return eHAL_STATUS_FAILURE;
14729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 }
14733 return eHAL_STATUS_SUCCESS;
14734}
14735
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014736#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14737
14738static tSirRetStatus
14739csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14740 tANI_U8* pBD,
14741 tANI_U8 type,
14742 tANI_U8 subType,
14743 tSirMacAddr peerAddr,
14744 tSirMacAddr selfMacAddr)
14745{
14746 tSirRetStatus statusCode = eSIR_SUCCESS;
14747 tpSirMacMgmtHdr pMacHdr;
14748
14749 /* Prepare MAC management header */
14750 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14751
14752 /* Prepare FC */
14753 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14754 pMacHdr->fc.type = type;
14755 pMacHdr->fc.subType = subType;
14756
14757 /* Prepare Address 1 */
14758 palCopyMemory( pMac->hHdd,
14759 (tANI_U8 *) pMacHdr->da,
14760 (tANI_U8 *) peerAddr,
14761 sizeof( tSirMacAddr ));
14762
14763 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14764
14765 /* Prepare Address 3 */
14766 palCopyMemory( pMac->hHdd,
14767 (tANI_U8 *) pMacHdr->bssId,
14768 (tANI_U8 *) peerAddr,
14769 sizeof( tSirMacAddr ));
14770 return statusCode;
14771} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14772
14773static tSirRetStatus
14774csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14775 tANI_U8 nChannelNum,
14776 tANI_U32 dot11mode,
14777 tSirMacAddr selfMacAddr,
14778 tANI_U8 *pFrame,
14779 tANI_U16 *pusLen)
14780{
14781 tDot11fProbeRequest pr;
14782 tANI_U32 nStatus, nBytes, nPayload;
14783 tSirRetStatus nSirStatus;
14784 /*Bcast tx*/
14785 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14786 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14787
14788
14789 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14790
14791 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14792
14793 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14794 {
14795 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14796 }
14797
14798
14799 if (IS_DOT11_MODE_HT(dot11mode))
14800 {
14801 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14802 }
14803
14804
14805 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14806 if ( DOT11F_FAILED( nStatus ) )
14807 {
14808 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14809 "Failed to calculate the packed size f"
14810 "or a Probe Request (0x%08x).\n", nStatus );
14811
14812
14813 nPayload = sizeof( tDot11fProbeRequest );
14814 }
14815 else if ( DOT11F_WARNED( nStatus ) )
14816 {
14817 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14818 "There were warnings while calculating"
14819 "the packed size for a Probe Request ("
14820 "0x%08x).\n", nStatus );
14821 }
14822
14823 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14824
14825 /* Prepare outgoing frame*/
14826 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14827
14828
14829 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014830 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014831
14832 if ( eSIR_SUCCESS != nSirStatus )
14833 {
14834 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14835 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14836 nSirStatus );
14837 return nSirStatus;
14838 }
14839
14840
14841 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14842 sizeof( tSirMacMgmtHdr ),
14843 nPayload, &nPayload );
14844 if ( DOT11F_FAILED( nStatus ) )
14845 {
14846 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14847 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14848 return eSIR_FAILURE;
14849 }
14850 else if ( DOT11F_WARNED( nStatus ) )
14851 {
14852 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14853 "There were warnings while packing a Probe Request (0x%08x).\n" );
14854 }
14855
14856 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14857 return eSIR_SUCCESS;
14858}
14859
14860eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14861{
14862 vos_msg_t msg;
14863 tSirRoamOffloadScanReq *pRequestBuf;
14864 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14865 tCsrRoamSession *pSession;
14866 tANI_U8 i,num_channels = 0, ucDot11Mode;
14867 tANI_U8 *ChannelList = NULL;
14868 tANI_U32 sessionId;
14869 eHalStatus status = eHAL_STATUS_SUCCESS;
14870 tpCsrChannelInfo currChannelListInfo;
14871 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14872
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070014873 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014874 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014875 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set \n");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014876 return eHAL_STATUS_FAILURE;
14877 }
14878 status = csrRoamGetSessionIdFromBSSID(pMac,
14879 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14880 &sessionId);
14881 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14882 * It is important to ensure that the command is passed down to the FW only
14883 * if the Infra Station is in a connected state.A connected station could also be
14884 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14885 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14886 * irrespective of whichever state we are in.*/
14887 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14888 (command != ROAM_SCAN_OFFLOAD_STOP))
14889 {
14890 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14891 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14892 return eHAL_STATUS_FAILURE;
14893 }
14894
14895 if ( !HAL_STATUS_SUCCESS( status ) )
14896 {
14897 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14898 return eHAL_STATUS_FAILURE;
14899 }
14900 pSession = CSR_GET_SESSION( pMac, sessionId );
14901 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14902 if (NULL == pRequestBuf)
14903 {
14904 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14905 return eHAL_STATUS_FAILED_ALLOC;
14906 }
14907
14908 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14909 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14910 * host driver reloads, but Riva still up and running*/
14911 if(command == ROAM_SCAN_OFFLOAD_STOP)
14912 pRequestBuf->RoamScanOffloadEnabled = 0;
14913 else
14914 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14915 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14916 sizeof(tCsrBssid));
14917 pRequestBuf->ConnectedNetwork.ssId.length =
14918 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14919 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14920 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14921 pRequestBuf->ConnectedNetwork.ssId.length);
14922 pRequestBuf->ConnectedNetwork.authentication =
14923 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14924 pRequestBuf->ConnectedNetwork.encryption =
14925 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14926 pRequestBuf->ConnectedNetwork.mcencryption =
14927 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14928 pRequestBuf->LookupThreshold =
14929 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14930 pRequestBuf->RoamRssiDiff =
14931 pMac->roam.configParam.RoamRssiDiff;
14932 pRequestBuf->Command = command;
14933 pRequestBuf->StartScanReason = reason;
14934 pRequestBuf->NeighborScanTimerPeriod =
14935 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14936 pRequestBuf->NeighborRoamScanRefreshPeriod =
14937 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14938 pRequestBuf->NeighborScanChannelMinTime =
14939 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14940 pRequestBuf->NeighborScanChannelMaxTime =
14941 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14942 pRequestBuf->EmptyRefreshScanPeriod =
14943 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14944#ifdef FEATURE_WLAN_CCX
14945 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14946#endif
14947 if (
14948#ifdef FEATURE_WLAN_CCX
14949 ((pNeighborRoamInfo->isCCXAssoc) &&
14950 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14951 eANI_BOOLEAN_FALSE)) ||
14952 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14953#endif // CCX
14954 currChannelListInfo->numOfChannels == 0)
14955 {
14956
14957 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14958 * Give Preference to INI Channels.*/
14959 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14960 {
14961 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14962 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14963 {
14964 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14965 {
14966 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14967 }
14968 ChannelList++;
14969 }
14970 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14971 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14972 }
14973 else{
14974 ChannelList = pMac->scan.occupiedChannels.channelList;
14975 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14976 {
14977 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14978 {
14979 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14980 }
14981 ChannelList++;
14982 }
14983 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14984 /* If the profile changes as to what it was earlier, inform the FW through
14985 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14986 * for the earlier profile and try to learn them afresh.*/
14987 if (reason == REASON_FLUSH_CHANNEL_LIST)
14988 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14989 else {
14990 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14991 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14992 else
14993 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14994 }
14995 }
14996 }
14997#ifdef FEATURE_WLAN_CCX
14998 else
14999 {
15000 /* If CCX is enabled, and a neighbor Report is received,then
15001 * Ignore the INI Channels or the Occupied Channel List. Consider
15002 * the channels in the neighbor list sent by the CCX AP.*/
15003 if (currChannelListInfo->numOfChannels != 0)
15004 {
15005 ChannelList = currChannelListInfo->ChannelList;
15006 for (i=0;i<currChannelListInfo->numOfChannels;i++)
15007 {
15008 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15009 {
15010 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15011 }
15012 ChannelList++;
15013 }
15014 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15015 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15016 }
15017 }
15018#endif
15019 num_channels = 0;
15020 ChannelList = NULL;
15021
15022 /* Maintain the Valid Channels List*/
15023 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
15024 {
15025 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
15026 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
15027 {
15028 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15029 {
15030 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15031 }
15032 ChannelList++;
15033 }
15034 pRequestBuf->ValidChannelCount = num_channels;
15035 } else {
Bansidhar Gopalachari898908b2013-07-29 19:38:23 -070015036 tANI_U32 host_channels = sizeof(pMac->roam.validChannelList);
15037 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
15038 {
15039 ChannelList = pMac->roam.validChannelList;
15040 pMac->roam.numValidChannels = host_channels;
15041 }
15042 else
15043 {
15044 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15045 "%s:Failed to get the valid channel list", __func__);
15046 return eHAL_STATUS_FAILURE;
15047 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015048 for(i=0; i<pMac->roam.numValidChannels; i++)
15049 {
15050 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15051 {
15052 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15053 }
15054 ChannelList++;
15055 }
15056 pRequestBuf->ValidChannelCount = num_channels;
15057 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015058 pRequestBuf->MDID.mdiePresent =
15059 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15060 pRequestBuf->MDID.mobilityDomain =
15061 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015062 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15063
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015064 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015065
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015066 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15067 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15068 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15069 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15070 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15071
15072 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15073 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015074 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015075 msg.reserved = 0;
15076 msg.bodyptr = pRequestBuf;
15077 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15078 {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015079 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 -070015080 vos_mem_free(pRequestBuf);
15081 return eHAL_STATUS_FAILURE;
15082 }
15083
15084 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15085 return status;
15086}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015087
15088eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15089{
15090 switch(reason)
15091 {
15092 case 0:
15093 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15094 break;
15095 case REASON_OS_REQUESTED_ROAMING_NOW:
15096 csrNeighborRoamProceedWithHandoffReq(pMac);
15097 break;
15098 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015099 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 -070015100 }
15101 return eHAL_STATUS_SUCCESS;
15102}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015103#endif
15104
Jeff Johnson295189b2012-06-20 16:38:30 -070015105tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15106 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15107{
15108 tANI_BOOLEAN found = FALSE;
15109 eHalStatus status = eHAL_STATUS_SUCCESS;
15110 tCsrPeStatsReqInfo staEntry;
15111 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15112 tListElem *pStaEntry = NULL;
15113 VOS_STATUS vosStatus;
15114 tPmcPowerState powerState;
15115 *pFound = FALSE;
15116
15117 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15118 if(pStaEntry)
15119 {
15120 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15121 if(pTempStaEntry->periodicity)
15122 {
15123 pTempStaEntry->periodicity =
15124 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15125 }
15126 else
15127 {
15128 pTempStaEntry->periodicity = periodicity;
15129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 pTempStaEntry->numClient++;
15131 found = TRUE;
15132 }
15133 else
15134 {
15135 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
15136 staEntry.numClient = 1;
15137 staEntry.periodicity = periodicity;
15138 staEntry.pMac = pMac;
15139 staEntry.rspPending = FALSE;
15140 staEntry.staId = staId;
15141 staEntry.statsMask = statsMask;
15142 staEntry.timerRunning = FALSE;
15143 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15144 if(!pTempStaEntry)
15145 {
15146 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015147 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 return NULL;
15149 }
15150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15152 if(ePMC_FULL_POWER == powerState)
15153 {
15154 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15155 {
15156 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15157 }
15158 }
15159 else
15160 {
15161 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15162 {
15163 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15164 }
15165 }
15166 if(!pTempStaEntry->timerRunning)
15167 {
15168 //send down a req in case of one time req, for periodic ones wait for timer to expire
15169 if(!pTempStaEntry->rspPending &&
15170 !pTempStaEntry->periodicity)
15171 {
15172 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15173 if(!HAL_STATUS_SUCCESS(status))
15174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 }
15177 else
15178 {
15179 pTempStaEntry->rspPending = TRUE;
15180 }
15181 }
15182 if(pTempStaEntry->periodicity)
15183 {
15184 if(!found)
15185 {
15186
15187 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15188 csrRoamPeStatsTimerHandler, pTempStaEntry );
15189 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15190 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015191 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 return NULL;
15193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 }
15195 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015196 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15198 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015200 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 return NULL;
15202 }
15203 pTempStaEntry->timerRunning = TRUE;
15204 }
15205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 *pFound = found;
15207 return pTempStaEntry;
15208}
15209
Jeff Johnson295189b2012-06-20 16:38:30 -070015210/*
15211 pStaEntry is no longer invalid upon the return of this function.
15212*/
15213static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15214{
15215 if(pEntry)
15216 {
15217 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15218 {
15219 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015221 }
15222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015223
15224void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15225{
15226 tListElem *pEntry;
15227 tCsrPeStatsReqInfo *pTempStaEntry;
15228 VOS_STATUS vosStatus;
15229 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015230 if(!pEntry)
15231 {
15232 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015233 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 return;
15235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 while( pEntry )
15237 {
15238 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015239 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015241 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 if(pTempStaEntry->timerRunning)
15243 {
15244 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15245 /* If we are not able to stop the timer here, just remove
15246 * the entry from the linked list. Destroy the timer object
15247 * and free the memory in the timer CB
15248 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015249 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 {
15251 /* the timer is successfully stopped */
15252 pTempStaEntry->timerRunning = FALSE;
15253
15254 /* Destroy the timer */
15255 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15256 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015258 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015259 }
15260 }
15261 else
15262 {
15263 // the timer could not be stopped. Hence destroy and free the
15264 // memory for the PE stat entry in the timer CB.
15265 pTempStaEntry->timerStopFailed = TRUE;
15266 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015268
15269 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15270 {
15271 // Only free the memory if we could stop the timer successfully
15272 if(!pTempStaEntry->timerStopFailed)
15273 {
15274 palFreeMemory(pMac->hHdd, pTempStaEntry);
15275 pTempStaEntry = NULL;
15276 }
15277 break;
15278 }
15279
15280 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15281 }
15282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 return;
15284}
15285
15286
Jeff Johnsone7245742012-09-05 17:12:55 -070015287void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015288{
15289
Jeff Johnsone7245742012-09-05 17:12:55 -070015290 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15291 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15292 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15293 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15294 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15295 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15296 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015298 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15299 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15300 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15301 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15302 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15303 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015304 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015305 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15306 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015307
15308}
15309
Jeff Johnson295189b2012-06-20 16:38:30 -070015310void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15311 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15312{
15313 tANI_U8 stats[500];
15314 tANI_U8 *pStats = NULL;
15315 tANI_U32 tempMask = 0;
15316 tANI_U8 counter = 0;
15317 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 if(!callback)
15319 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015320 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 return;
15322 }
15323 if(!statsMask)
15324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015325 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015326 return;
15327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015329 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 while(tempMask)
15331 {
15332 if(tempMask & 1)
15333 {
15334 //new stats info from PE, fill up the stats strucutres in PMAC
15335 switch(counter)
15336 {
15337 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015338 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15340 sizeof(tCsrSummaryStatsInfo));
15341 if(!HAL_STATUS_SUCCESS(status))
15342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015343 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 }
15345 pStats += sizeof(tCsrSummaryStatsInfo);
15346 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015348 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15350 sizeof(tCsrGlobalClassAStatsInfo));
15351 if(!HAL_STATUS_SUCCESS(status))
15352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015353 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 }
15355 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015358 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15360 sizeof(tCsrGlobalClassBStatsInfo));
15361 if(!HAL_STATUS_SUCCESS(status))
15362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015363 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 }
15365 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015368 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015369 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15370 sizeof(tCsrGlobalClassCStatsInfo));
15371 if(!HAL_STATUS_SUCCESS(status))
15372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015373 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015374 }
15375 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015378 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15380 sizeof(tCsrGlobalClassDStatsInfo));
15381 if(!HAL_STATUS_SUCCESS(status))
15382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015383 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015384 }
15385 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015387 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015388 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15390 sizeof(tCsrPerStaStatsInfo));
15391 if(!HAL_STATUS_SUCCESS(status))
15392 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015393 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015394 }
15395 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015398 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 }
15401 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015402 tempMask >>=1;
15403 counter++;
15404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015406}
15407
Jeff Johnson295189b2012-06-20 16:38:30 -070015408eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15409{
15410 tListElem *pEntry = NULL;
15411 tListElem *pPrevEntry = NULL;
15412 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15413 eHalStatus status = eHAL_STATUS_SUCCESS;
15414 VOS_STATUS vosStatus;
15415 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015416 if(!pEntry)
15417 {
15418 //list empty
15419 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015420 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 return status;
15422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 while( pEntry )
15424 {
15425 if(pPrevEntry)
15426 {
15427 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15428 //send up the stats report
15429 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15430 pTempStaEntry->staId, pTempStaEntry->pContext);
15431 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015434 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15435 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015436 pTempStaEntry->pPeStaEntry->numClient--;
15437 //check if we need to delete the entry from peStatsReqList too
15438 if(!pTempStaEntry->pPeStaEntry->numClient)
15439 {
15440 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 //check if we need to stop the tl stats timer too
15444 pMac->roam.tlStatsReqInfo.numClient--;
15445 if(!pMac->roam.tlStatsReqInfo.numClient)
15446 {
15447 if(pMac->roam.tlStatsReqInfo.timerRunning)
15448 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015449 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15450 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015452 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 //we will continue
15454 }
15455 }
15456 pMac->roam.tlStatsReqInfo.periodicity = 0;
15457 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 if (pTempStaEntry->periodicity)
15460 {
15461 //While creating StaEntry in csrGetStatistics,
15462 //Initializing and starting timer only when periodicity is set.
15463 //So Stop and Destroy timer only when periodicity is set.
15464
Jeff Johnsone7245742012-09-05 17:12:55 -070015465 vos_timer_stop( &pTempStaEntry->timer );
15466 // Destroy the vos timer...
15467 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15468 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015470 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015473
Jeff Johnson295189b2012-06-20 16:38:30 -070015474
15475 pPrevEntry = pEntry;
15476 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15477 }
15478 //the last one
15479 if(pPrevEntry)
15480 {
15481 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15482 //send up the stats report
15483 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15484 pTempStaEntry->staId, pTempStaEntry->pContext);
15485 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 return status;
15488
15489}
15490
Jeff Johnson295189b2012-06-20 16:38:30 -070015491eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15492 tRequestFullPowerReason *pReason,
15493 tANI_BOOLEAN *pfNeedPower )
15494{
15495 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15496 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15497 tPmcState pmcState;
15498 eHalStatus status = eHAL_STATUS_SUCCESS;
15499 // TODO : Session info unavailable
15500 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 if( pfNeedPower )
15502 {
15503 *pfNeedPower = eANI_BOOLEAN_FALSE;
15504 }
15505 //We only handle CSR commands
15506 if( !(eSmeCsrCommandMask & pCommand->command) )
15507 {
15508 return eHAL_STATUS_SUCCESS;
15509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015510 //Check PMC state first
15511 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 switch( pmcState )
15513 {
15514 case REQUEST_IMPS:
15515 case IMPS:
15516 if( eSmeCommandScan == pCommand->command )
15517 {
15518 switch( pCommand->u.scanCmd.reason )
15519 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015520#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15521 case eCsrScanGetLfrResult:
15522#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015523 case eCsrScanGetResult:
15524 case eCsrScanBGScanAbort:
15525 case eCsrScanBGScanEnable:
15526 case eCsrScanGetScanChnInfo:
15527 //Internal process, no need for full power
15528 fNeedFullPower = eANI_BOOLEAN_FALSE;
15529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 default:
15531 //Other scans are real scan, ask for power
15532 fNeedFullPower = eANI_BOOLEAN_TRUE;
15533 break;
15534 } //switch
15535 }
15536 else
15537 {
15538 //ask for power for roam and status change
15539 fNeedFullPower = eANI_BOOLEAN_TRUE;
15540 }
15541 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 case REQUEST_BMPS:
15543 case BMPS:
15544 case REQUEST_START_UAPSD:
15545 case UAPSD:
15546 //We treat WOWL same as BMPS
15547 case REQUEST_ENTER_WOWL:
15548 case WOWL:
15549 if( eSmeCommandRoam == pCommand->command )
15550 {
15551 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15552 tCsrScanResult *pScanResult;
15553 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 switch ( pCommand->u.roamCmd.roamReason )
15555 {
15556 case eCsrForcedDisassoc:
15557 case eCsrForcedDisassocMICFailure:
15558 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15559 fNeedFullPower = eANI_BOOLEAN_TRUE;
15560 break;
15561 case eCsrSmeIssuedDisassocForHandoff:
15562 case eCsrForcedDeauth:
15563 case eCsrHddIssuedReassocToSameAP:
15564 case eCsrSmeIssuedReassocToSameAP:
15565 fNeedFullPower = eANI_BOOLEAN_TRUE;
15566 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 case eCsrCapsChange:
15568 fNeedFullPower = eANI_BOOLEAN_TRUE;
15569 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 default:
15571 //Check whether the profile is already connected. If so, no need for full power
15572 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15573 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15574 {
15575 //Only need to check the first one
15576 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15577 if( pEntry )
15578 {
15579 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15580#if 0
15581 // TODO : Session Specific info pConnectBssDesc
15582 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15583 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15584 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15585 {
15586 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15587 // with Authenticating first. To force this, stop the current association (Disassociate) and
15588 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15589 // a new Association.
15590 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15591 {
15592 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15593 {
15594 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15595 //No need for full power
15596 //Set the flag so the code later can avoid to do the above
15597 //check again.
15598 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15599 break;
15600 }
15601 }
15602 }
15603#endif
15604 }
15605 }
15606 //If we are here, full power is needed
15607 fNeedFullPower = eANI_BOOLEAN_TRUE;
15608 break;
15609 }
15610 }
15611 else if( eSmeCommandWmStatusChange == pCommand->command )
15612 {
15613 //need full power for all
15614 fNeedFullPower = eANI_BOOLEAN_TRUE;
15615 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15616 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015617#ifdef FEATURE_WLAN_TDLS
15618 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15619 {
15620 //TDLS link is getting established. need full power
15621 fNeedFullPower = eANI_BOOLEAN_TRUE;
15622 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15623 }
15624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015625 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 case REQUEST_STOP_UAPSD:
15627 case REQUEST_EXIT_WOWL:
15628 if( eSmeCommandRoam == pCommand->command )
15629 {
15630 fNeedFullPower = eANI_BOOLEAN_TRUE;
15631 switch ( pCommand->u.roamCmd.roamReason )
15632 {
15633 case eCsrForcedDisassoc:
15634 case eCsrForcedDisassocMICFailure:
15635 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15636 break;
15637 default:
15638 break;
15639 }
15640 }
15641 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015642 case STOPPED:
15643 case REQUEST_STANDBY:
15644 case STANDBY:
15645 case LOW_POWER:
15646 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015647 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 status = eHAL_STATUS_FAILURE;
15649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 case FULL_POWER:
15651 case REQUEST_FULL_POWER:
15652 default:
15653 //No need to ask for full power. This has to be FULL_POWER state
15654 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015656 if( pReason )
15657 {
15658 *pReason = reason;
15659 }
15660 if( pfNeedPower )
15661 {
15662 *pfNeedPower = fNeedFullPower;
15663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015664 return ( status );
15665}
15666
Jeff Johnson295189b2012-06-20 16:38:30 -070015667static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15668{
15669 eHalStatus status = eHAL_STATUS_SUCCESS;
15670 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15671 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015672 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15674 {
15675 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 return ( status );
15678}
15679
Jeff Johnson295189b2012-06-20 16:38:30 -070015680tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15681{
15682 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015683 if( pCmd )
15684 {
15685 pMac->roam.sPendingCommands++;
15686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015687 return ( pCmd );
15688}
15689
Jeff Johnson295189b2012-06-20 16:38:30 -070015690void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15691{
15692 if (pMac->roam.sPendingCommands > 0)
15693 {
15694 //All command allocated through csrGetCommandBuffer need to
15695 //decrement the pending count when releasing.
15696 pMac->roam.sPendingCommands--;
15697 smeReleaseCommand( pMac, pCommand );
15698 }
15699 else
15700 {
15701 smsLog(pMac, LOGE, FL( "no pending commands"));
15702 VOS_ASSERT(0);
15703 }
15704}
15705
Jeff Johnson295189b2012-06-20 16:38:30 -070015706//Return SUCCESS is the command is queued, failed
15707eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15708{
15709 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015710 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15711 {
15712 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15713 pCommand->u.scanCmd.reason);
15714 return eHAL_STATUS_CSR_WRONG_STATE;
15715 }
15716
15717 //We can call request full power first before putting the command into pending Q
15718 //because we are holding SME lock at this point.
15719 status = csrRequestFullPower( pMac, pCommand );
15720 if( HAL_STATUS_SUCCESS( status ) )
15721 {
15722 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015723 //make sure roamCmdPendingList is not empty first
15724 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15725 if( fNoCmdPending )
15726 {
15727 smePushCommand( pMac, pCommand, fHighPriority );
15728 }
15729 else
15730 {
15731 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15732 //no list lock is needed since SME lock is held
15733 if( !fHighPriority )
15734 {
15735 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15736 }
15737 else {
15738 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15739 }
15740 }
15741 }
15742 else if( eHAL_STATUS_PMC_PENDING == status )
15743 {
15744 //no list lock is needed since SME lock is held
15745 if( !fHighPriority )
15746 {
15747 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15748 }
15749 else {
15750 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15751 }
15752 //Let caller know the command is queue
15753 status = eHAL_STATUS_SUCCESS;
15754 }
15755 else
15756 {
15757 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15758 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015759 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015761 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015762}
Jeff Johnson295189b2012-06-20 16:38:30 -070015763eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15764{
15765 eHalStatus status = eHAL_STATUS_SUCCESS;
15766 tSirUpdateAPWPSIEsReq *pMsg;
15767 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15768
15769 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15770 if (NULL == pSession)
15771 {
15772 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15773 return eHAL_STATUS_FAILURE;
15774 }
15775
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 do
15777 {
15778 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15779 if (!HAL_STATUS_SUCCESS(status)) break;
15780 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15781 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15782
15783 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070015784 VOS_ASSERT(pBuf);
15785
Jeff Johnson295189b2012-06-20 16:38:30 -070015786 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015787 // transactionId
15788 *pBuf = 0;
15789 *( pBuf + 1 ) = 0;
15790 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 // bssId
15792 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15793 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015794 //sessionId
15795 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015796 // APWPSIEs
15797 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15798 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015800 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015801 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015802 return ( status );
15803}
Jeff Johnson295189b2012-06-20 16:38:30 -070015804eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15805{
15806 eHalStatus status = eHAL_STATUS_SUCCESS;
15807 tSirUpdateAPWPARSNIEsReq *pMsg;
15808 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15810 if (NULL == pSession)
15811 {
15812 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15813 return eHAL_STATUS_FAILURE;
15814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 do
15816 {
15817 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15818 if (!HAL_STATUS_SUCCESS(status)) break;
15819 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15820 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 pBuf = (tANI_U8 *)&pMsg->transactionId;
15822 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015823 // transactionId
15824 *pBuf = 0;
15825 *( pBuf + 1 ) = 0;
15826 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070015827 VOS_ASSERT(pBuf);
15828
Jeff Johnson295189b2012-06-20 16:38:30 -070015829 // bssId
15830 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15831 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015832 // sessionId
15833 *pBuf++ = (tANI_U8)sessionId;
15834
15835 // APWPARSNIEs
15836 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15837 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015838 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015840 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 return ( status );
15842}
Jeff Johnson295189b2012-06-20 16:38:30 -070015843
15844#ifdef WLAN_FEATURE_VOWIFI_11R
15845//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15846eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15847{
15848 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15849 tpSirFTPreAuthReq pftPreAuthReq;
15850 tANI_U16 auth_req_len = 0;
15851 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015852 auth_req_len = sizeof(tSirFTPreAuthReq);
15853 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15854 if (pftPreAuthReq == NULL)
15855 {
15856 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15857 return eHAL_STATUS_RESOURCES;
15858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 // Save the SME Session ID here. We need it while processing the preauth response
15860 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015861 vos_mem_zero(pftPreAuthReq, auth_req_len);
15862
15863 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15864 sizeof(pBssDescription->length) + pBssDescription->length);
15865
15866 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15867
15868 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15869
Jeff Johnson295189b2012-06-20 16:38:30 -070015870 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15872
Jeff Johnson295189b2012-06-20 16:38:30 -070015873#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015874 if (csrRoamIs11rAssoc(pMac) &&
15875 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015876 {
15877 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15878 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15879 pMac->ft.ftSmeContext.auth_ft_ies_length);
15880 }
15881 else
15882#endif
15883 {
15884 pftPreAuthReq->ft_ies_length = 0;
15885 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015886 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15887 sizeof(pBssDescription->length) + pBssDescription->length);
15888 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015889 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15890}
Jeff Johnson295189b2012-06-20 16:38:30 -070015891/*--------------------------------------------------------------------------
15892 * This will receive and process the FT Pre Auth Rsp from the current
15893 * associated ap.
15894 *
15895 * This will invoke the hdd call back. This is so that hdd can now
15896 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15897 ------------------------------------------------------------------------*/
15898void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15899{
15900 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15901 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015902#ifdef FEATURE_WLAN_LFR
15903 tCsrRoamInfo roamInfo;
15904#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015905
15906#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015907 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015908#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015909#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015910 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015911 if (status != eHAL_STATUS_SUCCESS) {
15912 /*
15913 * Bail out if pre-auth was not even processed.
15914 */
15915 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15916 return;
15917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015918#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15920 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15921 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 // Implies a success
15923 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015924 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15925 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070015926 /* No need to notify qos module if this is a non 11r roam*/
15927 if (csrRoamIs11rAssoc(pMac))
15928 {
15929 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15932 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015933 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15934 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070015935 if (eHAL_STATUS_SUCCESS != status)
15936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015937 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015938 return;
15939 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015940 // Save the received response
15941 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15942 if (csrRoamIs11rAssoc(pMac))
15943 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15944 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15945
15946 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015947#ifdef FEATURE_WLAN_LFR
15948 // If Legacy Fast Roaming is enabled, signal the supplicant
15949 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015950 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015951 {
15952 // Save the bssid from the received response
15953 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15954 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15955 }
15956
15957#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015958
15959 // Done with it, init it.
15960 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15961}
15962#endif
15963#ifdef FEATURE_WLAN_BTAMP_UT_RF
15964void csrRoamJoinRetryTimerHandler(void *pv)
15965{
15966 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15967 tpAniSirGlobal pMac = pInfo->pMac;
15968 tANI_U32 sessionId = pInfo->sessionId;
15969 tCsrRoamSession *pSession;
15970
15971 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015973 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 pSession = CSR_GET_SESSION( pMac, sessionId );
15975 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15976 {
15977 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015979 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015980 }
15981 }
15982 }
15983}
Jeff Johnson295189b2012-06-20 16:38:30 -070015984eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15985{
15986 eHalStatus status = eHAL_STATUS_FAILURE;
15987 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15988
15989 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015991 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015992 pSession->maxRetryCount--;
15993 pSession->joinRetryTimerInfo.pMac = pMac;
15994 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015995 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
15996 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015998 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015999 }
16000 }
16001 else
16002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016003 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 pSession->maxRetryCount);
16005 }
16006
16007 return (status);
16008}
Jeff Johnson295189b2012-06-20 16:38:30 -070016009eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16010{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016011 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16013 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016014 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016015 }
16016
16017 return eHAL_STATUS_SUCCESS;
16018}
16019#endif
16020
16021
16022/*
16023 pBuf points to the beginning of the message
16024 LIM packs disassoc rsp as below,
16025 messageType - 2 bytes
16026 messageLength - 2 bytes
16027 sessionId - 1 byte
16028 transactionId - 2 bytes (tANI_U16)
16029 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16030 peerMacAddr - 6 bytes
16031 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16032*/
16033static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16034{
16035 if(pBuf && pRsp)
16036 {
16037 pBuf += 4; //skip type and length
16038 pRsp->sessionId = *pBuf++;
16039 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16040 pBuf += 2;
16041 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16042 pBuf += 4;
16043 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16044 }
16045}
16046
Jeff Johnsond13512a2012-07-17 11:42:19 -070016047eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16048{
16049 static uNvTables nvTables;
16050 eHalStatus status = eHAL_STATUS_SUCCESS;
16051 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16052
16053 /* read the country code from NV and use it */
16054 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16055 {
16056 palCopyMemory( pMac->hHdd, pCountry,
16057 nvTables.defaultCountryTable.countryCode,
16058 WNI_CFG_COUNTRY_CODE_LEN );
16059 return status;
16060 }
16061 else
16062 {
16063 palCopyMemory( pMac->hHdd, pCountry,
16064 "XXX",
16065 WNI_CFG_COUNTRY_CODE_LEN );
16066 status = eHAL_STATUS_FAILURE;
16067 return status;
16068 }
16069}
16070
16071eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16072{
16073 palCopyMemory( pMac->hHdd, pCountry,
16074 pMac->scan.countryCode11d,
16075 WNI_CFG_COUNTRY_CODE_LEN );
16076 return eHAL_STATUS_SUCCESS;
16077}
schang86c22c42013-03-13 18:41:24 -070016078
16079eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16080{
16081 tSirSetTxPowerReq *pMsg = NULL;
16082 eHalStatus status = eHAL_STATUS_SUCCESS;
16083 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16084
16085 if (!pSession)
16086 {
16087 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16088 return eHAL_STATUS_FAILURE;
16089 }
16090
16091 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
16092 if (HAL_STATUS_SUCCESS(status))
16093 {
16094 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
16095 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16096 pMsg->length = sizeof(tSirSetTxPowerReq);
16097 pMsg->mwPower = mW;
16098 palCopyMemory( pMac->hHdd,
16099 (tSirMacAddr *)pMsg->bssId,
16100 &pSession->selfMacAddr,
16101 sizeof(tSirMacAddr) );
16102 status = palSendMBMessage(pMac->hHdd, pMsg);
16103 if (!HAL_STATUS_SUCCESS(status))
16104 {
16105 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016106 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016107 }
16108 }
16109 return status;
16110}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016111
16112/* Returns whether a session is in VOS_STA_MODE...or not */
16113tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16114{
16115 tCsrRoamSession *pSession = NULL;
16116 pSession = CSR_GET_SESSION ( pMac, sessionId );
16117 if(!pSession)
16118 {
16119 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16120 return eANI_BOOLEAN_FALSE;
16121 }
16122 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16123 {
16124 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16125 return eANI_BOOLEAN_FALSE;
16126 }
16127 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16128 {
16129 return eANI_BOOLEAN_FALSE;
16130 }
16131 /* There is a possibility that the above check may fail,because
16132 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16133 * when it is connected.So,we may sneak through the above check even
16134 * if we are not a STA mode INFRA station. So, if we sneak through
16135 * the above condition, we can use the following check if we are
16136 * really in STA Mode.*/
16137
16138 if ( NULL != pSession->pCurRoamProfile )
16139 {
16140 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16141 {
16142 return eANI_BOOLEAN_TRUE;
16143 } else {
16144 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16145 return eANI_BOOLEAN_FALSE;
16146 }
16147 }
16148
16149 return eANI_BOOLEAN_FALSE;
16150}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016151
16152#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16153eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16154 tCsrHandoffRequest *pHandoffInfo)
16155{
16156 eHalStatus status = eHAL_STATUS_SUCCESS;
16157 vos_msg_t msg;
16158
16159 tAniHandoffReq *pMsg;
16160 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
16161 if ( !HAL_STATUS_SUCCESS(status) )
16162 {
16163 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
16164 return status;
16165 }
16166 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16167 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16168 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16169 pMsg->channel = pHandoffInfo->channel;
16170 palCopyMemory(pMac->hHdd, pMsg->bssid,
16171 pHandoffInfo->bssid,
16172 6);
16173 msg.type = eWNI_SME_HANDOFF_REQ;
16174 msg.bodyptr = pMsg;
16175 msg.reserved = 0;
16176 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16177 {
16178 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
16179 palFreeMemory(pMac->hHdd, (void *)pMsg);
16180 status = eHAL_STATUS_FAILURE;
16181 }
16182 return status;
16183}
16184#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */