blob: c3aee00db543563f0961a046319ab502c8f998f9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
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
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053061#include "sme_Trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "logDump.h"
63#include "smeQosInternal.h"
64#include "wlan_qct_tl.h"
65#include "smeInside.h"
66#include "vos_diag_core_event.h"
67#include "vos_diag_core_log.h"
68#include "csrApi.h"
69#include "pmc.h"
70#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053071#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070072#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
73#include "csrNeighborRoam.h"
74#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080075#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
76#include "csrEse.h"
77#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053078#include "vos_utils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#define CSR_NUM_IBSS_START_CHANNELS_50 4
80#define CSR_NUM_IBSS_START_CHANNELS_24 3
81#define CSR_DEF_IBSS_START_CHANNEL_50 36
82#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080083#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 -070084#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
85/*---------------------------------------------------------------------------
86 OBIWAN recommends [8 10]% : pick 9%
87---------------------------------------------------------------------------*/
88#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070089/*---------------------------------------------------------------------------
90 OBIWAN recommends -85dBm
91---------------------------------------------------------------------------*/
92#define CSR_VCC_RSSI_THRESHOLD 80
93#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
94#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
95#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
96#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070097//We use constatnt 4 here
98//This macro returns true when higher AC parameter is bigger than lower AC for a difference
99//The bigger the number, the less chance of TX
100//It must put lower AC as the first parameter.
101#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700102//Flag to send/do not send disassoc frame over the air
103#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700104#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700105#define MAX_CB_VALUE_IN_INI (2)
106
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700107#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
108static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
109#endif
110
Jeff Johnson295189b2012-06-20 16:38:30 -0700111/*--------------------------------------------------------------------------
112 Static Type declarations
113 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800114static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Type declarations
118 ------------------------------------------------------------------------*/
119#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700120int diagAuthTypeFromCSRType(eCsrAuthType authType)
121{
122 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700123 switch(authType)
124 {
125 case eCSR_AUTH_TYPE_SHARED_KEY:
126 n = AUTH_SHARED;
127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 case eCSR_AUTH_TYPE_WPA:
129 n = AUTH_WPA_EAP;
130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 case eCSR_AUTH_TYPE_WPA_PSK:
132 n = AUTH_WPA_PSK;
133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530135#ifdef WLAN_FEATURE_11W
136 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 n = AUTH_WPA2_EAP;
139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700141#ifdef WLAN_FEATURE_11W
142 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
143#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 n = AUTH_WPA2_PSK;
145 break;
146#ifdef FEATURE_WLAN_WAPI
147 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
148 n = AUTH_WAPI_CERT;
149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
151 n = AUTH_WAPI_PSK;
152 break;
153#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 default:
155 break;
156 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 return (n);
158}
Jeff Johnson295189b2012-06-20 16:38:30 -0700159int diagEncTypeFromCSRType(eCsrEncryptionType encType)
160{
161 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 switch(encType)
163 {
164 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
165 case eCSR_ENCRYPT_TYPE_WEP40:
166 n = ENC_MODE_WEP40;
167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
169 case eCSR_ENCRYPT_TYPE_WEP104:
170 n = ENC_MODE_WEP104;
171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 case eCSR_ENCRYPT_TYPE_TKIP:
173 n = ENC_MODE_TKIP;
174 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 case eCSR_ENCRYPT_TYPE_AES:
176 n = ENC_MODE_AES;
177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700178#ifdef FEATURE_WLAN_WAPI
179 case eCSR_ENCRYPT_TYPE_WPI:
180 n = ENC_MODE_SMS4;
181 break;
182#endif /* FEATURE_WLAN_WAPI */
183 default:
184 break;
185 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 return (n);
187}
Jeff Johnson295189b2012-06-20 16:38:30 -0700188#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700189static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
190static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700191static void initConfigParam(tpAniSirGlobal pMac);
192static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
193 eCsrRoamCompleteResult Result, void *Context );
194static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
195 tCsrRoamProfile *pProfile,
196 tANI_BOOLEAN *pfSameIbss );
197static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
198static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700199 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
200static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700201eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
202static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
203eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
204eHalStatus csrRoamClose(tpAniSirGlobal pMac);
205void csrRoamMICErrorTimerHandler(void *pv);
206void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
207tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
208
209static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
210static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
211static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700212eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
213eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
214static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700215static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700216static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
218eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
219 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
220 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
221 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
222 tANI_U8 *pKeyRsc );
223static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
224 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
225 tCsrRoamProfile *pProfile );
226void csrRoamStatisticsTimerHandler(void *pv);
227void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700228static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
229VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
230 v_U8_t rssiNotification,
231 void * context);
232static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
233void csrRoamVccTrigger(tpAniSirGlobal pMac);
234eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
235/*
236 pStaEntry is no longer invalid upon the return of this function.
237*/
238static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700239static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700240static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700241tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
242 tDblLinkList *pStaList,
243 tCsrStatsClientReqInfo *pStaEntry);
244void csrRoamStatsClientTimerHandler(void *pv);
245tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
246 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
247void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
248 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700249void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700250void csrRoamTlStatsTimerHandler(void *pv);
251void csrRoamPeStatsTimerHandler(void *pv);
252tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
253void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
254tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
255eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
256static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
257static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
258static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
259static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
260 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
261//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
262static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
263void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
264#ifdef FEATURE_WLAN_BTAMP_UT_RF
265void csrRoamJoinRetryTimerHandler(void *pv);
266#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530267void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700268extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700269extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700271void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
273//Initialize global variables
274static void csrRoamInitGlobals(tpAniSirGlobal pMac)
275{
276 if(pMac)
277 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800278 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
279 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 }
281 return;
282}
283
Jeff Johnson295189b2012-06-20 16:38:30 -0700284static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
285{
286 if(pMac)
287 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800288 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 }
290 return;
291}
Jeff Johnson295189b2012-06-20 16:38:30 -0700292eHalStatus csrOpen(tpAniSirGlobal pMac)
293{
294 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530295#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 static uNvTables nvTables;
297 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530299#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 tANI_U32 i;
301
302 do
303 {
304 /* Initialize CSR Roam Globals */
305 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
307 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
308
309 initConfigParam(pMac);
310 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
311 break;
312 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
313 break;
314 pMac->roam.nextRoamId = 1; //Must not be 0
315 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
316 break;
317 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
318 break;
319 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
320 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530321
322#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
324 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
325 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530326 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
327 WNI_CFG_COUNTRY_CODE_LEN);
328 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330 else
331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800332 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 //hardcoded for now
334 pMac->scan.countryCodeDefault[0] = 'U';
335 pMac->scan.countryCodeDefault[1] = 'S';
336 pMac->scan.countryCodeDefault[2] = 'I';
337 //status = eHAL_STATUS_SUCCESS;
338 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700339 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530340
341 if (!('0' == pMac->scan.countryCodeDefault[0] &&
342 '0' == pMac->scan.countryCodeDefault[1]))
343 {
344 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
345 &regId, COUNTRY_NV);
346 }
347 else
348 {
349 regId = REGDOMAIN_WORLD;
350 }
Abhishek Singha306a442013-11-07 18:39:01 +0530351 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 pMac->scan.domainIdDefault = regId;
353 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530354 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
355 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530359
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 return (status);
361}
362
Mihir Shetee1093ba2014-01-21 20:13:32 +0530363/* --------------------------------------------------------------------------
364 \fn csrInitChannels
365 \brief This function must be called to initialize CSR channel lists
366 \return eHalStatus
367 ----------------------------------------------------------------------------*/
368eHalStatus csrInitChannels(tpAniSirGlobal pMac)
369{
370 eHalStatus status = eHAL_STATUS_SUCCESS;
371 static uNvTables nvTables;
372 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530373 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530374
375 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
376 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
377 {
378 vos_mem_copy(pMac->scan.countryCodeDefault,
379 nvTables.defaultCountryTable.countryCode,
380 WNI_CFG_COUNTRY_CODE_LEN);
381 }
382 else
383 {
384 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
385 //hardcoded for now
386 pMac->scan.countryCodeDefault[0] = 'U';
387 pMac->scan.countryCodeDefault[1] = 'S';
388 pMac->scan.countryCodeDefault[2] = 'I';
389 }
390 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
391
Mihir Shetee1093ba2014-01-21 20:13:32 +0530392 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
393 pMac->scan.domainIdDefault = regId;
394 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
395 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
396 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530397 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
398 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530399 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
400 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530401 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530402 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530403
404 return status;
405}
406
Mihir Shete04206452014-11-20 17:50:58 +0530407#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530408eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530409{
410 eHalStatus status = eHAL_STATUS_SUCCESS;
411 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530412 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530413
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530414 /* In case of driver load ; driver need to get channel
415 * list with default Countrycode.
416 * In case of SSR; driver need to get channel list
417 * with old country code. 0 is for init and
418 * 1 is for reinit
419 */
420 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530421 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530422 case INIT:
423 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
424 WNI_CFG_COUNTRY_CODE_LEN);
425 if (!('0' == cc[0] &&
426 '0' == cc[1]))
427 {
428 csrGetRegulatoryDomainForCountry(pMac, cc,
429 &regId, COUNTRY_NV);
430 }
431 else
432 {
433 return status;
434 }
435 pMac->scan.domainIdDefault = regId;
436 break;
437 case REINIT:
438 vos_getCurrentCountryCode(&cc[0]);
439 status = csrGetRegulatoryDomainForCountry(pMac,
440 cc, &regId, COUNTRY_QUERY);
441 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530442 }
443 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530444 pMac->scan.domainIdCurrent = regId;
445 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530446 WNI_CFG_COUNTRY_CODE_LEN);
447 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530448
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
450 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
451 pMac->scan.countryCodeCurrent[1]);
452
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530453 /* reset info based on new cc, and we are done */
454 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
455 csrScanFilterResults(pMac);
456
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530457 return status;
458}
Mihir Shete04206452014-11-20 17:50:58 +0530459#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530460
Jeff Johnson295189b2012-06-20 16:38:30 -0700461eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
462{
463 eHalStatus status = eHAL_STATUS_SUCCESS;
464 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
465 v_REGDOMAIN_t regId;
466 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 if(NULL == apCntryCode)
468 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530469 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 return eHAL_STATUS_FAILURE;
471 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530472 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 /* To get correct Regulatory domain from NV table
474 * 2 character Country code should be used
475 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700476 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
477/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700479
480 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800482 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700483 return eHAL_STATUS_FAILURE;
484 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700485*/
Kiet Lam6c583332013-10-14 05:37:09 +0530486 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
487 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 if (status != eHAL_STATUS_SUCCESS)
489 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700490 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 return status;
492 }
Abhishek Singha306a442013-11-07 18:39:01 +0530493 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 if (status != eHAL_STATUS_SUCCESS)
495 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700496 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 return status;
498 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 pMac->scan.domainIdDefault = regId;
500 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530502 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
503
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530505 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
506
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 /* If 2 bytes country code, 3rd byte must be filled with space */
508 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
509 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530510 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530512 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
513 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 return status;
516}
Jeff Johnson295189b2012-06-20 16:38:30 -0700517eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
518{
519 eHalStatus status = eHAL_STATUS_SUCCESS;
520 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
521 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530522 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
523 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
525 {
526 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
527 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
528 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
529 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
530 }
531 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
532
533 return status;
534}
Jeff Johnson295189b2012-06-20 16:38:30 -0700535eHalStatus csrClose(tpAniSirGlobal pMac)
536{
537 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800538
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 csrRoamClose(pMac);
540 csrScanClose(pMac);
541 csrLLClose(&pMac->roam.statsClientReqList);
542 csrLLClose(&pMac->roam.peStatsReqList);
543 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 /* DeInit Globals */
545 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 return (status);
547}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530548
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800549eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530550{
551 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800552 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530553 tANI_U32 numChan = 0;
554 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530555 vos_msg_t msg;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530556 tANI_U8 i, j;
557 tANI_U8 num_channel = 0;
558 tANI_U8 channel_state;
559 tANI_U8 cfgnumChannels = 0;
560 tANI_U8 *cfgChannelList = NULL;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530561
Atul Mittalb849d5a2014-07-29 12:08:39 +0530562 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530563 numChan = sizeof(pMac->roam.validChannelList);
564
565 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
566 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
567 {
568 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
569 return eHAL_STATUS_FAILED_ALLOC;
570 }
571
572 bufLen = sizeof(tSirUpdateChanList) +
573 (sizeof(tSirUpdateChanParam) * (numChan - 1));
574
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530575 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
576 if (!pChanList)
577 {
578 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
579 "Failed to allocate memory for tSirUpdateChanList");
580 return eHAL_STATUS_FAILED_ALLOC;
581 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530582 vos_mem_zero(pChanList, bufLen);
583
584 smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"),
585 pMac->scan.fEnableDFSChnlScan);
586
587 for (i = 0; i < numChan; i++)
588 {
589 channel_state =
590 vos_nv_getChannelEnabledState(pMac->roam.validChannelList[i]);
591
592 if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
593 && (channel_state == NV_CHANNEL_DFS))
594 {
595 continue;
596 }
597 pChanList->chanParam[num_channel].chanId =
598 pMac->roam.validChannelList[i];
599 pChanList->chanParam[num_channel].pwr =
600 cfgGetRegulatoryMaxTransmitPower(pMac,
601 pScan->defaultPowerTable[i].chanId);
Sushant Kaushikece4b562015-04-09 18:27:33 +0530602 if (!pChanList->chanParam[num_channel].pwr)
603 {
604 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
605 "setting to default %d"),
606 pChanList->chanParam[num_channel].chanId,
607 TX_POWER_DEFAULT);
608 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
609 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530610 if (channel_state == NV_CHANNEL_DFS)
611 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
612 else
613 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
614
615 /* When DFS mode is 2, mark static channels as active */
616 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
617 {
618 cfgnumChannels =
619 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
620 cfgChannelList =
621 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
622
623 if (cfgChannelList)
624 {
625 for(j=0; j< cfgnumChannels; j++)
626 {
627 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
628 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
629 {
630 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
631 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
632 "%s Marked DFS ch %d as active\n", __func__,
633 cfgChannelList[j]);
634 }
635 }
636 }
637 else
638 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
639 "%s cfgChannelList is NULL \n", __func__);
640 }
641
642 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
643 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
644 pChanList->chanParam[num_channel].chanId,
645 pChanList->chanParam[num_channel].dfsSet,
646 pChanList->chanParam[num_channel].pwr);
647 num_channel++;
648 }
649 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530650
Sachin Ahuja2d15ff62015-06-30 12:46:44 +0530651 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
652 "%s : regID : %d \n", __func__,
653 pChanList->regId);
654
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530655 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
656 msg.reserved = 0;
657 msg.bodyptr = pChanList;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530658 pChanList->numChan = num_channel;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +0530659 MTRACE(vos_trace(VOS_MODULE_ID_SME,
660 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530661 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
662 {
663 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
664 "%s: Failed to post msg to WDA", __func__);
665 vos_mem_free(pChanList);
666 return eHAL_STATUS_FAILURE;
667 }
668
669 return eHAL_STATUS_SUCCESS;
670}
671
Jeff Johnson295189b2012-06-20 16:38:30 -0700672eHalStatus csrStart(tpAniSirGlobal pMac)
673{
674 eHalStatus status = eHAL_STATUS_SUCCESS;
675 tANI_U32 i;
676
677 do
678 {
679 //save the global vos context
680 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
681 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
682 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
683
684 status = csrRoamStart(pMac);
685 if(!HAL_STATUS_SUCCESS(status)) break;
686 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
687 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
688 if(!HAL_STATUS_SUCCESS(status)) break;
689 pMac->roam.sPendingCommands = 0;
690 csrScanEnable(pMac);
691#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
692 status = csrNeighborRoamInit(pMac);
693#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
694 pMac->roam.tlStatsReqInfo.numClient = 0;
695 pMac->roam.tlStatsReqInfo.periodicity = 0;
696 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
697 //init the link quality indication also
698 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
699 if(!HAL_STATUS_SUCCESS(status))
700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800701 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 break;
703 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530704
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700706#if defined(ANI_LOGDUMP)
707 csrDumpInit(pMac);
708#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 return (status);
710}
711
Kiet Lama72a2322013-11-15 11:18:11 +0530712eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713{
714 tANI_U32 sessionId;
715 tANI_U32 i;
716
717 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
718 {
mukul sharmabab477d2015-06-11 17:14:55 +0530719 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 csrScanDisable(pMac);
722 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
723 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
725
726#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
727 csrNeighborRoamClose(pMac);
728#endif
729 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 // deregister from PMC since we register during csrStart()
731 // (ignore status since there is nothing we can do if it fails)
732 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 //Reset the domain back to the deault
734 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800735 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700736
737 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
738 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530739 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
741 }
742
Kiet Lama72a2322013-11-15 11:18:11 +0530743#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
744 /* When HAL resets all the context information
745 * in HAL is lost, so we might need to send the
746 * scan offload request again when it comes
747 * out of reset for scan offload to be functional
748 */
749 if (HAL_STOP_TYPE_SYS_RESET == stopType)
750 {
751 bRoamScanOffloadStarted = VOS_FALSE;
752 }
753#endif
754
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 return (eHAL_STATUS_SUCCESS);
756}
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758eHalStatus csrReady(tpAniSirGlobal pMac)
759{
760 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 csrScanGetSupportedChannels( pMac );
762 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
763 //use it to init the background scan list
764 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 //Store the AC weights in TL for later use
766 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 status = csrInitChannelList( pMac );
768 if ( ! HAL_STATUS_SUCCESS( status ) )
769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800770 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 status );
772 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 return (status);
774}
Jeff Johnson295189b2012-06-20 16:38:30 -0700775void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
776{
777 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
779 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
780}
Jeff Johnson295189b2012-06-20 16:38:30 -0700781void csrSetGlobalCfgs( tpAniSirGlobal pMac )
782{
Jeff Johnsone7245742012-09-05 17:12:55 -0700783
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
785 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
786 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
787 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
788 NULL, eANI_BOOLEAN_FALSE);
789 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700790 /* 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
791 * Once session is established we will use the session related params stored in PE session for CB mode
792 */
793 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
795
796 //Update the operating mode to configured value during initialization,
797 //So that client can advertise full capabilities in Probe request frame.
798 csrSetDefaultDot11Mode( pMac );
799}
800
Jeff Johnson295189b2012-06-20 16:38:30 -0700801eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
802{
803 eHalStatus status = eHAL_STATUS_SUCCESS;
804 tANI_U32 i;
805 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 do
807 {
808 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
809 {
810 pSession = CSR_GET_SESSION( pMac, i );
811 pSession->roamingTimerInfo.pMac = pMac;
812 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
813 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
815 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530816 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
817 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530819 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800821 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 break;
823 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530824 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
825 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
826 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800828 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 return eHAL_STATUS_FAILURE;
830 }
831 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 return (status);
833}
834
Jeff Johnson295189b2012-06-20 16:38:30 -0700835eHalStatus csrRoamClose(tpAniSirGlobal pMac)
836{
837 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
839 {
mukul sharmabab477d2015-06-11 17:14:55 +0530840 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530842 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
843 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
844 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
845 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 return (eHAL_STATUS_SUCCESS);
847}
848
Jeff Johnson295189b2012-06-20 16:38:30 -0700849eHalStatus csrRoamStart(tpAniSirGlobal pMac)
850{
851 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 return (eHAL_STATUS_SUCCESS);
853}
854
Jeff Johnson295189b2012-06-20 16:38:30 -0700855void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
856{
857 csrRoamStopRoamingTimer(pMac, sessionId);
858 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
859 csrRoamDeregStatisticsReq(pMac);
860}
Jeff Johnson295189b2012-06-20 16:38:30 -0700861eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
862{
863 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800864 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 {
866 status = eHAL_STATUS_SUCCESS;
867 *pState = pMac->roam.roamSession[sessionId].connectState;
868 }
869 return (status);
870}
871
Jeff Johnson295189b2012-06-20 16:38:30 -0700872eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
873{
874 eHalStatus status = eHAL_STATUS_FAILURE;
875 tANI_U32 size = 0;
876 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700877
878 if(!pSession)
879 {
880 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
881 return eHAL_STATUS_FAILURE;
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883
884 if(pProfile)
885 {
886 if(pSession->pConnectBssDesc)
887 {
888 do
889 {
890 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
891 if(size)
892 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530893 pProfile->pBssDesc = vos_mem_malloc(size);
894 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530896 vos_mem_copy(pProfile->pBssDesc,
897 pSession->pConnectBssDesc, size);
898 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 }
900 else
901 break;
902 }
903 else
904 {
905 pProfile->pBssDesc = NULL;
906 }
907 pProfile->AuthType = pSession->connectedProfile.AuthType;
908 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
909 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
910 pProfile->BSSType = pSession->connectedProfile.BSSType;
911 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
912 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
914 sizeof(tCsrBssid));
915 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
916 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700917#ifdef WLAN_FEATURE_VOWIFI_11R
918 if (pSession->connectedProfile.MDID.mdiePresent)
919 {
920 pProfile->MDID.mdiePresent = 1;
921 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
922 }
923 else
924 {
925 pProfile->MDID.mdiePresent = 0;
926 pProfile->MDID.mobilityDomain = 0;
927 }
928#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800929#ifdef FEATURE_WLAN_ESE
930 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
931 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800933 vos_mem_copy (pProfile->eseCckmInfo.krk,
934 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530935 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800936 pProfile->eseCckmInfo.reassoc_req_num=
937 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
938 pProfile->eseCckmInfo.krk_plumbed =
939 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 }
941#endif
942 }while(0);
943 }
944 }
945
946 return (status);
947}
948
Jeff Johnson295189b2012-06-20 16:38:30 -0700949eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
950{
951 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700952
953 if((csrIsConnStateConnected(pMac, sessionId)) ||
954 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 {
956 if(pProfile)
957 {
958 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
959 }
960 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 return (status);
962}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700963
Jeff Johnson295189b2012-06-20 16:38:30 -0700964eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
965{
966 eHalStatus status = eHAL_STATUS_SUCCESS;
967
Kiet Lam64c1b492013-07-12 13:56:44 +0530968 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530970 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530972 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700973 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530974 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700975 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530976 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
979 return (status);
980}
981
Jeff Johnson295189b2012-06-20 16:38:30 -0700982static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
983{
984 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 if( pConnectedInfo->pbFrames )
986 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530987 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 pConnectedInfo->pbFrames = NULL;
989 }
990 pConnectedInfo->nBeaconLength = 0;
991 pConnectedInfo->nAssocReqLength = 0;
992 pConnectedInfo->nAssocRspLength = 0;
993 pConnectedInfo->staId = 0;
994#ifdef WLAN_FEATURE_VOWIFI_11R
995 pConnectedInfo->nRICRspLength = 0;
996#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800997#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 pConnectedInfo->nTspecIeLength = 0;
999#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 return ( status );
1001}
1002
Jeff Johnson295189b2012-06-20 16:38:30 -07001003
1004
Jeff Johnsone7245742012-09-05 17:12:55 -07001005
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001006void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1007{
1008 csrReinitPreauthCmd(pMac, pCommand);
1009 csrReleaseCommand( pMac, pCommand );
1010}
1011
Jeff Johnson295189b2012-06-20 16:38:30 -07001012void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1013{
1014 csrReinitRoamCmd(pMac, pCommand);
1015 csrReleaseCommand( pMac, pCommand );
1016}
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1019{
1020 csrReinitScanCmd(pMac, pCommand);
1021 csrReleaseCommand( pMac, pCommand );
1022}
1023
Jeff Johnson295189b2012-06-20 16:38:30 -07001024void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1025{
1026 csrReinitWmStatusChangeCmd(pMac, pCommand);
1027 csrReleaseCommand( pMac, pCommand );
1028}
1029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1031{
Kiet Lam64c1b492013-07-12 13:56:44 +05301032 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001033}
1034
Jeff Johnson295189b2012-06-20 16:38:30 -07001035void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1036{
Kiet Lam64c1b492013-07-12 13:56:44 +05301037 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001038}
1039
Jeff Johnson295189b2012-06-20 16:38:30 -07001040void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1041{
1042 csrReinitSetKeyCmd(pMac, pCommand);
1043 csrReleaseCommand( pMac, pCommand );
1044}
Jeff Johnson295189b2012-06-20 16:38:30 -07001045void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1046{
1047 csrReinitRemoveKeyCmd(pMac, pCommand);
1048 csrReleaseCommand( pMac, pCommand );
1049}
Jeff Johnson295189b2012-06-20 16:38:30 -07001050void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1051{
1052
1053 if( eSmeCsrCommandMask & pCommand->command )
1054 {
1055 switch (pCommand->command)
1056 {
1057 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001058 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001059 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1060 __func__, pCommand->u.scanCmd.reason,
1061 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 if (NULL != pCommand->u.scanCmd.callback)
1063 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001064 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1066 }
1067 csrReleaseCommandScan( pMac, pCommand );
1068 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 case eSmeCommandRoam:
1070 csrReleaseCommandRoam( pMac, pCommand );
1071 break;
1072
1073 case eSmeCommandWmStatusChange:
1074 csrReleaseCommandWmStatusChange( pMac, pCommand );
1075 break;
1076
1077 case eSmeCommandSetKey:
1078 csrReleaseCommandSetKey( pMac, pCommand );
1079 break;
1080
1081 case eSmeCommandRemoveKey:
1082 csrReleaseCommandRemoveKey( pMac, pCommand );
1083 break;
1084
1085 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001086 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 csrReleaseCommand( pMac, pCommand );
1088 break;
1089 }
1090 }
1091}
1092
Jeff Johnson295189b2012-06-20 16:38:30 -07001093void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1094{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301095 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1096 macTraceGetcsrRoamSubState(NewSubstate),
1097 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001098
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1100 {
1101 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pMac->roam.curSubState[sessionId] = NewSubstate;
1104}
1105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1107{
1108 eCsrRoamState PreviousState;
1109
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301110 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1111 macTraceGetcsrRoamState(NewRoamState),
1112 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113
1114 PreviousState = pMac->roam.curState[sessionId];
1115
1116 if ( NewRoamState != pMac->roam.curState[sessionId] )
1117 {
1118 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1119 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1120 {
1121 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1122 }
1123
1124 pMac->roam.curState[sessionId] = NewRoamState;
1125 }
1126 return( PreviousState );
1127}
1128
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001129void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001130{
1131 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 if(catOffset)
1133 {
1134 pMac->roam.configParam.bCatRssiOffset = catOffset;
1135 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1136 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001137 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 }
1139 }
1140}
1141
Jeff Johnson295189b2012-06-20 16:38:30 -07001142static void initConfigParam(tpAniSirGlobal pMac)
1143{
1144 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301146 pMac->roam.configParam.channelBondingMode24GHz =
1147 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1148 pMac->roam.configParam.channelBondingMode5GHz =
1149 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1151 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1152 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1153 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1154 pMac->roam.configParam.HeartbeatThresh24 = 40;
1155 pMac->roam.configParam.HeartbeatThresh50 = 40;
1156 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1157 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1158 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001159 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 pMac->roam.configParam.RTSThreshold = 2346;
1161 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1162 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1163 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1164 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1165 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1166 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1167 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1168 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1169 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1170 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1171 {
1172 pMac->roam.configParam.BssPreferValue[i] = i;
1173 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001174 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1176 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1177 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1179 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301180 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1182 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1183 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1184 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001185 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1186 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001187 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001188#ifdef WLAN_AP_STA_CONCURRENCY
1189 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1190 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1191 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1192 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1193 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001194 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1195 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1198 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1199 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1200 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001201#ifdef WLAN_FEATURE_VOWIFI_11R
1202 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1203#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001204#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1205 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1206 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1207 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1208 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1209 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1210 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1211 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1212 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1213 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1214 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1215 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001216 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301217 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001218#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001219#ifdef WLAN_FEATURE_11AC
1220 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001222
1223 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1224 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001225
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001226 //Remove this code once SLM_Sessionization is supported
1227 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001228 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
Jeff Johnsone7245742012-09-05 17:12:55 -07001230}
Jeff Johnson295189b2012-06-20 16:38:30 -07001231eCsrBand csrGetCurrentBand(tHalHandle hHal)
1232{
1233 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1234 return pMac->roam.configParam.bandCapability;
1235}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001237
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001238#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001239/*
1240 This function flushes the roam scan cache
1241*/
1242eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1243{
1244 eHalStatus status = eHAL_STATUS_SUCCESS;
1245 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1246
1247 /* Free up the memory first (if required) */
1248 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1249 {
1250 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1251 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1252 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1253 }
1254 return status;
1255}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001256#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001257
1258
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001259#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001260/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001261 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001262*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001263eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001264{
1265 eHalStatus status = eHAL_STATUS_SUCCESS;
1266 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1267
1268 /* Free up the memory first (if required) */
1269 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1270 {
1271 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1272 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001273 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001274 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001275 return status;
1276}
1277
1278
1279
1280/*
1281 This function flushes the roam scan cache and creates fresh cache
1282 based on the input channel list
1283*/
1284eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1285 const tANI_U8 *pChannelList,
1286 const tANI_U8 numChannels)
1287{
1288 eHalStatus status = eHAL_STATUS_SUCCESS;
1289 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1290
Srinivas Girigowdade697412013-02-14 16:31:48 -08001291 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1292
1293 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1294 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1295
1296 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1297 {
1298 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1299 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1300 return eHAL_STATUS_RESOURCES;
1301 }
1302
1303 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301304 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1305 pChannelList,
1306 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001307 return status;
1308}
1309
1310/* This function modifies the bgscan channel list set via config ini or
1311 runtime, whenever the band changes.
1312 if the band is auto, then no operation is performed on the channel list
1313 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1314 if the band is 5G, then make sure channel list contains only 5G valid channels
1315*/
1316eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1317 eCsrBand eBand)
1318{
1319 eHalStatus status = eHAL_STATUS_SUCCESS;
1320 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1321 tANI_U8 outNumChannels = 0;
1322 tANI_U8 inNumChannels = 0;
1323 tANI_U8 *inPtr = NULL;
1324 tANI_U8 i = 0;
1325 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1326
1327 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1328
1329 {
1330 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1331 "No update required for channel list "
1332 "either cfg.ini channel list is not set up or "
1333 "auto band (Band %d)", eBand);
1334 return status;
1335 }
1336
1337 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1338 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1339 if (eCSR_BAND_24 == eBand)
1340 {
1341 for (i = 0; i < inNumChannels; i++)
1342 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001343 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001344 {
1345 ChannelList[outNumChannels++] = inPtr[i];
1346 }
1347 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001348 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001349 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001350 }
1351 else if (eCSR_BAND_5G == eBand)
1352 {
1353 for (i = 0; i < inNumChannels; i++)
1354 {
1355 /* Add 5G Non-DFS channel */
1356 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001357 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001358 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1359 {
1360 ChannelList[outNumChannels++] = inPtr[i];
1361 }
1362 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001363 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001364 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001365 }
1366 else if (eCSR_BAND_ALL == eBand)
1367 {
1368 for (i = 0; i < inNumChannels; i++)
1369 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001370 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001371 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1372 {
1373 ChannelList[outNumChannels++] = inPtr[i];
1374 }
1375 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001376 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001377 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001378 }
1379 else
1380 {
1381 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1382 "Invalid band, No operation carried out (Band %d)", eBand);
1383 status = eHAL_STATUS_INVALID_PARAMETER;
1384 }
1385
1386 return status;
1387}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001388#endif
1389
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001390#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001391/* This function modifies the roam scan channel list as per AP neighbor
1392 report; AP neighbor report may be empty or may include only other AP
1393 channels; in any case, we merge the channel list with the learned occupied
1394 channels list.
1395 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1396 if the band is 5G, then make sure channel list contains only 5G valid channels
1397*/
1398eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1399 tANI_U8 *pChannelList,
1400 tANI_U8 numChannels,
1401 const eCsrBand eBand)
1402{
1403 eHalStatus status = eHAL_STATUS_SUCCESS;
1404 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1405 tANI_U8 outNumChannels = 0;
1406 tANI_U8 inNumChannels = numChannels;
1407 tANI_U8 *inPtr = pChannelList;
1408 tANI_U8 i = 0;
1409 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1410 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1411 tANI_U8 mergedOutputNumOfChannels = 0;
1412 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1413
1414 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1415 * report Channels. This increases the chances of the DUT to get a candidate AP while
1416 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1417 if (pMac->scan.occupiedChannels.numChannels)
1418 {
1419 csrNeighborRoamMergeChannelLists(pMac,
1420 &pMac->scan.occupiedChannels.channelList[0],
1421 pMac->scan.occupiedChannels.numChannels,
1422 inPtr,
1423 inNumChannels,
1424 &mergedOutputNumOfChannels);
1425 inNumChannels = mergedOutputNumOfChannels;
1426 }
1427
1428 if (eCSR_BAND_24 == eBand)
1429 {
1430 for (i = 0; i < inNumChannels; i++)
1431 {
1432 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1433 {
1434 ChannelList[outNumChannels++] = inPtr[i];
1435 }
1436 }
1437 }
1438 else if (eCSR_BAND_5G == eBand)
1439 {
1440 for (i = 0; i < inNumChannels; i++)
1441 {
1442 /* Add 5G Non-DFS channel */
1443 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1444 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1445 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1446 {
1447 ChannelList[outNumChannels++] = inPtr[i];
1448 }
1449 }
1450 }
1451 else if (eCSR_BAND_ALL == eBand)
1452 {
1453 for (i = 0; i < inNumChannels; i++)
1454 {
1455 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1456 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1457 {
1458 ChannelList[outNumChannels++] = inPtr[i];
1459 }
1460 }
1461 }
1462 else
1463 {
1464 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1465 "Invalid band, No operation carried out (Band %d)", eBand);
1466 return eHAL_STATUS_INVALID_PARAMETER;
1467 }
1468
1469 /* if roaming within band is enabled, then select only the
1470 in band channels .
1471 This is required only if the band capability is set to ALL,
1472 E.g., if band capability is only 2.4G then all the channels in the
1473 list are already filtered for 2.4G channels, hence ignore this check*/
1474
1475 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1476 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301477 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001478 pMac,
1479 ChannelList,
1480 outNumChannels,
1481 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301482 &outNumChannels,
1483 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301484 vos_mem_copy(ChannelList,
1485 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001486 }
1487
1488 /* Prepare final roam scan channel list */
1489 if(outNumChannels)
1490 {
1491 /* Clear the channel list first */
1492 if (NULL != currChannelListInfo->ChannelList)
1493 {
1494 vos_mem_free(currChannelListInfo->ChannelList);
1495 currChannelListInfo->ChannelList = NULL;
1496 currChannelListInfo->numOfChannels = 0;
1497 }
1498
1499 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1500 if (NULL == currChannelListInfo->ChannelList)
1501 {
1502 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1503 "Failed to allocate memory for roam scan channel list");
1504 currChannelListInfo->numOfChannels = 0;
1505 return VOS_STATUS_E_RESOURCES;
1506 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301507 vos_mem_copy(currChannelListInfo->ChannelList,
1508 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001509 }
1510 return status;
1511}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001512#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001513
Jeff Johnson295189b2012-06-20 16:38:30 -07001514eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1515{
1516 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1517 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1519 (eBand == eCSR_BAND_24))
1520 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001521 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001523 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001524 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 pMac->roam.configParam.uCfgDot11Mode, eBand);
1526 return eHAL_STATUS_INVALID_PARAMETER;
1527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1529 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1530 (eBand == eCSR_BAND_5G))
1531 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001532 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001534 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001535 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 pMac->roam.configParam.uCfgDot11Mode, eBand);
1537 return eHAL_STATUS_INVALID_PARAMETER;
1538 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001539 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001540 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001541 pMac->roam.configParam.eBand = eBand;
1542 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001544#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001545 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1546 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 status = csrInitGetChannels( pMac );
1549 if (eHAL_STATUS_SUCCESS == status)
1550 csrInitChannelList( hHal );
1551 return status;
1552}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001553
1554
Jeff Johnsone7245742012-09-05 17:12:55 -07001555/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1556 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1557 * Ideally we should have kept the ini value and enum value same and representing the same
1558 * cb values as in 11n standard i.e.
1559 * Set to 1 (SCA) if the secondary channel is above the primary channel
1560 * Set to 3 (SCB) if the secondary channel is below the primary channel
1561 * Set to 0 (SCN) if no secondary channel is present
1562 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1563 * 0 - secondary none
1564 * 1 - secondary LOW
1565 * 2 - secondary HIGH
1566 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1567 * The enum values are as follows:
1568 * PHY_SINGLE_CHANNEL_CENTERED = 0
1569 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1570 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1571 */
1572ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1573{
1574
1575 ePhyChanBondState phyCbState;
1576 switch (cbIniValue) {
1577 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301578 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001579 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1580 break;
1581 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301582 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001583 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1584 break;
1585 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301586 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001587 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1588 break;
1589#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301590 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1591 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001592 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301593 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001594 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1595 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301596 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1597 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1598 break;
1599 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001600 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1601 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301602 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001603 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301604 break;
1605 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001606 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1607 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301608 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001609 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301610 break;
1611#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 default:
1613 // If an invalid value is passed, disable CHANNEL BONDING
1614 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1615 break;
1616 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301617
Jeff Johnsone7245742012-09-05 17:12:55 -07001618 return phyCbState;
1619}
1620
1621v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1622{
1623
1624 v_U32_t cbIniValue;
1625 switch (phyCbState) {
1626 // secondary none
1627 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301628 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001629 break;
1630 // secondary LOW
1631 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301632 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001633 break;
1634 // secondary HIGH
1635 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301636 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 break;
1638#ifdef WLAN_FEATURE_11AC
1639 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301640 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001641 break;
1642 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301643 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 break;
1645 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301646 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 break;
1648 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301649 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001650 break;
1651 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301652 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001653 break;
1654 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301655 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001656 break;
1657 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301658 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001659 break;
1660#endif
1661 default:
1662 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301663 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001664 break;
1665 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301666
Jeff Johnsone7245742012-09-05 17:12:55 -07001667 return cbIniValue;
1668}
Jeff Johnson295189b2012-06-20 16:38:30 -07001669
1670eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1671{
1672 eHalStatus status = eHAL_STATUS_SUCCESS;
1673
1674 if(pParam)
1675 {
1676 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1677 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1678 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1679 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1680 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1681 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1682
1683 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001684 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1685
Jeff Johnsone7245742012-09-05 17:12:55 -07001686 /* channelBondingMode5GHz plays a dual role right now
1687 * 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
1688 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1689 */
1690 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001692 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001693 }
1694 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1695 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001697 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001698 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301699#ifdef WLAN_FEATURE_AP_HT40_24G
1700 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1701#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001702 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1704 pMac->roam.configParam.phyMode = pParam->phyMode;
1705 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1706 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1707 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1708 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1709 pMac->roam.configParam.TxRate = pParam->TxRate;
1710 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1711 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1712 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1713 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1714 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001715 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 //if HDD passed down non zero values then only update,
1717 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301718 if (pParam->nInitialDwellTime)
1719 {
1720 pMac->roam.configParam.nInitialDwellTime =
1721 pParam->nInitialDwellTime;
1722 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001723 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 {
1725 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301726 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1727 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001729 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 {
1731 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301732 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1733 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001735 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 {
1737 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301738 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1739 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001741 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 {
1743 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301744 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1745 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301747 if (pParam->nOBSSScanWidthTriggerInterval)
1748 {
1749 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1750 pParam->nOBSSScanWidthTriggerInterval;
1751 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1752 pParam->nOBSSScanWidthTriggerInterval);
1753 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001754 if (pParam->nActiveMaxChnTimeBtc)
1755 {
1756 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1757 }
1758 if (pParam->nActiveMinChnTimeBtc)
1759 {
1760 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1761 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001762#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001763 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001764 {
1765 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1766 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001767 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001768 {
1769 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1770 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001771 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001772 {
1773 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1774 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001775 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001776 {
1777 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1778 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001779 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001780 {
1781 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1782 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001783 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001784 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001785 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1786 }
1787 if (pParam->nNumP2PChanCombinedConc)
1788 {
1789 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001790 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001793 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 {
1795 //Change the unit from second to microsecond
1796 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1798 {
1799 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1800 }
1801 else
1802 {
1803 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1804 }
1805 }
1806 else
1807 {
1808 pMac->roam.configParam.impsSleepTime = 0;
1809 }
1810 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1812 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 //if HDD passed down non zero values for age params, then only update,
1814 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001815 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 {
1817 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 if(pParam->scanAgeTimeNCNPS)
1820 {
1821 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 if(pParam->scanAgeTimeNCPS)
1824 {
1825 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 if(pParam->scanAgeTimeCNPS)
1828 {
1829 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1830 }
1831 if(pParam->scanAgeTimeCPS)
1832 {
1833 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1834 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301835 if (pParam->initialScanSkipDFSCh)
1836 {
1837 pMac->roam.configParam.initialScanSkipDFSCh =
1838 pParam->initialScanSkipDFSCh;
1839 }
1840
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001841 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1843 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1844 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1845 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1846 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1848 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1850 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1851 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1852 //Assign this before calling CsrInit11dInfo
1853 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 if( csrIs11dSupported( pMac ) )
1855 {
1856 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1857 }
1858 else
1859 {
1860 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1861 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001862
1863 /* Initialize the power + channel information if 11h is enabled.
1864 If 11d is enabled this information has already been initialized */
1865 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1866 {
1867 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1868 }
1869
1870
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301871#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301872 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1873 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001874 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001875#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001876#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001878 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001879 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001880 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001881 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001882 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001883 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001884 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001885 pMac->roam.configParam.nProbes = pParam->nProbes;
1886 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001887#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001888#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1889 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001890 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001891#endif
1892#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001893 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001894 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001895#endif
1896
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001897#ifdef FEATURE_WLAN_ESE
1898 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001899#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001900#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301901 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1902 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001903 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1904 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1905 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1906 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1907 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1908 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1909 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1910 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301911 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 {
1913 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001914 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 -07001915 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1916 {
1917 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 }
1920#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1922 pMac->scan.fValidateList = pParam->fValidateList;
1923 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1924 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001925 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001927 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301928 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001929 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1930 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1931 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1932 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1933 * single session
1934 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001935 //Remove this code once SLM_Sessionization is supported
1936 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001937 pMac->roam.configParam.doBMPSWorkaround = 0;
1938
Jeff Johnsone7245742012-09-05 17:12:55 -07001939#ifdef WLAN_FEATURE_11AC
1940 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001941 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001942 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001943 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301944 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1945 if ( pParam->enableTxBF )
1946 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1947 else
1948 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001949#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001950 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001951
1952 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001953 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05301954 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05301955 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
krunal sonie9002db2013-11-25 14:24:17 -08001956 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1957 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301958 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301959 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301960#ifdef WLAN_FEATURE_AP_HT40_24G
1961 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
1962#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05301963 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 }
1965
1966 return status;
1967}
1968
Jeff Johnson295189b2012-06-20 16:38:30 -07001969eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1970{
1971 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 if(pParam)
1973 {
1974 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1975 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1976 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1977 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1978 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1979 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001980 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301981#ifdef WLAN_FEATURE_AP_HT40_24G
1982 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
1983#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001984 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1986 pParam->phyMode = pMac->roam.configParam.phyMode;
1987 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1988 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1989 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1990 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1991 pParam->TxRate = pMac->roam.configParam.TxRate;
1992 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1993 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1994 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1995 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1996 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1998 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1999 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2000 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002001 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
2002 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
2003 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002004#ifdef WLAN_AP_STA_CONCURRENCY
2005 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2006 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2007 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2008 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2009 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002010 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2011 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002012#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 //Change the unit from microsecond to second
2014 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2015 pParam->eBand = pMac->roam.configParam.eBand;
2016 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2017 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2018 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2019 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2020 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2021 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2022 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2023 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2024 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2025 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2026 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2027 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2028 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2030 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2031 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2032 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2034 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2035 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2036 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
2037 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002038 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002039 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002040 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002041 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302042 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002043#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302044 vos_mem_copy(&pParam->neighborRoamConfig,
2045 &pMac->roam.configParam.neighborRoamConfig,
2046 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002047#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002048#ifdef WLAN_FEATURE_11AC
2049 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002050 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002051 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002052 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302053 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2054 if ( pParam->enableTxBF )
2055 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2056 else
2057 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002058#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002059#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302060 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2061 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002062#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002063#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002064 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2065 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2066 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2067 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2068 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002069 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002070 pParam->nProbes = pMac->roam.configParam.nProbes;
2071 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002072#endif
2073#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2074 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2075 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
2076#endif
2077#ifdef FEATURE_WLAN_LFR
2078 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2079#endif
2080
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002081#ifdef FEATURE_WLAN_ESE
2082 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002083#endif
2084#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302085 vos_mem_copy(&pParam->neighborRoamConfig,
2086 &pMac->roam.configParam.neighborRoamConfig,
2087 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002088 {
2089 int i;
2090 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2091 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2092 {
2093 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2094 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002095 }
2096#endif
2097
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002098 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002099
krunal soni5afa96c2013-09-06 22:19:02 -07002100 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002101 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302102 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302103 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
krunal soni5afa96c2013-09-06 22:19:02 -07002104
krunal sonie9002db2013-11-25 14:24:17 -08002105 pParam->isCoalesingInIBSSAllowed =
2106 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302107 pParam->allowDFSChannelRoam =
2108 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302109 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302111#ifdef WLAN_FEATURE_AP_HT40_24G
2112 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2113#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002114
2115 status = eHAL_STATUS_SUCCESS;
2116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 return (status);
2118}
2119
Jeff Johnson295189b2012-06-20 16:38:30 -07002120eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2121{
2122 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2123 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2124 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2125 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 do
2127 {
2128 if(eCSR_BAND_24 == eBand)
2129 {
2130 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2131 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2132 }
2133 if(eCSR_BAND_5G == eBand)
2134 {
2135 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2136 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2137 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2138 )
2139 {
2140 break;
2141 }
2142 }
2143 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2144 {
2145 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2146 }
2147 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2148 {
2149 newPhyMode = eCSR_DOT11_MODE_AUTO;
2150 }
2151 else
2152 {
2153 //Check for dual band and higher capability first
2154 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2155 {
2156 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2157 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2158 }
2159 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2160 {
2161 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2162 if(eCSR_BAND_24 == eBand) break;
2163 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2164 eBand = eCSR_BAND_5G;
2165 }
2166 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2167 {
2168 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2169 if(eCSR_BAND_5G == eBand) break;
2170 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2171 eBand = eCSR_BAND_24;
2172 }
2173 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2174 {
2175 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2176 if(eCSR_BAND_5G == eBand) break;
2177 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2178 eBand = eCSR_BAND_24;
2179 }
2180 else if(eCSR_DOT11_MODE_11n & phyMode)
2181 {
2182 newPhyMode = eCSR_DOT11_MODE_11n;
2183 }
2184 else if(eCSR_DOT11_MODE_abg & phyMode)
2185 {
2186 newPhyMode = eCSR_DOT11_MODE_abg;
2187 }
2188 else if(eCSR_DOT11_MODE_11a & phyMode)
2189 {
2190 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2191 {
2192 if(eCSR_BAND_ALL == eBand)
2193 {
2194 newPhyMode = eCSR_DOT11_MODE_abg;
2195 }
2196 else
2197 {
2198 //bad setting
2199 break;
2200 }
2201 }
2202 else
2203 {
2204 newPhyMode = eCSR_DOT11_MODE_11a;
2205 eBand = eCSR_BAND_5G;
2206 }
2207 }
2208 else if(eCSR_DOT11_MODE_11g & phyMode)
2209 {
2210 newPhyMode = eCSR_DOT11_MODE_11g;
2211 eBand = eCSR_BAND_24;
2212 }
2213 else if(eCSR_DOT11_MODE_11b & phyMode)
2214 {
2215 newPhyMode = eCSR_DOT11_MODE_11b;
2216 eBand = eCSR_BAND_24;
2217 }
2218 else
2219 {
2220 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002221 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 newPhyMode = eCSR_DOT11_MODE_AUTO;
2223 }
2224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 //Done validating
2226 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 //Now we need to check whether a restart is needed.
2228 if(eBand != pMac->roam.configParam.eBand)
2229 {
2230 fRestartNeeded = eANI_BOOLEAN_TRUE;
2231 break;
2232 }
2233 if(newPhyMode != pMac->roam.configParam.phyMode)
2234 {
2235 fRestartNeeded = eANI_BOOLEAN_TRUE;
2236 break;
2237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 if(HAL_STATUS_SUCCESS(status))
2240 {
2241 pMac->roam.configParam.eBand = eBand;
2242 pMac->roam.configParam.phyMode = newPhyMode;
2243 if(pfRestartNeeded)
2244 {
2245 *pfRestartNeeded = fRestartNeeded;
2246 }
2247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 return (status);
2249}
2250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2252{
2253 tANI_U8 Index;
2254 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 // for dual band NICs, don't need to trim the channel list....
2256 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2257 {
2258 // 2.4 GHz band operation requires the channel list to be trimmed to
2259 // the 2.4 GHz channels only...
2260 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2261 {
2262 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2263 Index++ )
2264 {
2265 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2266 {
2267 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2268 cChannels++;
2269 }
2270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2272 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2273 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2274 // only if we need to.
2275 //
2276 // The amount of memory to clear is the number of channesl that we trimmed
2277 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2278
2279 if ( pChannelList->numChannels > cChannels )
2280 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302281 vos_mem_set(&pChannelList->channelList[ cChannels ],
2282 sizeof( pChannelList->channelList[ 0 ] ) *
2283 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 }
2285
2286 pChannelList->numChannels = cChannels;
2287 }
2288 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2289 {
2290 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2291 {
2292 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2293 {
2294 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2295 cChannels++;
2296 }
2297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2299 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2300 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2301 // only if we need to.
2302 //
2303 // The amount of memory to clear is the number of channesl that we trimmed
2304 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2305 if ( pChannelList->numChannels > cChannels )
2306 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302307 vos_mem_set(&pChannelList->channelList[ cChannels ],
2308 sizeof( pChannelList->channelList[ 0 ] ) *
2309 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 }
2311
2312 pChannelList->numChannels = cChannels;
2313 }
2314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002315}
Jeff Johnson295189b2012-06-20 16:38:30 -07002316#define INFRA_AP_DEFAULT_CHANNEL 6
2317eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2318{
2319 tANI_U8 index= 0;
2320 eHalStatus status = eHAL_STATUS_FAILURE;
2321 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2322 {
2323 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2324 status = eHAL_STATUS_SUCCESS;
2325 break;
2326 }
2327 }
2328 return status;
2329}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002330
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002331
Jeff Johnson295189b2012-06-20 16:38:30 -07002332eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2333{
2334 eHalStatus status = eHAL_STATUS_SUCCESS;
2335 tANI_U8 num20MHzChannelsFound = 0;
2336 VOS_STATUS vosStatus;
2337 tANI_U8 Index = 0;
2338 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002339
Jeff Johnson295189b2012-06-20 16:38:30 -07002340
2341 //TODO: this interface changed to include the 40MHz channel list
2342 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2343 // Read the scan channel list (including the power limit) from EEPROM
2344 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2345 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2346 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002348 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 status = eHAL_STATUS_FAILURE;
2350 }
2351 else
2352 {
2353 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2354 {
2355 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2356 }
2357 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2358 // Move the channel list to the global data
2359 // structure -- this will be used as the scan list
2360 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2361 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 }
2364 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2365 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2366 {
2367 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2368 }
2369 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2370 {
2371 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2372 }
2373 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 return (status);
2376}
Jeff Johnson295189b2012-06-20 16:38:30 -07002377eHalStatus csrInitChannelList( tHalHandle hHal )
2378{
2379 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2380 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2382 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002383 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2384 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002386 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302387 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 return (status);
2389}
Jeff Johnson295189b2012-06-20 16:38:30 -07002390eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2391 tCsrUpdateConfigParam *pUpdateConfigParam)
2392{
2393 eHalStatus status = eHAL_STATUS_FAILURE;
2394 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2396 status = CsrInit11dInfo(pMac, ps11dinfo);
2397 return status;
2398}
2399
Jeff Johnson295189b2012-06-20 16:38:30 -07002400static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2401{
2402 eHalStatus status = eHAL_STATUS_FAILURE;
2403 tANI_U8 index;
2404 tANI_U32 count=0;
2405 tSirMacChanInfo *pChanInfo;
2406 tSirMacChanInfo *pChanInfoStart;
2407 tANI_BOOLEAN applyConfig = TRUE;
2408
Mihir Shetebc866f62014-02-13 16:08:53 +05302409 pMac->scan.currentCountryRSSI = -128;
2410
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 if(!ps11dinfo)
2412 {
2413 return (status);
2414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2416 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302417 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2418 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2419 ps11dinfo->Channels.channelList,
2420 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 }
2422 else
2423 {
2424 //No change
2425 return (eHAL_STATUS_SUCCESS);
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302428
2429 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2430 WNI_CFG_COUNTRY_CODE_LEN);
2431
2432
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 //Tush: at csropen get this initialized with default, during csr reset if this
2434 // already set with some value no need initilaize with default again
2435 if(0 == pMac->scan.countryCodeCurrent[0])
2436 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302437 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2438 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302441 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2442 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302444 vos_mem_set(pChanInfo,
2445 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2446 0);
2447
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002449 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2450 {
2451 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2452 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2453 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2454 pChanInfo++;
2455 count++;
2456 }
2457 if(count)
2458 {
2459 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2460 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302461 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002462 }
2463 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2464 if( HAL_STATUS_SUCCESS(status) )
2465 {
2466 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2467 {
2468 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2469 {
2470 applyConfig = FALSE;
2471 }
2472 }
2473
2474 if(TRUE == applyConfig)
2475 {
2476 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002477 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002478 }
2479
2480 }
2481 return (status);
2482}
2483/* Initialize the Channel + Power List in the local cache and in the CFG */
2484eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2485{
2486 tANI_U8 index;
2487 tANI_U32 count=0;
2488 tSirMacChanInfo *pChanInfo;
2489 tSirMacChanInfo *pChanInfoStart;
2490
2491 if(!ps11dinfo || !pMac)
2492 {
2493 return eHAL_STATUS_FAILURE;
2494 }
2495
Kiet Lam64c1b492013-07-12 13:56:44 +05302496 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2497 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002498 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302499 vos_mem_set(pChanInfo,
2500 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2501 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002502 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002503
2504 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2505 {
2506 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2507 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2508 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2509 pChanInfo++;
2510 count++;
2511 }
2512 if(count)
2513 {
2514 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2515 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302516 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 }
2518
Jeff Johnsone7245742012-09-05 17:12:55 -07002519 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002520}
2521
2522//pCommand may be NULL
2523//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2524void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2525{
2526 tListElem *pEntry, *pNextEntry;
2527 tSmeCmd *pDupCommand;
2528 tDblLinkList localList;
2529
2530 vos_mem_zero(&localList, sizeof(tDblLinkList));
2531 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2532 {
2533 smsLog(pMac, LOGE, FL(" failed to open list"));
2534 return;
2535 }
2536 csrLLLock( &pMac->sme.smeCmdPendingList );
2537 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2538 while( pEntry )
2539 {
2540 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2541 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 // Remove the previous command if..
2543 // - the new roam command is for the same RoamReason...
2544 // - the new roam command is a NewProfileList.
2545 // - the new roam command is a Forced Dissoc
2546 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2547 if (
2548 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2549 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002550 /* This peermac check is requried for Softap/GO scenarios
2551 * For STA scenario below OR check will suffice as pCommand will
2552 * always be NULL for STA scenarios
2553 */
2554 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2556 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2557 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2558 ||
2559 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002560 ( (sessionId == pDupCommand->sessionId) &&
2561 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 ((eCsrForcedDisassoc == eRoamReason) ||
2563 (eCsrHddIssued == eRoamReason))
2564 )
2565 )
2566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002567 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 // Remove the 'stale' roam command from the pending list...
2569 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2570 {
2571 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2572 }
2573 }
2574 pEntry = pNextEntry;
2575 }
2576 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2577
2578 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2579 {
2580 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2581 //Tell caller that the command is cancelled
2582 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2583 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2584 csrReleaseCommandRoam(pMac, pDupCommand);
2585 }
2586 csrLLClose(&localList);
2587}
Jeff Johnson295189b2012-06-20 16:38:30 -07002588eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2589 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2590{
2591 eHalStatus status = eHAL_STATUS_SUCCESS;
2592#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2593 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2594#endif
2595 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2597 {
2598 pSession = CSR_GET_SESSION( pMac, sessionId );
2599 }
2600 else
2601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002602 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 VOS_ASSERT(0);
2604 return eHAL_STATUS_FAILURE;
2605 }
krunal soni587bf012014-02-04 12:35:11 -08002606
2607 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2608 {
2609 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2610 return eHAL_STATUS_FAILURE;
2611 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002612
krunal soni587bf012014-02-04 12:35:11 -08002613 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2614
krunal soni7f7d2c92014-02-06 15:08:43 -08002615 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002617 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002619 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2620 /*
2621 * Decrement bRefAssocStartCnt for FT reassoc failure.
2622 * Reason: For FT reassoc failures, we first call
2623 * csrRoamCallCallback before notifying a failed roam
2624 * completion through csrRoamComplete. The latter in
2625 * turn calls csrRoamProcessResults which tries to
2626 * once again call csrRoamCallCallback if bRefAssocStartCnt
2627 * is non-zero. Since this is redundant for FT reassoc
2628 * failure, decrement bRefAssocStartCnt.
2629 */
2630 pSession->bRefAssocStartCnt--;
2631 }
2632
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 if(NULL != pSession->callback)
2634 {
2635 if( pRoamInfo )
2636 {
2637 pRoamInfo->sessionId = (tANI_U8)sessionId;
2638 }
2639
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302640 /* avoid holding the global lock when making the roaming callback, original change came
2641 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2642 is possible on other OS ports where the callback may need to take locks to protect
2643 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2645 that may actually depend on the lock being held */
2646 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2647 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2648 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2649 }
2650 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2651 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2652#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302653 vos_mem_set(&connectionStatus,
2654 sizeof(vos_event_wlan_status_payload_type), 0);
2655
krunal soni7f7d2c92014-02-06 15:08:43 -08002656 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 {
2658 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2659 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2660 if(NULL != pRoamInfo->pBssDesc)
2661 {
2662 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2663 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2666 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2667 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302668 vos_mem_copy(connectionStatus.ssid,
2669 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2670
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2672 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2675 {
2676 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2677 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2678 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 if(eCSR_ROAM_RESULT_FORCED == u2)
2681 {
2682 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2683 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2684 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2687 {
2688 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2689 connectionStatus.reason = eCSR_REASON_DISASSOC;
2690 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2693 {
2694 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2695 connectionStatus.reason = eCSR_REASON_DEAUTH;
2696 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002698#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2699
2700 return (status);
2701}
Jeff Johnson295189b2012-06-20 16:38:30 -07002702// Returns whether handoff is currently in progress or not
2703tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2704{
2705#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2706 return csrNeighborRoamIsHandoffInProgress(pMac);
2707#else
2708 return eANI_BOOLEAN_FALSE;
2709#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002710}
Jeff Johnson295189b2012-06-20 16:38:30 -07002711eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2712 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2713{
2714 eHalStatus status = eHAL_STATUS_SUCCESS;
2715 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2716 tANI_U16 reasonCode;
2717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002718
2719 if(!pSession)
2720 {
2721 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2722 return eHAL_STATUS_FAILURE;
2723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002724
2725 //Restore AC weight in case we change it
2726 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2727 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002728 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 -07002729 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2730 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2731 }
2732
2733 if ( fMICFailure )
2734 {
2735 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2736 }
2737 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2738 {
2739 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002740 }
2741 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 {
2743 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002745#ifdef WLAN_FEATURE_VOWIFI_11R
2746 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2747 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2748 {
2749 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302750 vos_mem_copy(&bssId,
2751 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2752 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002753 }
2754 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002755#endif
2756 if(pSession->pConnectBssDesc)
2757 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302758 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002760
Jeff Johnson295189b2012-06-20 16:38:30 -07002761
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302762 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2763 " subState = %s reason=%d"),
2764 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2765 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002766
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2768
2769 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2770
2771 if(HAL_STATUS_SUCCESS(status))
2772 {
2773 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2775 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2776 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2777 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002778 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2780 }
2781#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002782 }
2783 else
2784 {
2785 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2786 }
2787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 return (status);
2789}
Jeff Johnson295189b2012-06-20 16:38:30 -07002790
Jeff Johnson295189b2012-06-20 16:38:30 -07002791/* ---------------------------------------------------------------------------
2792 \fn csrRoamIssueDisassociateStaCmd
2793 \brief csr function that HDD calls to disassociate a associated station
2794 \param sessionId - session Id for Soft AP
2795 \param pPeerMacAddr - MAC of associated station to delete
2796 \param reason - reason code, be one of the tSirMacReasonCodes
2797 \return eHalStatus
2798 ---------------------------------------------------------------------------*/
2799eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05302800 tANI_U32 sessionId,
2801#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2802 const tANI_U8 *pPeerMacAddr,
2803#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05302805#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 tANI_U32 reason)
2807{
2808 eHalStatus status = eHAL_STATUS_SUCCESS;
2809 tSmeCmd *pCommand;
2810
2811 do
2812 {
2813 pCommand = csrGetCommandBuffer( pMac );
2814 if ( !pCommand )
2815 {
2816 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2817 status = eHAL_STATUS_RESOURCES;
2818 break;
2819 }
2820 pCommand->command = eSmeCommandRoam;
2821 pCommand->sessionId = (tANI_U8)sessionId;
2822 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2823 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2824 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2825 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2826 if( !HAL_STATUS_SUCCESS( status ) )
2827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002828 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 csrReleaseCommandRoam( pMac, pCommand );
2830 }
2831 }while(0);
2832
2833 return status;
2834}
2835
2836
Jeff Johnson295189b2012-06-20 16:38:30 -07002837/* ---------------------------------------------------------------------------
2838 \fn csrRoamIssueDeauthSta
2839 \brief csr function that HDD calls to delete a associated station
2840 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302841 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 \return eHalStatus
2843 ---------------------------------------------------------------------------*/
2844eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302845 tANI_U32 sessionId,
2846 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002847{
2848 eHalStatus status = eHAL_STATUS_SUCCESS;
2849 tSmeCmd *pCommand;
2850
2851 do
2852 {
2853 pCommand = csrGetCommandBuffer( pMac );
2854 if ( !pCommand )
2855 {
2856 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2857 status = eHAL_STATUS_RESOURCES;
2858 break;
2859 }
2860 pCommand->command = eSmeCommandRoam;
2861 pCommand->sessionId = (tANI_U8)sessionId;
2862 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302863 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2864 sizeof(tSirMacAddr));
2865 pCommand->u.roamCmd.reason =
2866 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2868 if( !HAL_STATUS_SUCCESS( status ) )
2869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002870 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 csrReleaseCommandRoam( pMac, pCommand );
2872 }
2873 }while(0);
2874
2875 return status;
2876}
Jeff Johnson295189b2012-06-20 16:38:30 -07002877eHalStatus
2878csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2879 tANI_BOOLEAN bEnable )
2880{
2881 eHalStatus status = eHAL_STATUS_FAILURE;
2882 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2883 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 if (!pSession)
2885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002886 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 return (status);
2888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 if (pSession->pConnectBssDesc)
2890 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302891 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 }
2893 else
2894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002895 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 return (status);
2897 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002898 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2899 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2901 return (status);
2902}
Jeff Johnson295189b2012-06-20 16:38:30 -07002903eHalStatus
2904csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2905 VOS_MODULE_ID modId, void *pUsrContext,
2906 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2907{
2908 eHalStatus status = eHAL_STATUS_SUCCESS;
2909 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2910 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 if (!pSession)
2912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002913 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 return (status);
2915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 if(pSession->pConnectBssDesc)
2917 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302918 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 }
2920 else
2921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002922 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 return (status);
2924 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002925 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2926 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2928 return (status);
2929}
Jeff Johnson295189b2012-06-20 16:38:30 -07002930eHalStatus
2931csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2932 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2933{
2934 eHalStatus status = eHAL_STATUS_SUCCESS;
2935 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2936 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2937
2938 if (!pSession)
2939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002940 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 return (status);
2942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 if(pSession->pConnectBssDesc)
2944 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302945 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 }
2947 else
2948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002949 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 return (status);
2951 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002952 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2953 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002954
2955 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2956
2957 return (status);
2958}
Jeff Johnson295189b2012-06-20 16:38:30 -07002959eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2960{
2961 eHalStatus status = eHAL_STATUS_SUCCESS;
2962 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2963 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002964
2965 if (!pSession)
2966 {
2967 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2968 return eHAL_STATUS_FAILURE;
2969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
2971 if(pSession->pConnectBssDesc)
2972 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302973 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002975 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2976 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2978
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302979 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302980 if(HAL_STATUS_SUCCESS(status))
2981 {
2982 csrRoamLinkDown(pMac, sessionId);
2983 }
2984 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002985 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302986 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2987 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002988 }
2989
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 return (status);
2991}
2992
Jeff Johnson295189b2012-06-20 16:38:30 -07002993eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2994{
2995 eHalStatus status = eHAL_STATUS_SUCCESS;
2996 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2997 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002998
2999 if(!pSession)
3000 {
3001 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3002 return eHAL_STATUS_FAILURE;
3003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003004
3005 // If no BSS description was found in this connection (happens with start IBSS), then
3006 // nix the BSS description that we keep around for the connected BSS) and get out...
3007 if(NULL == pBssDesc)
3008 {
3009 csrFreeConnectBssDesc(pMac, sessionId);
3010 }
3011 else
3012 {
3013 size = pBssDesc->length + sizeof( pBssDesc->length );
3014 if(NULL != pSession->pConnectBssDesc)
3015 {
3016 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3017 {
3018 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3019 csrFreeConnectBssDesc(pMac, sessionId);
3020 }
3021 }
3022 if(NULL == pSession->pConnectBssDesc)
3023 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303024 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303026 if (NULL == pSession->pConnectBssDesc)
3027 status = eHAL_STATUS_FAILURE;
3028 else
3029 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 return (status);
3032}
3033
Jeff Johnson295189b2012-06-20 16:38:30 -07003034eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3035 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3036 tDot11fBeaconIEs *pIes)
3037{
3038 eHalStatus status = eHAL_STATUS_SUCCESS;
3039 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303041 if (pIes == NULL)
3042 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003043
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 do
3045 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303046 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3047 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 //get qos
3049 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3050 //get SSID
3051 if(pIes->SSID.present)
3052 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303053 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3055 }
3056 else
3057 pBssConfig->SSID.length = 0;
3058 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003060 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 //Return failed if profile doesn't have an SSID either.
3062 if(pProfile->SSIDs.numOfSSIDs == 0)
3063 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003064 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 status = eHAL_STATUS_FAILURE;
3066 break;
3067 }
3068 }
3069 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3070 {
3071 pBssConfig->eBand = eCSR_BAND_5G;
3072 }
3073 else
3074 {
3075 pBssConfig->eBand = eCSR_BAND_24;
3076 }
3077 //phymode
3078 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3079 {
3080 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3081 }
3082 else
3083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003084 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 //force it
3086 if(eCSR_BAND_24 == pBssConfig->eBand)
3087 {
3088 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3089 }
3090 else
3091 {
3092 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3093 }
3094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 //Qos
3096 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3097 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3098 {
3099 //Joining BSS is not 11n capable and WMM is disabled on client.
3100 //Disable QoS and WMM
3101 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3102 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303103
3104 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303105 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303106 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3107 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3108 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3109 {
3110 //Joining BSS is 11n capable and WMM is disabled on AP.
3111 //Assume all HT AP's are QOS AP's and enable WMM
3112 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3113 }
3114
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 //auth type
3116 switch( pProfile->negotiatedAuthType )
3117 {
3118 default:
3119 case eCSR_AUTH_TYPE_WPA:
3120 case eCSR_AUTH_TYPE_WPA_PSK:
3121 case eCSR_AUTH_TYPE_WPA_NONE:
3122 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3123 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3124 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 case eCSR_AUTH_TYPE_SHARED_KEY:
3126 pBssConfig->authType = eSIR_SHARED_KEY;
3127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 case eCSR_AUTH_TYPE_AUTOSWITCH:
3129 pBssConfig->authType = eSIR_AUTO_SWITCH;
3130 break;
3131 }
3132 //short slot time
3133 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3134 {
3135 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3136 }
3137 else
3138 {
3139 pBssConfig->uShortSlotTime = 0;
3140 }
3141 if(pBssConfig->BssCap.ibss)
3142 {
3143 //We don't support 11h on IBSS
3144 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3145 }
3146 else
3147 {
3148 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3149 }
3150 //power constraint
3151 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3152 //heartbeat
3153 if ( CSR_IS_11A_BSS( pBssDesc ) )
3154 {
3155 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3156 }
3157 else
3158 {
3159 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3160 }
3161 //Join timeout
3162 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003163 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 if ( pBssDesc->beaconInterval )
3165 {
3166 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003167 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 }
3169 else
3170 {
3171 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3172 }
3173 //validate CB
3174 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303175 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3176 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 return (status);
3179}
3180
Jeff Johnson295189b2012-06-20 16:38:30 -07003181static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3182 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3183{
3184 eHalStatus status = eHAL_STATUS_SUCCESS;
3185 tANI_U8 operationChannel = 0;
3186 tANI_U8 qAPisEnabled = FALSE;
3187 //SSID
3188 pBssConfig->SSID.length = 0;
3189 if(pProfile->SSIDs.numOfSSIDs)
3190 {
3191 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303192 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3193 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 }
3195 else
3196 {
3197 //SSID must present
3198 return eHAL_STATUS_FAILURE;
3199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 //Settomg up the capabilities
3201 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3202 {
3203 pBssConfig->BssCap.ibss = 1;
3204 }
3205 else
3206 {
3207 pBssConfig->BssCap.ess = 1;
3208 }
3209 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3210 {
3211 pBssConfig->BssCap.privacy = 1;
3212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 pBssConfig->eBand = pMac->roam.configParam.eBand;
3214 //phymode
3215 if(pProfile->ChannelInfo.ChannelList)
3216 {
3217 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3220 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 //QOS
3222 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 if ( pBssConfig->BssCap.ess == 1 )
3224 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 /*For Softap case enable WMM*/
3226 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3227 qAPisEnabled = TRUE;
3228 }
3229 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3231 qAPisEnabled = TRUE;
3232 } else {
3233 qAPisEnabled = FALSE;
3234 }
3235 } else {
3236 qAPisEnabled = TRUE;
3237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3239 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3240 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3241 )
3242 {
3243 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3244 } else {
3245 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3246 }
3247
3248 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003249 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 {
3251 default:
3252 case eCSR_AUTH_TYPE_WPA:
3253 case eCSR_AUTH_TYPE_WPA_PSK:
3254 case eCSR_AUTH_TYPE_WPA_NONE:
3255 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3256 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3257 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 case eCSR_AUTH_TYPE_SHARED_KEY:
3259 pBssConfig->authType = eSIR_SHARED_KEY;
3260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 case eCSR_AUTH_TYPE_AUTOSWITCH:
3262 pBssConfig->authType = eSIR_AUTO_SWITCH;
3263 break;
3264 }
3265 //short slot time
3266 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3267 {
3268 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3269 }
3270 else
3271 {
3272 pBssConfig->uShortSlotTime = 0;
3273 }
3274 //power constraint. We don't support 11h on IBSS
3275 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3276 pBssConfig->uPowerLimit = 0;
3277 //heartbeat
3278 if ( eCSR_BAND_5G == pBssConfig->eBand )
3279 {
3280 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3281 }
3282 else
3283 {
3284 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3285 }
3286 //Join timeout
3287 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003288
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 return (status);
3290}
Jeff Johnson295189b2012-06-20 16:38:30 -07003291static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3292{
3293 eHalStatus status = eHAL_STATUS_FAILURE;
3294 tDot11fBeaconIEs *pIes = NULL;
3295
3296 do
3297 {
3298 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3299 {
3300 //err msg
3301 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003302 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 break;
3304 }
3305 //check if the AP is QAP & it supports APSD
3306 if( CSR_IS_QOS_BSS(pIes) )
3307 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303308 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 }
3310 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303311
3312 if (NULL != pIes)
3313 {
3314 vos_mem_free(pIes);
3315 }
3316
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 return status;
3318}
3319
Jeff Johnson295189b2012-06-20 16:38:30 -07003320void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3321{
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3323 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3324 // See !!Note: below in this function...
3325 tANI_U32 PrivacyEnabled = 0;
3326 tANI_U32 RsnEnabled = 0;
3327 tANI_U32 WepDefaultKeyId = 0;
3328 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3329 tANI_U32 Key0Length = 0;
3330 tANI_U32 Key1Length = 0;
3331 tANI_U32 Key2Length = 0;
3332 tANI_U32 Key3Length = 0;
3333
3334 // Reserve for the biggest key
3335 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3336 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3337 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3338 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3339
3340 switch ( pProfile->negotiatedUCEncryptionType )
3341 {
3342 case eCSR_ENCRYPT_TYPE_NONE:
3343
3344 // for NO encryption, turn off Privacy and Rsn.
3345 PrivacyEnabled = 0;
3346 RsnEnabled = 0;
3347
3348 // WEP key length and Wep Default Key ID don't matter in this case....
3349
3350 // clear out the WEP keys that may be hanging around.
3351 Key0Length = 0;
3352 Key1Length = 0;
3353 Key2Length = 0;
3354 Key3Length = 0;
3355
3356 break;
3357
3358 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303359 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003360
3361 // Privacy is ON. NO RSN for Wep40 static key.
3362 PrivacyEnabled = 1;
3363 RsnEnabled = 0;
3364
3365 // Set the Wep default key ID.
3366 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 // Wep key size if 5 bytes (40 bits).
3368 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3369
3370 // set encryption keys in the CFG database or clear those that are not present in this profile.
3371 if ( pProfile->Keys.KeyLength[0] )
3372 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303373 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3374 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3376 }
3377 else
3378 {
3379 Key0Length = 0;
3380 }
3381
3382 if ( pProfile->Keys.KeyLength[1] )
3383 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303384 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3385 WNI_CFG_WEP_KEY_LENGTH_5);
3386 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 }
3388 else
3389 {
3390 Key1Length = 0;
3391 }
3392
3393 if ( pProfile->Keys.KeyLength[2] )
3394 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303395 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3396 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3398 }
3399 else
3400 {
3401 Key2Length = 0;
3402 }
3403
3404 if ( pProfile->Keys.KeyLength[3] )
3405 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303406 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3407 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3409 }
3410 else
3411 {
3412 Key3Length = 0;
3413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 break;
3415
3416 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303417 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003418
3419 // Privacy is ON. NO RSN for Wep40 static key.
3420 PrivacyEnabled = 1;
3421 RsnEnabled = 0;
3422
3423 // Set the Wep default key ID.
3424 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3425
3426 // Wep key size if 13 bytes (104 bits).
3427 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3428
3429 // set encryption keys in the CFG database or clear those that are not present in this profile.
3430 if ( pProfile->Keys.KeyLength[0] )
3431 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303432 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3433 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3435 }
3436 else
3437 {
3438 Key0Length = 0;
3439 }
3440
3441 if ( pProfile->Keys.KeyLength[1] )
3442 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303443 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3444 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3446 }
3447 else
3448 {
3449 Key1Length = 0;
3450 }
3451
3452 if ( pProfile->Keys.KeyLength[2] )
3453 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303454 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3455 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3457 }
3458 else
3459 {
3460 Key2Length = 0;
3461 }
3462
3463 if ( pProfile->Keys.KeyLength[3] )
3464 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303465 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3466 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3468 }
3469 else
3470 {
3471 Key3Length = 0;
3472 }
3473
3474 break;
3475
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 case eCSR_ENCRYPT_TYPE_TKIP:
3477 case eCSR_ENCRYPT_TYPE_AES:
3478#ifdef FEATURE_WLAN_WAPI
3479 case eCSR_ENCRYPT_TYPE_WPI:
3480#endif /* FEATURE_WLAN_WAPI */
3481 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3482 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3483 PrivacyEnabled = (0 != fPrivacy);
3484
3485 // turn on RSN enabled for WPA associations
3486 RsnEnabled = 1;
3487
3488 // WEP key length and Wep Default Key ID don't matter in this case....
3489
3490 // clear out the static WEP keys that may be hanging around.
3491 Key0Length = 0;
3492 Key1Length = 0;
3493 Key2Length = 0;
3494 Key3Length = 0;
3495
3496 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 default:
3498 PrivacyEnabled = 0;
3499 RsnEnabled = 0;
3500 break;
3501 }
3502
3503 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3504 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3505 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3506 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3507 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3508 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3509 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3510 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3511}
3512
Jeff Johnson295189b2012-06-20 16:38:30 -07003513static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3514{
3515 tANI_U32 len = 0;
3516 if(pSSID->length <= WNI_CFG_SSID_LEN)
3517 {
3518 len = pSSID->length;
3519 }
3520 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3521}
3522
Jeff Johnson295189b2012-06-20 16:38:30 -07003523eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3524{
3525 eHalStatus status = eHAL_STATUS_SUCCESS;
3526 tANI_U32 QoSEnabled;
3527 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 // set the CFG enable/disable variables based on the qosType being configured...
3529 switch( qosType )
3530 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3532 QoSEnabled = FALSE;
3533 WmeEnabled = TRUE;
3534 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3536 QoSEnabled = FALSE;
3537 WmeEnabled = TRUE;
3538 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3540 QoSEnabled = FALSE;
3541 WmeEnabled = TRUE;
3542 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3544 QoSEnabled = TRUE;
3545 WmeEnabled = FALSE;
3546 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 case eCSR_MEDIUM_ACCESS_11e_HCF:
3548 QoSEnabled = TRUE;
3549 WmeEnabled = FALSE;
3550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 default:
3552 case eCSR_MEDIUM_ACCESS_DCF:
3553 QoSEnabled = FALSE;
3554 WmeEnabled = FALSE;
3555 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 }
3557 //save the WMM setting for later use
3558 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303559 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 return (status);
3561}
Jeff Johnson295189b2012-06-20 16:38:30 -07003562static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303563 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003564{
3565 eHalStatus status = eHAL_STATUS_FAILURE;
3566 int i;
3567 eCsrCfgDot11Mode cfgDot11Mode;
3568 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303569 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303570 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3571 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003573
3574 if( NULL != pIes )
3575 {
3576 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 // Originally, we thought that for 11a networks, the 11a rates are always
3578 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3579 // appear in the Operational Rate set. Consequently, in either case, we
3580 // would blindly put the rates we support into our Operational Rate set
3581 // (including the basic rates, which we have already verified are
3582 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 // However, it turns out that this is not always the case. Some AP's
3584 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3585 // too. Now, we're a little more careful:
3586 pDstRate = pOpRateSet->rate;
3587 if(pIes->SuppRates.present)
3588 {
3589 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3590 {
3591 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3592 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003593 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3594 {
3595 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3596 *pDstRate++ = pIes->SuppRates.rates[ i ];
3597 pOpRateSet->numRates++;
3598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 }
3600 }
3601 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303602 /* If there are Extended Rates in the beacon, we will reflect those
3603 * extended rates that we support in out Extended Operational Rate
3604 * set*/
3605 pDstRate = pExRateSet->rate;
3606 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303608 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303610 if (csrRatesIsDot11RateSupported(pMac,
3611 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303613 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3614 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303616 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3617 &rateBitmap);
3618 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3619 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 }
3621 }
3622 }
3623 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303624 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 }//Parsing BSSDesc
3626 else
3627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003628 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 }
3630 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3631 return status;
3632}
3633
3634static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3635 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3636{
3637 int i;
3638 tANI_U8 *pDstRate;
3639 eCsrCfgDot11Mode cfgDot11Mode;
3640 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3641 tANI_U32 OperationalRatesLength = 0;
3642 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3643 tANI_U32 ExtendedOperationalRatesLength = 0;
3644 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3645 tANI_U32 ProprietaryOperationalRatesLength = 0;
3646 tANI_U32 PropRatesEnable = 0;
3647 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3648 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 if( NULL != pIes )
3651 {
3652 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 // Originally, we thought that for 11a networks, the 11a rates are always
3654 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3655 // appear in the Operational Rate set. Consequently, in either case, we
3656 // would blindly put the rates we support into our Operational Rate set
3657 // (including the basic rates, which we have already verified are
3658 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 // However, it turns out that this is not always the case. Some AP's
3660 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3661 // too. Now, we're a little more careful:
3662 pDstRate = OperationalRates;
3663 if(pIes->SuppRates.present)
3664 {
3665 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3666 {
3667 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3668 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3669 {
3670 *pDstRate++ = pIes->SuppRates.rates[ i ];
3671 OperationalRatesLength++;
3672 }
3673 }
3674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3676 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3677 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3678 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3679 {
3680 // If there are Extended Rates in the beacon, we will reflect those
3681 // extended rates that we support in out Extended Operational Rate
3682 // set:
3683 pDstRate = ExtendedOperationalRates;
3684 if(pIes->ExtSuppRates.present)
3685 {
3686 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3687 {
3688 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3689 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3690 {
3691 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3692 ExtendedOperationalRatesLength++;
3693 }
3694 }
3695 }
3696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 // Enable proprietary MAC features if peer node is Airgo node and STA
3698 // user wants to use them
3699 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3700 {
3701 PropRatesEnable = 1;
3702 }
3703 else
3704 {
3705 PropRatesEnable = 0;
3706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 // For ANI network companions, we need to populate the proprietary rate
3708 // set with any proprietary rates we found in the beacon, only if user
3709 // allows them...
3710 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3711 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3712 {
3713 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3714 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3715 {
3716 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3717 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303718 vos_mem_copy(ProprietaryOperationalRates,
3719 pIes->Airgo.PropSuppRates.rates,
3720 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 }
3722 else {
3723 // No proprietary modes...
3724 ProprietaryOperationalRatesLength = 0;
3725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 /* Get MCS Rate */
3727 pDstRate = MCSRateIdxSet;
3728 if ( pIes->HTCaps.present )
3729 {
3730 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3731 {
3732 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3733 {
3734 MCSRateLength++;
3735 *pDstRate++ = i;
3736 }
3737 }
3738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 // Set the operational rate set CFG variables...
3740 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3741 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3742 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3743 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3744 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3745 ProprietaryOperationalRates,
3746 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3747 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3748 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3749 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3750 }//Parsing BSSDesc
3751 else
3752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003753 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 }
3755}
3756
Jeff Johnson295189b2012-06-20 16:38:30 -07003757static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3758 tCsrRoamProfile *pProfile )
3759{
3760 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3761 { 8,
3762 { SIR_MAC_RATE_6,
3763 SIR_MAC_RATE_9,
3764 SIR_MAC_RATE_12,
3765 SIR_MAC_RATE_18,
3766 SIR_MAC_RATE_24,
3767 SIR_MAC_RATE_36,
3768 SIR_MAC_RATE_48,
3769 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3771 { 4,
3772 { SIR_MAC_RATE_1,
3773 SIR_MAC_RATE_2,
3774 SIR_MAC_RATE_5_5,
3775 SIR_MAC_RATE_11 } } };
3776
3777
3778 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3779 { SIR_MAC_RATE_72,
3780 SIR_MAC_RATE_96,
3781 SIR_MAC_RATE_108 } };
3782 eCsrCfgDot11Mode cfgDot11Mode;
3783 eCsrBand eBand;
3784 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3785 tANI_U32 OperationalRatesLength = 0;
3786 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3787 tANI_U32 ExtendedOperationalRatesLength = 0;
3788 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3789 tANI_U32 ProprietaryOperationalRatesLength = 0;
3790 tANI_U32 PropRatesEnable = 0;
3791 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 if(pProfile->ChannelInfo.ChannelList)
3793 {
3794 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3798 // networks, the 11b rates appear in the Operational Rate set. In either case,
3799 // we can blindly put the rates we support into our Operational Rate set
3800 // (including the basic rates, which we have already verified are supported
3801 // earlier in the roaming decision).
3802 if ( eCSR_BAND_5G == eBand )
3803 {
3804 // 11a rates into the Operational Rate Set.
3805 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3806 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303807 vos_mem_copy(OperationalRates,
3808 DefaultSupportedRates11a.supportedRateSet.rate,
3809 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003810
3811 // Nothing in the Extended rate set.
3812 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 // populate proprietary rates if user allows them
3814 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3815 {
3816 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3817 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303818 vos_mem_copy(ProprietaryOperationalRates,
3819 DefaultSupportedPropRates.propRate,
3820 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 }
3822 else
3823 {
3824 // No proprietary modes
3825 ProprietaryOperationalRatesLength = 0;
3826 }
3827 }
3828 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3829 {
3830 // 11b rates into the Operational Rate Set.
3831 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3832 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303833 vos_mem_copy(OperationalRates,
3834 DefaultSupportedRates11b.supportedRateSet.rate,
3835 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 // Nothing in the Extended rate set.
3837 ExtendedOperationalRatesLength = 0;
3838 // No proprietary modes
3839 ProprietaryOperationalRatesLength = 0;
3840 }
3841 else
3842 {
3843 // 11G
3844
3845 // 11b rates into the Operational Rate Set.
3846 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3847 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303848 vos_mem_copy(OperationalRates,
3849 DefaultSupportedRates11b.supportedRateSet.rate,
3850 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003851
3852 // 11a rates go in the Extended rate set.
3853 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3854 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303855 vos_mem_copy(ExtendedOperationalRates,
3856 DefaultSupportedRates11a.supportedRateSet.rate,
3857 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003858
3859 // populate proprietary rates if user allows them
3860 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3861 {
3862 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3863 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303864 vos_mem_copy(ProprietaryOperationalRates,
3865 DefaultSupportedPropRates.propRate,
3866 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 }
3868 else
3869 {
3870 // No proprietary modes
3871 ProprietaryOperationalRatesLength = 0;
3872 }
3873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3875 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3876 {
3877 PropRatesEnable = 1;
3878 }
3879 else
3880 {
3881 PropRatesEnable = 0;
3882 }
3883
3884 // Set the operational rate set CFG variables...
3885 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3886 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3887 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3888 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3889 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3890 ProprietaryOperationalRates,
3891 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3892 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003893}
Jeff Johnson295189b2012-06-20 16:38:30 -07003894void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3895{
3896 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003897
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3899 tANI_U32 sessionId;
3900 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 if(NULL == pEntry)
3902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003903 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 return;
3905 }
3906 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3907 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303908 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3909 " current state : %d sub state : %d "),
3910 result, pMac->roam.curState[sessionId],
3911 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3913 {
3914 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3915 }
3916}
3917
Jeff Johnson295189b2012-06-20 16:38:30 -07003918//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3919tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3920{
3921 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3922 {
3923 return (WNI_CFG_PHY_MODE_11B);
3924 }
3925 else
3926 {
3927 if(eCSR_BAND_24 == band)
3928 return (WNI_CFG_PHY_MODE_11G);
3929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 return (WNI_CFG_PHY_MODE_11A);
3931}
Jeff Johnson295189b2012-06-20 16:38:30 -07003932
Jeff Johnsone7245742012-09-05 17:12:55 -07003933
3934#ifdef WLAN_FEATURE_11AC
3935ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3936{
3937 switch ( aniCBMode )
3938 {
3939 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3940 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3941 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3942 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3943 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3944 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3945 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3946 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3947 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003948 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003949 return PHY_SINGLE_CHANNEL_CENTERED;
3950 }
3951}
3952#endif
3953
Jeff Johnson295189b2012-06-20 16:38:30 -07003954//pIes may be NULL
3955eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3956 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303957 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003958{
3959 eHalStatus status = eHAL_STATUS_SUCCESS;
3960 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3961 tANI_U8 channel = 0;
3962 //Make sure we have the domain info for the BSS we try to connect to.
3963 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303964 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303966 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 {
3968 //Make sure the 11d info from this BSSDesc can be applied
3969 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303970 if (VOS_TRUE == resetCountry)
3971 {
3972 csrApplyCountryInformation(pMac, FALSE);
3973 }
3974 else
3975 {
3976 csrApplyCountryInformation(pMac, TRUE);
3977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 }
Kiran4a17ebe2013-01-31 10:43:43 -08003979 if ((csrIs11dSupported (pMac)) && pIes)
3980 {
3981 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003982 {
Kiran4a17ebe2013-01-31 10:43:43 -08003983 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003984 }
3985 else
3986 {
3987 //Let's also update the below to make sure we don't update CC while
3988 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303989 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003990 pBssDesc->bssId, sizeof(tSirMacAddr));
3991 }
Kiran4a17ebe2013-01-31 10:43:43 -08003992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 //Qos
3995 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3996 //SSID
3997 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3998 //fragment threshold
3999 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4000 //RTS threshold
4001 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4002
4003 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 //Auth type
4005 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4006 //encryption type
4007 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4008 //short slot time
4009 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 //11d
4011 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4012 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4013 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 /*//11h
4015 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4016 */
4017 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4018 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004019
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004020 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 {
4022 channel = pProfile->operationChannel;
4023 }
4024 else
4025 {
4026 if(pBssDesc)
4027 {
4028 channel = pBssDesc->channelId;
4029 }
4030 }
4031 if(0 != channel)
4032 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304033 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4034 !pMac->roam.configParam.channelBondingMode24GHz &&
4035 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4036 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304038 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4039 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4040 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 }
4042 else
4043 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004044 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 }
4046 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004047#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004048 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4049 // in function csrConvertCBIniValueToPhyCBState()
4050 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4051 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004052 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004053 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004054 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004055 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304056 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004057 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004058 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004059 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004060 }
4061 else
4062#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4064 //Rate
4065 //Fixed Rate
4066 if(pBssDesc)
4067 {
4068 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4069 }
4070 else
4071 {
4072 csrSetCfgRateSetFromProfile(pMac, pProfile);
4073 }
4074 //Make this the last CFG to set. The callback will trigger a join_req
4075 //Join time out
4076 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4077
4078 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 return (status);
4080}
4081
Jeff Johnson295189b2012-06-20 16:38:30 -07004082eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4083 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4084{
4085 eHalStatus status;
4086 tBssConfigParam *pBssConfig;
4087 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004088
4089 if(!pSession)
4090 {
4091 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4092 return eHAL_STATUS_FAILURE;
4093 }
4094
Kiet Lam64c1b492013-07-12 13:56:44 +05304095 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4096 if ( NULL == pBssConfig )
4097 status = eHAL_STATUS_FAILURE;
4098 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304100 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4102 if(HAL_STATUS_SUCCESS(status))
4103 {
4104 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004105 /* This will allow to pass cbMode during join req */
4106 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 //For IBSS, we need to prepare some more information
4108 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 )
4111 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004112 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 }
4114 // If we are in an IBSS, then stop the IBSS...
4115 ////Not worry about WDS connection for now
4116 if ( csrIsConnStateIbss( pMac, sessionId ) )
4117 {
4118 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4119 }
4120 else
4121 {
4122 // if we are in an Infrastructure association....
4123 if ( csrIsConnStateInfra( pMac, sessionId ) )
4124 {
4125 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4126 // across SSIDs (roaming to a new SSID)... //
4127 //Not worry about WDS connection for now
4128 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304129 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 {
4131 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304132 status = csrRoamIssueDisassociate( pMac, sessionId,
4133 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304135 else
4136 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4138 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304139 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304141 // Set parameters for this Bss.
4142 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4143 pBssDesc, pBssConfig,
4144 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304148 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 {
4150 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4151 // Nothing to stop.
4152 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304154 )
4155 {
4156 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4157 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4158 // Set parameters for this Bss.
4159 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4160 pBssDesc, pBssConfig,
4161 pIes, is11rRoamingFlag);
4162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 }
4164 }
4165 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304166 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 return (status);
4169}
4170
Jeff Johnson295189b2012-06-20 16:38:30 -07004171eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4172 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4173{
4174 eCsrJoinState eRoamState = eCsrContinueRoaming;
4175 eHalStatus status;
4176 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4177 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4178 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004179
4180 if(!pSession)
4181 {
4182 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4183 return (eCsrStopRoaming);
4184 }
4185
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 if( CSR_IS_WDS_STA( pProfile ) )
4187 {
4188 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4189 if( !HAL_STATUS_SUCCESS( status ) )
4190 {
4191 eRoamState = eCsrStopRoaming;
4192 }
4193 }
4194 else
4195 {
4196 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4197 {
4198 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4199 return (eCsrStopRoaming);
4200 }
4201 if ( csrIsInfraBssDesc( pBssDesc ) )
4202 {
4203 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4204 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4205 // have changed and handle the changes (without disturbing the current association).
4206
4207 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4208 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4209 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4210 )
4211 {
4212 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4213 // with Authenticating first. To force this, stop the current association (Disassociate) and
4214 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4215 // a new Association.
4216 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4217 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004218 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4220 {
4221 eRoamState = eCsrReassocToSelfNoCapChange;
4222 }
4223 else
4224 {
4225 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304227 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4229 if(HAL_STATUS_SUCCESS(status))
4230 {
4231 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004232 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304234 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4235 pBssDesc, &bssConfig,
4236 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 if(!HAL_STATUS_SUCCESS(status))
4238 {
4239 eRoamState = eCsrStopRoaming;
4240 }
4241 }
4242 else
4243 {
4244 eRoamState = eCsrStopRoaming;
4245 }
4246 }//same profile
4247 }
4248 else
4249 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304250 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4252 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304253 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4254 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304258 }
4259 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 {
4261 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 // stop the existing network before attempting to join the new network...
4263 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4264 {
4265 eRoamState = eCsrStopRoaming;
4266 }
4267 }
4268 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304269 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 {
4271 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4272 {
4273 eRoamState = eCsrStopRoaming;
4274 }
4275 }
4276 if( pIesLocal && !pScanResult->pvIes )
4277 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304278 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 }
4280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 return( eRoamState );
4282}
4283
Jeff Johnson295189b2012-06-20 16:38:30 -07004284eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4285 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4286{
4287 eHalStatus status = eHAL_STATUS_SUCCESS;
4288 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304289 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 roamInfo.pBssDesc = pBssDesc;
4291 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4292 return (status);
4293}
Jeff Johnson295189b2012-06-20 16:38:30 -07004294//In case no matching BSS is found, use whatever default we can find
4295static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4296{
4297 //Need to get all negotiated types in place first
4298 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004299 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 {
4301 default:
4302 case eCSR_AUTH_TYPE_WPA:
4303 case eCSR_AUTH_TYPE_WPA_PSK:
4304 case eCSR_AUTH_TYPE_WPA_NONE:
4305 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4306 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4307 break;
4308
4309 case eCSR_AUTH_TYPE_SHARED_KEY:
4310 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4311 break;
4312
4313 case eCSR_AUTH_TYPE_AUTOSWITCH:
4314 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4315 break;
4316 }
4317 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4318 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4319 //In this case, the multicast encryption needs to follow the uncast ones.
4320 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4321 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4322}
4323
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004324
4325static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4326{
4327 switch(pCommand->u.roamCmd.roamReason)
4328 {
4329 case eCsrLostLink1:
4330 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4331 break;
4332 case eCsrLostLink2:
4333 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4334 break;
4335 case eCsrLostLink3:
4336 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4337 break;
4338 default:
4339 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4340 pCommand->u.roamCmd.roamReason);
4341 break;
4342 }
4343}
4344
Jeff Johnson295189b2012-06-20 16:38:30 -07004345static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4346{
4347 eHalStatus status;
4348 tCsrScanResult *pScanResult = NULL;
4349 eCsrJoinState eRoamState = eCsrStopRoaming;
4350 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4351 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4352 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4353#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4354 v_U8_t acm_mask = 0;
4355#endif
4356 tANI_U32 sessionId = pCommand->sessionId;
4357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4358 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4359 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004360
4361 if(!pSession)
4362 {
4363 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4364 return (eCsrStopRoaming);
4365 }
4366
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 do
4368 {
4369 // Check for Cardbus eject condition, before trying to Roam to any BSS
4370 //***if( !balIsCardPresent(pAdapter) ) break;
4371
Kiet Lam64c1b492013-07-12 13:56:44 +05304372 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304373 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 if(NULL != pBSSList)
4375 {
4376 // When handling AP's capability change, continue to associate to
4377 // same BSS and make sure pRoamBssEntry is not Null.
4378 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4379 {
4380 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4381 {
4382 //Try the first BSS
4383 pCommand->u.roamCmd.pLastRoamBss = NULL;
4384 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4385 }
4386 else
4387 {
4388 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4389 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4390 {
4391 //Done with all the BSSs
4392 //In this case, will tell HDD the completion
4393 break;
4394 }
4395 else
4396 {
4397 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304398 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4400 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4401 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4402 pRoamInfo = &roamInfo;
4403 }
4404 }
4405 while(pCommand->u.roamCmd.pRoamBssEntry)
4406 {
4407 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 /*If concurrency enabled take the concurrent connected channel first. */
4409 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304410 if (vos_concurrent_open_sessions_running() &&
4411 !csrIsValidMcConcurrentSession(pMac, sessionId,
4412 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 {
4414 concurrentChannel =
4415 csrGetConcurrentOperationChannel(pMac);
4416 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004417 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 if ((concurrentChannel) &&
4419 (concurrentChannel ==
4420 pScanResult->Result.BssDescriptor.channelId))
4421 {
4422 //make this 0 because we do not want the
4423 //below check to pass as we don't want to
4424 //connect on other channel
4425 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4426 FL("Concurrent channel match =%d"),
4427 concurrentChannel);
4428 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 }
4430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004431
4432 if (!concurrentChannel)
4433 {
4434
4435 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4436 sessionId, &pScanResult->Result.BssDescriptor,
4437 pCommand->u.roamCmd.roamId)))
4438 {
4439 //Ok to roam this
4440 break;
4441 }
4442 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004443 else
4444 {
4445 eRoamState = eCsrStopRoamingDueToConcurrency;
4446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4448 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4449 {
4450 //Done with all the BSSs
4451 fDone = eANI_BOOLEAN_TRUE;
4452 break;
4453 }
4454 }
4455 if(fDone)
4456 {
4457 break;
4458 }
4459 }
4460 }
4461 //We have something to roam, tell HDD when it is infra.
4462 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4463 //For WDS, the indication is eCSR_ROAM_WDS_IND
4464 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4465 {
4466 if(pRoamInfo)
4467 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004468 if(pSession->bRefAssocStartCnt)
4469 {
4470 pSession->bRefAssocStartCnt--;
4471 //Complete the last association attemp because a new one is about to be tried
4472 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4473 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004475 }
4476 }
4477 /* If the roaming has stopped, not to continue the roaming command*/
4478 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4479 {
4480 //No need to complete roaming here as it already completes
4481 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4482 pCommand->u.roamCmd.roamReason);
4483 eRoamState = eCsrStopRoaming;
4484 csrSetAbortRoamingCommand(pMac, pCommand);
4485 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304487 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 if(pScanResult)
4489 {
4490 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004493 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 fDone = eANI_BOOLEAN_TRUE;
4495 eRoamState = eCsrStopRoaming;
4496 break;
4497 }
4498 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4499 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4500 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4501 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4502 CSR_IS_QOS_BSS(pIesLocal) &&
4503 CSR_IS_UAPSD_BSS(pIesLocal) )
4504 {
4505#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4507 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004508#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 }
4510 else
4511 {
4512 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4513 }
4514 if( pIesLocal && !pScanResult->Result.pvIes)
4515 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304516 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 }
4518 }
4519 else
4520 {
4521 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4522 }
4523 roamInfo.pProfile = pProfile;
4524 pSession->bRefAssocStartCnt++;
4525 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4526 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4529 {
4530 // If this is a start IBSS profile, then we need to start the IBSS.
4531 if ( CSR_IS_START_IBSS(pProfile) )
4532 {
4533 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 // Attempt to start this IBSS...
4535 csrRoamAssignDefaultParam( pMac, pCommand );
4536 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4537 if(HAL_STATUS_SUCCESS(status))
4538 {
4539 if ( fSameIbss )
4540 {
4541 eRoamState = eCsrStartIbssSameIbss;
4542 }
4543 else
4544 {
4545 eRoamState = eCsrContinueRoaming;
4546 }
4547 }
4548 else
4549 {
4550 //it somehow fail need to stop
4551 eRoamState = eCsrStopRoaming;
4552 }
4553 break;
4554 }
4555 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 )
4558 {
4559 // Attempt to start this WDS...
4560 csrRoamAssignDefaultParam( pMac, pCommand );
4561 /* For AP WDS, we dont have any BSSDescription */
4562 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4563 if(HAL_STATUS_SUCCESS(status))
4564 {
4565 eRoamState = eCsrContinueRoaming;
4566 }
4567 else
4568 {
4569 //it somehow fail need to stop
4570 eRoamState = eCsrStopRoaming;
4571 }
4572 }
4573 else
4574 {
4575 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004576 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 eRoamState = eCsrStopRoaming;
4578 break;
4579 }
4580 }
4581 else //We have BSS
4582 {
4583 //Need to assign these value because they are used in csrIsSameProfile
4584 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004585 /* The OSEN IE doesn't provide the cipher suite.
4586 * Therefore set to constant value of AES */
4587 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4588 {
4589 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4590 eCSR_ENCRYPT_TYPE_AES;
4591 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4592 eCSR_ENCRYPT_TYPE_AES;
4593 }
4594 else
4595 {
4596 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4597 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4598 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4599 pScanResult->mcEncryptionType;
4600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4602 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4603 {
4604 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4605 {
4606 eRoamState = eCsrStartIbssSameIbss;
4607 break;
4608 }
4609 }
4610 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4611 {
4612 //trying to connect to the one already connected
4613 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4614 eRoamState = eCsrReassocToSelfNoCapChange;
4615 break;
4616 }
4617 // Attempt to Join this Bss...
4618 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4619 break;
4620 }
4621
4622 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4624 {
4625 //Need to indicate association_completion if association_start has been done
4626 if(pSession->bRefAssocStartCnt > 0)
4627 {
4628 pSession->bRefAssocStartCnt--;
4629 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004630 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4632 eCSR_ROAM_ASSOCIATION_COMPLETION,
4633 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4634 }
4635 }
4636
4637 return( eRoamState );
4638}
4639
Jeff Johnson295189b2012-06-20 16:38:30 -07004640static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4641{
4642 eHalStatus status = eHAL_STATUS_SUCCESS;
4643 eCsrJoinState RoamState;
4644 tANI_U32 sessionId = pCommand->sessionId;
4645
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 //***if( hddIsRadioStateOn( pAdapter ) )
4647 {
4648 // Attept to join a Bss...
4649 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004650
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004652 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 {
4654 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 // and if connected in Infrastructure mode...
4656 if ( csrIsConnStateInfra(pMac, sessionId) )
4657 {
4658 //... then we need to issue a disassociation
4659 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4660 if(!HAL_STATUS_SUCCESS(status))
4661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004662 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 //roam command is completed by caller in the failed case
4664 fComplete = eANI_BOOLEAN_TRUE;
4665 }
4666 }
4667 else if( csrIsConnStateIbss(pMac, sessionId) )
4668 {
4669 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4670 if(!HAL_STATUS_SUCCESS(status))
4671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004672 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 //roam command is completed by caller in the failed case
4674 fComplete = eANI_BOOLEAN_TRUE;
4675 }
4676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4678 {
4679 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4680 if(!HAL_STATUS_SUCCESS(status))
4681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004682 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 //roam command is completed by caller in the failed case
4684 fComplete = eANI_BOOLEAN_TRUE;
4685 }
4686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 else
4688 {
4689 fComplete = eANI_BOOLEAN_TRUE;
4690 }
4691 if(fComplete)
4692 {
4693 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004694 if(eCsrStopRoamingDueToConcurrency == RoamState)
4695 {
4696 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4697 }
4698 else
4699 {
4700 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 }
4703 }
4704 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4705 {
4706 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4707 }
4708 else if ( eCsrStartIbssSameIbss == RoamState )
4709 {
4710 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4711 }
4712 }//hddIsRadioStateOn
4713
4714 return status;
4715}
Jeff Johnson295189b2012-06-20 16:38:30 -07004716eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4717{
4718 tANI_U32 sessionId;
4719 tCsrRoamSession *pSession;
4720 tCsrScanResult *pScanResult = NULL;
4721 tSirBssDescription *pBssDesc = NULL;
4722 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 sessionId = pCommand->sessionId;
4724 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004725
4726 if(!pSession)
4727 {
4728 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4729 return eHAL_STATUS_FAILURE;
4730 }
4731
Jeff Johnson295189b2012-06-20 16:38:30 -07004732 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4733 {
4734 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004735 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4737 return eHAL_STATUS_FAILURE;
4738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 if (pCommand->u.roamCmd.pRoamBssEntry)
4740 {
4741 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4742 pBssDesc = &pScanResult->Result.BssDescriptor;
4743 }
4744 else
4745 {
4746 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004747 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4749 return eHAL_STATUS_FAILURE;
4750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4752 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4753 return status;
4754}
4755
Jeff Johnson295189b2012-06-20 16:38:30 -07004756eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4757{
4758 eHalStatus status = eHAL_STATUS_SUCCESS;
4759 tCsrRoamInfo roamInfo;
4760 tANI_U32 sessionId = pCommand->sessionId;
4761 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004762
4763 if(!pSession)
4764 {
4765 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4766 return eHAL_STATUS_FAILURE;
4767 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304768 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
4769 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 switch ( pCommand->u.roamCmd.roamReason )
4771 {
4772 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004774 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 case eCsrSmeIssuedDisassocForHandoff:
4777 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4778#if 0 // TODO : Confirm this change
4779 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4780#else
4781 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4782#endif
4783
4784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004786 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004787 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004791 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 case eCsrHddIssuedReassocToSameAP:
4794 case eCsrSmeIssuedReassocToSameAP:
4795 {
4796 tDot11fBeaconIEs *pIes = NULL;
4797
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 if( pSession->pConnectBssDesc )
4799 {
4800 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4801 if(!HAL_STATUS_SUCCESS(status) )
4802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004803 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 }
4805 else
4806 {
4807 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4808 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4809 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4811 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4812 pSession->bRefAssocStartCnt++;
4813 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4814 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4815
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004816 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004817 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4818 &pCommand->u.roamCmd.roamProfile );
4819 if(!HAL_STATUS_SUCCESS(status))
4820 {
4821 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004822 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004823 }
4824
Kiet Lam64c1b492013-07-12 13:56:44 +05304825 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 pIes = NULL;
4827 }
4828 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304829 else
4830 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 break;
4832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004834 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4836 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4837 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004839 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4841 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004842
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 case eCsrStopBss:
4844 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4845 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4846 break;
4847
4848 case eCsrForcedDisassocSta:
4849 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4850 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4851 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4852 pCommand->u.roamCmd.reason);
4853 break;
4854
4855 case eCsrForcedDeauthSta:
4856 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4857 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4858 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4859 pCommand->u.roamCmd.reason);
4860 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004861
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004862 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004863 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004864 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4865 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004867
4868 default:
4869 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4870
4871 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4872 {
4873 //Remember the roaming profile
4874 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304875 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4876 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304878 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4880 }
4881 }
4882
4883 //At this point, original uapsd_mask is saved in pCurRoamProfile
4884 //uapsd_mask in the pCommand may change from this point on.
4885
4886 // Attempt to roam with the new scan results (if we need to..)
4887 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004888 if(!HAL_STATUS_SUCCESS(status))
4889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004890 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 break;
4893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 return (status);
4895}
4896
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004897void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4898{
4899 pCommand->u.roamCmd.pLastRoamBss = NULL;
4900 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4901 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304902 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004903}
4904
Jeff Johnson295189b2012-06-20 16:38:30 -07004905void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4906{
4907 if(pCommand->u.roamCmd.fReleaseBssList)
4908 {
4909 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4910 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4911 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4912 }
4913 if(pCommand->u.roamCmd.fReleaseProfile)
4914 {
4915 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4916 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4917 }
4918 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4919 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304920 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004921}
4922
Jeff Johnson295189b2012-06-20 16:38:30 -07004923void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4924{
Kiet Lam64c1b492013-07-12 13:56:44 +05304925 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004926}
Jeff Johnson295189b2012-06-20 16:38:30 -07004927void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4928{
4929 tListElem *pEntry;
4930 tSmeCmd *pCommand;
4931 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004932 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4934 if ( pEntry )
4935 {
4936 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 // If the head of the queue is Active and it is a ROAM command, remove
4938 // and put this on the Free queue.
4939 if ( eSmeCommandRoam == pCommand->command )
4940 {
4941 //we need to process the result first before removing it from active list because state changes
4942 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4943 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4944 if( fReleaseCommand )
4945 {
4946 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4947 {
4948 csrReleaseCommandRoam( pMac, pCommand );
4949 }
4950 else
4951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004952 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004953 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 }
4955 }
4956 else
4957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004958 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004959 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 }
4961 }
4962 else
4963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004964 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 }
4966 }
4967 else
4968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004969 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 if( fReleaseCommand )
4972 {
4973 smeProcessPendingQueue( pMac );
4974 }
4975}
4976
Jeff Johnson295189b2012-06-20 16:38:30 -07004977void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4978{
4979 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004980 if(!pSession)
4981 {
4982 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4983 return;
4984 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304985 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4986 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 pSession->NumPmkidCandidate = 0;
4988}
Jeff Johnson295189b2012-06-20 16:38:30 -07004989#ifdef FEATURE_WLAN_WAPI
4990void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4991{
4992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004993 if(!pSession)
4994 {
4995 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4996 return;
4997 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304998 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4999 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 pSession->NumBkidCandidate = 0;
5001}
5002#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005003extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5004
Jeff Johnson295189b2012-06-20 16:38:30 -07005005static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
5006 tSirBssDescription *pSirBssDesc,
5007 tDot11fBeaconIEs *pIes)
5008{
5009 eHalStatus status = eHAL_STATUS_SUCCESS;
5010 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5011 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005012
5013 if(!pSession)
5014 {
5015 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5016 return eHAL_STATUS_FAILURE;
5017 }
5018
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 if((eCSR_AUTH_TYPE_WPA == authType) ||
5020 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5021 (eCSR_AUTH_TYPE_RSN == authType) ||
5022 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5023#if defined WLAN_FEATURE_VOWIFI_11R
5024 ||
5025 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5026 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5027#endif /* FEATURE_WLAN_WAPI */
5028#ifdef FEATURE_WLAN_WAPI
5029 ||
5030 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5031 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5032#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005033#ifdef WLAN_FEATURE_11W
5034 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305035 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5036 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005037#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 )
5039 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005042 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 }
5044 if( pIesLocal )
5045 {
5046 tANI_U32 nIeLen;
5047 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 if((eCSR_AUTH_TYPE_RSN == authType) ||
5049#if defined WLAN_FEATURE_VOWIFI_11R
5050 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5051 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5052#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005053#if defined WLAN_FEATURE_11W
5054 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305055 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005056#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5058 {
5059 if(pIesLocal->RSN.present)
5060 {
5061 //Calculate the actual length
5062 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5063 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5064 + 2 //akm_suite_count
5065 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5066 + 2; //reserved
5067 if( pIesLocal->RSN.pmkid_count )
5068 {
5069 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5070 }
5071 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305072 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5073 if (NULL == pSession->pWpaRsnRspIE)
5074 status = eHAL_STATUS_FAILURE;
5075 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305077 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5079 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5080 //copy upto akm_suites
5081 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305082 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5083 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005084 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305085 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5086 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005087 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305088 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5089 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005090 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 if( pIesLocal->RSN.pwise_cipher_suite_count )
5092 {
5093 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305094 vos_mem_copy(pIeBuf,
5095 pIesLocal->RSN.pwise_cipher_suites,
5096 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5098 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305099 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 pIeBuf += 2;
5101 if( pIesLocal->RSN.akm_suite_count )
5102 {
5103 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305104 vos_mem_copy(pIeBuf,
5105 pIesLocal->RSN.akm_suites,
5106 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5108 }
5109 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305110 vos_mem_copy(pIeBuf,
5111 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5112 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5114 }
5115 }
5116 }
5117 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5118 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5119 {
5120 if(pIesLocal->WPA.present)
5121 {
5122 //Calculate the actual length
5123 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5124 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5125 + 2 //auth_suite_count
5126 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5127 // The WPA capabilities follows the Auth Suite (two octects)--
5128 // this field is optional, and we always "send" zero, so just
5129 // remove it. This is consistent with our assumptions in the
5130 // frames compiler; c.f. bug 15234:
5131 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305132
5133 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5134 if ( NULL == pSession->pWpaRsnRspIE )
5135 status = eHAL_STATUS_FAILURE;
5136 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 {
5138 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5139 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5140 pIeBuf = pSession->pWpaRsnRspIE + 2;
5141 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305142 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305144 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5145 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305147 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5148 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5150 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5151 }
5152 }
5153 }
5154#ifdef FEATURE_WLAN_WAPI
5155 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5156 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5157 {
5158 if(pIesLocal->WAPI.present)
5159 {
5160 //Calculate the actual length
5161 nIeLen = 4 //version + akm_suite_count
5162 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5163 + 2 //pwise_cipher_suite_count
5164 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5165 + 6; //gp_cipher_suite + preauth + reserved
5166 if( pIesLocal->WAPI.bkid_count )
5167 {
5168 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5169 }
5170
5171 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305172 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5173 if ( NULL == pSession->pWapiRspIE )
5174 status = eHAL_STATUS_FAILURE;
5175 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 {
5177 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5178 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5179 pIeBuf = pSession->pWapiRspIE + 2;
5180 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305181 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 pIeBuf += 4;
5183 if( pIesLocal->WAPI.akm_suite_count )
5184 {
5185 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305186 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5187 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305189 }
5190 vos_mem_copy(pIeBuf,
5191 &pIesLocal->WAPI.unicast_cipher_suite_count,
5192 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5195 {
5196 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305197 vos_mem_copy( pIeBuf,
5198 pIesLocal->WAPI.unicast_cipher_suites,
5199 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5201 }
lukez3c809222013-05-03 10:23:02 -07005202 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305203 vos_mem_copy(pIeBuf,
5204 pIesLocal->WAPI.multicast_cipher_suite,
5205 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005206 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305207 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305208 vos_mem_copy(pIeBuf,
5209 pIesLocal->WAPI.multicast_cipher_suite + 4,
5210 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005211 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305212 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305214 //bkid_count
5215 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5216 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305218 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5219 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5221 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305222 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 }
5225 }
5226#endif /* FEATURE_WLAN_WAPI */
5227 if( !pIes )
5228 {
5229 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305230 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 }
5232 }
5233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 return (status);
5235}
5236
Jeff Johnson295189b2012-06-20 16:38:30 -07005237static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5238{
5239 v_U8_t bACWeights[WLANTL_MAX_AC];
5240 v_U8_t paramBk, paramBe, paramVi, paramVo;
5241 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5243 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5244 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5245 //This doesn't address the case where the lower AC needs a real higher weight
5246 if( pIEs->WMMParams.present )
5247 {
5248 //no change to the lowest ones
5249 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5250 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5251 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5252 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5253 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5254 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5255 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5256 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5257 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5258 {
5259 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5260 fWeightChange = VOS_TRUE;
5261 }
5262 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5263 {
5264 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5265 fWeightChange = VOS_TRUE;
5266 }
5267 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5268 {
5269 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5270 fWeightChange = VOS_TRUE;
5271 }
5272 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5273 {
5274 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5275 fWeightChange = VOS_TRUE;
5276 }
5277 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5278 {
5279 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5280 fWeightChange = VOS_TRUE;
5281 }
5282 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5283 {
5284 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5285 fWeightChange = VOS_TRUE;
5286 }
5287 if(fWeightChange)
5288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005289 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 bACWeights[2], bACWeights[3]);
5291 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5292 }
5293 }
5294}
Jeff Johnson295189b2012-06-20 16:38:30 -07005295#ifdef WLAN_FEATURE_VOWIFI_11R
5296//Returns whether the current association is a 11r assoc or not
5297tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5298{
5299#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5300 return csrNeighborRoamIs11rAssoc(pMac);
5301#else
5302 return eANI_BOOLEAN_FALSE;
5303#endif
5304}
5305#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005306#ifdef FEATURE_WLAN_ESE
5307//Returns whether the current association is a ESE assoc or not
5308tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005309{
5310#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005311 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005312#else
5313 return eANI_BOOLEAN_FALSE;
5314#endif
5315}
5316#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005317#ifdef FEATURE_WLAN_LFR
5318//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305319tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005320{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305321 tCsrRoamSession *pSession = NULL;
5322
5323 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5324 {
5325 pSession = CSR_GET_SESSION( pMac, sessionId );
5326 if (NULL != pSession->pCurRoamProfile)
5327 {
5328 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5329 {
5330 return eANI_BOOLEAN_FALSE;
5331 }
5332 }
5333 }
5334
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005335#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5336 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5337 {
5338 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5339 }
5340 else
5341#endif
5342 {
5343 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005344 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005345 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005346}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005347
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005348#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005349/* ---------------------------------------------------------------------------
5350
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005351 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005352
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005353 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005354
5355 \param pMac - The handle returned by macOpen.
5356
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005357 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005358
5359---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005360tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005361{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005362 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005363}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005364#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005365
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005366#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5367//Returns whether "FW based BG scan" is currently enabled...or not
5368tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5369{
5370 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5371}
5372#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005373#endif
5374
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005375#if defined(FEATURE_WLAN_ESE)
5376tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005377{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005378 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005379}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005380#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005381
Jeff Johnson295189b2012-06-20 16:38:30 -07005382//Return true means the command can be release, else not
5383static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5384 eCsrRoamCompleteResult Result, void *Context )
5385{
5386 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5387 tSirBssDescription *pSirBssDesc = NULL;
5388 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5389 tCsrScanResult *pScanResult = NULL;
5390 tCsrRoamInfo roamInfo;
5391 sme_QosAssocInfo assocInfo;
5392 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5393 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5394 tDot11fBeaconIEs *pIes = NULL;
5395 tANI_U32 sessionId = pCommand->sessionId;
5396 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5397 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5398 eRoamCmdStatus roamStatus;
5399 eCsrRoamResult roamResult;
5400 eHalStatus status;
5401 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005403
Jeff Johnson32d95a32012-09-10 13:15:23 -07005404 if(!pSession)
5405 {
5406 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5407 return eANI_BOOLEAN_FALSE;
5408 }
5409
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005410 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 switch( Result )
5412 {
5413 case eCsrJoinSuccess:
5414 // reset the IDLE timer
5415 // !!
5416 // !! fall through to the next CASE statement here is intentional !!
5417 // !!
5418 case eCsrReassocSuccess:
5419 if(eCsrReassocSuccess == Result)
5420 {
5421 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5422 }
5423 else
5424 {
5425 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5426 }
5427 // Success Join Response from LIM. Tell NDIS we are connected and save the
5428 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005429 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305430 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 //always free the memory here
5432 if(pSession->pWpaRsnRspIE)
5433 {
5434 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305435 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 pSession->pWpaRsnRspIE = NULL;
5437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005438#ifdef FEATURE_WLAN_WAPI
5439 if(pSession->pWapiRspIE)
5440 {
5441 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305442 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 pSession->pWapiRspIE = NULL;
5444 }
5445#endif /* FEATURE_WLAN_WAPI */
5446#ifdef FEATURE_WLAN_BTAMP_UT_RF
5447 //Reset counter so no join retry is needed.
5448 pSession->maxRetryCount = 0;
5449 csrRoamStopJoinRetryTimer(pMac, sessionId);
5450#endif
5451 /* This creates problem since we have not saved the connected profile.
5452 So moving this after saving the profile
5453 */
5454 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305455
5456 /* Reset remainInPowerActiveTillDHCP as it might have been set
5457 * by last failed secured connection.
5458 * It should be set only for secured connection.
5459 */
5460 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5462 {
5463 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5464 }
5465 else
5466 {
5467 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 //Use the last connected bssdesc for reassoc-ing to the same AP.
5470 //NOTE: What to do when reassoc to a different AP???
5471 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5472 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5473 {
5474 pSirBssDesc = pSession->pConnectBssDesc;
5475 if(pSirBssDesc)
5476 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305477 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5478 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }
5480 }
5481 else
5482 {
5483
5484 if(pCommand->u.roamCmd.pRoamBssEntry)
5485 {
5486 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5487 if(pScanResult != NULL)
5488 {
5489 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5490 //this can be NULL
5491 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305492 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5493 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 }
5495 }
5496 }
5497 if( pSirBssDesc )
5498 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5501 //Save WPA/RSN IE
5502 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005503#ifdef FEATURE_WLAN_ESE
5504 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005505#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305506#ifdef WLAN_FEATURE_VOWIFI_11R
5507 if (pSirBssDesc->mdiePresent)
5508 {
5509 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5510#ifdef FEATURE_WLAN_ESE
5511 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5512 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5513#endif
5514 )
5515 {
5516 // is11Rconnection;
5517 roamInfo.is11rAssoc = VOS_TRUE;
5518 }
5519 else
5520 {
5521 // is11Rconnection;
5522 roamInfo.is11rAssoc = VOS_FALSE;
5523 }
5524 }
5525#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5527 // substate change.
5528 // Moving even save profile above so that below mentioned conditon is also met.
5529 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5530 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5532 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5533 // will be dropped for the security context may not be set properly.
5534 //
5535 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5536 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5537 //
5538 // this reordering was done on titan_prod_usb branch and is being replicated here.
5539 //
5540
5541 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5542 !pProfile->bWPSAssociation)
5543 {
5544 // Issue the set Context request to LIM to establish the Unicast STA context
5545 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5546 pProfile->negotiatedUCEncryptionType,
5547 pSirBssDesc, &(pSirBssDesc->bssId),
5548 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005550 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5552 }
5553 // Issue the set Context request to LIM to establish the Broadcast STA context
5554 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5555 pSirBssDesc, &BroadcastMac,
5556 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5557 }
5558 else
5559 {
5560 //Need to wait for supplicant authtication
5561 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 //Set the subestate to WaitForKey in case authentiation is needed
5563 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5564
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 if(pProfile->bWPSAssociation)
5566 {
5567 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5568 }
5569 else
5570 {
5571 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5572 }
5573
5574 //Save sessionId in case of timeout
5575 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5576 //This time should be long enough for the rest of the process plus setting key
5577 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5578 {
5579 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005580 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5582 }
5583 }
5584
5585 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5586 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 if(Context)
5588 {
5589 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5590 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5592 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5593#ifdef WLAN_FEATURE_VOWIFI_11R
5594 len += pJoinRsp->parsedRicRspLen;
5595#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005596#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 len += pJoinRsp->tspecIeLen;
5598#endif
5599 if(len)
5600 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305601 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5602 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305604 vos_mem_copy(pSession->connectedInfo.pbFrames,
5605 pJoinRsp->frames, len);
5606 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5607 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5608 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005609#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305610 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005611#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005612#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305613 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305615 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5616 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5617 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5618 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 }
5620 }
5621 if(pCommand->u.roamCmd.fReassoc)
5622 {
5623 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5624 }
5625 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5626 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5627 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5628 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305629 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 }
5631 else
5632 {
5633 if(pCommand->u.roamCmd.fReassoc)
5634 {
5635 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5636 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5637 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5638 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5639 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5640 }
5641 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305642 /* Update the staId from the previous connected profile info
5643 as the reassociation is triggred at SME/HDD */
5644 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5645 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5646 {
5647 roamInfo.staId = pSession->connectedInfo.staId;
5648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005649#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5650 // Indicate SME-QOS with reassoc success event, only after
5651 // copying the frames
5652 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 roamInfo.pBssDesc = pSirBssDesc;
5655 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5656 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5657#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5658 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5659#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5660 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5662 //It may be better to let QoS do this????
5663 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005665 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5667 pmcStartUapsd( pMac, NULL, NULL );
5668 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305669 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5671 if( pSession->bRefAssocStartCnt > 0 )
5672 {
5673 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005674 //Remove this code once SLM_Sessionization is supported
5675 //BMPS_WORKAROUND_NOT_NEEDED
5676 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005677 {
5678 pMac->roam.configParam.doBMPSWorkaround = 1;
5679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5681 }
5682
5683 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 // reset the PMKID candidate list
5685 csrResetPMKIDCandidateList( pMac, sessionId );
5686 //Update TL's AC weight base on the current EDCA parameters
5687 //These parameters may change in the course of the connection, that sictuation
5688 //is not taken care here. This change is mainly to address a WIFI WMM test where
5689 //BE has a equal or higher TX priority than VI.
5690 //We only do this for infra link
5691 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5692 {
5693 csrCheckAndUpdateACWeight(pMac, pIes);
5694 }
5695#ifdef FEATURE_WLAN_WAPI
5696 // reset the BKID candidate list
5697 csrResetBKIDCandidateList( pMac, sessionId );
5698#endif /* FEATURE_WLAN_WAPI */
5699 }
5700 else
5701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005702 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 csrScanCancelIdleScan(pMac);
5705 //Not to signal link up because keys are yet to be set.
5706 //The linkup function will overwrite the sub-state that we need to keep at this point.
5707 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5708 {
5709 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5712 //enough to let security and DHCP handshake succeed before entry into BMPS
5713 if (pmcShouldBmpsTimerRun(pMac))
5714 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305715 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5716 * until keys are set before going into BMPS.
5717 */
5718 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5719 {
5720 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5721 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5722 "to make sure we wait until keys are set before"
5723 " going to BMPS"));
5724 }
5725
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5727 != eHAL_STATUS_SUCCESS)
5728 {
5729 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5730 }
5731 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 break;
5734
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 case eCsrStartBssSuccess:
5736 // on the StartBss Response, LIM is returning the Bss Description that we
5737 // are beaconing. Add this Bss Description to our scan results and
5738 // chain the Profile to this Bss Description. On a Start BSS, there was no
5739 // detected Bss description (no partner) so we issued the Start Bss to
5740 // start the Ibss without any Bss description. Lim was kind enough to return
5741 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005742 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305745 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 if( CSR_IS_IBSS( pProfile ) )
5747 {
5748 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 else if (CSR_IS_INFRA_AP(pProfile))
5751 {
5752 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 else
5755 {
5756 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5757 }
5758 if( !CSR_IS_WDS_STA( pProfile ) )
5759 {
5760 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5763 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305764 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 roamInfo.pBssDesc = pSirBssDesc;
5766 //We need to associate_complete it first, becasue Associate_start already indicated.
5767 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5768 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5769 break;
5770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005773 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 }
5775 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5776 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5777 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5778 if(pSirBssDesc)
5779 {
5780 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305781 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5782 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 }
5784 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305785 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005786#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5787 {
5788 vos_log_ibss_pkt_type *pIbssLog;
5789 tANI_U32 bi;
5790
5791 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5792 if(pIbssLog)
5793 {
5794 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5795 {
5796 //We start the IBSS (didn't find any matched IBSS out there)
5797 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5798 }
5799 else
5800 {
5801 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5802 }
5803 if(pSirBssDesc)
5804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305805 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5807 }
5808 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5809 {
5810 //***U8 is not enough for beacon interval
5811 pIbssLog->beaconInterval = (v_U8_t)bi;
5812 }
5813 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5814 }
5815 }
5816#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5817 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5818 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5820 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5822 csrRoamIssueSetContextReq( pMac, sessionId,
5823 pProfile->negotiatedMCEncryptionType,
5824 pSirBssDesc, &BroadcastMac,
5825 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5826 }
5827 }
5828 else
5829 {
5830 //Keep the state to eCSR_ROAMING_STATE_JOINING
5831 //Need to send join_req.
5832 if(pCommand->u.roamCmd.pRoamBssEntry)
5833 {
5834 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5835 {
5836 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5837 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5838 // Set the roaming substate to 'join attempt'...
5839 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005840 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 }
5842 }
5843 else
5844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005845 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 VOS_ASSERT( 0 );
5847 }
5848 }
5849 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5850 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5851 //trigger the connection start indication in Vista
5852 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5853 {
5854 roamStatus = eCSR_ROAM_IBSS_IND;
5855 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5856 if( CSR_IS_WDS( pProfile ) )
5857 {
5858 roamStatus = eCSR_ROAM_WDS_IND;
5859 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 if( CSR_IS_INFRA_AP( pProfile ) )
5862 {
5863 roamStatus = eCSR_ROAM_INFRA_IND;
5864 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005866
5867 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5868 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5869 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305870 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5872 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005873 //We start the IBSS (didn't find any matched IBSS out there)
5874 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305876 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5877 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005878 //Remove this code once SLM_Sessionization is supported
5879 //BMPS_WORKAROUND_NOT_NEEDED
5880 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005881 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005882 {
5883 pMac->roam.configParam.doBMPSWorkaround = 1;
5884 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005885
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5887 }
5888
5889 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005890
5891 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 {
5893 //need to send stop BSS because we fail to send join_req
5894 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5895 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5896 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 case eCsrStartBssFailure:
5900#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5901 {
5902 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5904 if(pIbssLog)
5905 {
5906 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5907 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5908 }
5909 }
5910#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 roamStatus = eCSR_ROAM_IBSS_IND;
5912 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5913 if( CSR_IS_WDS( pProfile ) )
5914 {
5915 roamStatus = eCSR_ROAM_WDS_IND;
5916 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 if( CSR_IS_INFRA_AP( pProfile ) )
5919 {
5920 roamStatus = eCSR_ROAM_INFRA_IND;
5921 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 if(Context)
5924 {
5925 pSirBssDesc = (tSirBssDescription *)Context;
5926 }
5927 else
5928 {
5929 pSirBssDesc = NULL;
5930 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305931 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 roamInfo.pBssDesc = pSirBssDesc;
5933 //We need to associate_complete it first, becasue Associate_start already indicated.
5934 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5935 csrSetDefaultDot11Mode( pMac );
5936 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 case eCsrSilentlyStopRoaming:
5938 // We are here because we try to start the same IBSS
5939 //No message to PE
5940 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005941 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5943 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305944 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5946 if( roamInfo.pBssDesc )
5947 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305948 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5949 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 }
5951 //Since there is no change in the current state, simply pass back no result otherwise
5952 //HDD may be mistakenly mark to disconnected state.
5953 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5954 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 case eCsrSilentlyStopRoamingSaveState:
5957 //We are here because we try to connect to the same AP
5958 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005959 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305960 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961
5962 //to aviod resetting the substate to NONE
5963 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5964 //No need to change substate to wai_for_key because there is no state change
5965 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5966 if( roamInfo.pBssDesc )
5967 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305968 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5969 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5972 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5973 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5974 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5975 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5976 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5977 roamInfo.staId = pSession->connectedInfo.staId;
5978 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 pSession->bRefAssocStartCnt--;
5981 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5982 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5983 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5984 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 case eCsrReassocFailure:
5986#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5987 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5988#endif
5989 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005990 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 csrFreeConnectBssDesc(pMac, sessionId);
5992 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5993 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305994 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5996 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5997 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5998 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5999 eCSR_ROAM_WDS_IND,
6000 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6001 //Need to issue stop_bss
6002 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 case eCsrJoinFailure:
6004 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006005 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 default:
6007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006008 smsLog(pMac, LOGW, FL("receives no association indication"));
6009 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006010 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6012 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6013 {
6014 //do not free for the other profiles as we need to send down stop BSS later
6015 csrFreeConnectBssDesc(pMac, sessionId);
6016 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6017 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6018 csrSetDefaultDot11Mode( pMac );
6019 }
6020
6021 switch( pCommand->u.roamCmd.roamReason )
6022 {
6023 // If this transition is because of an 802.11 OID, then we transition
6024 // back to INIT state so we sit waiting for more OIDs to be issued and
6025 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006026 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 case eCsrSmeIssuedAssocToSimilarAP:
6028 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006029 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306031 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6033 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6034 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306035 vos_mem_copy(&roamInfo.bssid,
6036 &pSession->joinFailStatusCode.bssId,
6037 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006038
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 /* Defeaturize this later if needed */
6040#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6041 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6042 if (csrRoamIsHandoffInProgress(pMac))
6043 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 /* Should indicate neighbor roam algorithm about the connect failure here */
6045 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 if(pSession->bRefAssocStartCnt > 0)
6049 {
6050 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006051 if(eCsrJoinFailureDueToConcurrency == Result)
6052 {
6053 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6054 eCSR_ROAM_ASSOCIATION_COMPLETION,
6055 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6056 }
6057 else
6058 {
6059 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 eCSR_ROAM_ASSOCIATION_COMPLETION,
6061 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006064 else
6065 {
6066 /* bRefAssocStartCnt is not incremented when
6067 * eRoamState == eCsrStopRoamingDueToConcurrency
6068 * in csrRoamJoinNextBss API. so handle this in
6069 * else case by sending assoc failure
6070 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006071 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006072 pCommand->u.scanCmd.roamId,
6073 eCSR_ROAM_ASSOCIATION_FAILURE,
6074 eCSR_ROAM_RESULT_FAILURE);
6075 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006076 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006077#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306078 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6080#endif
6081 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6082 csrScanStartIdleScan(pMac);
6083#ifdef FEATURE_WLAN_BTAMP_UT_RF
6084 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6085 //BT activity and not able to recevie WLAN traffic. Retry the join
6086 if( CSR_IS_WDS_STA(pProfile) )
6087 {
6088 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6089 }
6090#endif
6091 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 case eCsrHddIssuedReassocToSameAP:
6093 case eCsrSmeIssuedReassocToSameAP:
6094 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6095
6096 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6097#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6098 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6099#endif
6100 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6101 csrScanStartIdleScan(pMac);
6102 break;
6103 case eCsrForcedDisassoc:
6104 case eCsrForcedDeauth:
6105 case eCsrSmeIssuedIbssJoinFailure:
6106 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6107
6108 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6109 {
6110 // Notify HDD that IBSS join failed
6111 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6112 }
6113 else
6114 {
6115 csrRoamCallCallback(pMac, sessionId, NULL,
6116 pCommand->u.roamCmd.roamId,
6117 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6118 }
6119#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6120 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6121#endif
6122 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006123 /*
6124 *DelSta not done FW still in conneced state so dont
6125 *issue IMPS req
6126 */
6127 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6128 {
6129 smsLog(pMac, LOGW, FL("FW still in connected state "));
6130 break;
6131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 csrScanStartIdleScan(pMac);
6133 break;
6134 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306135 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 csrRoamCallCallback(pMac, sessionId, NULL,
6137 pCommand->u.roamCmd.roamId,
6138 eCSR_ROAM_IBSS_LEAVE,
6139 eCSR_ROAM_RESULT_IBSS_STOP);
6140 break;
6141 case eCsrForcedDisassocMICFailure:
6142 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6143
6144 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6145#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6146 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6147#endif
6148 csrScanStartIdleScan(pMac);
6149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 case eCsrStopBss:
6151 csrRoamCallCallback(pMac, sessionId, NULL,
6152 pCommand->u.roamCmd.roamId,
6153 eCSR_ROAM_INFRA_IND,
6154 eCSR_ROAM_RESULT_INFRA_STOPPED);
6155 break;
6156 case eCsrForcedDisassocSta:
6157 case eCsrForcedDeauthSta:
6158 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6159 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6160 {
6161 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006162
6163 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6164 {
6165 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306166 vos_mem_copy(roamInfo.peerMac,
6167 pCommand->u.roamCmd.peerMac,
6168 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6170 roamInfo.statusCode = eSIR_SME_SUCCESS;
6171 status = csrRoamCallCallback(pMac, sessionId,
6172 &roamInfo, pCommand->u.roamCmd.roamId,
6173 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6174 }
6175 }
6176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 case eCsrLostLink1:
6178 // if lost link roam1 failed, then issue lost link Scan2 ...
6179 csrScanRequestLostLink2(pMac, sessionId);
6180 break;
6181 case eCsrLostLink2:
6182 // if lost link roam2 failed, then issue lost link scan3 ...
6183 csrScanRequestLostLink3(pMac, sessionId);
6184 break;
6185 case eCsrLostLink3:
6186 default:
6187 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6188
6189 //We are done with one round of lostlink roaming here
6190 csrScanHandleFailedLostlink3(pMac, sessionId);
6191 break;
6192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 break;
6194 }
6195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 return ( fReleaseCommand );
6197}
6198
Jeff Johnson295189b2012-06-20 16:38:30 -07006199eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6200{
6201 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 return (status);
6203}
6204
Jeff Johnson295189b2012-06-20 16:38:30 -07006205eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6206{
6207 eHalStatus status = eHAL_STATUS_SUCCESS;
6208 tANI_U32 size = 0;
6209
6210 do
6211 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306212 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6214 {
6215 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306216 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6217 if ( NULL == pDstProfile->BSSIDs.bssid )
6218 status = eHAL_STATUS_FAILURE;
6219 else
6220 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 if(!HAL_STATUS_SUCCESS(status))
6222 {
6223 break;
6224 }
6225 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306226 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6227 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
6229 if(pSrcProfile->SSIDs.numOfSSIDs)
6230 {
6231 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306232 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6233 if ( NULL == pDstProfile->SSIDs.SSIDList )
6234 status = eHAL_STATUS_FAILURE;
6235 else
6236 status = eHAL_STATUS_SUCCESS;
6237 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 {
6239 break;
6240 }
6241 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306242 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6243 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 }
6245 if(pSrcProfile->nWPAReqIELength)
6246 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306247 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6248 if ( NULL == pDstProfile->pWPAReqIE )
6249 status = eHAL_STATUS_FAILURE;
6250 else
6251 status = eHAL_STATUS_SUCCESS;
6252
6253 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 {
6255 break;
6256 }
6257 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306258 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6259 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 }
6261 if(pSrcProfile->nRSNReqIELength)
6262 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306263 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6264 if ( NULL == pDstProfile->pRSNReqIE )
6265 status = eHAL_STATUS_FAILURE;
6266 else
6267 status = eHAL_STATUS_SUCCESS;
6268
6269 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 {
6271 break;
6272 }
6273 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306274 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6275 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 }
6277#ifdef FEATURE_WLAN_WAPI
6278 if(pSrcProfile->nWAPIReqIELength)
6279 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306280 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6281 if ( NULL == pDstProfile->pWAPIReqIE )
6282 status = eHAL_STATUS_FAILURE;
6283 else
6284 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 if(!HAL_STATUS_SUCCESS(status))
6286 {
6287 break;
6288 }
6289 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306290 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6291 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 }
6293#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 if(pSrcProfile->nAddIEScanLength)
6295 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306296 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6297 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306299 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306300 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306301 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6302 }
6303 else
6304 {
6305 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6306 FL(" AddIEScanLength is not valid %u"),
6307 pSrcProfile->nAddIEScanLength);
6308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 if(pSrcProfile->nAddIEAssocLength)
6311 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306312 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6313 if ( NULL == pDstProfile->pAddIEAssoc )
6314 status = eHAL_STATUS_FAILURE;
6315 else
6316 status = eHAL_STATUS_SUCCESS;
6317
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 if(!HAL_STATUS_SUCCESS(status))
6319 {
6320 break;
6321 }
6322 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306323 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6324 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 if(pSrcProfile->ChannelInfo.ChannelList)
6327 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306328 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6329 pSrcProfile->ChannelInfo.numOfChannels);
6330 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6331 status = eHAL_STATUS_FAILURE;
6332 else
6333 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 if(!HAL_STATUS_SUCCESS(status))
6335 {
6336 break;
6337 }
6338 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306339 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6340 pSrcProfile->ChannelInfo.ChannelList,
6341 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 pDstProfile->AuthType = pSrcProfile->AuthType;
6344 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6345 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6346 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6347 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6348 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006349#ifdef WLAN_FEATURE_11W
6350 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6351 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6352 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6353#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 pDstProfile->BSSType = pSrcProfile->BSSType;
6355 pDstProfile->phyMode = pSrcProfile->phyMode;
6356 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6357
6358#ifdef FEATURE_WLAN_WAPI
6359 if(csrIsProfileWapi(pSrcProfile))
6360 {
6361 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6362 {
6363 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6364 }
6365 }
6366#endif /* FEATURE_WLAN_WAPI */
6367 pDstProfile->CBMode = pSrcProfile->CBMode;
6368 /*Save the WPS info*/
6369 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006370 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 pDstProfile->privacy = pSrcProfile->privacy;
6374 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6375 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6376 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6377 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6378 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6379 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6380 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6381 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6382 pDstProfile->wps_state = pSrcProfile->wps_state;
6383 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306384 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6385 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006386#ifdef WLAN_FEATURE_VOWIFI_11R
6387 if (pSrcProfile->MDID.mdiePresent)
6388 {
6389 pDstProfile->MDID.mdiePresent = 1;
6390 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6391 }
6392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 }while(0);
6394
6395 if(!HAL_STATUS_SUCCESS(status))
6396 {
6397 csrReleaseProfile(pMac, pDstProfile);
6398 pDstProfile = NULL;
6399 }
6400
6401 return (status);
6402}
Jeff Johnson295189b2012-06-20 16:38:30 -07006403eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6404{
6405 eHalStatus status = eHAL_STATUS_SUCCESS;
6406 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6407 do
6408 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306409 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 if(pSrcProfile->bssid)
6411 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306412 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6413 if ( NULL == pDstProfile->BSSIDs.bssid )
6414 status = eHAL_STATUS_FAILURE;
6415 else
6416 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 if(!HAL_STATUS_SUCCESS(status))
6418 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306419 smsLog( pMac, LOGE,
6420 FL("failed to allocate memory for BSSID"
6421 "%02x:%02x:%02x:%02x:%02x:%02x"),
6422 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6423 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 break;
6425 }
6426 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306427 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6428 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 }
6430 if(pSrcProfile->SSID.ssId)
6431 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306432 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6433 if ( NULL == pDstProfile->SSIDs.SSIDList )
6434 status = eHAL_STATUS_FAILURE;
6435 else
6436 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 if(!HAL_STATUS_SUCCESS(status))
6438 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306439 smsLog( pMac, LOGE,
6440 FL("failed to allocate memory for SSIDList"
6441 "%02x:%02x:%02x:%02x:%02x:%02x"),
6442 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6443 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 break;
6445 }
6446 pDstProfile->SSIDs.numOfSSIDs = 1;
6447 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6448 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306449 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6450 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006452 if(pSrcProfile->nAddIEAssocLength)
6453 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306454 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6455 if ( NULL == pDstProfile->pAddIEAssoc)
6456 status = eHAL_STATUS_FAILURE;
6457 else
6458 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006459 if(!HAL_STATUS_SUCCESS(status))
6460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006461 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006462 break;
6463 }
6464 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306465 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6466 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006467 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306468 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6469 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6470 status = eHAL_STATUS_FAILURE;
6471 else
6472 status = eHAL_STATUS_SUCCESS;
6473
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 if(!HAL_STATUS_SUCCESS(status))
6475 {
6476 break;
6477 }
6478 pDstProfile->ChannelInfo.numOfChannels = 1;
6479 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 pDstProfile->AuthType.numEntries = 1;
6481 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6482 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6483 pDstProfile->EncryptionType.numEntries = 1;
6484 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6485 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6486 pDstProfile->mcEncryptionType.numEntries = 1;
6487 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6488 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6489 pDstProfile->BSSType = pSrcProfile->BSSType;
6490 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306491 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6492 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306493#ifdef WLAN_FEATURE_11W
6494 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6495 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6496 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6497#endif
6498
Jeff Johnson295189b2012-06-20 16:38:30 -07006499#ifdef WLAN_FEATURE_VOWIFI_11R
6500 if (pSrcProfile->MDID.mdiePresent)
6501 {
6502 pDstProfile->MDID.mdiePresent = 1;
6503 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6504 }
6505#endif
6506
6507 }while(0);
6508
6509 if(!HAL_STATUS_SUCCESS(status))
6510 {
6511 csrReleaseProfile(pMac, pDstProfile);
6512 pDstProfile = NULL;
6513 }
6514
6515 return (status);
6516}
6517
Jeff Johnson295189b2012-06-20 16:38:30 -07006518eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6519 tScanResultHandle hBSSList,
6520 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6521 tANI_BOOLEAN fClearScan)
6522{
6523 eHalStatus status = eHAL_STATUS_SUCCESS;
6524 tSmeCmd *pCommand;
6525
6526 pCommand = csrGetCommandBuffer(pMac);
6527 if(NULL == pCommand)
6528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006529 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 status = eHAL_STATUS_RESOURCES;
6531 }
6532 else
6533 {
6534 if( fClearScan )
6535 {
6536 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306537 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 }
6539 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6540 if(NULL == pProfile)
6541 {
6542 //We can roam now
6543 //Since pProfile is NULL, we need to build our own profile, set everything to default
6544 //We can only support open and no encryption
6545 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6546 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6547 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6548 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6549 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6550 }
6551 else
6552 {
6553 //make a copy of the profile
6554 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6555 if(HAL_STATUS_SUCCESS(status))
6556 {
6557 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6558 }
6559 }
6560 pCommand->command = eSmeCommandRoam;
6561 pCommand->sessionId = (tANI_U8)sessionId;
6562 pCommand->u.roamCmd.hBSSList = hBSSList;
6563 pCommand->u.roamCmd.roamId = roamId;
6564 pCommand->u.roamCmd.roamReason = reason;
6565 //We need to free the BssList when the command is done
6566 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6567 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6569 FL("CSR PERSONA=%d"),
6570 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6572 if( !HAL_STATUS_SUCCESS( status ) )
6573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006574 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 csrReleaseCommandRoam( pMac, pCommand );
6576 }
6577 }
6578
6579 return (status);
6580}
Jeff Johnson295189b2012-06-20 16:38:30 -07006581eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6582 tCsrRoamModifyProfileFields *pMmodProfileFields,
6583 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6584{
6585 eHalStatus status = eHAL_STATUS_SUCCESS;
6586 tSmeCmd *pCommand;
6587
6588 pCommand = csrGetCommandBuffer(pMac);
6589 if(NULL == pCommand)
6590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006591 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 status = eHAL_STATUS_RESOURCES;
6593 }
6594 else
6595 {
6596 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306597 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 if(pProfile)
6599 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 //This is likely trying to reassoc to different profile
6601 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6602 //make a copy of the profile
6603 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6604 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 }
6606 else
6607 {
6608 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6609 //how to update WPA/WPA2 info in roamProfile??
6610 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 if(HAL_STATUS_SUCCESS(status))
6613 {
6614 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6615 }
6616 pCommand->command = eSmeCommandRoam;
6617 pCommand->sessionId = (tANI_U8)sessionId;
6618 pCommand->u.roamCmd.roamId = roamId;
6619 pCommand->u.roamCmd.roamReason = reason;
6620 //We need to free the BssList when the command is done
6621 //For reassoc there is no BSS list, so the boolean set to false
6622 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6623 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6624 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6626 if( !HAL_STATUS_SUCCESS( status ) )
6627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006628 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6630 csrReleaseCommandRoam( pMac, pCommand );
6631 }
6632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 return (status);
6634}
6635
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006636eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6637 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306638// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006639{
6640 eHalStatus status = eHAL_STATUS_SUCCESS;
6641 tSmeCmd *pCommand;
6642
6643 pCommand = csrGetCommandBuffer(pMac);
6644 if(NULL == pCommand)
6645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006646 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006647 status = eHAL_STATUS_RESOURCES;
6648 }
6649 else
6650 {
6651 if(pBssDescription)
6652 {
6653 //copy over the parameters we need later
6654 pCommand->command = eSmeCommandRoam;
6655 pCommand->sessionId = (tANI_U8)sessionId;
6656 pCommand->u.roamCmd.roamReason = reason;
6657 //this is the important parameter
6658 //in this case we are using this field for the "next" BSS
6659 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6660 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6661 if( !HAL_STATUS_SUCCESS( status ) )
6662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006663 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006664 csrReleaseCommandPreauth( pMac, pCommand );
6665 }
6666 }
6667 else
6668 {
6669 //Return failure
6670 status = eHAL_STATUS_RESOURCES;
6671 }
6672 }
6673 return (status);
6674}
6675
6676eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6677{
6678 tListElem *pEntry;
6679 tSmeCmd *pCommand;
6680 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6681 if ( pEntry )
6682 {
6683 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6684 if ( (eSmeCommandRoam == pCommand->command) &&
6685 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6686 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006687 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006688 pCommand->command, pCommand->u.roamCmd.roamReason);
6689 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6690 csrReleaseCommandPreauth( pMac, pCommand );
6691 }
6692 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006693 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006694 pCommand->command, pCommand->u.roamCmd.roamReason);
6695 }
6696 }
6697 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006698 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006699 }
6700 smeProcessPendingQueue( pMac );
6701 return eHAL_STATUS_SUCCESS;
6702}
6703
Jeff Johnson295189b2012-06-20 16:38:30 -07006704eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6705 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6706{
6707 eHalStatus status = eHAL_STATUS_FAILURE;
6708 tScanResultHandle hBSSList;
6709 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6711 if(HAL_STATUS_SUCCESS(status))
6712 {
6713 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6714 if(pRoamId)
6715 {
6716 *pRoamId = roamId;
6717 }
6718 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6719 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6720 if(!HAL_STATUS_SUCCESS(status))
6721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006722 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 csrScanResultPurge(pMac, hBSSList);
6724 }
6725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 return (status);
6727}
6728
Jeff Johnson295189b2012-06-20 16:38:30 -07006729eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6730 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6731{
6732 eHalStatus status = eHAL_STATUS_SUCCESS;
6733 tScanResultHandle hBSSList;
6734 tCsrScanResultFilter *pScanFilter;
6735 tANI_U32 roamId = 0;
6736 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6737 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 if (NULL == pProfile)
6739 {
6740 smsLog(pMac, LOGP, FL("No profile specified"));
6741 return eHAL_STATUS_FAILURE;
6742 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306743 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6744 "encryType = %d"),
6745 lim_BssTypetoString(pProfile->BSSType),
6746 pProfile->BSSType,
6747 pProfile->AuthType.authType[0],
6748 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 if( CSR_IS_WDS( pProfile ) &&
6750 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006752 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006753 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 return status;
6755 }
6756 csrRoamCancelRoaming(pMac, sessionId);
6757 csrScanRemoveFreshScanCommand(pMac, sessionId);
6758 csrScanCancelIdleScan(pMac);
6759 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306760 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306761
6762 if (!vos_concurrent_open_sessions_running() &&
6763 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306765 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 csrScanDisable(pMac);
6767 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306768
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6770 //Check whether ssid changes
6771 if(csrIsConnStateConnected(pMac, sessionId))
6772 {
6773 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6774 {
6775 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6776 }
6777 }
6778#ifdef FEATURE_WLAN_BTAMP_UT_RF
6779 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6780#endif
6781 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006783 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6785 if(pRoamId)
6786 {
6787 roamId = *pRoamId;
6788 }
6789 if(!HAL_STATUS_SUCCESS(status))
6790 {
6791 fCallCallback = eANI_BOOLEAN_TRUE;
6792 }
6793 }
6794 else
6795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306796 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6797 if ( NULL == pScanFilter )
6798 status = eHAL_STATUS_FAILURE;
6799 else
6800 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 if(HAL_STATUS_SUCCESS(status))
6802 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306803 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006804 //Try to connect to any BSS
6805 if(NULL == pProfile)
6806 {
6807 //No encryption
6808 pScanFilter->EncryptionType.numEntries = 1;
6809 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6810 }//we don't have a profile
6811 else
6812 {
6813 //Here is the profile we need to connect to
6814 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6815 }//We have a profile
6816 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6817 if(pRoamId)
6818 {
6819 *pRoamId = roamId;
6820 }
6821
6822 if(HAL_STATUS_SUCCESS(status))
6823 {
6824 /*Save the WPS info*/
6825 if(NULL != pProfile)
6826 {
6827 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006828 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 }
6830 else
6831 {
6832 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006833 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 do
6836 {
6837 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 )
6840 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006841 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6843 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6844 if(!HAL_STATUS_SUCCESS(status))
6845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006846 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 fCallCallback = eANI_BOOLEAN_TRUE;
6848 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006849 else
6850 {
6851 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 break;
6854 }
6855 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006856 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 if(HAL_STATUS_SUCCESS(status))
6858 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6860 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6861 if(!HAL_STATUS_SUCCESS(status))
6862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006863 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 csrScanResultPurge(pMac, hBSSList);
6865 fCallCallback = eANI_BOOLEAN_TRUE;
6866 }
6867 }//Have scan result
6868 else if(NULL != pProfile)
6869 {
6870 //Check whether it is for start ibss
6871 if(CSR_IS_START_IBSS(pProfile))
6872 {
6873 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6874 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6875 if(!HAL_STATUS_SUCCESS(status))
6876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006877 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 fCallCallback = eANI_BOOLEAN_TRUE;
6879 }
6880 }
6881 else
6882 {
6883 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006884 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 if(!HAL_STATUS_SUCCESS(status))
6886 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006887 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 fCallCallback = eANI_BOOLEAN_TRUE;
6889 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006890 else
6891 {
6892 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 }
6895 }
6896 else
6897 {
6898 fCallCallback = eANI_BOOLEAN_TRUE;
6899 }
6900 } while (0);
6901 if(NULL != pProfile)
6902 {
6903 //we need to free memory for filter if profile exists
6904 csrFreeScanFilter(pMac, pScanFilter);
6905 }
6906 }//Got the scan filter from profile
6907
Kiet Lam64c1b492013-07-12 13:56:44 +05306908 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 }//allocated memory for pScanFilter
6910 }//No Bsslist coming in
6911 //tell the caller if we fail to trigger a join request
6912 if( fCallCallback )
6913 {
6914 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6915 }
6916
6917 return (status);
6918}
Jeff Johnson295189b2012-06-20 16:38:30 -07006919eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6920 tCsrRoamModifyProfileFields modProfileFields,
6921 tANI_U32 *pRoamId)
6922{
6923 eHalStatus status = eHAL_STATUS_SUCCESS;
6924 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6925 tANI_U32 roamId = 0;
6926 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 if (NULL == pProfile)
6928 {
6929 smsLog(pMac, LOGP, FL("No profile specified"));
6930 return eHAL_STATUS_FAILURE;
6931 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306932 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6933 "encryType = %d"),
6934 lim_BssTypetoString(pProfile->BSSType),
6935 pProfile->BSSType,
6936 pProfile->AuthType.authType[0],
6937 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 csrRoamCancelRoaming(pMac, sessionId);
6939 csrScanRemoveFreshScanCommand(pMac, sessionId);
6940 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306941 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 if(csrIsConnStateConnected(pMac, sessionId))
6944 {
6945 if(pProfile)
6946 {
6947 if(pProfile->SSIDs.numOfSSIDs &&
6948 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6949 {
6950 fCallCallback = eANI_BOOLEAN_FALSE;
6951 }
6952 else
6953 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006954 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 }
6956 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306957 else if (!vos_mem_compare(&modProfileFields,
6958 &pSession->connectedProfile.modifyProfileFields,
6959 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 {
6961 fCallCallback = eANI_BOOLEAN_FALSE;
6962 }
6963 else
6964 {
6965 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006966 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 }
6968 }
6969 else
6970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006971 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 if(!fCallCallback)
6974 {
6975 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6976 if(pRoamId)
6977 {
6978 *pRoamId = roamId;
6979 }
6980
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6982 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 }
6984 else
6985 {
6986 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6987 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 return status;
6990}
Jeff Johnson295189b2012-06-20 16:38:30 -07006991eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6992{
6993 eHalStatus status = eHAL_STATUS_FAILURE;
6994 tScanResultHandle hBSSList = NULL;
6995 tCsrScanResultFilter *pScanFilter = NULL;
6996 tANI_U32 roamId;
6997 tCsrRoamProfile *pProfile = NULL;
6998 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006999
7000 if(!pSession)
7001 {
7002 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7003 return eHAL_STATUS_FAILURE;
7004 }
7005
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 do
7007 {
7008 if(pSession->pCurRoamProfile)
7009 {
7010 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307011 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307013 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7014 if ( NULL == pProfile )
7015 status = eHAL_STATUS_FAILURE;
7016 else
7017 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 if(!HAL_STATUS_SUCCESS(status))
7019 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307020 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307022 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007023 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307024 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7025 if ( NULL == pScanFilter )
7026 status = eHAL_STATUS_FAILURE;
7027 else
7028 status = eHAL_STATUS_SUCCESS;
7029
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 if(!HAL_STATUS_SUCCESS(status))
7031 {
7032 break;
7033 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307034 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7036 if(!HAL_STATUS_SUCCESS(status))
7037 {
7038 break;
7039 }
7040 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7041 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7042 if(HAL_STATUS_SUCCESS(status))
7043 {
7044 //we want to put the last connected BSS to the very beginning, if possible
7045 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7046 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7047 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7048 if(!HAL_STATUS_SUCCESS(status))
7049 {
7050 csrScanResultPurge(pMac, hBSSList);
7051 break;
7052 }
7053 }
7054 else
7055 {
7056 //Do a scan on this profile
7057 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007058 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 if(!HAL_STATUS_SUCCESS(status))
7060 {
7061 break;
7062 }
7063 }
7064 }//We have a profile
7065 else
7066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007067 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 break;
7069 }
7070 }while(0);
7071 if(pScanFilter)
7072 {
7073 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307074 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 }
7076 if(NULL != pProfile)
7077 {
7078 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307079 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 return (status);
7082}
Jeff Johnson295189b2012-06-20 16:38:30 -07007083eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7084{
7085 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 if(csrIsConnStateConnected(pMac, sessionId))
7087 {
7088 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7089 if(HAL_STATUS_SUCCESS(status))
7090 {
7091 status = csrRoamJoinLastProfile(pMac, sessionId);
7092 }
7093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 return (status);
7095}
7096
Jeff Johnson295189b2012-06-20 16:38:30 -07007097eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7098{
7099 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007100 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007101 csrRoamCancelRoaming(pMac, sessionId);
7102 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7103 if(csrIsConnStateDisconnected(pMac, sessionId))
7104 {
7105 status = csrRoamJoinLastProfile(pMac, sessionId);
7106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007107 return (status);
7108}
7109
Jeff Johnson295189b2012-06-20 16:38:30 -07007110eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7111{
7112 eHalStatus status = eHAL_STATUS_SUCCESS;
7113 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7114 eCsrRoamSubState NewSubstate;
7115 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307116
7117 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7118 {
7119 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7120 " eCSR_ROAM_SUBSTATE_NONE"));
7121 csrRoamStopWaitForKeyTimer( pMac );
7122 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 // change state to 'Roaming'...
7125 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7126
7127 if ( csrIsConnStateIbss( pMac, sessionId ) )
7128 {
7129 // If we are in an IBSS, then stop the IBSS...
7130 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7131 fComplete = (!HAL_STATUS_SUCCESS(status));
7132 }
7133 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007135 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 -07007136 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7137 //Restore AC weight in case we change it
7138 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7139 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7140 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7141 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7142 {
7143 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7144 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307145 else
7146 {
7147 // If we are in neighbor preauth done state then on receiving
7148 // disassoc or deauth we dont roam instead we just disassoc
7149 // from current ap and then go to disconnected state
7150 // This happens for ESE and 11r FT connections ONLY.
7151#ifdef WLAN_FEATURE_VOWIFI_11R
7152 if (csrRoamIs11rAssoc(pMac) &&
7153 (csrNeighborRoamStatePreauthDone(pMac)))
7154 {
7155 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7156 }
7157#endif
7158#ifdef FEATURE_WLAN_ESE
7159 if (csrRoamIsESEAssoc(pMac) &&
7160 (csrNeighborRoamStatePreauthDone(pMac)))
7161 {
7162 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7163 }
7164#endif
7165#ifdef FEATURE_WLAN_LFR
7166 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7167 (csrNeighborRoamStatePreauthDone(pMac)))
7168 {
7169 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7170 }
7171#endif
7172 }
7173
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 if( fDisassoc )
7175 {
7176 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307177 if (pMac->roam.configParam.roamDelayStatsEnabled)
7178 {
7179 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 }
7182 else
7183 {
7184 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7185 }
7186 fComplete = (!HAL_STATUS_SUCCESS(status));
7187 }
7188 else if ( csrIsConnStateWds( pMac, sessionId ) )
7189 {
7190 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7191 {
7192 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7193 fComplete = (!HAL_STATUS_SUCCESS(status));
7194 }
7195 //This has to be WDS station
7196 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7197 {
7198
7199 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7200 if( fDisassoc )
7201 {
7202 status = csrRoamIssueDisassociate( pMac, sessionId,
7203 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7204 fComplete = (!HAL_STATUS_SUCCESS(status));
7205 }
7206 }
7207 } else {
7208 // we got a dis-assoc request while not connected to any peer
7209 // just complete the command
7210 fComplete = eANI_BOOLEAN_TRUE;
7211 status = eHAL_STATUS_FAILURE;
7212 }
7213 if(fComplete)
7214 {
7215 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7216 }
7217
7218 if(HAL_STATUS_SUCCESS(status))
7219 {
7220 if ( csrIsConnStateInfra( pMac, sessionId ) )
7221 {
7222 //Set the state to disconnect here
7223 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307224#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7225 //we don't need to run this timer any more
7226 if (VOS_TIMER_STATE_RUNNING ==
7227 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7228 {
7229 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7230 if (status != eHAL_STATUS_SUCCESS)
7231 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7232 }
7233#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 }
7235 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007236 else
7237 {
7238 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 return (status);
7241}
7242
Jeff Johnson295189b2012-06-20 16:38:30 -07007243/* This is been removed from latest code base */
7244/*
7245static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7246{
7247 eHalStatus status;
7248 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7250 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 return ( status );
7252}
7253*/
7254
Jeff Johnson295189b2012-06-20 16:38:30 -07007255eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7256{
7257 eHalStatus status = eHAL_STATUS_SUCCESS;
7258 tSmeCmd *pCommand;
7259 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 do
7261 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 pCommand = csrGetCommandBuffer( pMac );
7263 if ( !pCommand )
7264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007265 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 status = eHAL_STATUS_RESOURCES;
7267 break;
7268 }
7269 //Change the substate in case it is wait-for-key
7270 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7271 {
7272 csrRoamStopWaitForKeyTimer( pMac );
7273 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7274 }
7275 pCommand->command = eSmeCommandRoam;
7276 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307277 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7278 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 switch ( reason )
7280 {
7281 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7282 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 case eCSR_DISCONNECT_REASON_DEAUTH:
7285 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 case eCSR_DISCONNECT_REASON_HANDOFF:
7288 fHighPriority = eANI_BOOLEAN_TRUE;
7289 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7292 case eCSR_DISCONNECT_REASON_DISASSOC:
7293 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7294 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7296 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7297 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7299 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7300 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 default:
7302 break;
7303 }
7304 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7305 if( !HAL_STATUS_SUCCESS( status ) )
7306 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007307 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 csrReleaseCommandRoam( pMac, pCommand );
7309 }
7310 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 return( status );
7312}
7313
Jeff Johnson295189b2012-06-20 16:38:30 -07007314eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7315{
7316 eHalStatus status = eHAL_STATUS_SUCCESS;
7317 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 pCommand = csrGetCommandBuffer( pMac );
7319 if ( NULL != pCommand )
7320 {
7321 //Change the substate in case it is wait-for-key
7322 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7323 {
7324 csrRoamStopWaitForKeyTimer( pMac );
7325 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7326 }
7327 pCommand->command = eSmeCommandRoam;
7328 pCommand->sessionId = (tANI_U8)sessionId;
7329 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7330 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7331 if( !HAL_STATUS_SUCCESS( status ) )
7332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007333 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 csrReleaseCommandRoam( pMac, pCommand );
7335 }
7336 }
7337 else
7338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007339 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 status = eHAL_STATUS_RESOURCES;
7341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 return ( status );
7343}
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7346{
7347 eHalStatus status = eHAL_STATUS_SUCCESS;
7348 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007349
7350 if(!pSession)
7351 {
7352 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7353 return eHAL_STATUS_FAILURE;
7354 }
7355
Jeff Johnson295189b2012-06-20 16:38:30 -07007356#ifdef FEATURE_WLAN_BTAMP_UT_RF
7357 //Stop te retry
7358 pSession->maxRetryCount = 0;
7359 csrRoamStopJoinRetryTimer(pMac, sessionId);
7360#endif
7361 //Not to call cancel roaming here
7362 //Only issue disconnect when necessary
7363 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7364 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7365 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7366
7367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007368 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7370 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307371 else
7372 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307373 csrScanAbortScanForSSID(pMac, sessionId);
7374 status = eHAL_STATUS_CMD_NOT_QUEUED;
7375 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7376 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007378 return (status);
7379}
7380
Jeff Johnson295189b2012-06-20 16:38:30 -07007381eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7382{
7383 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007384
7385 if(!pSession)
7386 {
7387 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7388 return eHAL_STATUS_FAILURE;
7389 }
7390
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7393
7394 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7395}
7396
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307397void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7398{
7399 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7400 if(!pSession)
7401 {
7402 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7403 return;
7404 }
7405 pSession->abortConnection = TRUE;
7406 return;
7407}
7408
Jeff Johnson295189b2012-06-20 16:38:30 -07007409eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7410 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7411{
7412 eHalStatus status = eHAL_STATUS_SUCCESS;
7413 tDot11fBeaconIEs *pIesTemp = pIes;
7414 tANI_U8 index;
7415 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7416 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007417
7418 if(!pSession)
7419 {
7420 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7421 return eHAL_STATUS_FAILURE;
7422 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007423 if(pConnectProfile->pAddIEAssoc)
7424 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307425 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007426 pConnectProfile->pAddIEAssoc = NULL;
7427 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307428 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7430 pConnectProfile->AuthInfo = pProfile->AuthType;
7431 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7432 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7433 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7434 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7435 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7436 pConnectProfile->BSSType = pProfile->BSSType;
7437 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7438 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007439 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307440 if (!pConnectProfile->beaconInterval)
7441 {
7442 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7443 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307444 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007445 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7446 if(pProfile->nAddIEAssocLength)
7447 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307448 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7449 if ( NULL == pConnectProfile->pAddIEAssoc )
7450 status = eHAL_STATUS_FAILURE;
7451 else
7452 status = eHAL_STATUS_SUCCESS;
7453 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007454 {
7455 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7456 return eHAL_STATUS_FAILURE;
7457 }
7458 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307459 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7460 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007461 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307462
7463#ifdef WLAN_FEATURE_11W
7464 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7465 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7466 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7467#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007468
Jeff Johnson295189b2012-06-20 16:38:30 -07007469 //Save bssid
7470 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7471#ifdef WLAN_FEATURE_VOWIFI_11R
7472 if (pSirBssDesc->mdiePresent)
7473 {
7474 pConnectProfile->MDID.mdiePresent = 1;
7475 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7476 }
7477#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007478 if( NULL == pIesTemp )
7479 {
7480 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7481 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007482#ifdef FEATURE_WLAN_ESE
7483 if ((csrIsProfileESE(pProfile) ||
7484 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307485 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7486 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7487 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7488 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7489#ifdef WLAN_FEATURE_11W
7490 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307491 || (pProfile->negotiatedAuthType ==
7492 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307493#endif
7494 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007495 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007497 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 }
7499#endif
7500 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 if(HAL_STATUS_SUCCESS(status))
7502 {
7503 if(pIesTemp->SSID.present)
7504 {
7505 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307506 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7507 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 }
7509
7510 //Save the bss desc
7511 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307512
7513 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307515 //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 -07007516 pConnectProfile->qap = TRUE;
7517 }
7518 else
7519 {
7520 pConnectProfile->qap = FALSE;
7521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007522 if ( NULL == pIes )
7523 {
7524 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307525 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 }
7527 }
7528 //Save Qos connection
7529 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7530
7531 if(!HAL_STATUS_SUCCESS(status))
7532 {
7533 csrFreeConnectBssDesc(pMac, sessionId);
7534 }
7535 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7536 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307537 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7538 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7539 pConnectProfile->SSID.ssId,
7540 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 {
7542 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7543 break;
7544 }
7545 pConnectProfile->handoffPermitted = FALSE;
7546 }
7547
7548 return (status);
7549}
7550
Jeff Johnson295189b2012-06-20 16:38:30 -07007551static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7552{
7553 tListElem *pEntry = NULL;
7554 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307555 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 //The head of the active list is the request we sent
7557 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7558 if(pEntry)
7559 {
7560 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7561 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307562 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7564 {
7565 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7566 {
7567#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7568 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7569#endif
7570 }
7571 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307572 if(!pSession)
7573 {
7574 smsLog(pMac, LOGE, FL(" session %d not found "),
7575 pSmeJoinRsp->sessionId);
7576 return;
7577 }
7578 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 }
7580 else
7581 {
7582 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007583 if(!pSession)
7584 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307585 smsLog(pMac, LOGE, FL(" session %d not found "),
7586 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007587 return;
7588 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307589 if (pSession->abortConnection)
7590 {
7591 smsLog(pMac, LOG1, FL("Disconnection in progess"
7592 "abort Join request"));
7593 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7594 pSession->abortConnection = FALSE;
7595 return;
7596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 //The head of the active list is the request we sent
7598 //Try to get back the same profile and roam again
7599 if(pCommand)
7600 {
7601 roamId = pCommand->u.roamCmd.roamId;
7602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7604 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007605 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007606#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7607 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7608 if (csrRoamIsHandoffInProgress(pMac))
7609 {
7610 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7611 /* Should indicate neighbor roam algorithm about the connect failure here */
7612 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7613 }
7614#endif
7615 if (pCommand)
7616 {
7617 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7618 {
7619 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7620 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7621 csrRoamReissueRoamCommand(pMac);
7622 }
7623 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7624 {
7625 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7626 }
7627 else
7628 {
7629 csrRoam(pMac, pCommand);
7630 }
7631 }
7632 else
7633 {
7634 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7635 }
7636 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7637}
7638
Jeff Johnson295189b2012-06-20 16:38:30 -07007639eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7640 tDot11fBeaconIEs *pIes,
7641 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7642{
7643 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007644 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7645 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007646
7647 // Set the roaming substate to 'join attempt'...
7648 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007650 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 return (status);
7652}
7653
Jeff Johnson295189b2012-06-20 16:38:30 -07007654static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7655 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7656{
7657 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 // Set the roaming substate to 'join attempt'...
7659 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7660
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307661 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7662 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307663 if (pMac->roam.configParam.roamDelayStatsEnabled)
7664 {
7665 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7666 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007669 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007670}
7671
Jeff Johnson295189b2012-06-20 16:38:30 -07007672void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7673{
7674 tListElem *pEntry;
7675 tSmeCmd *pCommand;
7676 tCsrRoamInfo roamInfo;
7677 tANI_U32 sessionId;
7678 tCsrRoamSession *pSession;
7679
7680 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7681 if(pEntry)
7682 {
7683 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7684 if ( eSmeCommandRoam == pCommand->command )
7685 {
7686 sessionId = pCommand->sessionId;
7687 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007688
7689 if(!pSession)
7690 {
7691 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7692 return;
7693 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307694 /* While switching between two AP, csr will reissue roam command again
7695 to the nextbss if it was interrupted by the dissconnect req for the
7696 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7697 so reset the bRefAssocStartCnt.
7698 */
7699 if(pSession->bRefAssocStartCnt > 0)
7700 {
7701 pSession->bRefAssocStartCnt--;
7702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 if( pCommand->u.roamCmd.fStopWds )
7704 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307705 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7707 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7708 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7711 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7712 eCSR_ROAM_WDS_IND,
7713 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7715 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7716 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7717 eCSR_ROAM_INFRA_IND,
7718 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7719 }
7720
Jeff Johnson295189b2012-06-20 16:38:30 -07007721
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007724 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7726 }
7727 }
7728 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007730 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7732 }
7733 }
7734 else
7735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007736 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 }
7738 }
7739 else
7740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007741 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 }
7743}
7744
Jeff Johnson295189b2012-06-20 16:38:30 -07007745tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7746{
7747 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7748 tListElem *pEntry;
7749 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 //alwasy lock active list before locking pending list
7751 csrLLLock( &pMac->sme.smeCmdActiveList );
7752 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7753 if(pEntry)
7754 {
7755 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7756 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7757 {
7758 fRet = eANI_BOOLEAN_TRUE;
7759 }
7760 }
7761 if(eANI_BOOLEAN_FALSE == fRet)
7762 {
7763 csrLLLock(&pMac->sme.smeCmdPendingList);
7764 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7765 while(pEntry)
7766 {
7767 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7768 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7769 {
7770 fRet = eANI_BOOLEAN_TRUE;
7771 break;
7772 }
7773 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7774 }
7775 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7776 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307777 if (eANI_BOOLEAN_FALSE == fRet)
7778 {
7779 csrLLLock(&pMac->roam.roamCmdPendingList);
7780 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7781 while (pEntry)
7782 {
7783 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7784 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7785 {
7786 fRet = eANI_BOOLEAN_TRUE;
7787 break;
7788 }
7789 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7790 }
7791 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007793 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007794 return (fRet);
7795}
7796
Jeff Johnson295189b2012-06-20 16:38:30 -07007797tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7798{
7799 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7800 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7802 {
7803 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7804 {
7805 break;
7806 }
7807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 return ( fRet );
7809}
7810
Jeff Johnson295189b2012-06-20 16:38:30 -07007811tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7812{
7813 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007814 //alwasy lock active list before locking pending list
7815 csrLLLock( &pMac->sme.smeCmdActiveList );
7816 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7817 if(eANI_BOOLEAN_FALSE == fRet)
7818 {
7819 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7820 }
7821 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 return (fRet);
7823}
7824
Jeff Johnson295189b2012-06-20 16:38:30 -07007825tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7826{
7827 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7828 tListElem *pEntry;
7829 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 //alwasy lock active list before locking pending list
7831 csrLLLock( &pMac->sme.smeCmdActiveList );
7832 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7833 if( pEntry )
7834 {
7835 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7836 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7837 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7838 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7839 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7840 {
7841 fRet = eANI_BOOLEAN_TRUE;
7842 }
7843 }
7844 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 return (fRet);
7846}
Jeff Johnson295189b2012-06-20 16:38:30 -07007847eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7848{
7849 eHalStatus status = eHAL_STATUS_SUCCESS;
7850 tSmeCmd *pCommand = NULL;
7851 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7852 tANI_BOOLEAN fRemoveCmd = FALSE;
7853 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 // Delete the old assoc command. All is setup for reassoc to be serialized
7855 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7856 if ( pEntry )
7857 {
7858 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7859 if ( !pCommand )
7860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007861 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 return eHAL_STATUS_RESOURCES;
7863 }
7864 if ( eSmeCommandRoam == pCommand->command )
7865 {
7866 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7867 {
7868 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7869 }
7870 else
7871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007872 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
7874 if (fRemoveCmd == FALSE)
7875 {
7876 // Implies we did not get the serialized assoc command we
7877 // were expecting
7878 pCommand = NULL;
7879 }
7880 }
7881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 if(NULL == pCommand)
7883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007884 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 return eHAL_STATUS_RESOURCES;
7886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 do
7888 {
7889 //Change the substate in case it is wait-for-key
7890 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7891 {
7892 csrRoamStopWaitForKeyTimer( pMac );
7893 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7894 }
7895 pCommand->command = eSmeCommandRoam;
7896 pCommand->sessionId = (tANI_U8)sessionId;
7897 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007898 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7899 if( !HAL_STATUS_SUCCESS( status ) )
7900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007901 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007902 csrReleaseCommandRoam( pMac, pCommand );
7903 }
7904 } while( 0 );
7905
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 return( status );
7907}
7908static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7909{
7910 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7911 tCsrScanResult *pScanResult = NULL;
7912 tSirBssDescription *pBssDesc = NULL;
7913 tSmeCmd *pCommand = NULL;
7914 tANI_U32 sessionId;
7915 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 if(NULL == pEntry)
7917 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307918 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 return;
7920 }
7921 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7922 sessionId = pCommand->sessionId;
7923 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007924
7925 if(!pSession)
7926 {
7927 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7928 return;
7929 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307930 smsLog(pMac, LOG1, FL("CFG return value is %d "
7931 " current state is : %d substate is : %d "),
7932 result, pMac->roam.curState[sessionId],
7933 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7935 {
7936 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007937 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7939 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007940 /* If the roaming has stopped, not to continue the roaming command*/
7941 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7942 {
7943 //No need to complete roaming here as it already completes
7944 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7945 pCommand->u.roamCmd.roamReason);
7946 csrSetAbortRoamingCommand( pMac, pCommand );
7947 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 else
7950 {
7951 if ( CCM_IS_RESULT_SUCCESS(result) )
7952 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307953 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 // Successfully set the configuration parameters for the new Bss. Attempt to
7955 // join the roaming Bss.
7956 if(pCommand->u.roamCmd.pRoamBssEntry)
7957 {
7958 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7959 pBssDesc = &pScanResult->Result.BssDescriptor;
7960 }
7961 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7962 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007963 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 )
7965 {
7966 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7967 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7968 pBssDesc, pCommand->u.roamCmd.roamId )))
7969 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307970 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 //We need to complete the command
7972 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7973 }
7974 }
7975 else
7976 {
7977 if (!pCommand->u.roamCmd.pRoamBssEntry)
7978 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307979 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 //We need to complete the command
7981 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7982 return;
7983 }
7984 // If we are roaming TO an Infrastructure BSS...
7985 VOS_ASSERT(pScanResult != NULL);
7986 if ( csrIsInfraBssDesc( pBssDesc ) )
7987 {
7988 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307989 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7991 {
7992 // ..and currently in an Infrastructure connection....
7993 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7994 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307995 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007996 // ...and the SSIDs are equal, then we Reassoc.
7997 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7998 pIesLocal ) )
7999 // ..and currently in an infrastructure connection
8000 {
8001 // then issue a Reassoc.
8002 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8003 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8004 &pCommand->u.roamCmd.roamProfile );
8005 }
8006 else
8007 {
8008
8009 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8010 // previously associated AP.
8011 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8012 pIesLocal,
8013 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8014 {
8015 //try something else
8016 csrRoam( pMac, pCommand );
8017 }
8018 }
8019 }
8020 else
8021 {
8022 eHalStatus status = eHAL_STATUS_SUCCESS;
8023
8024 /* We need to come with other way to figure out that this is because of HO in BMP
8025 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008026 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 * use join request */
8028#ifdef WLAN_FEATURE_VOWIFI_11R
8029 if (csrRoamIsHandoffInProgress(pMac) &&
8030 csrRoamIs11rAssoc(pMac))
8031 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308032 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8034 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8035 }
8036 else
8037#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008038#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008040 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308042 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 // Now serialize the reassoc command.
8044 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8045 }
8046 else
8047#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008048#ifdef FEATURE_WLAN_LFR
8049 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308050 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008051 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308052 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008053 // Now serialize the reassoc command.
8054 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8055 }
8056 else
8057#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 // else we are not connected and attempting to Join. Issue the
8059 // Join request.
8060 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308061 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8063 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8064 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8065 }
8066 if(!HAL_STATUS_SUCCESS(status))
8067 {
8068 //try something else
8069 csrRoam( pMac, pCommand );
8070 }
8071 }
8072 if( !pScanResult->Result.pvIes )
8073 {
8074 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308075 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 }
8077 }
8078 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8079 else
8080 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008081 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 }
8083 }//else
8084 }//if ( WNI_CFG_SUCCESS == result )
8085 else
8086 {
8087 // In the event the configuration failed, for infra let the roam processor
8088 //attempt to join something else...
8089 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8090 {
8091 csrRoam(pMac, pCommand);
8092 }
8093 else
8094 {
8095 //We need to complete the command
8096 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8097 {
8098 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8099 }
8100 else
8101 {
8102 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8103 }
8104 }
8105 }
8106 }//we have active entry
8107}
8108
Jeff Johnson295189b2012-06-20 16:38:30 -07008109static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8110{
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008113 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8115 // join the new one...
8116 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8118 }
8119 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008120 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 /***profHandleLostLinkAfterReset(pAdapter);
8122 // In the event the authenticate fails, let the roam processor attempt to join something else...
8123 roamRoam( pAdapter );***/
8124 }
8125}
8126
Jeff Johnson295189b2012-06-20 16:38:30 -07008127static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8128{
8129 eCsrRoamCompleteResult result;
8130 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8131 tCsrRoamInfo roamInfo;
8132 tANI_U32 roamId = 0;
8133
8134 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
8135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008136 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 /* Defeaturize this part later if needed */
8139#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8140 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8141 * we need the response contents while processing the result in csrRoamProcessResults() */
8142 if (csrRoamIsHandoffInProgress(pMac))
8143 {
8144 /* Need to dig more on indicating events to SME QoS module */
8145 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8146 csrRoamComplete( pMac, result, pSmeJoinRsp);
8147 }
8148 else
8149#endif
8150 {
8151 csrRoamComplete( pMac, result, NULL );
8152 }
8153 }
8154 /* Should we handle this similar to handling the join failure? Is it ok
8155 * to call csrRoamComplete() with state as CsrJoinFailure */
8156 else
8157 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008158 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 result = eCsrReassocFailure;
8160#ifdef WLAN_FEATURE_VOWIFI_11R
8161 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308162 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8163 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 {
8165 // Inform HDD to turn off FT flag in HDD
8166 if (pNeighborRoamInfo)
8167 {
8168 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8169 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8170 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008171 /*
8172 * Since the above callback sends a disconnect
8173 * to HDD, we should clean-up our state
8174 * machine as well to be in sync with the upper
8175 * layers. There is no need to send a disassoc
8176 * since: 1) we will never reassoc to the current
8177 * AP in LFR, and 2) there is no need to issue a
8178 * disassoc to the AP with which we were trying
8179 * to reassoc.
8180 */
8181 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8182 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 }
8184 }
8185#endif
8186 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8187 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8188 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8189 //The disassoc rsp message will remove the command from active list
8190 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8191 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8192 {
8193 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8194 }
8195 }
8196}
8197
Jeff Johnson295189b2012-06-20 16:38:30 -07008198static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8199{
Jeff Johnson295189b2012-06-20 16:38:30 -07008200#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8201 {
8202 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8204 if(pIbssLog)
8205 {
8206 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8207 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8208 {
8209 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8210 }
8211 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8212 }
8213 }
8214#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8216 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8217 {
8218 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8219 }
8220 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8221 {
8222 csrRoamReissueRoamCommand(pMac);
8223 }
8224}
8225
Jeff Johnson295189b2012-06-20 16:38:30 -07008226void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8227{
8228 tSirResultCodes statusCode;
8229#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8230 tScanResultHandle hBSSList;
8231 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8232 eHalStatus status;
8233 tCsrRoamInfo roamInfo;
8234 tCsrScanResultFilter *pScanFilter = NULL;
8235 tANI_U32 roamId = 0;
8236 tCsrRoamProfile *pCurRoamProfile = NULL;
8237 tListElem *pEntry = NULL;
8238 tSmeCmd *pCommand = NULL;
8239#endif
8240 tANI_U32 sessionId;
8241 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008242
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 tSirSmeDisassocRsp SmeDisassocRsp;
8244
8245 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8246 sessionId = SmeDisassocRsp.sessionId;
8247 statusCode = SmeDisassocRsp.statusCode;
8248
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008249 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008250
8251 if ( csrIsConnStateInfra( pMac, sessionId ) )
8252 {
8253 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008256
8257 if(!pSession)
8258 {
8259 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8260 return;
8261 }
8262
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8264 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308265 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8267 }
8268 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8269 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8270 {
8271 if ( eSIR_SME_SUCCESS == statusCode )
8272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008273 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8275 }
8276 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8279 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308280 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8281 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008282#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008283 /*
8284 * First ensure if the roam profile is in the scan cache.
8285 * If not, post a reassoc failure and disconnect.
8286 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308287 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8288 if ( NULL == pScanFilter )
8289 status = eHAL_STATUS_FAILURE;
8290 else
8291 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008292 if(HAL_STATUS_SUCCESS(status))
8293 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308294 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008295 status = csrRoamPrepareFilterFromProfile(pMac,
8296 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8297 if(!HAL_STATUS_SUCCESS(status))
8298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008299 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008300 __func__, status);
8301 goto POST_ROAM_FAILURE;
8302 }
8303 else
8304 {
8305 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8306 if (!HAL_STATUS_SUCCESS(status))
8307 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008308 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008309 __func__, status);
8310 goto POST_ROAM_FAILURE;
8311 }
8312 }
8313 }
8314 else
8315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008316 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008317 __func__, status);
8318 goto POST_ROAM_FAILURE;
8319 }
8320
8321 /*
8322 * After ensuring that the roam profile is in the scan result list,
8323 * dequeue the command from the active list.
8324 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8326 if ( pEntry )
8327 {
8328 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008329 /* If the head of the queue is Active and it is a ROAM command, remove
8330 * and put this on the Free queue.
8331 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 if ( eSmeCommandRoam == pCommand->command )
8333 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008334
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008335 /*
8336 * we need to process the result first before removing it from active list
8337 * because state changes still happening insides roamQProcessRoamResults so
8338 * no other roam command should be issued.
8339 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008340 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8341 if(pCommand->u.roamCmd.fReleaseProfile)
8342 {
8343 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8344 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 else
8349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008350 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008351 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 }
8353 }
8354 else
8355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008356 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 }
8358 }
8359 else
8360 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008361 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008363
8364 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8366
Kiet Lam64c1b492013-07-12 13:56:44 +05308367 vos_mem_copy(roamInfo.bssid,
8368 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8369 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008370
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008371 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8372 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008373
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008374 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308375 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8376 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308378 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008379 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8380 //make sure to put it at the head of the cmd queue
8381 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8382 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8383 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8384
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 if(!HAL_STATUS_SUCCESS(status))
8386 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008387 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008388 __func__, status);
8389 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 }
8391
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008392 /* Notify sub-modules like QoS etc. that handoff happening */
8393 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308394 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008395 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308396 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308398 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008399 return;
8400 }
8401
8402POST_ROAM_FAILURE:
8403 if (pScanFilter)
8404 {
8405 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308406 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008407 }
8408 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308409 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008410
8411 /* Inform the upper layers that the reassoc failed */
8412 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8413 csrRoamCallCallback(pMac, sessionId,
8414 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8415
8416 /*
8417 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8418 * Upon success, we would re-enter this routine after receiving the disassoc
8419 * response and will fall into the reassoc fail sub-state. And, eventually
8420 * call csrRoamComplete which would remove the roam command from SME active
8421 * queue.
8422 */
8423 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8424 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008426 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008427 __func__, status);
8428 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008430#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008431
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8433 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8434 {
8435 // Disassoc due to Reassoc failure falls into this codepath....
8436 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8437 }
8438 else
8439 {
8440 if ( eSIR_SME_SUCCESS == statusCode )
8441 {
8442 // Successfully disassociated from the 'old' Bss...
8443 //
8444 // We get Disassociate response in three conditions.
8445 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8446 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8447 // Infrastructure network.
8448 // - Third is where we are doing an Infra to Infra roam between networks with different
8449 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8450
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008451 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 }
8453 else
8454 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008455 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 }
8457 //We are not done yet. Get the data and continue roaming
8458 csrRoamReissueRoamCommand(pMac);
8459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008460}
8461
Jeff Johnson295189b2012-06-20 16:38:30 -07008462static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8463{
8464 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008466 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008467 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8468 {
8469 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8470 }
8471 else
8472 {
8473 if ( eSIR_SME_SUCCESS == statusCode )
8474 {
8475 // Successfully deauth from the 'old' Bss...
8476 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008477 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 }
8479 else
8480 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008481 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 }
8483 //We are not done yet. Get the data and continue roaming
8484 csrRoamReissueRoamCommand(pMac);
8485 }
8486}
8487
Jeff Johnson295189b2012-06-20 16:38:30 -07008488static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8489{
8490 eCsrRoamCompleteResult result;
8491
8492 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008494 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 result = eCsrStartBssSuccess;
8496 }
8497 else
8498 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008499 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 //Let csrRoamComplete decide what to do
8501 result = eCsrStartBssFailure;
8502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008504}
8505
Jeff Johnson295189b2012-06-20 16:38:30 -07008506/*
8507 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8508 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8509 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8510 For the messages where sender allocates memory for specific structures, then it can be
8511 cast accordingly.
8512*/
8513void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8514{
8515 tSirSmeRsp *pSmeRsp;
8516 tSmeIbssPeerInd *pIbssPeerInd;
8517 tCsrRoamInfo roamInfo;
8518 // TODO Session Id need to be acquired in this function
8519 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308521 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8522 pSmeRsp->messageType, pSmeRsp->messageType,
8523 macTraceGetcsrRoamSubState(
8524 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 pSmeRsp->messageType = (pSmeRsp->messageType);
8526 pSmeRsp->length = (pSmeRsp->length);
8527 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 switch (pSmeRsp->messageType)
8529 {
8530
8531 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8532 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8533 {
8534 //We sent a JOIN_REQ
8535 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8536 }
8537 break;
8538
8539 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8540 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8541 {
8542 //We sent a AUTH_REQ
8543 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8544 }
8545 break;
8546
8547 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8548 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8549 {
8550 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8551 }
8552 break;
8553
8554 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8555 {
8556 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8557 }
8558 break;
8559
8560 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8561 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8562 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8563 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8564 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8565 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8566//HO
8567 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8568 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308569 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8570 macTraceGetcsrRoamSubState(
8571 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308573 if (pMac->roam.configParam.roamDelayStatsEnabled)
8574 {
8575 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 }
8578 break;
8579
8580 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8581 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8582 {
8583 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8584 }
8585 break;
8586
8587 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8588 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8589 {
8590 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8591 }
8592 break;
8593
8594 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8595 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8596 {
8597 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8601 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8602 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008603 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308604 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8605 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8607 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308608 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8609 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8611 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8612 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8613 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05308614 case eWNI_SME_LOST_LINK_PARAMS_IND:
8615 {
8616 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
8617 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8618 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8619 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8620 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
8621 pRoamInfo = &roamInfo;
8622 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
8623 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
8624 break;
8625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308627 smsLog(pMac, LOG1,
8628 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8629 pSmeRsp->messageType, pSmeRsp->messageType,
8630 macTraceGetcsrRoamSubState(
8631 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008632
8633 //If we are connected, check the link status change
8634 if(!csrIsConnStateDisconnected(pMac, sessionId))
8635 {
8636 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8637 }
8638 break;
8639 }
8640}
8641
Jeff Johnson295189b2012-06-20 16:38:30 -07008642void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8643{
8644 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008645 switch (pSirMsg->messageType)
8646 {
8647 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008648 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 csrRoamStatsRspProcessor( pMac, pSirMsg );
8650 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8652 {
8653 tCsrRoamSession *pSession;
8654 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8655 tCsrRoamInfo roamInfo;
8656 tCsrRoamInfo *pRoamInfo = NULL;
8657 tANI_U32 sessionId;
8658 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008659 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308660 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8663 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8664 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008665
8666 if(!pSession)
8667 {
8668 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8669 return;
8670 }
8671
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8673 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8675 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8676 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8678 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308679 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8680 sizeof(tSirMacAddr));
8681 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8682 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008683 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308684#ifdef WLAN_FEATURE_AP_HT40_24G
8685 pRoamInfo->HT40MHzIntoEnabledSta =
8686 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8687 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8688 pRoamInfo->HT40MHzIntoEnabledSta);
8689#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8691 {
8692 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8693 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8694 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8695 }
8696 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8697 {
8698 vos_sleep( 100 );
8699 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8700 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8701 }
8702
Jeff Johnson295189b2012-06-20 16:38:30 -07008703 }
8704 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 default:
8706 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8707 break;
8708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008709}
8710
Jeff Johnson295189b2012-06-20 16:38:30 -07008711eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8712 tSirBssDescription *pBssDescription,
8713 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8714 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8715 tANI_U8 keyId, tANI_U16 keyLength,
8716 tANI_U8 *pKey, tANI_U8 paeRole )
8717{
8718 eHalStatus status = eHAL_STATUS_SUCCESS;
8719 tAniEdType edType;
8720
8721 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8722 {
8723 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8724 }
8725
8726 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8727
8728 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8729 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8730 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8731 addKey )
8732 {
8733 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 setKey.encType = EncryptType;
8735 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308736 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 setKey.paeRole = paeRole; //0 for supplicant
8738 setKey.keyId = keyId; // Kye index
8739 setKey.keyLength = keyLength;
8740 if( keyLength )
8741 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308742 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 }
8744 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 return (status);
8747}
8748
Jeff Johnson295189b2012-06-20 16:38:30 -07008749static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8750 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8751{
8752 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8753 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008754#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008756#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008757
8758 do
8759 {
8760 pCommand = csrGetCommandBuffer(pMac);
8761 if(NULL == pCommand)
8762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008763 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 status = eHAL_STATUS_RESOURCES;
8765 break;
8766 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308767 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 pCommand->command = eSmeCommandSetKey;
8769 pCommand->sessionId = (tANI_U8)sessionId;
8770 // validate the key length, Adjust if too long...
8771 // for static WEP the keys are not set thru' SetContextReq
8772 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8773 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8774 {
8775 //KeyLength maybe 0 for static WEP
8776 if( pSetKey->keyLength )
8777 {
8778 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008780 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 break;
8782 }
8783
8784 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308785 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8786 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 }
8788 }
8789 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8790 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8791 {
8792 //KeyLength maybe 0 for static WEP
8793 if( pSetKey->keyLength )
8794 {
8795 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008797 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 break;
8799 }
8800
8801 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308802 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8803 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 }
8805 }
8806 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8807 {
8808 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008810 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 break;
8812 }
8813 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308814 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8815 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 }
8817 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8818 {
8819 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008821 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 break;
8823 }
8824 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308825 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8826 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 }
8828#ifdef FEATURE_WLAN_WAPI
8829 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8830 {
8831 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008833 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 break;
8835 }
8836 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308837 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8838 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 }
8840#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008841#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8843 {
8844 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008846 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 break;
8848 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008849 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308850 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008851 pSession->eseCckmInfo.reassoc_req_num=1;
8852 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 status = eHAL_STATUS_SUCCESS;
8854 break;
8855 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008856#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008857
Jeff Johnson295189b2012-06-20 16:38:30 -07008858#ifdef WLAN_FEATURE_11W
8859 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008860 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008862 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008864 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 break;
8866 }
8867 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308868 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 }
8870#endif
8871 status = eHAL_STATUS_SUCCESS;
8872 pCommand->u.setKeyCmd.roamId = roamId;
8873 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8874 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308875 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8876 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8878 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308879 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 //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
8881
8882 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8883 if( !HAL_STATUS_SUCCESS( status ) )
8884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008885 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 }
8887 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008889 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008890 if ( ( NULL != pCommand ) &&
8891 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008892#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008894#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008895 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 {
8897 csrReleaseCommandSetKey( pMac, pCommand );
8898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 return( status );
8900}
8901
Jeff Johnson295189b2012-06-20 16:38:30 -07008902eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8903 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8904{
8905 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8906 tSmeCmd *pCommand = NULL;
8907 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 do
8909 {
8910 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008912 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 status = eHAL_STATUS_CSR_WRONG_STATE;
8914 break;
8915 }
8916 pCommand = csrGetCommandBuffer(pMac);
8917 if(NULL == pCommand)
8918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008919 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 status = eHAL_STATUS_RESOURCES;
8921 break;
8922 }
8923 pCommand->command = eSmeCommandRemoveKey;
8924 pCommand->sessionId = (tANI_U8)sessionId;
8925 pCommand->u.removeKeyCmd.roamId = roamId;
8926 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308927 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8928 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8930 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8931 {
8932 //in this case, put it to the end of the Q incase there is a set key pending.
8933 fImediate = eANI_BOOLEAN_FALSE;
8934 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008935 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008937 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8939 if( !HAL_STATUS_SUCCESS( status ) )
8940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008941 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 break;
8943 }
8944 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8946 {
8947 csrReleaseCommandRemoveKey( pMac, pCommand );
8948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 return (status );
8950}
8951
Jeff Johnson295189b2012-06-20 16:38:30 -07008952eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8953{
8954 eHalStatus status;
8955 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8956 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8957 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8958 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008959#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8960 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8961 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308962 if(!pSession)
8963 {
8964 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8965 return eHAL_STATUS_FAILURE;
8966 }
lukez3c809222013-05-03 10:23:02 -07008967 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008968 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308969 vos_mem_set(&setKeyEvent,
8970 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008971 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8972 {
8973 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8974 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8975 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8976 }
8977 else
8978 {
8979 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8980 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8981 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8982 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308983 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008984 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 {
8986 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 //It has to be static WEP here
8988 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8989 {
8990 setKeyEvent.keyId = (v_U8_t)defKeyId;
8991 }
8992 }
8993 else
8994 {
8995 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8996 }
8997 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8998 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8999 }
9000#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 if( csrIsSetKeyAllowed(pMac, sessionId) )
9002 {
9003 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9004 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9005 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9006 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9007 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9008 pCommand->u.setKeyCmd.keyRsc);
9009 }
9010 else
9011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009012 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 //Set this status so the error handling take care of the case.
9014 status = eHAL_STATUS_CSR_WRONG_STATE;
9015 }
9016 if( !HAL_STATUS_SUCCESS(status) )
9017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009018 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009020#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009021 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 {
9023 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9024 {
9025 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9026 }
9027 else
9028 {
9029 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9030 }
9031 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9032 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9033 }
9034#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009036 return ( status );
9037}
9038
Jeff Johnson295189b2012-06-20 16:38:30 -07009039eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9040{
9041 eHalStatus status;
9042 tpSirSmeRemoveKeyReq pMsg = NULL;
9043 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9044 tANI_U8 *p;
9045 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009046#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9047 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9048 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309049 if(!pSession)
9050 {
9051 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9052 return eHAL_STATUS_FAILURE;
9053 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309054 vos_mem_set(&removeKeyEvent,
9055 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9057 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9058 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309059 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9061 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9062 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9063#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009064 if( csrIsSetKeyAllowed(pMac, sessionId) )
9065 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309066 pMsg = vos_mem_malloc(wMsgLen);
9067 if ( NULL == pMsg )
9068 status = eHAL_STATUS_FAILURE;
9069 else
9070 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 }
9072 else
9073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009074 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009075 //Set the error status so error handling kicks in below
9076 status = eHAL_STATUS_CSR_WRONG_STATE;
9077 }
9078 if( HAL_STATUS_SUCCESS( status ) )
9079 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309080 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9082 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 pMsg->sessionId = (tANI_U8)sessionId;
9084 pMsg->transactionId = 0;
9085 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9086 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9087 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309088 vos_mem_copy(p,
9089 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9090 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 p += sizeof(tSirMacAddr);
9092 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309093 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 p += sizeof(tSirMacAddr);
9095 // edType
9096 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9097 p++;
9098 // weptype
9099 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9100 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9101 {
9102 *p = (tANI_U8)eSIR_WEP_STATIC;
9103 }
9104 else
9105 {
9106 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9107 }
9108 p++;
9109 //keyid
9110 *p = pCommand->u.removeKeyCmd.keyId;
9111 p++;
9112 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 status = palSendMBMessage(pMac->hHdd, pMsg);
9114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 if( !HAL_STATUS_SUCCESS( status ) )
9116 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009117 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009118#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9119 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009120 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009121 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9122#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 return ( status );
9126}
9127
Jeff Johnson295189b2012-06-20 16:38:30 -07009128eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9129{
9130 eHalStatus status;
9131
9132 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9133 {
9134 status = eHAL_STATUS_CSR_WRONG_STATE;
9135 }
9136 else
9137 {
9138 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 return ( status );
9141}
9142
Jeff Johnson295189b2012-06-20 16:38:30 -07009143/*
9144 Prepare a filter base on a profile for parsing the scan results.
9145 Upon successful return, caller MUST call csrFreeScanFilter on
9146 pScanFilter when it is done with the filter.
9147*/
9148eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9149 tCsrScanResultFilter *pScanFilter)
9150{
9151 eHalStatus status = eHAL_STATUS_SUCCESS;
9152 tANI_U32 size = 0;
9153 tANI_U8 index = 0;
9154
9155 do
9156 {
9157 if(pProfile->BSSIDs.numOfBSSIDs)
9158 {
9159 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309160 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9161 if ( NULL == pScanFilter->BSSIDs.bssid )
9162 status = eHAL_STATUS_FAILURE;
9163 else
9164 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009165 if(!HAL_STATUS_SUCCESS(status))
9166 {
9167 break;
9168 }
9169 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309170 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 }
9172 if(pProfile->SSIDs.numOfSSIDs)
9173 {
9174 if( !CSR_IS_WDS_STA( pProfile ) )
9175 {
9176 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9177 }
9178 else
9179 {
9180 //For WDS station
9181 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9182 pScanFilter->SSIDs.numOfSSIDs = 1;
9183 }
9184 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309185 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9186 if ( NULL == pScanFilter->SSIDs.SSIDList )
9187 status = eHAL_STATUS_FAILURE;
9188 else
9189 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 if(!HAL_STATUS_SUCCESS(status))
9191 {
9192 break;
9193 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309194 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9195 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 }
9197 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9198 {
9199 pScanFilter->ChannelInfo.numOfChannels = 0;
9200 pScanFilter->ChannelInfo.ChannelList = NULL;
9201 }
9202 else if(pProfile->ChannelInfo.numOfChannels)
9203 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309204 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9205 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9206 pProfile->ChannelInfo.numOfChannels);
9207 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9208 status = eHAL_STATUS_FAILURE;
9209 else
9210 status = eHAL_STATUS_SUCCESS;
9211
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 pScanFilter->ChannelInfo.numOfChannels = 0;
9213 if(HAL_STATUS_SUCCESS(status))
9214 {
9215 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9216 {
9217 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9218 {
9219 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9220 = pProfile->ChannelInfo.ChannelList[index];
9221 pScanFilter->ChannelInfo.numOfChannels++;
9222 }
9223 else
9224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009225 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 }
9228 }
9229 else
9230 {
9231 break;
9232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 }
9234 else
9235 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309236 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 status = eHAL_STATUS_FAILURE;
9238 break;
9239 }
9240 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9241 pScanFilter->authType = pProfile->AuthType;
9242 pScanFilter->EncryptionType = pProfile->EncryptionType;
9243 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9244 pScanFilter->BSSType = pProfile->BSSType;
9245 pScanFilter->phyMode = pProfile->phyMode;
9246#ifdef FEATURE_WLAN_WAPI
9247 //check if user asked for WAPI with 11n or auto mode, in that case modify
9248 //the phymode to 11g
9249 if(csrIsProfileWapi(pProfile))
9250 {
9251 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9252 {
9253 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9254 }
9255 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9256 {
9257 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9258 }
9259 if(!pScanFilter->phyMode)
9260 {
9261 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9262 }
9263 }
9264#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009265 /*Save the WPS info*/
9266 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009267 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009268 if( pProfile->countryCode[0] )
9269 {
9270 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309271 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9272 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009273 }
9274#ifdef WLAN_FEATURE_VOWIFI_11R
9275 if (pProfile->MDID.mdiePresent)
9276 {
9277 pScanFilter->MDID.mdiePresent = 1;
9278 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9279 }
9280#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309281
9282#ifdef WLAN_FEATURE_11W
9283 // Management Frame Protection
9284 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9285 pScanFilter->MFPRequired = pProfile->MFPRequired;
9286 pScanFilter->MFPCapable = pProfile->MFPCapable;
9287#endif
9288
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 }while(0);
9290
9291 if(!HAL_STATUS_SUCCESS(status))
9292 {
9293 csrFreeScanFilter(pMac, pScanFilter);
9294 }
9295
9296 return(status);
9297}
9298
Jeff Johnson295189b2012-06-20 16:38:30 -07009299tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9300 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9301{
9302 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9303 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 do
9305 {
9306 // Validate the type is ok...
9307 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9308 pCommand = csrGetCommandBuffer( pMac );
9309 if ( !pCommand )
9310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009311 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 break;
9313 }
9314 //Change the substate in case it is waiting for key
9315 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9316 {
9317 csrRoamStopWaitForKeyTimer( pMac );
9318 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9319 }
9320 pCommand->command = eSmeCommandWmStatusChange;
9321 pCommand->sessionId = (tANI_U8)sessionId;
9322 pCommand->u.wmStatusChangeCmd.Type = Type;
9323 if ( eCsrDisassociated == Type )
9324 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309325 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9326 pSmeRsp,
9327 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 }
9329 else
9330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309331 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9332 pSmeRsp,
9333 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 }
9335 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9336 {
9337 fCommandQueued = eANI_BOOLEAN_TRUE;
9338 }
9339 else
9340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009341 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 csrReleaseCommandWmStatusChange( pMac, pCommand );
9343 }
9344
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9346 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 return( fCommandQueued );
9349}
9350
Jeff Johnson295189b2012-06-20 16:38:30 -07009351static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9352{
9353 v_S7_t rssi = 0;
9354 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9355 if(pGetRssiReq)
9356 {
9357 if(NULL != pGetRssiReq->pVosContext)
9358 {
9359 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9360 }
9361 else
9362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009363 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 return;
9365 }
9366
9367 if(NULL != pGetRssiReq->rssiCallback)
9368 {
9369 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9370 }
9371 else
9372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009373 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 return;
9375 }
9376 }
9377 else
9378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009379 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 }
9381 return;
9382}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309383
9384static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9385{
9386 tANI_S8 snr = 0;
9387 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9388
9389 if (pGetSnrReq)
9390 {
9391 if (VOS_STATUS_SUCCESS !=
9392 WDA_GetSnr(pGetSnrReq->staId, &snr))
9393 {
9394 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9395 return;
9396 }
9397
9398 if (pGetSnrReq->snrCallback)
9399 {
9400 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9401 pGetSnrReq->pDevContext);
9402 }
9403 else
9404 {
9405 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9406 return;
9407 }
9408 }
9409 else
9410 {
9411 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9412 }
9413 return;
9414}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009415#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009416void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9417{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009418 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9419
Jeff Johnson36d483b2013-04-08 11:08:53 -07009420 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009421 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009422 /* Get roam Rssi request is backed up and passed back to the response,
9423 Extract the request message to fetch callback */
9424 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9425 v_S7_t rssi = pRoamRssiRsp->rssi;
9426
9427 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009428 {
9429 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9430 reqBkp->rssiCallback = NULL;
9431 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009432 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009433 }
9434 else
9435 {
9436 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9437 if (NULL != reqBkp)
9438 {
9439 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009440 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009441 }
9442 }
9443 }
9444 else
9445 {
9446 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9447 }
9448 return;
9449}
9450#endif
9451
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009452
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009453#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009454void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9455{
9456 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9457
9458 if (NULL != pTsmStatsRsp)
9459 {
9460 /* Get roam Rssi request is backed up and passed back to the response,
9461 Extract the request message to fetch callback */
9462 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9463
9464 if (NULL != reqBkp)
9465 {
9466 if (NULL != reqBkp->tsmStatsCallback)
9467 {
9468 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9469 pTsmStatsRsp->staId, reqBkp->pDevContext);
9470 reqBkp->tsmStatsCallback = NULL;
9471 }
9472 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009473 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009474 }
9475 else
9476 {
9477 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9478 if (NULL != reqBkp)
9479 {
9480 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009481 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009482 }
9483 }
9484 }
9485 else
9486 {
9487 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9488 }
9489 return;
9490}
9491
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009492void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009493{
9494 tANI_U32 roamTS2 = 0;
9495 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009496 tpPESession pSessionEntry = NULL;
9497 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009498
9499 if (NULL == pSession)
9500 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009501 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009502 return;
9503 }
9504
9505 roamTS2 = vos_timer_get_system_time();
9506 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009507 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9508 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009509 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009510
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009511 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9512 if (NULL == pSessionEntry)
9513 {
9514 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9515 return;
9516 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009517 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009518 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009519 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009520}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009521#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009522
Jeff Johnsone7245742012-09-05 17:12:55 -07009523static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9524{
9525 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9526 if(pTlRssiInd)
9527 {
9528 if(NULL != pTlRssiInd->tlCallback)
9529 {
9530 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009531 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009532 }
9533 else
9534 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009535 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009536 }
9537 }
9538 else
9539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009540 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009541 }
9542 return;
9543}
Jeff Johnson295189b2012-06-20 16:38:30 -07009544
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309545eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9546{
9547 tpSirResetAPCapsChange pMsg;
9548 tANI_U16 len;
9549 eHalStatus status = eHAL_STATUS_SUCCESS;
9550
9551 /* Create the message and send to lim */
9552 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309553 pMsg = vos_mem_malloc(len);
9554 if ( NULL == pMsg )
9555 status = eHAL_STATUS_FAILURE;
9556 else
9557 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309558 if (HAL_STATUS_SUCCESS(status))
9559 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309560 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309561 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9562 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309563 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009564 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9565 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309566 status = palSendMBMessage(pMac->hHdd, pMsg);
9567 }
9568 else
9569 {
9570 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9571 }
9572 return status;
9573}
9574
Jeff Johnson295189b2012-06-20 16:38:30 -07009575void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9576{
9577 tSirSmeAssocInd *pAssocInd;
9578 tSirSmeDisassocInd *pDisassocInd;
9579 tSirSmeDeauthInd *pDeauthInd;
9580 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9581 tSirSmeNewBssInfo *pNewBss;
9582 tSmeIbssPeerInd *pIbssPeerInd;
9583 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9584 tSirSmeApNewCaps *pApNewCaps;
9585 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9586 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9587 tCsrRoamInfo *pRoamInfo = NULL;
9588 tCsrRoamInfo roamInfo;
9589 eHalStatus status;
9590 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9591 tCsrRoamSession *pSession = NULL;
9592 tpSirSmeSwitchChannelInd pSwitchChnInd;
9593 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309594 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009595
9596
9597 if (NULL == pSirMsg)
9598 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9599 return;
9600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 switch( pSirMsg->messageType )
9602 {
9603 case eWNI_SME_ASSOC_IND:
9604 {
9605 tCsrRoamSession *pSession;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05309606 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9608 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9609 if( HAL_STATUS_SUCCESS( status ) )
9610 {
9611 pSession = CSR_GET_SESSION(pMac, sessionId);
9612
Jeff Johnson32d95a32012-09-10 13:15:23 -07009613 if(!pSession)
9614 {
9615 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9616 return;
9617 }
9618
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 pRoamInfo = &roamInfo;
9620
9621 // Required for indicating the frames to upper layer
9622 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9623 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9624
9625 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9626 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9627 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9628 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9629
9630 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9631 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9632 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9633
9634 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9635 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309636 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9637 sizeof(tSirMacAddr));
9638 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9639 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309641#ifdef WLAN_FEATURE_AP_HT40_24G
9642 pRoamInfo->HT40MHzIntoEnabledSta =
9643 pAssocInd->HT40MHzIntoEnabledSta;
9644 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9645 pRoamInfo->HT40MHzIntoEnabledSta);
9646#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9650 {
9651 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9652 {
9653 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9654 pSession->pConnectBssDesc,
9655 &(pRoamInfo->peerMac),
9656 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9657 pRoamInfo->fAuthRequired = FALSE;
9658 }
9659 else
9660 {
9661 pRoamInfo->fAuthRequired = TRUE;
9662 }
9663 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9664 if (!HAL_STATUS_SUCCESS(status))
9665 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 /* Send Association completion message to PE */
9668 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9669
9670 /* send a message to CSR itself just to avoid the EAPOL frames going
9671 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9673 {
9674 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9677 {
9678 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9679 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9680 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 }
9683 }
9684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309687 // Check if AP dis-associated us because of MIC failure. If so,
9688 // then we need to take action immediately and not wait till the
9689 // the WmStatusChange requests is pushed and processed
9690 tSmeCmd *pCommand;
9691
9692 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9693 status = csrRoamGetSessionIdFromBSSID( pMac,
9694 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9695 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309697 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9698 " for session %d "), sessionId);
9699 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9700 MAC_ADDRESS_STR " "
9701 " reason = %d status = %d "),
9702 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9703 pDisassocInd->reasonCode,
9704 pDisassocInd->statusCode);
9705 // If we are in neighbor preauth done state then on receiving
9706 // disassoc or deauth we dont roam instead we just disassoc
9707 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009708 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309709#ifdef WLAN_FEATURE_VOWIFI_11R
9710 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9711 {
9712 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009714#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009715#ifdef FEATURE_WLAN_ESE
9716 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309717 {
9718 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009720#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009721#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309722 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9723 {
9724 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9725 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009726#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309727 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009728
Agarwal Ashish4f616132013-12-30 23:32:50 +05309729 if (!pSession)
9730 {
9731 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9732 return;
9733 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009734
Agarwal Ashish4f616132013-12-30 23:32:50 +05309735 if ( csrIsConnStateInfra( pMac, sessionId ) )
9736 {
9737 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009739#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309740 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009741#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309742 csrRoamLinkDown(pMac, sessionId);
9743 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9744 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9745 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309746 pRoamInfo = &roamInfo;
9747 pRoamInfo->statusCode = pDisassocInd->statusCode;
9748 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9749 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009750
Agarwal Ashish4f616132013-12-30 23:32:50 +05309751 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9752 sizeof(tSirMacAddr));
9753 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9754 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009755
Agarwal Ashish4f616132013-12-30 23:32:50 +05309756 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9757 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
Agarwal Ashish4f616132013-12-30 23:32:50 +05309759 /*
9760 * STA/P2P client got disassociated so remove any pending deauth
9761 * commands in sme pending list
9762 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309763 pCommand = csrGetCommandBuffer(pMac);
9764 if (NULL == pCommand)
9765 {
9766 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9767 status = eHAL_STATUS_RESOURCES;
9768 return;
9769 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309770 pCommand->command = eSmeCommandRoam;
9771 pCommand->sessionId = (tANI_U8)sessionId;
9772 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9773 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9774 pDisassocInd->peerMacAddr,
9775 sizeof(tSirMacAddr));
9776 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9777 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009778
Agarwal Ashish4f616132013-12-30 23:32:50 +05309779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309781 else
9782 {
9783 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9784 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9785 }
Kiet Lam82004c62013-11-11 13:24:28 +05309786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009789 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9791 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9792 if( HAL_STATUS_SUCCESS( status ) )
9793 {
9794 // If we are in neighbor preauth done state then on receiving
9795 // disassoc or deauth we dont roam instead we just disassoc
9796 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009797 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009798#ifdef WLAN_FEATURE_VOWIFI_11R
9799 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9800 {
9801 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9802 }
9803#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009804#ifdef FEATURE_WLAN_ESE
9805 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 {
9807 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9808 }
9809#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009810#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309811 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009812 {
9813 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9814 }
9815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 pSession = CSR_GET_SESSION( pMac, sessionId );
9817
Jeff Johnson32d95a32012-09-10 13:15:23 -07009818 if(!pSession)
9819 {
9820 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9821 return;
9822 }
9823
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 if ( csrIsConnStateInfra( pMac, sessionId ) )
9825 {
9826 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009828#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9829 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9830#endif
9831 csrRoamLinkDown(pMac, sessionId);
9832 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9834 {
9835
9836 pRoamInfo = &roamInfo;
9837
9838 pRoamInfo->statusCode = pDeauthInd->statusCode;
9839 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9840
9841 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9842
Kiet Lam64c1b492013-07-12 13:56:44 +05309843 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9844 sizeof(tSirMacAddr));
9845 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9846 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009847
9848 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009850 }
9851 break;
9852
9853 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 -08009854 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9856 //Update with the new channel id.
9857 //The channel id is hidden in the statusCode.
9858 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9859 if( HAL_STATUS_SUCCESS( status ) )
9860 {
9861 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009862 if(!pSession)
9863 {
9864 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9865 return;
9866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9868 if(pSession->pConnectBssDesc)
9869 {
9870 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9871 }
9872 }
9873 break;
9874
9875 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009876 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 {
9878 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9879 sessionId = pDeauthRsp->sessionId;
9880 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9881 {
9882 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009883 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9884 {
9885 pRoamInfo = &roamInfo;
9886 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309887 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9888 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9890 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9891 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9892 }
9893 }
9894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009895 break;
9896
9897 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009898 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009899 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 {
9901 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9902 sessionId = pDisassocRsp->sessionId;
9903 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9904 {
9905 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9907 {
9908 pRoamInfo = &roamInfo;
9909 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309910 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9911 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9913 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9914 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9915 }
9916 }
9917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05309919 case eWNI_SME_LOST_LINK_PARAMS_IND:
9920 {
9921 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
9922 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9923 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9924 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9925 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
9926 pRoamInfo = &roamInfo;
9927 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
9928 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
9929 break;
9930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 case eWNI_SME_MIC_FAILURE_IND:
9932 {
9933 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9934 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9935 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009936
9937 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9938 if( HAL_STATUS_SUCCESS( status ) )
9939 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309940 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009941 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9942 pRoamInfo = &roamInfo;
9943 if(pMicInd->info.multicast)
9944 {
9945 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9946 }
9947 else
9948 {
9949 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9950 }
9951 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9952 }
9953
Jeff Johnson295189b2012-06-20 16:38:30 -07009954#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9955 {
lukez3c809222013-05-03 10:23:02 -07009956 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009958 if(!pSession)
9959 {
9960 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9961 return;
9962 }
lukez3c809222013-05-03 10:23:02 -07009963
Kiet Lam64c1b492013-07-12 13:56:44 +05309964 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009965 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9966 secEvent.encryptionModeMulticast =
9967 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9968 secEvent.encryptionModeUnicast =
9969 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9970 secEvent.authMode =
9971 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309972 vos_mem_copy(secEvent.bssid,
9973 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9975 }
9976#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009977 }
9978 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9980 {
9981 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9982 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009983 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009984
9985 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9986 if( HAL_STATUS_SUCCESS( status ) )
9987 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309988 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9990 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9991 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9992 }
9993 }
9994 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009995
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9997 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9998 switch( pStatusChangeMsg->statusChangeCode )
9999 {
10000 case eSIR_SME_IBSS_ACTIVE:
10001 sessionId = csrFindIbssSession( pMac );
10002 if( CSR_SESSION_ID_INVALID != sessionId )
10003 {
10004 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010005 if(!pSession)
10006 {
10007 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10008 return;
10009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10011 if(pSession->pConnectBssDesc)
10012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010013 vos_mem_copy(&roamInfo.bssid,
10014 pSession->pConnectBssDesc->bssId,
10015 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10017 pRoamInfo = &roamInfo;
10018 }
10019 else
10020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010021 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 }
10023 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10024 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10025 }
10026 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 case eSIR_SME_IBSS_INACTIVE:
10028 sessionId = csrFindIbssSession( pMac );
10029 if( CSR_SESSION_ID_INVALID != sessionId )
10030 {
10031 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010032 if(!pSession)
10033 {
10034 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10035 return;
10036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10038 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10039 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10040 }
10041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10043 sessionId = csrFindIbssSession( pMac );
10044 if( CSR_SESSION_ID_INVALID != sessionId )
10045 {
10046 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010047 if(!pSession)
10048 {
10049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10050 return;
10051 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 // update the connection state information
10053 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010054#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10055 {
10056 vos_log_ibss_pkt_type *pIbssLog;
10057 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10059 if(pIbssLog)
10060 {
10061 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10062 if(pNewBss)
10063 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010064 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 if(pNewBss->ssId.length)
10066 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010067 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
10068 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 }
10070 pIbssLog->operatingChannel = pNewBss->channelNumber;
10071 }
10072 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10073 {
10074 //***U8 is not enough for beacon interval
10075 pIbssLog->beaconInterval = (v_U8_t)bi;
10076 }
10077 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10078 }
10079 }
10080#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010081 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010082
10083 if ((eCSR_ENCRYPT_TYPE_NONE ==
10084 pSession->connectedProfile.EncryptionType ))
10085 {
10086 csrRoamIssueSetContextReq( pMac, sessionId,
10087 pSession->connectedProfile.EncryptionType,
10088 pSession->pConnectBssDesc,
10089 &Broadcastaddr,
10090 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10093 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010094 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10095 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 pRoamInfo = &roamInfo;
10097 //This BSSID is th ereal BSSID, let's save it
10098 if(pSession->pConnectBssDesc)
10099 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010100 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10101 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010104 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 // detection by LIM that the capabilities of the associated AP have changed.
10107 case eSIR_SME_AP_CAPS_CHANGED:
10108 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010109 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10111 if( HAL_STATUS_SUCCESS( status ) )
10112 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010113 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10114 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010115 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010116 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10117 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10118 )
10119 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010120 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10121 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010122 }
10123 else
10124 {
10125 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010126 FL("Skipping csrScanForCapabilityChange as "
10127 "CSR is in state %s and sub-state %s"),
10128 macTraceGetcsrRoamState(
10129 pMac->roam.curState[sessionId]),
10130 macTraceGetcsrRoamSubState(
10131 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010132 /* We ignore the caps change event if CSR is not in full connected state.
10133 * Send one event to PE to reset limSentCapsChangeNtf
10134 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10135 * otherwise lim cannot send any CAPS change events to SME */
10136 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 }
10139 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010140
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 default:
10142 roamStatus = eCSR_ROAM_FAILED;
10143 result = eCSR_ROAM_RESULT_NONE;
10144 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 } // end switch on statusChangeCode
10146 if(eCSR_ROAM_RESULT_NONE != result)
10147 {
10148 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10149 }
10150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 case eWNI_SME_IBSS_NEW_PEER_IND:
10152 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010153#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10154 {
10155 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010156 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10157 if(pIbssLog)
10158 {
10159 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010160 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10162 }
10163 }
10164#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 sessionId = csrFindIbssSession( pMac );
10166 if( CSR_SESSION_ID_INVALID != sessionId )
10167 {
10168 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010169
10170 if(!pSession)
10171 {
10172 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10173 return;
10174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10176 if(pSession->pConnectBssDesc)
10177 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010178 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10179 sizeof(tCsrBssid));
10180 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10181 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10183 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010184 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10185 - sizeof(tSmeIbssPeerInd)));
10186 if ( NULL == roamInfo.pbFrames )
10187 status = eHAL_STATUS_FAILURE;
10188 else
10189 status = eHAL_STATUS_SUCCESS;
10190 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 {
10192 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010193 vos_mem_copy(roamInfo.pbFrames,
10194 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10195 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 }
10197 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10198 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10199 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010200 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10201 if ( NULL == roamInfo.pBssDesc )
10202 status = eHAL_STATUS_FAILURE;
10203 else
10204 status = eHAL_STATUS_SUCCESS;
10205 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010207 vos_mem_copy(roamInfo.pBssDesc,
10208 pSession->pConnectBssDesc,
10209 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 }
10211 if(HAL_STATUS_SUCCESS(status))
10212 {
10213 pRoamInfo = &roamInfo;
10214 }
10215 else
10216 {
10217 if(roamInfo.pbFrames)
10218 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010219 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 }
10221 if(roamInfo.pBssDesc)
10222 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010223 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 }
10225 }
10226 }
10227 else
10228 {
10229 pRoamInfo = &roamInfo;
10230 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010231 if ((eCSR_ENCRYPT_TYPE_NONE ==
10232 pSession->connectedProfile.EncryptionType ))
10233 {
10234 csrRoamIssueSetContextReq( pMac, sessionId,
10235 pSession->connectedProfile.EncryptionType,
10236 pSession->pConnectBssDesc,
10237 &(pIbssPeerInd->peerAddr),
10238 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 }
10241 else
10242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010243 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 }
10245 //send up the sec type for the new peer
10246 if (pRoamInfo)
10247 {
10248 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10249 }
10250 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10251 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10252 if(pRoamInfo)
10253 {
10254 if(roamInfo.pbFrames)
10255 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010256 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010257 }
10258 if(roamInfo.pBssDesc)
10259 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010260 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 }
10262 }
10263 }
10264 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010265 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10266 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10267 sessionId = csrFindIbssSession( pMac );
10268 if( CSR_SESSION_ID_INVALID != sessionId )
10269 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010270#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10271 {
10272 vos_log_ibss_pkt_type *pIbssLog;
10273
10274 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10275 if(pIbssLog)
10276 {
10277 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10278 if(pIbssPeerInd)
10279 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010280 vos_mem_copy(pIbssLog->peerMacAddr,
10281 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 }
10283 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10284 }
10285 }
10286#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010287 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10289 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10290 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010291 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10292 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10294 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10295 }
10296 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010297 case eWNI_SME_SETCONTEXT_RSP:
10298 {
10299 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10300 tListElem *pEntry;
10301 tSmeCmd *pCommand;
10302
10303 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10304 if ( pEntry )
10305 {
10306 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10307 if ( eSmeCommandSetKey == pCommand->command )
10308 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010309 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010310 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010311
10312 if(!pSession)
10313 {
10314 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10315 return;
10316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010317
10318#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10319 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10320 {
10321 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010322 vos_mem_set(&setKeyEvent,
10323 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 if( pRsp->peerMacAddr[0] & 0x01 )
10325 {
10326 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10327 }
10328 else
10329 {
10330 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10331 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010332 if( pRsp->peerMacAddr[0] & 0x01 )
10333 {
10334 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
10335 smsLog(pMac, LOG1, FL("Reset"
10336 "remainInPowerActiveTillDHCP to allow BMPS"));
10337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 setKeyEvent.encryptionModeMulticast =
10339 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10340 setKeyEvent.encryptionModeUnicast =
10341 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010342 vos_mem_copy(setKeyEvent.bssid,
10343 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 setKeyEvent.authMode =
10345 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010346 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010347 {
10348 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10349 }
10350 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10351 }
10352#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10353 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10354 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010355 csrRoamStopWaitForKeyTimer( pMac );
10356
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 //We are done with authentication, whethere succeed or not
10358 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 //We do it here because this linkup function is not called after association
10360 //when a key needs to be set.
10361 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10362 {
10363 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10364 }
10365 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010366 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010368 vos_mem_copy(&roamInfo.peerMac,
10369 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010370 //Make sure we install the GTK before indicating to HDD as authenticated
10371 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010372 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10373 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010374 {
Yathish9f22e662012-12-10 14:21:35 -080010375#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10376 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10377 {
10378 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010379 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010380 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10381 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10382 pMsg->seesionId = sessionId;
10383 status = palSendMBMessage(pMac->hHdd, pMsg );
10384 }
10385#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010386 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010387 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010388 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010389 && (pSession->connectState ==
10390 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10391 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010392 && (VOS_P2P_GO_MODE !=
10393 pSession->pCurRoamProfile->csrPersona
10394 && VOS_STA_SAP_MODE !=
10395 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010396 {
10397 tpSirSmeHT40OBSSScanInd pMsg;
10398 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10399 pMsg->messageType =
10400 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10401 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010402 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10403 vos_mem_copy(pMsg->peerMacAddr,
10404 pSession->connectedProfile.bssid,
10405 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010406 status = palSendMBMessage(pMac->hHdd,
10407 pMsg );
10408 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010409 else
10410 {
10411 smsLog( pMac, LOG1,FL("OBSS SCAN"
10412 "Indication not sent to FW"
10413 "channel %d OBSS_SCAN: %d"),
10414 pSession->connectedProfile.
10415 operationChannel,
10416 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10417 smsLog( pMac, LOG1,FL("connectState %d"
10418 "pCurRoamProfile %p"),
10419 pSession->connectState,
10420 pSession->pCurRoamProfile);
10421 }
10422
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010423 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010424 }
10425 else
10426 {
10427 result = eCSR_ROAM_RESULT_NONE;
10428 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010429 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 }
10431 else
10432 {
10433 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010434 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10435 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10436 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 }
10438 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10439 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10441 // can go ahead and initiate the TSPEC if any are pending
10442 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010443#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010444 //Send Adjacent AP repot to new AP.
10445 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10446 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010447 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010448 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010449#ifdef FEATURE_WLAN_ESE_UPLOAD
10450 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010451#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010452 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010453#endif
10454 pSession->isPrevApInfoValid = FALSE;
10455 }
10456#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10458 {
10459 csrReleaseCommandSetKey( pMac, pCommand );
10460 }
10461 }
10462 else
10463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010464 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 }
10466 }
10467 else
10468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010469 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 smeProcessPendingQueue( pMac );
10472 }
10473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 case eWNI_SME_REMOVEKEY_RSP:
10475 {
10476 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10477 tListElem *pEntry;
10478 tSmeCmd *pCommand;
10479
10480 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10481 if ( pEntry )
10482 {
10483 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10484 if ( eSmeCommandRemoveKey == pCommand->command )
10485 {
10486 sessionId = pCommand->sessionId;
10487 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010488
10489 if(!pSession)
10490 {
10491 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10492 return;
10493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010494#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10495 {
10496 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010497 vos_mem_set(&removeKeyEvent,
10498 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10500 removeKeyEvent.encryptionModeMulticast =
10501 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10502 removeKeyEvent.encryptionModeUnicast =
10503 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010504 vos_mem_copy( removeKeyEvent.bssid,
10505 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010506 removeKeyEvent.authMode =
10507 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010508 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010509 {
10510 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10511 }
10512 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10513 }
10514#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010515 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010517 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10518 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 result = eCSR_ROAM_RESULT_NONE;
10520 pRoamInfo = &roamInfo;
10521 }
10522 else
10523 {
10524 result = eCSR_ROAM_RESULT_FAILURE;
10525 }
10526 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10527 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10528 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10529 {
10530 csrReleaseCommandRemoveKey( pMac, pCommand );
10531 }
10532 }
10533 else
10534 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010535 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 }
10537 }
10538 else
10539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010540 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 smeProcessPendingQueue( pMac );
10543 }
10544 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010545 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010546 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 csrRoamStatsRspProcessor( pMac, pSirMsg );
10548 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010549#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010550 case eWNI_SME_GET_ROAM_RSSI_RSP:
10551 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10552 csrRoamRssiRspProcessor( pMac, pSirMsg );
10553 break;
10554#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010555#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010556 case eWNI_SME_GET_TSM_STATS_RSP:
10557 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10558 csrTsmStatsRspProcessor( pMac, pSirMsg );
10559 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010560#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010562 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010563 csrUpdateRssi( pMac, pSirMsg );
10564 break;
10565
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010566 case eWNI_SME_GET_SNR_REQ:
10567 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10568 csrUpdateSnr(pMac, pSirMsg);
10569 break;
10570
Jeff Johnson295189b2012-06-20 16:38:30 -070010571#ifdef WLAN_FEATURE_VOWIFI_11R
10572 case eWNI_SME_FT_PRE_AUTH_RSP:
10573 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10574 break;
10575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10577 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010578 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 -070010579 sessionId = pSmeMaxAssocInd->sessionId;
10580 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010581 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10582 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10584 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10585 break;
10586
10587 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010588 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 btampEstablishLogLinkHdlr( pSirMsg );
10590 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010591 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010592 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010593 csrRoamRssiIndHdlr( pMac, pSirMsg );
10594 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010595#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10596 case eWNI_SME_CANDIDATE_FOUND_IND:
10597 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10598 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10599 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010600 case eWNI_SME_HANDOFF_REQ:
10601 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10602 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10603 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010604#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010605
10606 default:
10607 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010609}
10610
Jeff Johnson295189b2012-06-20 16:38:30 -070010611void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10612 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10613{
10614 if(pSession)
10615 {
10616 if(pSession->bRefAssocStartCnt)
10617 {
10618 pSession->bRefAssocStartCnt--;
10619 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10620 //Need to call association_completion because there is an assoc_start pending.
10621 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10622 eCSR_ROAM_ASSOCIATION_COMPLETION,
10623 eCSR_ROAM_RESULT_FAILURE);
10624 }
10625 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10626 }
10627 else
10628 {
10629 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10630 }
10631}
10632
10633
10634eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10635{
10636 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10638 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10639 {
10640 status = csrScanRequestLostLink1( pMac, sessionId );
10641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010642 return(status);
10643}
10644
Jeff Johnson295189b2012-06-20 16:38:30 -070010645//return a boolean to indicate whether roaming completed or continue.
10646tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10647 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10648{
10649 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10650 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10651 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010653 if(!pSession)
10654 {
10655 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10656 return eANI_BOOLEAN_FALSE;
10657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 //Check whether time is up
10659 if(pSession->fCancelRoaming || fForce ||
10660 ((curTime - pSession->roamingStartTime) > roamTime) ||
10661 eCsrReassocRoaming == pSession->roamingReason ||
10662 eCsrDynamicRoaming == pSession->roamingReason)
10663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010664 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10666 {
10667 //roaming is cancelled, tell HDD to indicate disconnect
10668 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10669 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10670 //to be eSIR_BEACON_MISSED
10671 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10672 {
10673 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10674 }
10675 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10676 {
10677 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10678 }
10679 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10680 {
10681 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10682 }
10683 else
10684 {
10685 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10686 }
10687 }
10688 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10689 pSession->roamingReason = eCsrNotRoaming;
10690 }
10691 else
10692 {
10693 pSession->roamResult = roamResult;
10694 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10695 {
10696 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10697 pSession->roamingReason = eCsrNotRoaming;
10698 }
10699 else
10700 {
10701 fCompleted = eANI_BOOLEAN_FALSE;
10702 }
10703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010704 return(fCompleted);
10705}
10706
Jeff Johnson295189b2012-06-20 16:38:30 -070010707void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10708{
10709 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010710
10711 if(!pSession)
10712 {
10713 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10714 return;
10715 }
10716
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 if(CSR_IS_ROAMING(pSession))
10718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010719 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10721 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10722 {
10723 //No need to do anything in here because the handler takes care of it
10724 }
10725 else
10726 {
10727 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10728 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10729 //Roaming is stopped after here
10730 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10731 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010732 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 csrRoamStopRoamingTimer(pMac, sessionId);
10734 }
10735 }
10736}
10737
Jeff Johnson295189b2012-06-20 16:38:30 -070010738void csrRoamRoamingTimerHandler(void *pv)
10739{
10740 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10741 tpAniSirGlobal pMac = pInfo->pMac;
10742 tANI_U32 sessionId = pInfo->sessionId;
10743 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010744
10745 if(!pSession)
10746 {
10747 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10748 return;
10749 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010750
10751 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10752 {
10753 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10754 {
10755 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10756 pSession->roamingReason = eCsrNotRoaming;
10757 }
10758 }
10759}
10760
Jeff Johnson295189b2012-06-20 16:38:30 -070010761eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10762{
10763 eHalStatus status;
10764 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010765
10766 if(!pSession)
10767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010768 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010769 return eHAL_STATUS_FAILURE;
10770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010771
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010772 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010774 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010775
10776 return (status);
10777}
10778
Jeff Johnson295189b2012-06-20 16:38:30 -070010779eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10780{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010781 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010782}
10783
Jeff Johnson295189b2012-06-20 16:38:30 -070010784void csrRoamWaitForKeyTimeOutHandler(void *pv)
10785{
10786 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10787 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010788 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010789 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010790
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010791 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10792 macTraceGetNeighbourRoamState(
10793 pMac->roam.neighborRoamInfo.neighborRoamState),
10794 macTraceGetcsrRoamSubState(
10795 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010796
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10798 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010799#ifdef FEATURE_WLAN_LFR
10800 if (csrNeighborRoamIsHandoffInProgress(pMac))
10801 {
10802 /*
10803 * Enable heartbeat timer when hand-off is in progress
10804 * and Key Wait timer expired.
10805 */
10806 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010807 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010808 pMac->roam.configParam.HeartbeatThresh24);
10809 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10810 pMac->roam.configParam.HeartbeatThresh24,
10811 NULL, eANI_BOOLEAN_FALSE);
10812 }
10813#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010814 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010817 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10818 {
10819 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10820 pInfo->sessionId);
10821 }
10822
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010823 if (pSession)
10824 {
10825 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10826 {
10827 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10828 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010829 if( (pSession->connectedProfile.AuthType ==
10830 eCSR_AUTH_TYPE_SHARED_KEY) &&
10831 ( (pSession->connectedProfile.EncryptionType ==
10832 eCSR_ENCRYPT_TYPE_WEP40) ||
10833 (pSession->connectedProfile.EncryptionType ==
10834 eCSR_ENCRYPT_TYPE_WEP104) ))
10835 {
10836 status = sme_AcquireGlobalLock( &pMac->sme );
10837 if ( HAL_STATUS_SUCCESS( status ) )
10838 {
10839 csrRoamDisconnect( pMac, pInfo->sessionId,
10840 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10841 sme_ReleaseGlobalLock( &pMac->sme );
10842 }
10843 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010844 }
10845 else
10846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010847 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010848 __func__);
10849 }
10850 }
10851 else
10852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010853 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 }
10856
10857}
10858
Jeff Johnson295189b2012-06-20 16:38:30 -070010859eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10860{
10861 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010862#ifdef FEATURE_WLAN_LFR
10863 if (csrNeighborRoamIsHandoffInProgress(pMac))
10864 {
10865 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010866 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10867 macTraceGetNeighbourRoamState(
10868 pMac->roam.neighborRoamInfo.neighborRoamState),
10869 macTraceGetcsrRoamSubState(
10870 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10871 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010872 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10873 }
10874#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010875 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010876 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010877
10878 return (status);
10879}
10880
Jeff Johnson295189b2012-06-20 16:38:30 -070010881eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10882{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010883 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10884 macTraceGetNeighbourRoamState(
10885 pMac->roam.neighborRoamInfo.neighborRoamState),
10886 macTraceGetcsrRoamSubState(
10887 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010888#ifdef FEATURE_WLAN_LFR
10889 if (csrNeighborRoamIsHandoffInProgress(pMac))
10890 {
10891 /*
10892 * Enable heartbeat timer when hand-off is in progress
10893 * and Key Wait timer got stopped for some reason
10894 */
10895 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010896 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010897 pMac->roam.configParam.HeartbeatThresh24);
10898 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10899 pMac->roam.configParam.HeartbeatThresh24,
10900 NULL, eANI_BOOLEAN_FALSE);
10901 }
10902#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010903 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010904}
10905
Jeff Johnson295189b2012-06-20 16:38:30 -070010906void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10907 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10908{
10909 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10910 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10912 /* To silence the KW tool Null chaeck is added */
10913 if(!pSession)
10914 {
10915 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10916 return;
10917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010918
10919 if(pCommand)
10920 {
10921 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10925 {
10926 //if success, force roaming completion
10927 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10928 }
10929 else
10930 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010931 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010932 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10934 }
10935}
10936
Jeff Johnson295189b2012-06-20 16:38:30 -070010937eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10938{
10939 eHalStatus status = eHAL_STATUS_SUCCESS;
10940 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10941 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10942 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10943 tCsrRoamInfo *pRoamInfo = NULL;
10944 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010945 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010947 /* To silence the KW tool Null chaeck is added */
10948 if(!pSession)
10949 {
10950 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10951 return eHAL_STATUS_FAILURE;
10952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010954 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10956 if ( eWNI_SME_DISASSOC_IND == type )
10957 {
10958 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10959 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10960 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010961 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 }
10963 else if ( eWNI_SME_DEAUTH_IND == type )
10964 {
10965 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10966 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10967 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010968 /* Convert into proper reason code */
Deepthi Gowridf91a662014-12-17 17:14:35 +053010969 if ((pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ||
10970 (pDeauthIndMsg->reasonCode ==
10971 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON))
10972 pSession->joinFailStatusCode.reasonCode = 0;
10973 else
10974 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
10975
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010976 /* cfg layer expects 0 as reason code if
10977 the driver dosent know the reason code
10978 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 }
10980 else
10981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010982 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010983 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010984 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 }
10986
10987 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 {
10990 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10991 }
10992
10993 if ( eWNI_SME_DISASSOC_IND == type )
10994 {
10995 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10996 }
10997 else if ( eWNI_SME_DEAUTH_IND == type )
10998 {
10999 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 if(!HAL_STATUS_SUCCESS(status))
11002 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011003 //If fail to send confirmation to PE, not to trigger roaming
11004 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011005 }
11006
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011007 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053011008 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011009 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11010 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011011 if( eWNI_SME_DISASSOC_IND == type)
11012 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011013 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053011014 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11015 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011016 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
11017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011018 else if( eWNI_SME_DEAUTH_IND == type )
11019 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011020 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053011021 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11022 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011023 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
11024 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011025 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011026
11027 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11028 that we are roaming. But if we cannot possibly roam, or if we are unable to
11029 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070011030 if(fToRoam)
11031 {
11032 //Only remove the connected BSS in infrastructure mode
11033 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11034 //Not to do anying for lostlink with WDS
11035 if( pMac->roam.configParam.nRoamingTime )
11036 {
11037 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
11038 ( eWNI_SME_DEAUTH_IND == type ) ?
11039 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
11040 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011041 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 //For IBSS, we need to give some more info to HDD
11043 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
11044 {
11045 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
11046 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11047 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11048 }
11049 else
11050 {
11051 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
11052 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011053 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
11055 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
11056 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11057 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
11058 }
11059 else
11060 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011061 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 fToRoam = eANI_BOOLEAN_FALSE;
11063 }
11064 }
11065 else
11066 {
11067 //We are told not to roam, indicate lostlink
11068 fToRoam = eANI_BOOLEAN_FALSE;
11069 }
11070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011071 if(!fToRoam)
11072 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070011073 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011074 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011075 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011076 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
11077 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
11078 * csrRoamCheckForLinkStatusChange API.
11079 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011080 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
11081 }
11082
11083 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 Still enable idle scan for polling in case concurrent sessions are running */
11085 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11086 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011087 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011088 }
11089 }
11090
11091 return (status);
11092}
11093
Jeff Johnson295189b2012-06-20 16:38:30 -070011094eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11095{
11096 eHalStatus status = eHAL_STATUS_SUCCESS;
11097 tListElem *pEntry = NULL;
11098 tSmeCmd *pCommand = NULL;
11099 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011100
11101 if(!pSession)
11102 {
11103 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11104 return eHAL_STATUS_FAILURE;
11105 }
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 //Only remove the connected BSS in infrastructure mode
11109 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11110 if(pMac->roam.configParam.nRoamingTime)
11111 {
11112 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11113 {
11114 //before starting the lost link logic release the roam command for handoff
11115 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11116 if(pEntry)
11117 {
11118 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11119 }
11120 if(pCommand)
11121 {
11122 if (( eSmeCommandRoam == pCommand->command ) &&
11123 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11124 {
11125 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11126 {
11127 csrReleaseCommandRoam( pMac, pCommand );
11128 }
11129 }
11130 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011131 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011132 }
11133 }
11134 else
11135 {
11136 //We are told not to roam, indicate lostlink
11137 status = eHAL_STATUS_FAILURE;
11138 }
11139
11140 return (status);
11141}
Jeff Johnson295189b2012-06-20 16:38:30 -070011142void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11143{
11144 tListElem *pEntry;
11145 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11147 if ( pEntry )
11148 {
11149 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11150 if ( eSmeCommandWmStatusChange == pCommand->command )
11151 {
11152 // Nothing to process in a Lost Link completion.... It just kicks off a
11153 // roaming sequence.
11154 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11155 {
11156 csrReleaseCommandWmStatusChange( pMac, pCommand );
11157 }
11158 else
11159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011160 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011161 }
11162
11163 }
11164 else
11165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011166 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011167 }
11168 }
11169 else
11170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011171 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011173 smeProcessPendingQueue( pMac );
11174}
11175
Jeff Johnson295189b2012-06-20 16:38:30 -070011176void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11177{
11178 eHalStatus status = eHAL_STATUS_FAILURE;
11179 tSirSmeRsp *pSirSmeMsg;
11180 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011181
11182 if(!pSession)
11183 {
11184 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11185 return;
11186 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011187 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11188 pCommand->sessionId,
11189 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 switch ( pCommand->u.wmStatusChangeCmd.Type )
11191 {
11192 case eCsrDisassociated:
11193 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11194 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11195 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 case eCsrDeauthenticated:
11197 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11198 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011201 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011202 break;
11203 }
11204 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11205 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11206 {
11207 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11208 {
11209 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011210 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011211 }
11212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11214 // command here since there is nothing else to do.
11215 csrRoamWmStatusChangeComplete( pMac );
11216}
11217
Jeff Johnson295189b2012-06-20 16:38:30 -070011218//This function returns band and mode information.
11219//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11220//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011221static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11222 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011223{
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11225 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11226 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011228
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 //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 -070011230 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11231 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11232 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11233 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 {
11235 switch( pMac->roam.configParam.uCfgDot11Mode )
11236 {
11237 case eCSR_CFG_DOT11_MODE_11A:
11238 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11239 eBand = eCSR_BAND_5G;
11240 break;
11241 case eCSR_CFG_DOT11_MODE_11B:
11242 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11243 eBand = eCSR_BAND_24;
11244 break;
11245 case eCSR_CFG_DOT11_MODE_11G:
11246 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11247 eBand = eCSR_BAND_24;
11248 break;
11249 case eCSR_CFG_DOT11_MODE_11N:
11250 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011251 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11252 break;
11253#ifdef WLAN_FEATURE_11AC
11254 case eCSR_CFG_DOT11_MODE_11AC:
11255 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11256 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011257 /* If the operating channel is in 2.4 GHz band, check for
11258 * INI item to disable VHT operation in 2.4 GHz band
11259 */
11260 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11261 !pMac->roam.configParam.enableVhtFor24GHz)
11262 {
11263 /* Disable 11AC operation */
11264 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11265 }
11266 else
11267 {
11268 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11269 }
11270 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011271 }
11272 else
11273 {
11274 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11275 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11276 }
11277 break;
11278 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11279 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11280 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011281 /* If the operating channel is in 2.4 GHz band, check for
11282 * INI item to disable VHT operation in 2.4 GHz band
11283 */
11284 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11285 !pMac->roam.configParam.enableVhtFor24GHz)
11286 {
11287 /* Disable 11AC operation */
11288 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11289 }
11290 else
11291 {
11292 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11293 }
11294 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011295 }
11296 else
11297 {
11298 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11299 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11300 }
11301 break;
11302#endif
11303 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011304#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011305 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11306 {
11307 /* If the operating channel is in 2.4 GHz band, check for
11308 * INI item to disable VHT operation in 2.4 GHz band
11309 */
11310 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11311 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011312 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011313 /* Disable 11AC operation */
11314 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011315 }
11316 else
11317 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011318 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11319 }
11320 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11321 }
11322 else
11323 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011324 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11325 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011326 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011327#else
11328 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11329 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11330#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 default:
11333 // Global dot11 Mode setting is 11a/b/g.
11334 // use the channel number to determine the Mode setting.
11335 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11336 {
11337 eBand = pMac->roam.configParam.eBand;
11338 if(eCSR_BAND_24 == eBand)
11339 {
11340 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11341 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11342 }
11343 else
11344 {
11345 //prefer 5GHz
11346 eBand = eCSR_BAND_5G;
11347 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11348 }
11349 }
11350 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11351 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011352 // WiFi tests require IBSS networks to start in 11b mode
11353 // without any change to the default parameter settings
11354 // on the adapter. We use ACU to start an IBSS through
11355 // creation of a startIBSS profile. This startIBSS profile
11356 // has Auto MACProtocol and the adapter property setting
11357 // for dot11Mode is also AUTO. So in this case, let's
11358 // start the IBSS network in 11b mode instead of 11g mode.
11359 // So this is for Auto=profile->MacProtocol && Auto=Global.
11360 // dot11Mode && profile->channel is < 14, then start the IBSS
11361 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011363 // Note: we used to have this start as an 11g IBSS for best
11364 // performance... now to specify that the user will have to
11365 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011366 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11367 eBand = eCSR_BAND_24;
11368 }
11369 else
11370 {
11371 // else, it's a 5.0GHz channel. Set mode to 11a.
11372 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11373 eBand = eCSR_BAND_5G;
11374 }
11375 break;
11376 }//switch
11377 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11378 else
11379 {
11380 //dot11 mode is set, lets pick the band
11381 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11382 {
11383 // channel is Auto also.
11384 eBand = pMac->roam.configParam.eBand;
11385 if(eCSR_BAND_ALL == eBand)
11386 {
11387 //prefer 5GHz
11388 eBand = eCSR_BAND_5G;
11389 }
11390 }
11391 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11392 {
11393 eBand = eCSR_BAND_24;
11394 }
11395 else
11396 {
11397 eBand = eCSR_BAND_5G;
11398 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 if(pBand)
11401 {
11402 *pBand = eBand;
11403 }
11404
11405 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011406 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11408 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011409
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011410 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11411 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 -070011412 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011413#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011414 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011415#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011416 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11417 {
11418 //We cannot do 11n here
11419 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11420 {
11421 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11422 }
11423 else
11424 {
11425 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11426 }
11427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011428 return( cfgDot11Mode );
11429}
11430
Jeff Johnson295189b2012-06-20 16:38:30 -070011431eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11432{
11433 eHalStatus status;
11434 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011435
11436 if(!pSession)
11437 {
11438 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11439 return eHAL_STATUS_FAILURE;
11440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011441
11442#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11443 {
11444 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11446 if(pIbssLog)
11447 {
11448 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11449 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11450 }
11451 }
11452#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 // Set the roaming substate to 'stop Bss request'...
11454 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11455
11456 // attempt to stop the Bss (reason code is ignored...)
11457 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011458 if(!HAL_STATUS_SUCCESS(status))
11459 {
11460 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 return (status);
11463}
11464
Jeff Johnson295189b2012-06-20 16:38:30 -070011465//pNumChan is a caller allocated space with the sizeof pChannels
11466eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11467{
11468
11469 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11470 (tANI_U8 *)pChannels,
11471 pNumChan));
11472}
11473
Kiran4a17ebe2013-01-31 10:43:43 -080011474tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11475{
11476 tANI_U32 cfgLength = 0;
11477 tANI_U16 cfgId = 0;
11478 tPowerdBm maxTxPwr = 0;
11479 tANI_U8 *pCountryInfo = NULL;
11480 eHalStatus status;
11481 tANI_U8 count = 0;
11482 tANI_U8 firstChannel;
11483 tANI_U8 maxChannels;
11484
11485 if (CSR_IS_CHANNEL_5GHZ(channel))
11486 {
11487 cfgId = WNI_CFG_MAX_TX_POWER_5;
11488 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11489 }
11490 else if (CSR_IS_CHANNEL_24GHZ(channel))
11491 {
11492 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11493 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11494 }
11495 else
11496 return maxTxPwr;
11497
Kiet Lam64c1b492013-07-12 13:56:44 +053011498 pCountryInfo = vos_mem_malloc(cfgLength);
11499 if ( NULL == pCountryInfo )
11500 status = eHAL_STATUS_FAILURE;
11501 else
11502 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011503 if (status != eHAL_STATUS_SUCCESS)
11504 {
11505 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011506 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011507 __FUNCTION__, status);
11508 goto error;
11509 }
11510 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11511 if (status != eHAL_STATUS_SUCCESS)
11512 {
11513 goto error;
11514 }
11515 /* Identify the channel and maxtxpower */
11516 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11517 {
11518 firstChannel = pCountryInfo[count++];
11519 maxChannels = pCountryInfo[count++];
11520 maxTxPwr = pCountryInfo[count++];
11521
11522 if ((channel >= firstChannel) &&
11523 (channel < (firstChannel + maxChannels)))
11524 {
11525 break;
11526 }
11527 }
11528
11529error:
11530 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011531 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011532
11533 return maxTxPwr;
11534}
11535
11536
Jeff Johnson295189b2012-06-20 16:38:30 -070011537tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11538{
11539 tANI_BOOLEAN fValid = FALSE;
11540 tANI_U32 idxValidChannels;
11541 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11542
11543 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11544 {
11545 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11546 {
11547 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11548 {
11549 fValid = TRUE;
11550 break;
11551 }
11552 }
11553 }
11554 pMac->roam.numValidChannels = len;
11555 return fValid;
11556}
11557
Jeff Johnson295189b2012-06-20 16:38:30 -070011558tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11559{
11560 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11561 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11563 {
11564 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11565 {
11566 fValid = eANI_BOOLEAN_TRUE;
11567 break;
11568 }
11569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 return (fValid);
11571}
11572
Jeff Johnson295189b2012-06-20 16:38:30 -070011573//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011574 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011575{
Jeff Johnsone7245742012-09-05 17:12:55 -070011576 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 tANI_U8 centerChn;
11578 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011579
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11581 {
11582 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11583 }
11584 else
11585 {
11586 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11587 }
11588 //Figure what the other side's CB mode
11589 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11590 {
11591 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11592 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011593 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11594 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11595 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11596 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011597 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11598 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011599 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011600 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011601
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011602 {
11603 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11604 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11605 }
11606
11607 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011609 /* This is called during INFRA STA/CLIENT and should use the merged value of
11610 * supported channel width and recommended tx width as per standard
11611 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011612 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011613 pIes->HTCaps.supportedChannelWidthSet,
11614 pIes->HTInfo.recommendedTxWidthSet,
11615 pIes->HTInfo.secondaryChannelOffset);
11616
11617 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11618 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011620 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11621 switch (eRet) {
11622 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11623 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11624 break;
11625 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11626 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11627 break;
11628 case PHY_SINGLE_CHANNEL_CENTERED:
11629 default:
11630 centerChn = primaryChn;
11631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011633 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011635 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011636 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053011638 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
11639 {
11640 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
11641 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 }
11644 }
11645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 return eRet;
11647}
Jeff Johnson295189b2012-06-20 16:38:30 -070011648tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11649{
11650 tANI_BOOLEAN fFound = FALSE;
11651 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11653 {
11654 if( pCipherList->encryptionType[idx] == encryptionType )
11655 {
11656 fFound = TRUE;
11657 break;
11658 }
11659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 return fFound;
11661}
Jeff Johnson295189b2012-06-20 16:38:30 -070011662tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11663{
11664 tANI_BOOLEAN fFound = FALSE;
11665 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011666 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11667 {
11668 if( pAuthList->authType[idx] == authType )
11669 {
11670 fFound = TRUE;
11671 break;
11672 }
11673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011674 return fFound;
11675}
Jeff Johnson295189b2012-06-20 16:38:30 -070011676tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11677{
11678 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11679 tCsrScanResultFilter *pScanFilter = NULL;
11680 eHalStatus status = eHAL_STATUS_SUCCESS;
11681
11682 if(pProfile1 && pProfile2)
11683 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011684 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11685 if ( NULL == pScanFilter )
11686 status = eHAL_STATUS_FAILURE;
11687 else
11688 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 if(HAL_STATUS_SUCCESS(status))
11690 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011691 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11693 if(HAL_STATUS_SUCCESS(status))
11694 {
11695 fCheck = eANI_BOOLEAN_FALSE;
11696 do
11697 {
11698 tANI_U32 i;
11699 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11700 {
11701 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11702 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11703 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11704 if ( fCheck ) break;
11705 }
11706 if(!fCheck)
11707 {
11708 break;
11709 }
11710 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11711 || pProfile2->BSSType != pProfile1->BSSType
11712 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11713 )
11714 {
11715 fCheck = eANI_BOOLEAN_FALSE;
11716 break;
11717 }
11718#ifdef WLAN_FEATURE_VOWIFI_11R
11719 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11720 {
11721 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11722 {
11723 fCheck = eANI_BOOLEAN_FALSE;
11724 break;
11725 }
11726 }
11727#endif
11728 //Match found
11729 fCheck = eANI_BOOLEAN_TRUE;
11730 }while(0);
11731 csrFreeScanFilter(pMac, pScanFilter);
11732 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011733 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 }
11735 }
11736
11737 return (fCheck);
11738}
11739
Jeff Johnson295189b2012-06-20 16:38:30 -070011740tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11741{
11742 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11743 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011744 do
11745 {
11746 //Only check for static WEP
11747 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11748 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11749 {
11750 fCheck = eANI_BOOLEAN_TRUE;
11751 break;
11752 }
11753 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11754 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11755 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11756 {
11757 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011758 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11759 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 {
11761 break;
11762 }
11763 }
11764 if( i == CSR_MAX_NUM_KEY)
11765 {
11766 fCheck = eANI_BOOLEAN_TRUE;
11767 }
11768 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 return (fCheck);
11770}
11771
Jeff Johnson295189b2012-06-20 16:38:30 -070011772//IBSS
11773
Jeff Johnson295189b2012-06-20 16:38:30 -070011774tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11775{
11776 tANI_U8 channel = 0;
11777 tANI_U32 idx;
11778 tANI_U32 idxValidChannels;
11779 tANI_BOOLEAN fFound = FALSE;
11780 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11781
11782 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11783 {
11784 channel = pMac->roam.configParam.AdHocChannel5G;
11785 if(!csrRoamIsChannelValid(pMac, channel))
11786 {
11787 channel = 0;
11788 }
11789 }
11790 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11791 {
11792 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11793 {
11794 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11795 {
11796 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11797 {
11798 fFound = TRUE;
11799 channel = csrStartIbssChannels50[ idx ];
11800 }
11801 }
11802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011803 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11804 if (!fFound)
11805 {
11806 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11807 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011808 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011810 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 break;
11812 }
11813 }
11814 }
11815 }//if
11816
11817 return( channel );
11818}
11819
Jeff Johnson295189b2012-06-20 16:38:30 -070011820tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11821{
11822 tANI_U8 channel = 1;
11823 tANI_U32 idx;
11824 tANI_U32 idxValidChannels;
11825 tANI_BOOLEAN fFound = FALSE;
11826 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11827
11828 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11829 {
11830 channel = pMac->roam.configParam.AdHocChannel24;
11831 if(!csrRoamIsChannelValid(pMac, channel))
11832 {
11833 channel = 0;
11834 }
11835 }
11836
11837 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11838 {
11839 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11840 {
11841 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11842 {
11843 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11844 {
11845 fFound = TRUE;
11846 channel = csrStartIbssChannels24[ idx ];
11847 }
11848 }
11849 }
11850 }
11851
11852 return( channel );
11853}
11854
Jeff Johnson295189b2012-06-20 16:38:30 -070011855static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11856 tCsrRoamStartBssParams *pParam )
11857{
11858 eCsrCfgDot11Mode cfgDot11Mode;
11859 eCsrBand eBand;
11860 tANI_U8 channel = 0;
11861 tSirNwType nwType;
11862 tANI_U8 operationChannel = 0;
11863
11864 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11865 {
11866 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11867 }
11868
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011870
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11872 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11873 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11874 )
11875 {
11876 /* This should never happen */
11877 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011878 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 pProfile->csrPersona);
11880 VOS_ASSERT(0);
11881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 switch( cfgDot11Mode )
11883 {
11884 case eCSR_CFG_DOT11_MODE_11G:
11885 nwType = eSIR_11G_NW_TYPE;
11886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 case eCSR_CFG_DOT11_MODE_11B:
11888 nwType = eSIR_11B_NW_TYPE;
11889 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 case eCSR_CFG_DOT11_MODE_11A:
11891 nwType = eSIR_11A_NW_TYPE;
11892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 default:
11894 case eCSR_CFG_DOT11_MODE_11N:
11895 case eCSR_CFG_DOT11_MODE_TAURUS:
11896 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11897 if(eCSR_BAND_24 == eBand)
11898 {
11899 nwType = eSIR_11G_NW_TYPE;
11900 }
11901 else
11902 {
11903 nwType = eSIR_11A_NW_TYPE;
11904 }
11905 break;
11906 }
11907
11908 pParam->extendedRateSet.numRates = 0;
11909
11910 switch ( nwType )
11911 {
11912 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011913 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 case eSIR_11A_NW_TYPE:
11915
11916 pParam->operationalRateSet.numRates = 8;
11917
11918 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11919 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11920 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11921 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11922 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11923 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11924 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11925 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11926
11927 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11928 {
11929 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11930 if( 0 == channel &&
11931 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11932 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11933 )
11934 {
11935 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11936 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11937 nwType = eSIR_11B_NW_TYPE;
11938 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11939 pParam->operationalRateSet.numRates = 4;
11940 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11941 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11942 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11943 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11944 }
11945 }
11946 else
11947 {
11948 channel = operationChannel;
11949 }
11950 break;
11951
11952 case eSIR_11B_NW_TYPE:
11953 pParam->operationalRateSet.numRates = 4;
11954 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11955 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11956 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11957 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11959 {
11960 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11961 }
11962 else
11963 {
11964 channel = operationChannel;
11965 }
11966
11967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011969 /* For P2P Client and P2P GO, disable 11b rates */
11970 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11971 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11972 )
11973 {
11974 pParam->operationalRateSet.numRates = 8;
11975
11976 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11977 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11978 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11979 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11980 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11981 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11982 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11983 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11984 }
11985 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 {
11987 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11989 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11990 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11991 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11992
11993 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11995 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11996 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11997 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11998 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11999 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12000 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12001 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12002 }
12003
12004 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12005 {
12006 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12007 }
12008 else
12009 {
12010 channel = operationChannel;
12011 }
12012
12013 break;
12014 }
12015 pParam->operationChn = channel;
12016 pParam->sirNwType = nwType;
12017}
12018
Jeff Johnson295189b2012-06-20 16:38:30 -070012019static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12020 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12021{
12022
12023 if( pParam )
12024 {
12025 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012026 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012027 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012028 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012029
12030 if( pIes )
12031 {
12032 if(pIes->SuppRates.present)
12033 {
12034 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12035 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012037 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 -070012038 pIes->SuppRates.num_rates);
12039 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12040 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012041 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12042 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012044 if (pIes->ExtSuppRates.present)
12045 {
12046 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012047 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012048 {
12049 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12050 SIR_MAC_RATESET_EID_MAX, resetting to \
12051 SIR_MAC_RATESET_EID_MAX"),
12052 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012053 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012054 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012055 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012056 pIes->ExtSuppRates.rates,
12057 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012059 if( pIes->SSID.present )
12060 {
12061 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012062 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12063 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 }
12065 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 }
12067 else
12068 {
12069 pParam->ssId.length = 0;
12070 pParam->operationalRateSet.numRates = 0;
12071 }
12072 }
12073}
12074
Jeff Johnson295189b2012-06-20 16:38:30 -070012075static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12076{
12077 tANI_U8 MaxRate = 0;
12078 tANI_U32 i;
12079 tANI_U8 *pRate;
12080
12081 pRate = pSirRateSet->rate;
12082 for ( i = 0; i < pSirRateSet->numRates; i++ )
12083 {
12084 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12085 }
12086
12087 // Save the max rate in the connected state information...
12088
12089 // modify LastRates variable as well
12090
12091 return;
12092}
12093
Jeff Johnson295189b2012-06-20 16:38:30 -070012094eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12095 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12096{
12097 eHalStatus status = eHAL_STATUS_SUCCESS;
12098 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 // Set the roaming substate to 'Start BSS attempt'...
12100 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012101#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12102 //Need to figure out whether we need to log WDS???
12103 if( CSR_IS_IBSS( pProfile ) )
12104 {
12105 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12107 if(pIbssLog)
12108 {
12109 if(pBssDesc)
12110 {
12111 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012112 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 }
12114 else
12115 {
12116 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12117 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012118 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 if(pProfile->ChannelInfo.numOfChannels == 0)
12120 {
12121 pIbssLog->channelSetting = AUTO_PICK;
12122 }
12123 else
12124 {
12125 pIbssLog->channelSetting = SPECIFIED;
12126 }
12127 pIbssLog->operatingChannel = pParam->operationChn;
12128 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12129 }
12130 }
12131#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12132 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012133 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12134 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012135
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 pParam->privacy = pProfile->privacy;
12137 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12138 pParam->authType = pProfile->csr80211AuthType;
12139 pParam->beaconInterval = pProfile->beaconInterval;
12140 pParam->dtimPeriod = pProfile->dtimPeriod;
12141 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12142 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12143 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12144 {
12145 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12146 {
12147 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12148 }
12149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 pParam->protEnabled = pProfile->protEnabled;
12151 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12152 pParam->ht_protection = pProfile->cfg_protection;
12153 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012154
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12156 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012158
12159#ifdef WLAN_FEATURE_11W
12160 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12161 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12162#endif
12163
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 // When starting an IBSS, start on the channel from the Profile.
12165 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 return (status);
12167}
12168
Jeff Johnson295189b2012-06-20 16:38:30 -070012169static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012170 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012171{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012172 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012173 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012175
12176 if(!pSession)
12177 {
12178 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12179 return;
12180 }
12181
Jeff Johnson295189b2012-06-20 16:38:30 -070012182 if( pBssDesc )
12183 {
12184 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12185 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12186 //The following code has to be do after that.
12187 //For WDS station, use selfMac as the self BSSID
12188 if( CSR_IS_WDS_STA( pProfile ) )
12189 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012190 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12191 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 }
12193 }
12194 else
12195 {
12196 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012197 //Use the first SSID
12198 if(pProfile->SSIDs.numOfSSIDs)
12199 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012200 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12201 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 }
12203 //For WDS station, use selfMac as the self BSSID
12204 if( CSR_IS_WDS_STA( pProfile ) )
12205 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012206 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12207 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 }
12209 //Use the first BSSID
12210 else if( pProfile->BSSIDs.numOfBSSIDs )
12211 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012212 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12213 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 }
12215 else
12216 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012217 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 }
12219 }
12220 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012221 //Set operating channel in pProfile which will be used
12222 //in csrRoamSetBssConfigCfg() to determine channel bonding
12223 //mode and will be configured in CFG later
12224 pProfile->operationChannel = Channel;
12225
12226 if(Channel == 0)
12227 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012228 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012229 }
12230 else
12231 {
12232
12233 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012234 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012235 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012236 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012237 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012238#ifdef WLAN_FEATURE_AP_HT40_24G
12239 if (CSR_IS_INFRA_AP(pProfile))
12240 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12241 else
12242 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12243#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012244 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012245#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012246 }
12247 else
12248 {
12249 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12250 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012251 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012252 pBssConfig->cbMode = cbMode;
12253 pSession->bssParams.cbMode = cbMode;
12254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 }
12256}
12257
Jeff Johnson295189b2012-06-20 16:38:30 -070012258static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12259 tANI_BOOLEAN *pfSameIbss )
12260{
12261 eHalStatus status = eHAL_STATUS_SUCCESS;
12262 tANI_BOOLEAN fSameIbss = FALSE;
12263
12264 if ( csrIsConnStateIbss( pMac, sessionId ) )
12265 {
12266 // Check if any profile parameter has changed ? If any profile parameter
12267 // has changed then stop old BSS and start a new one with new parameters
12268 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12269 {
12270 fSameIbss = TRUE;
12271 }
12272 else
12273 {
12274 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12275 }
12276 }
12277 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12278 {
12279 // Disassociate from the connected Infrastructure network...
12280 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12281 }
12282 else
12283 {
12284 tBssConfigParam *pBssConfig;
12285
Kiet Lam64c1b492013-07-12 13:56:44 +053012286 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12287 if ( NULL == pBssConfig )
12288 status = eHAL_STATUS_FAILURE;
12289 else
12290 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 if(HAL_STATUS_SUCCESS(status))
12292 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012293 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 // there is no Bss description before we start an IBSS so we need to adopt
12295 // all Bss configuration parameters from the Profile.
12296 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12297 if(HAL_STATUS_SUCCESS(status))
12298 {
12299 //save dotMode
12300 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12301 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012302 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012303 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12304 NULL, pBssConfig,
12305 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012307
12308 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 }//Allocate memory
12310 }
12311
12312 if(pfSameIbss)
12313 {
12314 *pfSameIbss = fSameIbss;
12315 }
12316 return( status );
12317}
12318
Jeff Johnson295189b2012-06-20 16:38:30 -070012319static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12320 tSirSmeNewBssInfo *pNewBss )
12321{
12322 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012323
12324 if(!pSession)
12325 {
12326 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12327 return;
12328 }
12329
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 if( pNewBss )
12331 {
12332 // Set the operating channel.
12333 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12334 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012335 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12336 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012338 return;
12339}
12340
Jeff Johnson295189b2012-06-20 16:38:30 -070012341#ifdef FEATURE_WLAN_WAPI
12342eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12343 tANI_U32 numItems )
12344{
12345 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12346 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012349 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 return status;
12351 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012352 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 pSession = CSR_GET_SESSION( pMac, sessionId );
12354 if(numItems <= CSR_MAX_BKID_ALLOWED)
12355 {
12356 status = eHAL_STATUS_SUCCESS;
12357 //numItems may be 0 to clear the cache
12358 pSession->NumBkidCache = (tANI_U16)numItems;
12359 if(numItems && pBKIDCache)
12360 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012361 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12362 sizeof(tBkidCacheInfo) * numItems);
12363 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 }
12365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 return (status);
12367}
Jeff Johnson295189b2012-06-20 16:38:30 -070012368eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12369 tBkidCacheInfo *pBkidCache)
12370{
12371 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12372 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012375 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 return status;
12377 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 pSession = CSR_GET_SESSION( pMac, sessionId );
12379 if(pNum && pBkidCache)
12380 {
12381 if(pSession->NumBkidCache == 0)
12382 {
12383 *pNum = 0;
12384 status = eHAL_STATUS_SUCCESS;
12385 }
12386 else if(*pNum >= pSession->NumBkidCache)
12387 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012388 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012389 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012390 smsLog(pMac, LOGE, FL("NumBkidCache :%d is more than CSR_MAX_BKID_ALLOWED, resetting to CSR_MAX_BKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012392 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012393 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012394 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12395 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 *pNum = pSession->NumBkidCache;
12397 status = eHAL_STATUS_SUCCESS;
12398 }
12399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012401}
Jeff Johnson295189b2012-06-20 16:38:30 -070012402tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12403{
12404 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012405}
12406#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012407eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012408 tPmkidCacheInfo *pPMKIDCache,
12409 tANI_U32 numItems,
12410 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012411{
12412 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12413 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012414
12415 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012416 {
12417 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12418 return eHAL_STATUS_FAILURE;
12419 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012420
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012421 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012422
12423 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 {
12425#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12426 {
12427 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012428 vos_mem_set(&secEvent,
12429 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12431 secEvent.encryptionModeMulticast =
12432 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12433 secEvent.encryptionModeUnicast =
12434 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012435 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 secEvent.authMode =
12437 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12438 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12439 }
12440#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012442 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012443 if (numItems && pPMKIDCache)
12444 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012445 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012446 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12447 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012448 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012449 }
12450 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012451 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012452 tPmkidCacheInfo *pmksa;
12453
12454 for (i = 0; i < numItems; i++) {
12455 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012456
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012457 /* Delete the entry if present */
12458 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12459
12460 /* Add entry to the cache */
12461 vos_mem_copy(
12462 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12463 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12464 vos_mem_copy(
12465 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12466 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12467
12468 /* Increment the CSR local cache index */
12469 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12470 pSession->CurCacheIndex++;
12471 else
12472 pSession->CurCacheIndex = 0;
12473
12474 pSession->NumPmkidCache++;
12475 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12476 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 }
12479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 return (status);
12481}
12482
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012483eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012484#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12485 const tANI_U8 *pBSSId,
12486#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012487 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012488#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012489 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012490{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012491 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12492 tANI_BOOLEAN fMatchFound = FALSE;
12493 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012494 tANI_U32 CurIndex;
12495 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012496
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012497 if(!pSession)
12498 {
12499 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12500 return eHAL_STATUS_FAILURE;
12501 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012502
12503 /* Check if there are no entries to delete */
12504 if (0 == pSession->NumPmkidCache) {
12505 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12506 return eHAL_STATUS_SUCCESS;
12507 }
12508
12509 if (!flush_cache) {
12510 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12511 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12512 pBSSId, VOS_MAC_ADDR_SIZE)) {
12513 fMatchFound = 1;
12514
12515 /* Clear this - the matched entry */
12516 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12517 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012518 break;
12519 }
12520 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012521
12522 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12523 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12524 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012525 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012526 else {
12527 /* Match Found */
12528 CurIndex = pSession->CurCacheIndex;
12529 if(Index < CurIndex) {
12530 for(i = Index; i < (CurIndex-1); i++) {
12531 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12532 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12533 }
12534 pSession->CurCacheIndex--;
12535 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12536 sizeof(tPmkidCacheInfo));
12537 } else if(Index > CurIndex) {
12538 for(i = Index; i > (CurIndex); i--) {
12539 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12540 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12541 }
12542 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12543 sizeof(tPmkidCacheInfo));
12544 }
12545 pSession->NumPmkidCache--;
12546 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012547 } else {
12548 /* Flush the entire cache */
12549 vos_mem_zero(pSession->PmkidCacheInfo,
12550 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12551 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012552 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012553 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012554
12555 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012556}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012557
Jeff Johnson295189b2012-06-20 16:38:30 -070012558tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12559{
12560 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12561}
12562
Jeff Johnson295189b2012-06-20 16:38:30 -070012563eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12564{
12565 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12566 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012567 tPmkidCacheInfo *pmksa;
12568 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012569
12570 if(!pSession)
12571 {
12572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12573 return eHAL_STATUS_FAILURE;
12574 }
12575
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 if(pNum && pPmkidCache)
12577 {
12578 if(pSession->NumPmkidCache == 0)
12579 {
12580 *pNum = 0;
12581 status = eHAL_STATUS_SUCCESS;
12582 }
12583 else if(*pNum >= pSession->NumPmkidCache)
12584 {
12585 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012587 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 -070012588 pSession->NumPmkidCache);
12589 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12590 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012591
12592 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12593 pmksa = &pSession->PmkidCacheInfo[i];
12594 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12595 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
12596 pPmkidCache++;
12597 j++;
12598 }
12599 }
12600
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 *pNum = pSession->NumPmkidCache;
12602 status = eHAL_STATUS_SUCCESS;
12603 }
12604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 return (status);
12606}
12607
Jeff Johnson295189b2012-06-20 16:38:30 -070012608eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12609{
12610 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12611 tANI_U32 len;
12612 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012613
12614 if(!pSession)
12615 {
12616 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12617 return eHAL_STATUS_FAILURE;
12618 }
12619
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 if(pLen)
12621 {
12622 len = *pLen;
12623 *pLen = pSession->nWpaRsnReqIeLength;
12624 if(pBuf)
12625 {
12626 if(len >= pSession->nWpaRsnReqIeLength)
12627 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012628 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12629 pSession->nWpaRsnReqIeLength);
12630 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 }
12632 }
12633 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 return (status);
12635}
12636
Jeff Johnson295189b2012-06-20 16:38:30 -070012637eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12638{
12639 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12640 tANI_U32 len;
12641 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012642
12643 if(!pSession)
12644 {
12645 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12646 return eHAL_STATUS_FAILURE;
12647 }
12648
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 if(pLen)
12650 {
12651 len = *pLen;
12652 *pLen = pSession->nWpaRsnRspIeLength;
12653 if(pBuf)
12654 {
12655 if(len >= pSession->nWpaRsnRspIeLength)
12656 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012657 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12658 pSession->nWpaRsnRspIeLength);
12659 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 }
12661 }
12662 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 return (status);
12664}
Jeff Johnson295189b2012-06-20 16:38:30 -070012665#ifdef FEATURE_WLAN_WAPI
12666eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12667{
12668 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12669 tANI_U32 len;
12670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012671
12672 if(!pSession)
12673 {
12674 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12675 return eHAL_STATUS_FAILURE;
12676 }
12677
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 if(pLen)
12679 {
12680 len = *pLen;
12681 *pLen = pSession->nWapiReqIeLength;
12682 if(pBuf)
12683 {
12684 if(len >= pSession->nWapiReqIeLength)
12685 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012686 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12687 pSession->nWapiReqIeLength);
12688 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 }
12690 }
12691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012692 return (status);
12693}
Jeff Johnson295189b2012-06-20 16:38:30 -070012694eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12695{
12696 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12697 tANI_U32 len;
12698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012699
12700 if(!pSession)
12701 {
12702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12703 return eHAL_STATUS_FAILURE;
12704 }
12705
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 if(pLen)
12707 {
12708 len = *pLen;
12709 *pLen = pSession->nWapiRspIeLength;
12710 if(pBuf)
12711 {
12712 if(len >= pSession->nWapiRspIeLength)
12713 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012714 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12715 pSession->nWapiRspIeLength);
12716 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 }
12718 }
12719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 return (status);
12721}
12722#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012723eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12724{
12725 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12726 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012727
12728 if(!pSession)
12729 {
12730 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12731 return (retStatus);
12732 }
12733
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 if(CSR_IS_ROAMING(pSession))
12735 {
12736 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12737 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 return (retStatus);
12740}
12741
Jeff Johnson295189b2012-06-20 16:38:30 -070012742//This function remove the connected BSS from te cached scan result
12743eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12744 tCsrRoamConnectedProfile *pConnProfile)
12745{
12746 eHalStatus status = eHAL_STATUS_FAILURE;
12747 tCsrScanResultFilter *pScanFilter = NULL;
12748 tListElem *pEntry;
12749 tCsrScanResult *pResult;
12750 tDot11fBeaconIEs *pIes;
12751 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12753 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12754 {
12755 do
12756 {
12757 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012758 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12759 if ( NULL == pScanFilter )
12760 status = eHAL_STATUS_FAILURE;
12761 else
12762 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012764 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12765 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12766 if ( NULL == pScanFilter->BSSIDs.bssid )
12767 status = eHAL_STATUS_FAILURE;
12768 else
12769 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012771 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12772 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12774 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12775 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012776 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12777 if ( NULL == pScanFilter->SSIDs.SSIDList )
12778 status = eHAL_STATUS_FAILURE;
12779 else
12780 status = eHAL_STATUS_SUCCESS;
12781 if (!HAL_STATUS_SUCCESS(status)) break;
12782 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12783 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 }
12785 pScanFilter->authType.numEntries = 1;
12786 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12787 pScanFilter->BSSType = pConnProfile->BSSType;
12788 pScanFilter->EncryptionType.numEntries = 1;
12789 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12790 pScanFilter->mcEncryptionType.numEntries = 1;
12791 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12792 //We ignore the channel for now, BSSID should be enough
12793 pScanFilter->ChannelInfo.numOfChannels = 0;
12794 //Also ignore the following fields
12795 pScanFilter->uapsd_mask = 0;
12796 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012797 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012798 pScanFilter->countryCode[0] = 0;
12799 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 csrLLLock(&pMac->scan.scanResultList);
12801 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12802 while( pEntry )
12803 {
12804 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12805 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12806 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12807 pScanFilter, NULL, NULL, NULL, &pIes);
12808 //Release the IEs allocated by csrMatchBSS is needed
12809 if( !pResult->Result.pvIes )
12810 {
12811 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012812 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 }
12814 if(fMatch)
12815 {
12816 //We found the one
12817 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12818 {
12819 //Free the memory
12820 csrFreeScanResultEntry( pMac, pResult );
12821 }
12822 break;
12823 }
12824 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12825 }//while
12826 csrLLUnlock(&pMac->scan.scanResultList);
12827 }while(0);
12828 if(pScanFilter)
12829 {
12830 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012831 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 }
12833 }
12834 return (status);
12835}
12836
Jeff Johnson295189b2012-06-20 16:38:30 -070012837//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012838eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12839{
12840 eHalStatus status = eHAL_STATUS_SUCCESS;
12841 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12843 {
12844 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12845 {
12846 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12847 {
12848 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012849 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 status = eHAL_STATUS_CSR_WRONG_STATE;
12851 break;
12852 }
12853 if( csrIsConnStateInfra( pMac, sessionId ) )
12854 {
12855 if( chnId &&
12856 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12857 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012858 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12860 status = eHAL_STATUS_CSR_WRONG_STATE;
12861 break;
12862 }
12863 }
12864 }
12865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 return ( status );
12867}
12868
Jeff Johnson295189b2012-06-20 16:38:30 -070012869static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12870{
12871 eHalStatus status = eHAL_STATUS_SUCCESS;
12872 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12873 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012874
12875 if(!pSession)
12876 {
12877 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12878 return eHAL_STATUS_FAILURE;
12879 }
12880
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 if ( csrIsConnStateIbss( pMac, sessionId ) )
12882 {
12883 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12884 }
12885 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12886 {
12887 // Disassociate from the connected Infrastructure network...
12888 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12889 }
12890 else
12891 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12893 //Otherwise we need to add code to handle the
12894 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12895 //send stop_bss to PE, before we can continue.
12896 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012897 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012899 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12900 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 // there is no Bss description before we start an WDS so we need
12902 // to adopt all Bss configuration parameters from the Profile.
12903 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12904 if(HAL_STATUS_SUCCESS(status))
12905 {
12906 //Save profile for late use
12907 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012908 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12909 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012911 vos_mem_set(pSession->pCurRoamProfile,
12912 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12914 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012915 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012916 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012917 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12918 NULL, &bssConfig,
12919 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012920 }
12921 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012922
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 return( status );
12924}
12925
Jeff Johnson295189b2012-06-20 16:38:30 -070012926////////////////////Mail box
12927
Jeff Johnson295189b2012-06-20 16:38:30 -070012928//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12929//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012930static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12931 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12933{
12934 tCsrChannelSet channelGroup;
12935 tSirMacCapabilityInfo *pAP_capabilityInfo;
12936 tAniBool fTmp;
12937 tANI_BOOLEAN found = FALSE;
12938 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012939 tANI_S8 pwrLimit = 0;
12940 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012941 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12942 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12943 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12944 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 // 802.11h
12946 //We can do this because it is in HOST CPU order for now.
12947 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012948 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12949 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12950 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 fTmp = (tAniBool)pal_cpu_to_be32(1);
12952 }
12953 else
12954 fTmp = (tAniBool)0;
12955
12956 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012957 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 pBuf += sizeof(tAniBool);
12959 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012960 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 // This is required for 11k test VoWiFi Ent: Test 2.
12962 // We need the power capabilities for Assoc Req.
12963 // This macro is provided by the halPhyCfg.h. We pick our
12964 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012965 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12966 if (0 != pwrLimit)
12967 {
12968 *pBuf++ = pwrLimit;
12969 }
12970 else
12971 {
12972 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 size = sizeof(pMac->roam.validChannelList);
12975 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053012976 {
12977 tANI_U8 *actualSize = pBuf++;
12978 *actualSize = 0;
12979
12980 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053012982 /* Only add 5ghz channels*/
12983 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
12984 {
12985 *actualSize +=1;
12986 *pBuf++ = pMac->roam.validChannelList[ i ];
12987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 }
12989 }
12990 else
12991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012992 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 *pBuf++ = 0; //tSirSupChnl->numChnl
12994 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 //Check whether it is ok to enter UAPSD
12996#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12997 if( btcIsReadyForUapsd(pMac) )
12998#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12999 {
13000 *pBuf++ = uapsdMask;
13001 }
13002#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13003 else
13004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013005 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 *pBuf++ = 0;
13007 }
13008#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13009
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013011 vos_mem_copy(pBuf, pBssDescription,
13012 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13014}
13015
Jeff Johnson295189b2012-06-20 16:38:30 -070013016/*
13017 * The communication between HDD and LIM is thru mailbox (MB).
13018 * Both sides will access the data structure "tSirSmeJoinReq".
13019 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13020 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13021 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13022 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13023 */
13024eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013025 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013026{
13027 eHalStatus status = eHAL_STATUS_SUCCESS;
13028 tSirSmeJoinReq *pMsg;
13029 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013030 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 tANI_U16 msgLen, wTmp, ieLen;
13032 tSirMacRateSet OpRateSet;
13033 tSirMacRateSet ExRateSet;
13034 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13035 tANI_U32 dwTmp;
13036 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013037 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013038 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013039 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013040
13041 if(!pSession)
13042 {
13043 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13044 return eHAL_STATUS_FAILURE;
13045 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013046 /* To satisfy klockworks */
13047 if (NULL == pBssDescription)
13048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013049 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013050 return eHAL_STATUS_FAILURE;
13051 }
13052
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 do {
13054 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13055 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013056 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13058 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13059 // IE fields, but the length field in the bssDescription needs to be interpreted to
13060 // determine length of the IE fields.
13061 //
13062 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13063 // add in the length from the bssDescription (then add the size of the 'length' field
13064 // itself because that is NOT included in the length field).
13065 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13066 pBssDescription->length + sizeof( pBssDescription->length ) +
13067 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
Kiet Lam64c1b492013-07-12 13:56:44 +053013068 pMsg = vos_mem_malloc(msgLen);
13069 if (NULL == pMsg)
13070 status = eHAL_STATUS_FAILURE;
13071 else
13072 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013074 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013075 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 pMsg->length = pal_cpu_to_be16(msgLen);
13077 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 // sessionId
13079 *pBuf = (tANI_U8)sessionId;
13080 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 // transactionId
13082 *pBuf = 0;
13083 *( pBuf + 1 ) = 0;
13084 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 // ssId
13086 if( pIes->SSID.present && pIes->SSID.num_ssid )
13087 {
13088 // ssId len
13089 *pBuf = pIes->SSID.num_ssid;
13090 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013091 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 pBuf += pIes->SSID.num_ssid;
13093 }
13094 else
13095 {
13096 *pBuf = 0;
13097 pBuf++;
13098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013100 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13101 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 pBuf += sizeof(tSirMacAddr);
13103 // bsstype
13104 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13105 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013106 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 pBuf += sizeof(tSirBssType);
13108 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013109 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13110 if (pBssDescription->channelId <= 14 &&
13111 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13112 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13113 {
13114 //Need to disable VHT operation in 2.4 GHz band
13115 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13116 }
13117 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 //Persona
13120 *pBuf = (tANI_U8)pProfile->csrPersona;
13121 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013122 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13123 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013124 //CBMode
13125 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13126 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013127
13128 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070013129 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
13130
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 // uapsdPerAcBitmask
13132 *pBuf = pProfile->uapsd_mask;
13133 pBuf++;
13134
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013135
13136
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013137 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013138 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 {
13140 // OperationalRateSet
13141 if (OpRateSet.numRates) {
13142 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013143 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 pBuf += OpRateSet.numRates;
13145 } else *pBuf++ = 0;
13146 // ExtendedRateSet
13147 if (ExRateSet.numRates) {
13148 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013149 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 pBuf += ExRateSet.numRates;
13151 } else *pBuf++ = 0;
13152 }
13153 else
13154 {
13155 *pBuf++ = 0;
13156 *pBuf++ = 0;
13157 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013158
13159 //rateBitmap
13160 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13161 pBuf += sizeof(tANI_U16);
13162
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 // rsnIE
13164 if ( csrIsProfileWpa( pProfile ) )
13165 {
13166 // Insert the Wpa IE into the join request
13167 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13168 (tCsrWpaIe *)( wpaRsnIE ) );
13169 }
13170 else if( csrIsProfileRSN( pProfile ) )
13171 {
13172 // Insert the RSN IE into the join request
13173 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13174 (tCsrRSNIe *)( wpaRsnIE ) );
13175 }
13176#ifdef FEATURE_WLAN_WAPI
13177 else if( csrIsProfileWapi( pProfile ) )
13178 {
13179 // Insert the WAPI IE into the join request
13180 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13181 (tCsrWapiIe *)( wpaRsnIE ) );
13182 }
13183#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 else
13185 {
13186 ieLen = 0;
13187 }
13188 //remember the IE for future use
13189 if( ieLen )
13190 {
13191 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013193 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 -070013194 ieLen = DOT11F_IE_RSN_MAX_LEN;
13195 }
13196#ifdef FEATURE_WLAN_WAPI
13197 if( csrIsProfileWapi( pProfile ) )
13198 {
13199 //Check whether we need to allocate more memory
13200 if(ieLen > pSession->nWapiReqIeLength)
13201 {
13202 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13203 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013204 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013206 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13207 if (NULL == pSession->pWapiReqIE)
13208 status = eHAL_STATUS_FAILURE;
13209 else
13210 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 if(!HAL_STATUS_SUCCESS(status)) break;
13212 }
13213 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013214 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013216 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013218 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 pBuf += ieLen;
13220 }
13221 else//should be WPA/WPA2 otherwise
13222#endif /* FEATURE_WLAN_WAPI */
13223 {
13224 //Check whether we need to allocate more memory
13225 if(ieLen > pSession->nWpaRsnReqIeLength)
13226 {
13227 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013229 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013231 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13232 if (NULL == pSession->pWpaRsnReqIE)
13233 status = eHAL_STATUS_FAILURE;
13234 else
13235 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 if(!HAL_STATUS_SUCCESS(status)) break;
13237 }
13238 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013239 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013241 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013243 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 pBuf += ieLen;
13245 }
13246 }
13247 else
13248 {
13249 //free whatever old info
13250 pSession->nWpaRsnReqIeLength = 0;
13251 if(pSession->pWpaRsnReqIE)
13252 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013253 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 pSession->pWpaRsnReqIE = NULL;
13255 }
13256#ifdef FEATURE_WLAN_WAPI
13257 pSession->nWapiReqIeLength = 0;
13258 if(pSession->pWapiReqIE)
13259 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013260 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013261 pSession->pWapiReqIE = NULL;
13262 }
13263#endif /* FEATURE_WLAN_WAPI */
13264 //length is two bytes
13265 *pBuf = 0;
13266 *(pBuf + 1) = 0;
13267 pBuf += 2;
13268 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013269#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013270 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013272 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 //length is two bytes
13274 *pBuf = 0;
13275 *(pBuf + 1) = 0;
13276 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013277 }
13278 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013280 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013281 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013282 {
13283 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013284#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013285 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013286 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013287 pSession->suppCckmIeInfo.cckmIe, ieLen);
13288#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013289 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013290 pSession,
13291 pProfile,
13292 pBssDescription,
13293 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 pSession->nWpaRsnReqIeLength,
13295 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013296#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013297 }
13298 else
13299 {
13300 ieLen = 0;
13301 }
13302 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13303 if( ieLen )
13304 {
13305 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13306 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013307 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013308 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013309 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013310 pBuf += ieLen;
13311 }
13312 else
13313 {
13314 //Indicate you have no CCKM IE
13315 //length is two bytes
13316 *pBuf = 0;
13317 *(pBuf + 1) = 0;
13318 pBuf += 2;
13319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013321#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013323 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 {
13325 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013326 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013328 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013330 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013332 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 pBuf += ieLen;
13334 }
13335 else
13336 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013337 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 *pBuf = 0;
13340 *(pBuf + 1) = 0;
13341 pBuf += 2;
13342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 // addIEAssoc
13344 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13345 {
13346 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 if(ieLen > pSession->nAddIEAssocLength)
13348 {
13349 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013350 {
13351 vos_mem_free(pSession->pAddIEAssoc);
13352 }
13353 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13354 if (NULL == pSession->pAddIEAssoc)
13355 status = eHAL_STATUS_FAILURE;
13356 else
13357 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013359 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013360 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013361 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013363 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013365 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 pBuf += ieLen;
13367 }
13368 else
13369 {
13370 pSession->nAddIEAssocLength = 0;
13371 if(pSession->pAddIEAssoc)
13372 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013373 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 pSession->pAddIEAssoc = NULL;
13375 }
13376 *pBuf = 0;
13377 *(pBuf + 1) = 0;
13378 pBuf += 2;
13379 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013380
13381 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013383 //Unmask any AC in reassoc that is ACM-set
13384 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13385 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013387 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13388 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013389#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013390 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013391#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013392 }
13393 else
13394 {
13395 uapsd_mask = 0;
13396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 }
13398 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013399
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013401 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013402 pBuf += sizeof(tANI_U32);
13403
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013405 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013406 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013407#ifdef WLAN_FEATURE_11W
13408 //MgmtEncryption
13409 if (pProfile->MFPEnabled)
13410 {
13411 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13412 }
13413 else
13414 {
13415 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13416 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013417 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013418 pBuf += sizeof(tANI_U32);
13419#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013420#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013421 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013422 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013423#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013424 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013425 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013426#endif
13427 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013428 {
13429 // is11Rconnection;
13430 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013431 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013432 pBuf += sizeof(tAniBool);
13433 }
13434 else
13435 {
13436 // is11Rconnection;
13437 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013438 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013439 pBuf += sizeof(tAniBool);
13440 }
13441#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013442#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013443
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013444 // isESEFeatureIniEnabled
13445 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013446 {
13447 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013448 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013449 pBuf += sizeof(tAniBool);
13450 }
13451 else
13452 {
13453 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013454 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013455 pBuf += sizeof(tAniBool);
13456 }
13457
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013458 /* A profile can not be both ESE and 11R. But an 802.11R AP
13459 * may be advertising support for ESE as well. So if we are
13460 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013461 * If we are associating explictly 11R only then we will get
13462 * 11R.
13463 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013464 if ((csrIsProfileESE(pProfile) ||
13465 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013466 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13467 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13468 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13469 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13470#ifdef WLAN_FEATURE_11W
13471 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013472 || (pProfile->negotiatedAuthType ==
13473 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013474#endif
13475 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013476 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013477 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013478 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013479 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013481 pBuf += sizeof(tAniBool);
13482 }
13483 else
13484 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013485 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013486 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013487 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013488 pBuf += sizeof(tAniBool);
13489 }
13490
13491 if (eWNI_SME_JOIN_REQ == messageType)
13492 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013493 tESETspecInfo eseTspec;
13494 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013495 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013496 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13497 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13498 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013499 }
13500 else if (eWNI_SME_REASSOC_REQ == messageType)
13501 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013502 if ((csrIsProfileESE(pProfile) ||
13503 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013504 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13505 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13506 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13507 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13508#ifdef WLAN_FEATURE_11W
13509 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013510 || (pProfile->negotiatedAuthType ==
13511 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013512#endif
13513 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013514 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013516 tESETspecInfo eseTspec;
13517 // ESE Tspec information
13518 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13519 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13520 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013523 if (eseTspec.numTspecs) {
13524 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13525 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013527 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013529 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013531 tESETspecInfo eseTspec;
13532 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013534 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13535 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13536 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 }
13538 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013539#endif // FEATURE_WLAN_ESE
13540#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013542 if (pMac->roam.configParam.isFastTransitionEnabled
13543#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013544 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013545#endif
13546 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013548 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013549 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013550 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 }
13552 else
13553 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013554 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013555 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013556 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 }
13558#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013559#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013560 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013561 {
13562 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013563 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013564 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013565 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013566 }
13567 else
13568 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013569 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013570 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013571 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013572 }
13573#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013574
13575 // txLdpcIniFeatureEnabled
13576 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13577 pBuf++;
13578
Kiran4a17ebe2013-01-31 10:43:43 -080013579 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13580 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13581 {
13582 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13583 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13584 csrApplyPower2Current(pMac);
13585 }
13586
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013587#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013588 // txBFIniFeatureEnabled
13589 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13590 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013591
13592 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053013593 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013594 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053013595 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13596 if (pIes->VHTCaps.numSoundingDim)
13597 txBFCsnValue = CSR_ROAM_MIN
13598 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013599 }
13600 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013601 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013602
13603 /* Only enable MuBf if no other MuBF session exist
13604 * and FW and HOST is MuBF capable.
13605 */
13606 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13607 {
13608 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13609 pBuf++;
13610 }
13611 else
13612 {
13613 *pBuf = 0;
13614 pBuf++;
13615 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013616#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013617 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13618 pBuf++;
13619
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013620 // WME
13621 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13622 {
13623 //WME enabled
13624 dwTmp = pal_cpu_to_be32(TRUE);
13625 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13626 pBuf += sizeof(tAniBool);
13627 }
13628 else
13629 {
13630 dwTmp = pal_cpu_to_be32(FALSE);
13631 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13632 pBuf += sizeof(tAniBool);
13633 }
13634
13635 // QOS
13636 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13637 {
13638 //QOS enabled
13639 dwTmp = pal_cpu_to_be32(TRUE);
13640 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13641 pBuf += sizeof(tAniBool);
13642 }
13643 else
13644 {
13645 dwTmp = pal_cpu_to_be32(FALSE);
13646 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13647 pBuf += sizeof(tAniBool);
13648 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013649 //BssDesc
13650 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13651 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013652
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013653 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013654 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13655 pMsg = NULL;
13656
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013657 if(!HAL_STATUS_SUCCESS(status))
13658 {
13659 break;
13660 }
13661 else
13662 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013663#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013664 if (eWNI_SME_JOIN_REQ == messageType)
13665 {
13666 //Tush-QoS: notify QoS module that join happening
13667 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13668 }
13669 else if (eWNI_SME_REASSOC_REQ == messageType)
13670 {
13671 //Tush-QoS: notify QoS module that reassoc happening
13672 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013674#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013675 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013677
13678 if (pMsg != NULL)
13679 {
13680 vos_mem_free( pMsg );
13681 }
13682
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013684}
13685
Jeff Johnson295189b2012-06-20 16:38:30 -070013686//
13687eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13688{
13689 eHalStatus status = eHAL_STATUS_SUCCESS;
13690 tSirSmeDisassocReq *pMsg;
13691 tANI_U8 *pBuf;
13692 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13694 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13695 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013697 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13698 if (NULL == pMsg)
13699 status = eHAL_STATUS_FAILURE;
13700 else
13701 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013703 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13705 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 pBuf = &pMsg->sessionId;
13707 // sessionId
13708 *pBuf++ = (tANI_U8)sessionId;
13709 // transactionId
13710 *pBuf = 0;
13711 *( pBuf + 1 ) = 0;
13712 pBuf += sizeof(tANI_U16);
13713
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013714 if ( (pSession->pCurRoamProfile != NULL) &&
13715 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13716 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 {
13718 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13720 sizeof( tSirMacAddr ));
13721 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013724 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13725 //perMacAddr is passed as bssId for softAP
13726 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 pBuf = pBuf + sizeof ( tSirMacAddr );
13728 }
13729 else
13730 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013732 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13733 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013735 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13736 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 if(!HAL_STATUS_SUCCESS(status))
13740 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013741 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 break;
13743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 // reasonCode
13745 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013746 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13747 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 if(!HAL_STATUS_SUCCESS(status))
13749 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013750 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 break;
13752 }
13753 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13755 Here we should not send the disassoc over the air to the AP */
13756 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13757#ifdef WLAN_FEATURE_VOWIFI_11R
13758 && csrRoamIs11rAssoc(pMac)
13759#endif
13760 )
13761 {
13762 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13763 }
13764 pBuf += sizeof(tANI_U8);
13765 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 return( status );
13768}
Jeff Johnson295189b2012-06-20 16:38:30 -070013769eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13770{
13771 eHalStatus status = eHAL_STATUS_SUCCESS;
13772 tSirSmeTkipCntrMeasReq *pMsg;
13773 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 do
13775 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013776 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13777 if ( NULL == pMsg )
13778 status = eHAL_STATUS_FAILURE;
13779 else
13780 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013782 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13784 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 pBuf = &pMsg->sessionId;
13786 // sessionId
13787 *pBuf++ = (tANI_U8)sessionId;
13788 // transactionId
13789 *pBuf = 0;
13790 *( pBuf + 1 ) = 0;
13791 pBuf += sizeof(tANI_U16);
13792 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13794 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 pBuf = pBuf + sizeof ( tSirMacAddr );
13796 // bEnable
13797 *pBuf = (tANI_BOOLEAN)bEnable;
13798 if(!HAL_STATUS_SUCCESS(status))
13799 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013800 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 break;
13802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 return( status );
13806}
Jeff Johnson295189b2012-06-20 16:38:30 -070013807eHalStatus
13808csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13809 VOS_MODULE_ID modId, tSirMacAddr bssId,
13810 void *pUsrContext, void *pfnSapEventCallback,
13811 tANI_U8 *pAssocStasBuf )
13812{
13813 eHalStatus status = eHAL_STATUS_SUCCESS;
13814 tSirSmeGetAssocSTAsReq *pMsg;
13815 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13816 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 do
13818 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013819 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13820 if ( NULL == pMsg )
13821 status = eHAL_STATUS_FAILURE;
13822 else
13823 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013825 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 pBuf = (tANI_U8 *)&pMsg->bssId;
13828 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013830 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 // modId
13833 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013834 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013837 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13838 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013840 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13841 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013843 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13844 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 status = palSendMBMessage( pMac->hHdd, pMsg );
13847 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 return( status );
13849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013850eHalStatus
13851csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13852 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13853 {
13854 eHalStatus status = eHAL_STATUS_SUCCESS;
13855 tSirSmeGetWPSPBCSessionsReq *pMsg;
13856 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013857
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 do
13859 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13861 if ( NULL == pMsg )
13862 status = eHAL_STATUS_FAILURE;
13863 else
13864 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013866 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013869 VOS_ASSERT(pBuf);
13870
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013873 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13874 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013876 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13877 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013879 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013882 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 return( status );
13888}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013889
13890eHalStatus
13891csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13892{
13893 tpSirChangeBIParams pMsg;
13894 tANI_U16 len = 0;
13895 eHalStatus status = eHAL_STATUS_SUCCESS;
13896 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13897
13898 if(!pSession)
13899 {
13900 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13901 return eHAL_STATUS_FAILURE;
13902 }
13903
13904 //NO need to update the Beacon Params if update beacon parameter flag is not set
13905 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13906 return eHAL_STATUS_SUCCESS;
13907
13908 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13909
13910 /* Create the message and send to lim */
13911 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013912 pMsg = vos_mem_malloc(len);
13913 if ( NULL == pMsg )
13914 status = eHAL_STATUS_FAILURE;
13915 else
13916 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013917 if(HAL_STATUS_SUCCESS(status))
13918 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013919 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013920 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13921 pMsg->length = len;
13922
13923 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013924 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13925 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013926 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13927 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013928 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013929 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013930 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13931 status = palSendMBMessage(pMac->hHdd, pMsg);
13932 }
13933 return status;
13934}
13935
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053013936#ifdef WLAN_FEATURE_AP_HT40_24G
13937eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
13938{
13939 tpSirSetHT2040Mode pMsg;
13940 tANI_U16 len = 0;
13941 eHalStatus status = eHAL_STATUS_SUCCESS;
13942 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13943
13944 if(!pSession)
13945 {
13946 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13947 return eHAL_STATUS_FAILURE;
13948 }
13949
13950 /* Create the message and send to lim */
13951 len = sizeof(tSirSetHT2040Mode);
13952 pMsg = vos_mem_malloc(len);
13953
13954 if ( NULL == pMsg )
13955 {
13956 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
13957 status = eHAL_STATUS_FAILURE;
13958 }
13959 else
13960 status = eHAL_STATUS_SUCCESS;
13961
13962 if(HAL_STATUS_SUCCESS(status))
13963 {
13964 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
13965 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
13966 pMsg->length = len;
13967
13968 // bssId
13969 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13970 sizeof(tSirMacAddr));
13971
13972 smsLog( pMac, LOGW, FL("CSR Attempting to set "
13973 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
13974 MAC_ADDR_ARRAY(pMsg->bssId));
13975
13976 pMsg->sessionId = sessionId;
13977 pMsg->cbMode = cbMode;
13978
13979 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
13980 sessionId, cbMode);
13981
13982 status = palSendMBMessage(pMac->hHdd, pMsg);
13983 }
13984 return status;
13985}
13986#endif
13987
Jeff Johnson295189b2012-06-20 16:38:30 -070013988eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13989{
13990 eHalStatus status = eHAL_STATUS_SUCCESS;
13991 tSirSmeDeauthReq *pMsg;
13992 tANI_U8 *pBuf;
13993 tANI_U16 wTmp;
13994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13995 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13996 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013998 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13999 if ( NULL == pMsg )
14000 status = eHAL_STATUS_FAILURE;
14001 else
14002 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014004 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
14006 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
14007 //sessionId
14008 pBuf = &pMsg->sessionId;
14009 *pBuf++ = (tANI_U8)sessionId;
14010
14011 //tansactionId
14012 *pBuf = 0;
14013 *(pBuf + 1 ) = 0;
14014 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
14018 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014019 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
14020 sizeof( pMsg->peerMacAddr ) );
14021 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 pBuf = pBuf + sizeof(tSirMacAddr);
14023 }
14024 else
14025 {
14026 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014027 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
14028 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 }
14031 if(!HAL_STATUS_SUCCESS(status))
14032 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014033 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 break;
14035 }
14036 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014037 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
14038 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 pBuf = pBuf + sizeof(tSirMacAddr);
14040 if(!HAL_STATUS_SUCCESS(status))
14041 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014042 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 break;
14044 }
14045 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014046 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
14047 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014048 if(!HAL_STATUS_SUCCESS(status))
14049 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014050 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 break;
14052 }
14053 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 return( status );
14056}
14057
Jeff Johnson295189b2012-06-20 16:38:30 -070014058eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
14059{
14060 eHalStatus status = eHAL_STATUS_SUCCESS;
14061 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070014062 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014063 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
14064 if ( NULL == pMsg )
14065 status = eHAL_STATUS_FAILURE;
14066 else
14067 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014069 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
14071 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14072 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053014073 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
14074 sizeof(pMsg->peerMacAddr));
14075 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 if(!HAL_STATUS_SUCCESS(status))
14077 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014078 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 break;
14080 }
14081//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053014082 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
14083 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 if(!HAL_STATUS_SUCCESS(status))
14085 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014086 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 break;
14088 }
14089//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 return( status );
14093}
14094
Jeff Johnson295189b2012-06-20 16:38:30 -070014095eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
14096{
14097 eHalStatus status = eHAL_STATUS_SUCCESS;
14098 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014100 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
14101 if ( NULL == pMsg )
14102 status = eHAL_STATUS_FAILURE;
14103 else
14104 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014106 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
14108 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14109 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053014110 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
14111 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 if(!HAL_STATUS_SUCCESS(status))
14113 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014114 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 break;
14116 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014117 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
14118 sizeof(pMsg->peerMacAddr));
14119 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 if(!HAL_STATUS_SUCCESS(status))
14121 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014122 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 break;
14124 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 return( status );
14128}
Jeff Johnson295189b2012-06-20 16:38:30 -070014129eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
14130{
14131 eHalStatus status = eHAL_STATUS_SUCCESS;
14132 tSirSmeAssocCnf *pMsg;
14133 tANI_U8 *pBuf;
14134 tSirResultCodes statusCode;
14135 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053014136
14137 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
14138 "HalStatus : %d"),
14139 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014141 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
14142 if ( NULL == pMsg )
14143 status = eHAL_STATUS_FAILURE;
14144 else
14145 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014147 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
14149 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 pBuf = (tANI_U8 *)&pMsg->statusCode;
14151 if(HAL_STATUS_SUCCESS(Halstatus))
14152 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14153 else
14154 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014155 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 pBuf += sizeof(tSirResultCodes);
14157 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014158 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14159 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 pBuf += sizeof (tSirMacAddr);
14161 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014162 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14163 sizeof(tSirMacAddr));
14164 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 pBuf += sizeof (tSirMacAddr);
14166 // aid
14167 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053014168 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 pBuf += sizeof (tANI_U16);
14170 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014171 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14172 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 pBuf += sizeof (tSirMacAddr);
14174 // alternateChannelId
14175 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 status = palSendMBMessage( pMac->hHdd, pMsg );
14177 if(!HAL_STATUS_SUCCESS(status))
14178 {
14179 //pMsg is freed by palSendMBMessage
14180 break;
14181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014182 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 return( status );
14184}
Jeff Johnson295189b2012-06-20 16:38:30 -070014185eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
14186 tpSirSmeAssocInd pAssocInd,
14187 eHalStatus Halstatus,
14188 tANI_U8 sessionId)
14189{
14190 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 tSirSmeAssocIndToUpperLayerCnf *pMsg;
14192 tANI_U8 *pBuf;
14193 tSirResultCodes statusCode;
14194 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014196 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14197 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14198 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070014199
Jeff Johnson295189b2012-06-20 16:38:30 -070014200 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
14201 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14202
14203 pMsg->sessionId = sessionId;
14204
14205 pBuf = (tANI_U8 *)&pMsg->statusCode;
14206 if(HAL_STATUS_SUCCESS(Halstatus))
14207 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14208 else
14209 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014210 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 pBuf += sizeof(tSirResultCodes);
14212 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014213 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 pBuf += sizeof (tSirMacAddr);
14215 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014216 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14217 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 pBuf += sizeof (tSirMacAddr);
14219 // StaId
14220 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014221 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 pBuf += sizeof (tANI_U16);
14223 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014224 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 pBuf += sizeof (tSirMacAddr);
14226 // alternateChannelId
14227 *pBuf = 11;
14228 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014229 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 //Wmm
14231 *pBuf = pAssocInd->wmmEnabledSta;
14232 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014234 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014237 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 //reassocReq
14240 *pBuf = pAssocInd->reassocReq;
14241 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053014242#ifdef WLAN_FEATURE_AP_HT40_24G
14243 // 40 MHz Intolerant
14244 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
14245 pBuf += sizeof (tANI_U8);
14246#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14248 msgQ.bodyptr = pMsg;
14249 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053014252 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070014253}
Jeff Johnson295189b2012-06-20 16:38:30 -070014254
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014255eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
14257 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
14258 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
14259 tANI_U8 *pKeyRsc )
14260{
14261 tSirSmeSetContextReq *pMsg;
14262 tANI_U16 msgLen;
14263 eHalStatus status = eHAL_STATUS_FAILURE;
14264 tAniEdType tmpEdType;
14265 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053014266 tANI_U8 *pBuf = NULL;
14267 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053014269 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14270 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014271 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
14274 // key set. Since we only support upto one key, we always allocate memory for 1 key
14275 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
14276 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
14277 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
14278 ( sizeof( pMsg->keyMaterial.key ) );
14279
Kiet Lam64c1b492013-07-12 13:56:44 +053014280 pMsg = vos_mem_malloc(msgLen);
14281 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14282 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
14284 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 //sessionId
14286 pBuf = &pMsg->sessionId;
14287 *pBuf = (tANI_U8)sessionId;
14288 pBuf++;
14289 // transactionId
14290 *pBuf = 0;
14291 *(pBuf + 1) = 0;
14292 pBuf += sizeof(tANI_U16);
14293 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014294 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014295
14296 pBuf += sizeof(tSirMacAddr);
14297
14298 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014299 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14300 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014301
14302 pBuf += sizeof(tSirMacAddr);
14303
14304 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014305 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14306 // in the tSirKeyMaterial keyMaterial; field).
14307 //
14308 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14309 // shorter than this max size. Is LIM interpreting this ok ?
14310 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 -070014311 // set pMsg->keyMaterial.edType
14312 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014313 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 // set the pMsg->keyMaterial.numKeys field
14316 *p = numKeys;
14317 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 // set pSirKey->keyId = keyId;
14319 *p = keyId;
14320 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014321 // set pSirKey->unicast = (tANI_U8)fUnicast;
14322 *p = (tANI_U8)fUnicast;
14323 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014324 // set pSirKey->keyDirection = aniKeyDirection;
14325 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014326 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014327 p += sizeof(tAniKeyDirection);
14328 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014329 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 // set pSirKey->paeRole
14332 *p = paeRole; // 0 is Supplicant
14333 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 // set pSirKey->keyLength = keyLength;
14335 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 if ( keyLength && pKey )
14337 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014338 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 if(keyLength == 16)
14340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014341 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 -070014342 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14343 pKey[5], pKey[6], pKey[7], pKey[8],
14344 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14345 }
14346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014348 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 return( status );
14350}
14351
Jeff Johnson295189b2012-06-20 16:38:30 -070014352eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14353 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14354{
14355 eHalStatus status;
14356 tSirSmeStartBssReq *pMsg;
14357 tANI_U8 *pBuf = NULL;
14358 tANI_U8 *wTmpBuf = NULL;
14359 tANI_U16 msgLen, wTmp;
14360 tANI_U32 dwTmp;
14361 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014362 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014365
14366 if(!pSession)
14367 {
14368 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14369 return eHAL_STATUS_FAILURE;
14370 }
14371
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 do {
14373 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14374 pSession->joinFailStatusCode.reasonCode = 0;
14375 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014376 pMsg = vos_mem_malloc(msgLen);
14377 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14378 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014380 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014381 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 //sessionId
14383 *pBuf = (tANI_U8)sessionId;
14384 pBuf++;
14385 // transactionId
14386 *pBuf = 0;
14387 *(pBuf + 1) = 0;
14388 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014389 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014390 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014391 pBuf += sizeof(tSirMacAddr);
14392 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014393 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 pBuf += sizeof(tSirMacAddr);
14395 // beaconInterval
14396 if( pBssDesc && pBssDesc->beaconInterval )
14397 {
14398 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 else if(pParam->beaconInterval)
14401 {
14402 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 else
14405 {
14406 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14407 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014408 if(csrIsconcurrentsessionValid (pMac, sessionId,
14409 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014410 == eHAL_STATUS_SUCCESS )
14411 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014412 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014413 pParam->bssPersona);
14414 //Update the beacon Interval
14415 pParam->beaconInterval = wTmp;
14416 }
14417 else
14418 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014419 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014420 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014421 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014422 return status;
14423 }
14424
Kiet Lam64c1b492013-07-12 13:56:44 +053014425 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 pBuf += sizeof(tANI_U16);
14427 // dot11mode
14428 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14429 pBuf += 1;
14430 // bssType
14431 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014432 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014433 pBuf += sizeof(tSirBssType);
14434 // ssId
14435 if( pParam->ssId.length )
14436 {
14437 // ssId len
14438 *pBuf = pParam->ssId.length;
14439 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014440 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 pBuf += pParam->ssId.length;
14442 }
14443 else
14444 {
14445 *pBuf = 0;
14446 pBuf++;
14447 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 // set the channel Id
14449 *pBuf = pParam->operationChn;
14450 pBuf++;
14451 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014452 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014453 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014454 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014455
Jeff Johnson295189b2012-06-20 16:38:30 -070014456 // Set privacy
14457 *pBuf = pParam->privacy;
14458 pBuf++;
14459
14460 //Set Uapsd
14461 *pBuf = pParam->ApUapsdEnable;
14462 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014463 //Set SSID hidden
14464 *pBuf = pParam->ssidHidden;
14465 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14467 pBuf++;
14468
14469 //Ht protection Enable/Disable
14470 *pBuf = (tANI_U8)pParam->protEnabled;
14471 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014472 //Enable Beacons to Receive for OBSS protection Enable/Disable
14473 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14474 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 //set cfg related to protection
14476 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014477 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014479 // Set Auth type
14480 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014481 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 // Set DTIM
14484 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014485 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 // Set wps_state
14488 *pBuf = pParam->wps_state;
14489 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014490 // set isCoalesingInIBSSAllowed
14491 *pBuf = pMac->isCoalesingInIBSSAllowed;
14492 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 //Persona
14494 *pBuf = (tANI_U8)pParam->bssPersona;
14495 pBuf++;
14496
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014497 //txLdpcIniFeatureEnabled
14498 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14499 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014500
Chet Lanctot8cecea22014-02-11 19:09:36 -080014501#ifdef WLAN_FEATURE_11W
14502 // Set MFP capable/required
14503 *pBuf = (tANI_U8)pParam->mfpCapable;
14504 pBuf++;
14505 *pBuf = (tANI_U8)pParam->mfpRequired;
14506 pBuf++;
14507#endif
14508
krunal soni4f087d22013-07-29 16:32:26 -070014509 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14511 {
14512 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014513 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 break;
14515 }
14516 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014517 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 pBuf += sizeof(tANI_U16);
14519 if( wTmp )
14520 {
14521 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014522 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 pBuf += wTmp;
14524 }
14525 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014526 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14529 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014530 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14531 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 pBuf += pParam->operationalRateSet.numRates ;
14533 *pBuf++ = pParam->extendedRateSet.numRates;
14534 if(0 != pParam->extendedRateSet.numRates)
14535 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014536 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14537 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 pBuf += pParam->extendedRateSet.numRates;
14539 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014540#ifdef WLAN_FEATURE_AP_HT40_24G
14541 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14542#endif
krunal sonie9002db2013-11-25 14:24:17 -080014543
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14545 pMsg->length = pal_cpu_to_be16(msgLen);
14546
14547 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 return( status );
14550}
14551
Jeff Johnson295189b2012-06-20 16:38:30 -070014552eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14553{
14554 eHalStatus status = eHAL_STATUS_FAILURE;
14555 tSirSmeStopBssReq *pMsg;
14556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14557 tANI_U8 *pBuf;
14558 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014559
14560 if(!pSession)
14561 {
14562 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14563 return eHAL_STATUS_FAILURE;
14564 }
14565
Abhishek Singhe2bb7842015-03-12 17:34:03 +053014566 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14567 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14568 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
14569 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14570 pBuf = &pMsg->sessionId;
14571 //sessionId
14572 *pBuf = (tANI_U8)sessionId;
14573 pBuf++;
14574 // transactionId
14575 *pBuf = 0;
14576 pBuf += sizeof(tANI_U16);
14577 //reason code
14578 *pBuf = 0;
14579 pBuf += sizeof(tSirResultCodes);
14580 // bssid
14581 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14582 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14583 {
14584 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14585 sizeof(tSirMacAddr));
14586 }
14587 else
14588 {
14589 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14590 sizeof(tSirMacAddr));
14591 }
14592 pBuf += sizeof(tSirMacAddr);
14593 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14594 pMsg->length = pal_cpu_to_be16(msgLen);
14595 status = palSendMBMessage( pMac->hHdd, pMsg );
14596
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 return( status );
14598}
14599
Jeff Johnson295189b2012-06-20 16:38:30 -070014600eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14601 tCsrRoamModifyProfileFields *pModProfileFields,
14602 tANI_U32 *pRoamId, v_BOOL_t fForce)
14603{
Jeff Johnson295189b2012-06-20 16:38:30 -070014604 eHalStatus status = eHAL_STATUS_FAILURE;
14605 tANI_U32 roamId = 0;
14606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014607 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014608 (fForce || (!vos_mem_compare( &pModProfileFields,
14609 &pSession->connectedProfile.modifyProfileFields,
14610 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014611 {
14612 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14613 if(pRoamId)
14614 {
14615 *pRoamId = roamId;
14616 }
14617
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14619 eCsrSmeIssuedReassocToSameAP, roamId,
14620 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 return status;
14623}
Jeff Johnson295189b2012-06-20 16:38:30 -070014624static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14625{
14626 eHalStatus status = eHAL_STATUS_SUCCESS;
14627 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014628 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014629 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14630 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14631 return (status);
14632}
Jeff Johnson295189b2012-06-20 16:38:30 -070014633eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14634{
14635 eHalStatus status = eHAL_STATUS_SUCCESS;
14636 tListElem *pEntry = NULL;
14637 tSmeCmd *pCommand = NULL;
14638 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 do
14640 {
14641 if(pMsg == NULL)
14642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014643 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 status = eHAL_STATUS_FAILURE;
14645 break;
14646 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014647 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14648 if(pEntry)
14649 {
14650 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14651 if(eSmeCommandAddStaSession == pCommand->command)
14652 {
14653 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014654 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014655 if (pRsp->status == eSIR_FAILURE) {
14656 VOS_ASSERT( 0 );
14657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014659 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014660 //Remove this command out of the active list
14661 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14662 {
14663 //Now put this command back on the avilable command list
14664 csrReleaseCommand(pMac, pCommand);
14665 }
14666 smeProcessPendingQueue( pMac );
14667 }
14668 else
14669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014670 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 -070014671 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014672 status = eHAL_STATUS_FAILURE;
14673 break;
14674 }
14675 }
14676 else
14677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014678 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 -070014679 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 status = eHAL_STATUS_FAILURE;
14681 break;
14682 }
14683 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014685}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014686eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14687 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014688{
14689 tSirSmeAddStaSelfReq *pMsg;
14690 tANI_U16 msgLen;
14691 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014692 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014693 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014694 pMsg = vos_mem_malloc(msgLen);
14695 if ( NULL == pMsg ) break;
14696 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014697 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14698 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014700 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014701 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14702
14703 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14704
Arif Hussain24bafea2013-11-15 15:10:03 -080014705 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14706 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 return( status );
14710}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014711eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14712 tANI_U32 sessionId,
14713 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014714{
14715 eHalStatus status = eHAL_STATUS_SUCCESS;
14716 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 pCommand = csrGetCommandBuffer(pMac);
14718 if(NULL == pCommand)
14719 {
14720 status = eHAL_STATUS_RESOURCES;
14721 }
14722 else
14723 {
14724 pCommand->command = eSmeCommandAddStaSession;
14725 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014726 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14727 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014728 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014729 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14730 if( !HAL_STATUS_SUCCESS( status ) )
14731 {
14732 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014733 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 }
14735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 return (status);
14737}
Jeff Johnson295189b2012-06-20 16:38:30 -070014738eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14739{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014740 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014741}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014742eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14743 csrRoamCompleteCallback callback,
14744 void *pContext, tANI_U8 *pSelfMacAddr,
14745 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014746{
14747 eHalStatus status = eHAL_STATUS_SUCCESS;
14748 tANI_U32 i;
14749 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 *pbSessionId = CSR_SESSION_ID_INVALID;
14751 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14752 {
14753 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14754 {
14755 pSession = CSR_GET_SESSION( pMac, i );
14756 status = eHAL_STATUS_SUCCESS;
14757 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14758 pSession->sessionId = (tANI_U8)i;
14759 pSession->callback = callback;
14760 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014761 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014763 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14764 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014766 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014768 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 break;
14770 }
14771#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014772 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14773 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014775 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014776 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014777 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 break;
14779 }
14780#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014781 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 break;
14783 }
14784 }
14785 if( CSR_ROAM_SESSION_MAX == i )
14786 {
14787 //No session is available
14788 status = eHAL_STATUS_RESOURCES;
14789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 return ( status );
14791}
Jeff Johnson295189b2012-06-20 16:38:30 -070014792eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14793{
14794 eHalStatus status = eHAL_STATUS_SUCCESS;
14795 tListElem *pEntry = NULL;
14796 tSmeCmd *pCommand = NULL;
14797 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 do
14799 {
14800 if(pMsg == NULL)
14801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014802 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 status = eHAL_STATUS_FAILURE;
14804 break;
14805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14807 if(pEntry)
14808 {
14809 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14810 if(eSmeCommandDelStaSession == pCommand->command)
14811 {
14812 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014814 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 //This session is done.
14816 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014817 if(pCommand->u.delStaSessionCmd.callback)
14818 {
14819
14820 status = sme_ReleaseGlobalLock( &pMac->sme );
14821 if ( HAL_STATUS_SUCCESS( status ) )
14822 {
14823 pCommand->u.delStaSessionCmd.callback(
14824 pCommand->u.delStaSessionCmd.pContext);
14825 status = sme_AcquireGlobalLock( &pMac->sme );
14826 if (! HAL_STATUS_SUCCESS( status ) )
14827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 return status;
14830 }
14831 }
14832 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014833 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 }
14835 }
14836
14837 //Remove this command out of the active list
14838 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14839 {
14840 //Now put this command back on the avilable command list
14841 csrReleaseCommand(pMac, pCommand);
14842 }
14843 smeProcessPendingQueue( pMac );
14844 }
14845 else
14846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014847 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 -070014848 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 status = eHAL_STATUS_FAILURE;
14850 break;
14851 }
14852 }
14853 else
14854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014855 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 -070014856 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 status = eHAL_STATUS_FAILURE;
14858 break;
14859 }
14860 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014862}
Jeff Johnson295189b2012-06-20 16:38:30 -070014863eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14864{
14865 tSirSmeDelStaSelfReq *pMsg;
14866 tANI_U16 msgLen;
14867 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14870 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014871 pMsg = vos_mem_malloc(msgLen);
14872 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14873 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14875 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014876 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014877 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14878 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014879 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 return( status );
14882}
Jeff Johnson295189b2012-06-20 16:38:30 -070014883eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053014884 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 tSirMacAddr sessionMacAddr,
14886 csrRoamSessionCloseCallback callback,
14887 void *pContext)
14888{
14889 eHalStatus status = eHAL_STATUS_SUCCESS;
14890 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 pCommand = csrGetCommandBuffer(pMac);
14892 if(NULL == pCommand)
14893 {
14894 status = eHAL_STATUS_RESOURCES;
14895 }
14896 else
14897 {
14898 pCommand->command = eSmeCommandDelStaSession;
14899 pCommand->sessionId = (tANI_U8)sessionId;
14900 pCommand->u.delStaSessionCmd.callback = callback;
14901 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014902 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14903 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053014904 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 if( !HAL_STATUS_SUCCESS( status ) )
14906 {
14907 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014908 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 }
14910 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014911 return (status);
14912}
Jeff Johnson295189b2012-06-20 16:38:30 -070014913eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14914{
14915 return csrSendMBDelSelfStaReqMsg( pMac,
14916 pCommand->u.delStaSessionCmd.selfMacAddr );
14917}
Jeff Johnson295189b2012-06-20 16:38:30 -070014918static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14919{
14920 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14921 tListElem *pEntry, *pNext;
14922 tSmeCmd *pCommand;
14923 tDblLinkList localList;
14924
14925 vos_mem_zero(&localList, sizeof(tDblLinkList));
14926 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14927 {
14928 smsLog(pMac, LOGE, FL(" failed to open list"));
14929 return;
14930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 csrLLLock(pList);
14932 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14933 while(pEntry != NULL)
14934 {
14935 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14936 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14937 if(pCommand->sessionId == sessionId)
14938 {
14939 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14940 {
14941 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14942 }
14943 }
14944 pEntry = pNext;
14945 }
14946 csrLLUnlock(pList);
14947
14948 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14949 {
14950 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14951 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14952 }
14953 csrLLClose(&localList);
14954}
14955
Jeff Johnson295189b2012-06-20 16:38:30 -070014956void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14957{
14958 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14959 {
14960 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 csrRoamStop(pMac, sessionId);
14962 csrFreeConnectBssDesc(pMac, sessionId);
14963 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14964 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014965 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014966#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014967 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014968#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014969 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14970 if (pMac->fScanOffload)
14971 {
14972 purgeSmeSessionCmdList(pMac, sessionId,
14973 &pMac->sme.smeScanCmdPendingList);
14974 }
14975
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 purgeCsrSessionCmdList(pMac, sessionId);
14977 csrInitSession(pMac, sessionId);
14978 }
14979}
14980
mukul sharmabab477d2015-06-11 17:14:55 +053014981void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14982{
14983 purgeSmeSessionCmdList(pMac, sessionId,
14984 &pMac->sme.smeCmdPendingList);
14985 if (pMac->fScanOffload)
14986 {
14987 purgeSmeSessionCmdList(pMac, sessionId,
14988 &pMac->sme.smeScanCmdPendingList);
14989 }
14990 purgeCsrSessionCmdList(pMac, sessionId);
14991}
14992
Jeff Johnson295189b2012-06-20 16:38:30 -070014993eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053014994 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 csrRoamSessionCloseCallback callback,
14996 void *pContext )
14997{
14998 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
15000 {
15001 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15002 if(fSync)
15003 {
15004 csrCleanupSession(pMac, sessionId);
15005 }
15006 else
mukul sharmabab477d2015-06-11 17:14:55 +053015007 {
15008 if(bPurgeList)
15009 csrPurgeSmeCmdList(pMac, sessionId);
15010 /* If bPurgeList is FALSE, it means HDD already free all the
15011 * cmd and later queue few essential cmd. Now sme should process
15012 * the cmd in pending queue order only.Hence we should
15013 * avoid DEL_SELF_STA as high priority cmd.
15014 */
15015 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 pSession->selfMacAddr, callback, pContext);
15017 }
15018 }
15019 else
15020 {
15021 status = eHAL_STATUS_INVALID_PARAMETER;
15022 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 return ( status );
15024}
15025
Jeff Johnson295189b2012-06-20 16:38:30 -070015026static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
15027{
15028 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015029
15030 if(!pSession)
15031 {
15032 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15033 return;
15034 }
15035
Jeff Johnson295189b2012-06-20 16:38:30 -070015036 pSession->sessionActive = eANI_BOOLEAN_FALSE;
15037 pSession->sessionId = CSR_SESSION_ID_INVALID;
15038 pSession->callback = NULL;
15039 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015040 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
15041 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
15042 csrFreeRoamProfile( pMac, sessionId );
15043 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
15044 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
15045 csrFreeConnectBssDesc(pMac, sessionId);
15046 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053015047 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
15048 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015050 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 pSession->pWpaRsnReqIE = NULL;
15052 }
15053 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053015054 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015055 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015056 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 pSession->pWpaRsnRspIE = NULL;
15058 }
15059 pSession->nWpaRsnRspIeLength = 0;
15060#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053015061 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015063 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 pSession->pWapiReqIE = NULL;
15065 }
15066 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053015067 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015069 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 pSession->pWapiRspIE = NULL;
15071 }
15072 pSession->nWapiRspIeLength = 0;
15073#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053015074 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015076 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070015077 }
15078 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015079
Kiet Lam64c1b492013-07-12 13:56:44 +053015080 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015082 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015085 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015086}
15087
Jeff Johnson295189b2012-06-20 16:38:30 -070015088eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
15089{
15090 eHalStatus status = eHAL_STATUS_FAILURE;
15091 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15093 {
15094 if( CSR_IS_SESSION_VALID( pMac, i ) )
15095 {
15096 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
15097 {
15098 //Found it
15099 status = eHAL_STATUS_SUCCESS;
15100 *pSessionId = i;
15101 break;
15102 }
15103 }
15104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 return( status );
15106}
15107
Jeff Johnson295189b2012-06-20 16:38:30 -070015108//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
15109//session because for IBSS, the bssid changes.
15110static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
15111{
15112 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
15113 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15115 {
15116 if( CSR_IS_SESSION_VALID( pMac, i ) )
15117 {
15118 pSession = CSR_GET_SESSION( pMac, i );
15119 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
15120 {
15121 //Found it
15122 nRet = i;
15123 break;
15124 }
15125 }
15126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 return (nRet);
15128}
Jeff Johnson295189b2012-06-20 16:38:30 -070015129static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
15130{
Mukul Sharma20aa6582014-08-07 21:36:12 +053015131 VOS_STATUS status = VOS_STATUS_SUCCESS;
15132
15133 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070015134 profile info from pmac global structure */
15135
Arif Hussain24bafea2013-11-15 15:10:03 -080015136 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
15137 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015138 /* Check for user misconfig of RSSI trigger threshold */
15139 pMac->roam.configParam.vccRssiThreshold =
15140 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
15141 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
15142 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 /* Check for user misconfig of UL MAC Loss trigger threshold */
15144 pMac->roam.configParam.vccUlMacLossThreshold =
15145 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
15146 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015147#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15148 {
15149 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015150 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 /* Indicate the neighbor roal algorithm about the connect indication */
15152 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
15153 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015154
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015155 /* Making sure we are roaming force fully to 5GHz AP only once and
15156 * only when we connected to 2.4GH AP only during initial association.
15157 */
15158 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
15159 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
15160 SIR_BAND_2_4_GHZ)
15161 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053015162 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015163 status = vos_timer_start(
15164 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
15165 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015166 if ( status != VOS_STATUS_SUCCESS )
15167 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015168 smsLog(pMac, LOGE,
15169 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
15170 status);
15171 //Send RSO start because in case 5G roaming
15172 //host have not enabled at initial connection
15173 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015174 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015175 else
15176 {
15177 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
15178 __func__);
15179 }
15180 }
15181 /*
15182 * Making ini value to false here only so we just roam to
15183 * only once for whole driver load to unload tenure
15184 * This feature is only applicable for first connection only
15185 */
15186 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
15187 {
15188 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
15189 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053015190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 }
15192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015193}
15194
Jeff Johnson295189b2012-06-20 16:38:30 -070015195static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
15196{
15197 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015198
15199 if(!pSession)
15200 {
15201 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15202 return;
15203 }
15204
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 //Only to handle the case for Handover on infra link
15206 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15207 {
15208 return;
15209 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015210 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
15211 csrRoamDeregStatisticsReq(pMac);
15212 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15213#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15214 /* Indicate the neighbor roal algorithm about the disconnect indication */
15215 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
15216#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070015217
15218 //Remove this code once SLM_Sessionization is supported
15219 //BMPS_WORKAROUND_NOT_NEEDED
15220 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070015221 csrIsInfraApStarted( pMac ) &&
15222 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070015223 {
15224 pMac->roam.configParam.doBMPSWorkaround = 0;
15225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015226}
15227
Jeff Johnson295189b2012-06-20 16:38:30 -070015228void csrRoamTlStatsTimerHandler(void *pv)
15229{
15230 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
15231 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15233
Jeff Johnsone7245742012-09-05 17:12:55 -070015234 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
15235
Jeff Johnson295189b2012-06-20 16:38:30 -070015236#if 0
15237 // TODO Persession .???
15238 //req TL for stats
15239 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
15240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015241 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 }
15243 else
15244 {
15245 //save in SME
15246 csrRoamSaveStatsFromTl(pMac, tlStats);
15247 }
15248#endif
15249 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15250 {
15251 if(pMac->roam.tlStatsReqInfo.periodicity)
15252 {
15253 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015254 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15255 pMac->roam.tlStatsReqInfo.periodicity);
15256 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015258 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015259 return;
15260 }
15261 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15262 }
15263 }
15264}
Jeff Johnson295189b2012-06-20 16:38:30 -070015265void csrRoamPeStatsTimerHandler(void *pv)
15266{
15267 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
15268 eHalStatus status;
15269 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
15270 VOS_STATUS vosStatus;
15271 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 pPeStatsReqListEntry->timerRunning = FALSE;
15273 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
15274 {
15275 // If we entered here, meaning the timer could not be successfully
15276 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
15277
15278 /* Destroy the timer */
15279 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
15280 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015282 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 }
15284
15285 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015286 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015287 pPeStatsReqListEntry = NULL;
15288 }
15289 else
15290 {
15291 if(!pPeStatsReqListEntry->rspPending)
15292 {
15293 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
15294 pPeStatsReqListEntry->staId);
15295 if(!HAL_STATUS_SUCCESS(status))
15296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015297 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 }
15299 else
15300 {
15301 pPeStatsReqListEntry->rspPending = TRUE;
15302 }
15303 }
15304
15305 //send down a req
15306 if(pPeStatsReqListEntry->periodicity &&
15307 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15308 {
15309 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15310 if(ePMC_FULL_POWER == powerState)
15311 {
15312 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15313 {
15314 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15315 }
15316 }
15317 else
15318 {
15319 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15320 {
15321 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15322 }
15323 }
15324 //start timer
15325 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15326 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015328 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015329 return;
15330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 pPeStatsReqListEntry->timerRunning = TRUE;
15332
15333 }
15334
15335 }
15336}
Jeff Johnson295189b2012-06-20 16:38:30 -070015337void csrRoamStatsClientTimerHandler(void *pv)
15338{
15339 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15341 {
15342#if 0
15343 // TODO Stats fix for multisession
15344 //start the timer
15345 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15346
15347 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015349 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 }
15351#endif
15352 }
15353#if 0
15354 //send up the stats report
15355 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15356 pStaEntry->staId, pStaEntry->pContext);
15357#endif
15358}
15359
15360
15361
Jeff Johnson295189b2012-06-20 16:38:30 -070015362eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15363{
15364 tAniGetPEStatsReq *pMsg;
15365 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015366 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15367 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015369 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015370 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 }
15372 // need to initiate a stats request to PE
15373 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15374 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15375 pMsg->staId = staId;
15376 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 if(!HAL_STATUS_SUCCESS(status))
15379 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015380 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 return status;
15383}
Jeff Johnson295189b2012-06-20 16:38:30 -070015384void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15385{
15386 tAniGetPEStatsRsp *pSmeStatsRsp;
15387 eHalStatus status = eHAL_STATUS_FAILURE;
15388 tListElem *pEntry = NULL;
15389 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15390 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15391 tANI_U32 tempMask = 0;
15392 tANI_U8 counter = 0;
15393 tANI_U8 *pStats = NULL;
15394 tANI_U32 length = 0;
15395 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015396 v_S7_t rssi = 0, snr = 0;
15397 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015398 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15400 if(pSmeStatsRsp->rc)
15401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015402 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015403 goto post_update;
15404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 tempMask = pSmeStatsRsp->statsMask;
15406 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 /* subtract all statistics from this length, and after processing the entire
15408 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15409 * in this 'stats' message.
15410 */
15411 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015412 //new stats info from PE, fill up the stats strucutres in PMAC
15413 while(tempMask)
15414 {
15415 if(tempMask & 1)
15416 {
15417 switch(counter)
15418 {
15419 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015420 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015421 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15422 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 pStats += sizeof(tCsrSummaryStatsInfo);
15424 length -= sizeof(tCsrSummaryStatsInfo);
15425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015427 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015428 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15429 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15431 length -= sizeof(tCsrGlobalClassAStatsInfo);
15432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015434 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015435 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15436 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15438 length -= sizeof(tCsrGlobalClassBStatsInfo);
15439 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015441 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015442 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15443 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15445 length -= sizeof(tCsrGlobalClassCStatsInfo);
15446 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015448 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15450 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015451 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15452 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 }
15454 else
15455 {
15456 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015457 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015458 VOS_ASSERT( 0 );
15459 }
15460 if(!HAL_STATUS_SUCCESS(status))
15461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015462 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 }
15464 pStats += sizeof(tCsrPerStaStatsInfo);
15465 length -= sizeof(tCsrPerStaStatsInfo);
15466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015468 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015469 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 }
15471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 tempMask >>=1;
15473 counter++;
15474 }
15475 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15476 if (length != 0)
15477 {
15478 pRssi = (tANI_U32*)pStats;
15479 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015480 pStats += sizeof(tANI_U32);
15481 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015482 }
15483 else
15484 {
15485 /* If riva is not sending rssi, continue to use the hack */
15486 rssi = RSSI_HACK_BMPS;
15487 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015488
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015490
15491 if (length != 0)
15492 {
15493 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015494 pStats += sizeof(tANI_U32);
15495 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015496 }
15497 else
15498 {
15499 linkCapacity = 0;
15500 }
15501
15502 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015503
15504 if (length != 0)
15505 {
15506 pSnr = (tANI_U32*)pStats;
15507 snr = (v_S7_t)*pSnr;
15508 }
15509 else
15510 {
15511 snr = SNR_HACK_BMPS;
15512 }
15513
15514 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015515post_update:
15516 //make sure to update the pe stats req list
15517 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15518 if(pEntry)
15519 {
15520 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15521 pPeStaEntry->rspPending = FALSE;
15522
15523 }
15524 //check the one timer cases
15525 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15526 if(pEntry)
15527 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015528 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015529 if(pTempStaEntry->timerExpired)
15530 {
15531 //send up the stats report
15532 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15533 pTempStaEntry->staId, pTempStaEntry->pContext);
15534 //also remove from the client list
15535 csrRoamRemoveStatListEntry(pMac, pEntry);
15536 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015537 }
15538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015539}
Jeff Johnson295189b2012-06-20 16:38:30 -070015540tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15541{
15542 tListElem *pEntry = NULL;
15543 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 if(!pEntry)
15546 {
15547 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015548 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 return NULL;
15550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 while( pEntry )
15552 {
15553 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 if(pTempStaEntry->statsMask == statsMask)
15555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015556 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 break;
15558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015561 return pEntry;
15562}
15563
Jeff Johnson295189b2012-06-20 16:38:30 -070015564tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15565 tANI_BOOLEAN update)
15566{
15567 tListElem *pEntry;
15568 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 if(!pEntry)
15571 {
15572 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015573 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015574 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015575 return NULL;
15576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 while( pEntry )
15578 {
15579 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15581 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015583 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015584 if(update)
15585 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015586 pTempStaEntry->periodicity = pStaEntry->periodicity;
15587 pTempStaEntry->callback = pStaEntry->callback;
15588 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015589 }
15590 break;
15591 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015592 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15593 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015594 return pEntry;
15595}
Jeff Johnson295189b2012-06-20 16:38:30 -070015596tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15597{
15598 tListElem *pEntry;
15599 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015600 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 if(!pEntry)
15602 {
15603 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015604 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015605 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 return NULL;
15607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015608 while( pEntry )
15609 {
15610 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015613 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 break;
15615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015616 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 return pEntry;
15619}
Jeff Johnson295189b2012-06-20 16:38:30 -070015620eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15621 csrRoamLinkQualityIndCallback callback,
15622 void *pContext)
15623{
15624 pMac->roam.linkQualityIndInfo.callback = callback;
15625 pMac->roam.linkQualityIndInfo.context = pContext;
15626 if( NULL == callback )
15627 {
15628 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15629 }
15630 else
15631 {
15632 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 /* do we need to invoke the callback to notify client of initial value ?? */
15634 }
15635 return eHAL_STATUS_SUCCESS;
15636}
Jeff Johnson295189b2012-06-20 16:38:30 -070015637void csrRoamVccTrigger(tpAniSirGlobal pMac)
15638{
15639 eCsrRoamLinkQualityInd newVccLinkQuality;
15640 tANI_U32 ul_mac_loss = 0;
15641 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015642 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15643 /*-------------------------------------------------------------------------
15644 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015645 Check for a change in link quality and notify client if necessary
15646 -------------------------------------------------------------------------*/
15647 ul_mac_loss_trigger_threshold =
15648 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015649 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015650 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015652 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015654 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15656 }
15657 else
15658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015659 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015660 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015662 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15663 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015664 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015666 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015667 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015669 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 newVccLinkQuality );
15671
15672 /* we now invoke the callback once to notify client of initial value */
15673 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15674 pMac->roam.linkQualityIndInfo.context );
15675 //event: EVENT_WLAN_VCC
15676 }
15677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 pMac->roam.vccLinkQuality = newVccLinkQuality;
15679
Jeff Johnson295189b2012-06-20 16:38:30 -070015680}
Jeff Johnson295189b2012-06-20 16:38:30 -070015681VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15682 v_U8_t rssiNotification,
15683 void * context)
15684{
15685 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15686 eCsrRoamLinkQualityInd newVccLinkQuality;
15687 // TODO : Session info unavailable
15688 tANI_U32 sessionId = 0;
15689 VOS_STATUS status = VOS_STATUS_SUCCESS;
15690 /*-------------------------------------------------------------------------
15691 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015692 Check for a change in link quality and notify client if necessary
15693 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015694 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 pMac->roam.configParam.vccRssiThreshold);
15696 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015698 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 return VOS_STATUS_SUCCESS;
15700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015703 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015704 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15705 }
15706 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15707 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015708 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015709 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15710 }
15711 else
15712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015713 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015714 //Set to this so the code below won't do anything
15715 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015716 VOS_ASSERT(0);
15717 }
15718
Jeff Johnson295189b2012-06-20 16:38:30 -070015719 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015721 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015722 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015724 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015725 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015726 /* we now invoke the callback once to notify client of initial value */
15727 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15728 pMac->roam.linkQualityIndInfo.context );
15729 //event: EVENT_WLAN_VCC
15730 }
15731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015732 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015733 return status;
15734}
Jeff Johnson295189b2012-06-20 16:38:30 -070015735tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15736 tDblLinkList *pStaList,
15737 tCsrStatsClientReqInfo *pStaEntry)
15738{
15739 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015740 //if same entity requested for same set of stats with different periodicity &
15741 // callback update it
15742 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15743 {
15744
Kiet Lam64c1b492013-07-12 13:56:44 +053015745 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15746 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 {
15748 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015749 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 return NULL;
15751 }
15752
Jeff Johnson295189b2012-06-20 16:38:30 -070015753 pNewStaEntry->callback = pStaEntry->callback;
15754 pNewStaEntry->pContext = pStaEntry->pContext;
15755 pNewStaEntry->periodicity = pStaEntry->periodicity;
15756 pNewStaEntry->requesterId = pStaEntry->requesterId;
15757 pNewStaEntry->statsMask = pStaEntry->statsMask;
15758 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15759 pNewStaEntry->pMac = pStaEntry->pMac;
15760 pNewStaEntry->staId = pStaEntry->staId;
15761 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15762
15763 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15764 }
15765 return pNewStaEntry;
15766}
15767
Jeff Johnson295189b2012-06-20 16:38:30 -070015768tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15769 tDblLinkList *pStaList,
15770 tCsrPeStatsReqInfo *pStaEntry)
15771{
15772 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015773 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15774 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015775 {
15776 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015777 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015778 return NULL;
15779 }
15780
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15782 pNewStaEntry->numClient = pStaEntry->numClient;
15783 pNewStaEntry->periodicity = pStaEntry->periodicity;
15784 pNewStaEntry->statsMask = pStaEntry->statsMask;
15785 pNewStaEntry->pMac = pStaEntry->pMac;
15786 pNewStaEntry->staId = pStaEntry->staId;
15787 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15788 pNewStaEntry->rspPending = pStaEntry->rspPending;
15789
15790 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 return pNewStaEntry;
15792}
Jeff Johnson295189b2012-06-20 16:38:30 -070015793eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15794 tCsrRssiCallback callback,
15795 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15796{
15797 eHalStatus status = eHAL_STATUS_SUCCESS;
15798 vos_msg_t msg;
15799 tANI_U32 sessionId;
15800
15801 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015802 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015803 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15804 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015806 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015807 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015809 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15810
15811 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15812 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15813 pMsg->sessionId = sessionId;
15814 pMsg->staId = staId;
15815 pMsg->rssiCallback = callback;
15816 pMsg->pDevContext = pContext;
15817 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015818 msg.type = eWNI_SME_GET_RSSI_REQ;
15819 msg.bodyptr = pMsg;
15820 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015823 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015824 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015825 status = eHAL_STATUS_FAILURE;
15826 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015827 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015828 return status;
15829}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015830
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015831eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15832 tCsrSnrCallback callback,
15833 tANI_U8 staId, tCsrBssid bssId,
15834 void *pContext)
15835{
15836 eHalStatus status = eHAL_STATUS_SUCCESS;
15837 vos_msg_t msg;
15838 tANI_U32 sessionId;
15839
15840 tAniGetSnrReq *pMsg;
15841
15842 smsLog(pMac, LOG2, FL("called"));
15843
15844 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15845 if (NULL == pMsg )
15846 {
15847 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15848 return status;
15849 }
15850
15851 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15852
15853 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15854 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15855 pMsg->sessionId = sessionId;
15856 pMsg->staId = staId;
15857 pMsg->snrCallback = callback;
15858 pMsg->pDevContext = pContext;
15859 msg.type = eWNI_SME_GET_SNR_REQ;
15860 msg.bodyptr = pMsg;
15861 msg.reserved = 0;
15862
15863 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15864 {
15865 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15866 vos_mem_free((v_VOID_t *)pMsg);
15867 status = eHAL_STATUS_FAILURE;
15868 }
15869
15870 smsLog(pMac, LOG2, FL("returned"));
15871 return status;
15872}
15873
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015874#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015875eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15876 tCsrRssiCallback callback,
15877 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15878{
15879 eHalStatus status = eHAL_STATUS_SUCCESS;
15880 tAniGetRssiReq *pMsg;
15881
Kiet Lam64c1b492013-07-12 13:56:44 +053015882 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15883 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015884 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015885 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015886 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015887 }
15888 // need to initiate a stats request to PE
15889 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15890 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15891 pMsg->staId = staId;
15892 pMsg->rssiCallback = callback;
15893 pMsg->pDevContext = pContext;
15894 pMsg->pVosContext = pVosContext;
15895 status = palSendMBMessage(pMac->hHdd, pMsg );
15896 if(!HAL_STATUS_SUCCESS(status))
15897 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015898 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015899 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015900 status = eHAL_STATUS_FAILURE;
15901 }
15902 return status;
15903}
15904#endif
15905
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015906
15907
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015908#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015909eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15910 tCsrTsmStatsCallback callback,
15911 tANI_U8 staId,
15912 tCsrBssid bssId,
15913 void *pContext,
15914 void* pVosContext,
15915 tANI_U8 tid)
15916{
15917 eHalStatus status = eHAL_STATUS_SUCCESS;
15918 tAniGetTsmStatsReq *pMsg = NULL;
15919
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015920 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15921 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015922 {
15923 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015924 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015925 }
15926 // need to initiate a stats request to PE
15927 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15928 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15929 pMsg->staId = staId;
15930 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015931 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015932 pMsg->tsmStatsCallback = callback;
15933 pMsg->pDevContext = pContext;
15934 pMsg->pVosContext = pVosContext;
15935 status = palSendMBMessage(pMac->hHdd, pMsg );
15936 if(!HAL_STATUS_SUCCESS(status))
15937 {
15938 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15939 //pMsg is freed by palSendMBMessage
15940 status = eHAL_STATUS_FAILURE;
15941 }
15942 return status;
15943}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015944#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015945
15946
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015947/* ---------------------------------------------------------------------------
15948 \fn csrGetTLSTAState
15949 \helper function to get teh TL STA State whenever the function is called.
15950
15951 \param staId - The staID to be passed to the TL
15952 to get the relevant TL STA State
15953 \return the state as tANI_U16
15954 ---------------------------------------------------------------------------*/
15955tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15956{
15957 WLANTL_STAStateType tlSTAState;
15958 tlSTAState = WLANTL_STA_INIT;
15959
15960 //request TL for STA State
15961 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15962 {
15963 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15964 }
15965
15966 return tlSTAState;
15967}
15968
Jeff Johnson295189b2012-06-20 16:38:30 -070015969eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15970 tANI_U32 statsMask,
15971 tCsrStatsCallback callback,
15972 tANI_U32 periodicity, tANI_BOOLEAN cache,
15973 tANI_U8 staId, void *pContext)
15974{
15975 tCsrStatsClientReqInfo staEntry;
15976 tCsrStatsClientReqInfo *pStaEntry = NULL;
15977 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15978 tListElem *pEntry = NULL;
15979 tANI_BOOLEAN found = FALSE;
15980 eHalStatus status = eHAL_STATUS_SUCCESS;
15981 tANI_BOOLEAN insertInClientList = FALSE;
15982 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015983 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015984
15985 if( csrIsAllSessionDisconnected(pMac) )
15986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015987 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 return eHAL_STATUS_FAILURE;
15989 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015990
15991 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15992 {
15993 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15994 return eHAL_STATUS_FAILURE;
15995 }
15996
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 if((!statsMask) && (!callback))
15998 {
15999 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016000 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 return eHAL_STATUS_FAILURE;
16002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016003 //for the search list method for deregister
16004 staEntry.requesterId = requesterId;
16005 staEntry.statsMask = statsMask;
16006 //requester wants to deregister or just an error
16007 if((statsMask) && (!callback))
16008 {
16009 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
16010 if(!pEntry)
16011 {
16012 //msg
16013 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016014 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016015 return eHAL_STATUS_FAILURE;
16016 }
16017 else
16018 {
16019 //clean up & return
16020 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070016021 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016023 pStaEntry->pPeStaEntry->numClient--;
16024 //check if we need to delete the entry from peStatsReqList too
16025 if(!pStaEntry->pPeStaEntry->numClient)
16026 {
16027 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
16028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070016030
Jeff Johnson295189b2012-06-20 16:38:30 -070016031 //check if we need to stop the tl stats timer too
16032 pMac->roam.tlStatsReqInfo.numClient--;
16033 if(!pMac->roam.tlStatsReqInfo.numClient)
16034 {
16035 if(pMac->roam.tlStatsReqInfo.timerRunning)
16036 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016037 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16038 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016040 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 return eHAL_STATUS_FAILURE;
16042 }
16043 }
16044 pMac->roam.tlStatsReqInfo.periodicity = 0;
16045 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16046 }
16047 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070016048 // Destroy the vos timer...
16049 vosStatus = vos_timer_destroy( &pStaEntry->timer );
16050 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016052 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016053 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 csrRoamRemoveStatListEntry(pMac, pEntry);
16055 pStaEntry = NULL;
16056 return eHAL_STATUS_SUCCESS;
16057 }
16058 }
16059
16060 if(cache && !periodicity)
16061 {
16062 //return the cached stats
16063 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
16064 }
16065 else
16066 {
16067 //add the request in the client req list
16068 staEntry.callback = callback;
16069 staEntry.pContext = pContext;
16070 staEntry.periodicity = periodicity;
16071 staEntry.pPeStaEntry = NULL;
16072 staEntry.staId = staId;
16073 staEntry.pMac = pMac;
16074 staEntry.timerExpired = FALSE;
16075
16076
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 //if periodic report requested with non cached result from PE/TL
16078 if(periodicity)
16079 {
16080
16081 //if looking for stats from PE
16082 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16083 {
16084
16085 //check if same request made already & waiting for rsp
16086 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
16087 periodicity, &found, staId);
16088 if(!pPeStaEntry)
16089 {
16090 //bail out, maxed out on number of req for PE
16091 return eHAL_STATUS_FAILURE;
16092 }
16093 else
16094 {
16095 staEntry.pPeStaEntry = pPeStaEntry;
16096 }
16097
16098 }
16099 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
16100 if(statsMask & (1 << eCsrGlobalClassDStats))
16101 {
16102 if(cache && pMac->roam.tlStatsReqInfo.numClient)
16103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016104 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016105 }
16106 else
16107 {
16108
16109 //update periodicity
16110 if(pMac->roam.tlStatsReqInfo.periodicity)
16111 {
16112 pMac->roam.tlStatsReqInfo.periodicity =
16113 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
16114 }
16115 else
16116 {
16117 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
16118 }
16119 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
16120 {
16121 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
16122 }
16123
16124 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16125 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016126 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016127 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016128 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016129 //req TL for class D stats
16130 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
16131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016132 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016133 }
16134 else
16135 {
16136 //save in SME
16137 csrRoamSaveStatsFromTl(pMac, pTlStats);
16138 }
16139 vos_mem_free(pTlStats);
16140 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016141 }
16142 else
16143 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016144 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016145 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016146
Jeff Johnson295189b2012-06-20 16:38:30 -070016147 if(pMac->roam.tlStatsReqInfo.periodicity)
16148 {
16149 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016150 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16151 pMac->roam.tlStatsReqInfo.periodicity);
16152 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016154 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016155 return eHAL_STATUS_FAILURE;
16156 }
16157 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16158 }
16159 }
16160 }
16161 pMac->roam.tlStatsReqInfo.numClient++;
16162 }
16163
16164 insertInClientList = TRUE;
16165 }
16166 //if one time report requested with non cached result from PE/TL
16167 else if(!cache && !periodicity)
16168 {
16169 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16170 {
16171 //send down a req
16172 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16173 if(!HAL_STATUS_SUCCESS(status))
16174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016175 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016176 }
16177 //so that when the stats rsp comes back from PE we respond to upper layer
16178 //right away
16179 staEntry.timerExpired = TRUE;
16180 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016181 }
16182 if(statsMask & (1 << eCsrGlobalClassDStats))
16183 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016184 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016185 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016186 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016187 //req TL for class D stats
16188 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
16189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016190 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016191 }
16192 else
16193 {
16194 //save in SME
16195 csrRoamSaveStatsFromTl(pMac, pTlStats);
16196 }
16197 vos_mem_free(pTlStats);
16198 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 }
16200 else
16201 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016202 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016204
16205 }
16206 //if looking for stats from TL only
16207 if(!insertInClientList)
16208 {
16209 //return the stats
16210 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
16211 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016213 if(insertInClientList)
16214 {
16215 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
16216 if(!pStaEntry)
16217 {
16218 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016219 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016220 return eHAL_STATUS_FAILURE;
16221 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016222 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016223 //Init & start timer if needed
16224 if(periodicity)
16225 {
16226 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
16227 csrRoamStatsClientTimerHandler, pStaEntry );
16228 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016230 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 return eHAL_STATUS_FAILURE;
16232 }
16233 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
16234 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016236 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016237 return eHAL_STATUS_FAILURE;
16238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016241 }
16242 return eHAL_STATUS_SUCCESS;
16243}
16244
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016245#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16246
16247static tSirRetStatus
16248csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
16249 tANI_U8* pBD,
16250 tANI_U8 type,
16251 tANI_U8 subType,
16252 tSirMacAddr peerAddr,
16253 tSirMacAddr selfMacAddr)
16254{
16255 tSirRetStatus statusCode = eSIR_SUCCESS;
16256 tpSirMacMgmtHdr pMacHdr;
16257
16258 /* Prepare MAC management header */
16259 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16260
16261 /* Prepare FC */
16262 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16263 pMacHdr->fc.type = type;
16264 pMacHdr->fc.subType = subType;
16265
16266 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016267 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
16268 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016269
16270 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
16271
16272 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016273 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
16274 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016275 return statusCode;
16276} /*** csrRoamScanOffloadPopulateMacHeader() ***/
16277
16278static tSirRetStatus
16279csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
16280 tANI_U8 nChannelNum,
16281 tANI_U32 dot11mode,
16282 tSirMacAddr selfMacAddr,
16283 tANI_U8 *pFrame,
16284 tANI_U16 *pusLen)
16285{
16286 tDot11fProbeRequest pr;
16287 tANI_U32 nStatus, nBytes, nPayload;
16288 tSirRetStatus nSirStatus;
16289 /*Bcast tx*/
16290 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
16291 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16292
16293
Kiet Lam64c1b492013-07-12 13:56:44 +053016294 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016295
16296 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
16297
16298 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
16299 {
16300 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
16301 }
16302
16303
16304 if (IS_DOT11_MODE_HT(dot11mode))
16305 {
16306 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16307 }
16308
16309
16310 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16311 if ( DOT11F_FAILED( nStatus ) )
16312 {
16313 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16314 "Failed to calculate the packed size f"
16315 "or a Probe Request (0x%08x).\n", nStatus );
16316
16317
16318 nPayload = sizeof( tDot11fProbeRequest );
16319 }
16320 else if ( DOT11F_WARNED( nStatus ) )
16321 {
16322 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16323 "There were warnings while calculating"
16324 "the packed size for a Probe Request ("
16325 "0x%08x).\n", nStatus );
16326 }
16327
16328 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16329
16330 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016331 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016332
16333
16334 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016335 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016336
16337 if ( eSIR_SUCCESS != nSirStatus )
16338 {
16339 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16340 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16341 nSirStatus );
16342 return nSirStatus;
16343 }
16344
16345
16346 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16347 sizeof( tSirMacMgmtHdr ),
16348 nPayload, &nPayload );
16349 if ( DOT11F_FAILED( nStatus ) )
16350 {
16351 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16352 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16353 return eSIR_FAILURE;
16354 }
16355 else if ( DOT11F_WARNED( nStatus ) )
16356 {
16357 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016358 "There were warnings while packing a Probe Request (0x%08x).\n",
16359 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016360 }
16361
16362 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16363 return eSIR_SUCCESS;
16364}
16365
Mukul Sharmad68cda62015-03-20 21:25:41 +053016366/*
16367 * Below Table describe whether RSO command can be send down to fimrware or not.
16368 * Host check it on the basis of previous RSO command sent down to firmware.
16369||===========================================================================||
16370|| New cmd | LAST SENT COMMAND ---> ||
16371||====|======================================================================||
16372|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
16373|| --------------------------------------------------------------------------||
16374|| RSO_START | NO | YES | NO | NO ||
16375|| RSO_STOP | YES | YES | YES | YES ||
16376|| RSO_RESTART | YES | NO | NO | YES ||
16377|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
16378||===========================================================================||
16379*/
16380
16381#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
16382#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
16383#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
16384#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
16385
16386#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
16387#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
16388 RSO_STOP_BIT | RSO_START_BIT )
16389#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT )
16390#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
16391 RSO_START_BIT)
16392
16393tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
16394{
16395 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16396 tANI_U8 desiredMask = 0;
16397 switch(command)
16398 {
16399 case ROAM_SCAN_OFFLOAD_START:
16400 desiredMask = RSO_START_ALLOW_MASK;
16401 break;
16402 case ROAM_SCAN_OFFLOAD_STOP:
16403 desiredMask = RSO_STOP_ALLOW_MASK;
16404 break;
16405 case ROAM_SCAN_OFFLOAD_RESTART:
16406 desiredMask = RSO_RESTART_ALLOW_MASK;
16407 break;
16408 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
16409 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
16410 break;
16411 default:
16412 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16413 FL("Wrong RSO command %d, not allowed"), command);
16414 return 0;/*Cmd Not allowed*/
16415 }
16416 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
16417}
16418
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016419eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16420{
16421 vos_msg_t msg;
16422 tSirRoamOffloadScanReq *pRequestBuf;
16423 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16424 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016425 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016426 tANI_U8 *ChannelList = NULL;
16427 tANI_U32 sessionId;
16428 eHalStatus status = eHAL_STATUS_SUCCESS;
16429 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016430 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016431 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016432 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016433 tSirBssDescription *pBssDesc = NULL;
16434 tDot11fBeaconIEs *pIes = NULL;
16435 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016436 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016437
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016438 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16439
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016440 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016441 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016442 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016443 return eHAL_STATUS_FAILURE;
16444 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016445
16446 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16447 {
16448 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16449 return eHAL_STATUS_FAILURE;
16450 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016451
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016452 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16453 * It is important to ensure that the command is passed down to the FW only
16454 * if the Infra Station is in a connected state.A connected station could also be
16455 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16456 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16457 * irrespective of whichever state we are in.*/
16458 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16459 (command != ROAM_SCAN_OFFLOAD_STOP))
16460 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016461 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16462 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16463 macTraceGetNeighbourRoamState(
16464 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016465 return eHAL_STATUS_FAILURE;
16466 }
16467
Mukul Sharmad68cda62015-03-20 21:25:41 +053016468 if (!CsrIsRSOCommandAllowed(pMac, command))
16469 {
16470 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16471 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
16472 command, pNeighborRoamInfo->lastSentCmd);
16473 return eHAL_STATUS_FAILURE;
16474 }
16475
Abhishek Singh3e915632014-11-01 17:14:50 +053016476 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16477 * Also there are cases where pNeighborRoamInfo->currAPbssid
16478 * is set to 0 during disconnect and so we might return without stopping
16479 * the roam scan. So no need to find the session if command is
16480 * ROAM_SCAN_OFFLOAD_STOP.
16481 */
16482 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016483 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016484 status = csrRoamGetSessionIdFromBSSID(pMac,
16485 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16486 &sessionId);
16487
16488 if ( !HAL_STATUS_SUCCESS( status ) )
16489 {
16490 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16491 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16492 return eHAL_STATUS_FAILURE;
16493 }
16494 pSession = CSR_GET_SESSION( pMac, sessionId );
16495 if (NULL == pSession)
16496 {
16497 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016498 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016499 return eHAL_STATUS_FAILURE;
16500 }
16501 pBssDesc = pSession->pConnectBssDesc;
16502 if (pBssDesc == NULL)
16503 {
16504 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16505 "%s: pBssDesc not found for current session", __func__);
16506 return eHAL_STATUS_FAILURE;
16507 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016508 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016509 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16510 if (NULL == pRequestBuf)
16511 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016512 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16513 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16514 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016515 }
16516
Abhishek Singh3e915632014-11-01 17:14:50 +053016517 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16518 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16519 * host driver reloads, but Riva still up and running*/
16520 pRequestBuf->Command = command;
16521 if(command == ROAM_SCAN_OFFLOAD_STOP)
16522 {
16523 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053016524 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053016525 /*For a STOP Command, there is no need to
16526 * go through filling up all the below parameters
16527 * since they are not required for the STOP command*/
16528 goto send_roam_scan_offload_cmd;
16529 }
16530 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016531 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016532 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16533 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016534 sizeof(tCsrBssid));
16535 pRequestBuf->ConnectedNetwork.ssId.length =
16536 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16537 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16538 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16539 pRequestBuf->ConnectedNetwork.ssId.length);
16540 pRequestBuf->ConnectedNetwork.authentication =
16541 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16542 pRequestBuf->ConnectedNetwork.encryption =
16543 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16544 pRequestBuf->ConnectedNetwork.mcencryption =
16545 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016546 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16547 {
16548 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016549 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016550 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16551 }
16552 else
16553 {
16554 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16555 operationChannel = pSession->connectedProfile.operationChannel;
16556
16557 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16558 {
16559 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16560 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16561 vos_mem_free(pRequestBuf);
16562 return eHAL_STATUS_FAILURE;
16563 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016564 if(NULL == pIes)
16565 {
16566 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16567 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016568 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016569 return eHAL_STATUS_FAILURE;
16570 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016571 if (pIes->SuppRates.present)
16572 {
16573 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16574 /*Check for both basic rates and extended rates.*/
16575 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16576 {
16577 /*Check if the Rate is Mandatory or Not*/
16578 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16579 && (pIes->SuppRates.rates[i] & 0x80))
16580 {
16581 /*Retrieve the actual data rate*/
16582 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16583 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16584 if (minRate == 0)
16585 minRate = dataRate;
16586 else
16587 minRate = (minRate < dataRate) ? minRate:dataRate;
16588 }
16589 }
16590
16591 if (pIes->ExtSuppRates.present)
16592 {
16593 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16594 {
16595 /*Check if the Rate is Mandatory or Not*/
16596 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16597 && (pIes->ExtSuppRates.rates[i] & 0x80))
16598 {
16599 /*Retrieve the actual data rate*/
16600 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16601 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16602 if (minRate == 0)
16603 minRate = dataRate;
16604 else
16605 minRate = (minRate < dataRate) ? minRate:dataRate;
16606 }
16607 }
16608 }
16609 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16610 }
16611 else
16612 {
16613 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16614 "%s: Supp Rates not present in pIes", __func__);
16615 vos_mem_free(pRequestBuf);
16616 return eHAL_STATUS_FAILURE;
16617 }
16618 if (NULL != pIes)
16619 {
16620 vos_mem_free(pIes);
16621 pIes = NULL;
16622 }
16623 switch (minRate)
16624 {
16625 case 1:
16626 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16627 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16628 break;
16629 case 2:
16630 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16631 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16632 break;
16633 case 5:
16634 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16635 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16636 break;
16637 case 6:
16638 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16639 {
16640 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16641 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16642 }
16643 else
16644 {
16645 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16646 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16647 }
16648 break;
16649 case 11:
16650 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16651 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16652 break;
16653 case 12:
16654 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16655 {
16656 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16657 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16658 }
16659 else
16660 {
16661 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16662 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16663 }
16664 break;
16665 case 24:
16666 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16667 {
16668 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16669 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16670 }
16671 else
16672 {
16673 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16674 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16675 }
16676 break;
16677 default:
16678 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16679 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16680 break;
16681 }
16682 }
16683 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16684 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16685 operationChannel, minRate,
16686 pRequestBuf->RxSensitivityThreshold,
16687 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016688 pRequestBuf->RoamRssiDiff =
16689 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016690 pRequestBuf->StartScanReason = reason;
16691 pRequestBuf->NeighborScanTimerPeriod =
16692 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16693 pRequestBuf->NeighborRoamScanRefreshPeriod =
16694 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16695 pRequestBuf->NeighborScanChannelMinTime =
16696 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16697 pRequestBuf->NeighborScanChannelMaxTime =
16698 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16699 pRequestBuf->EmptyRefreshScanPeriod =
16700 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016701 /* MAWC feature */
16702 pRequestBuf->MAWCEnabled =
16703 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016704#ifdef FEATURE_WLAN_ESE
16705 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016706#endif
16707 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016708#ifdef FEATURE_WLAN_ESE
16709 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016710 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16711 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016712 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16713#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016714 currChannelListInfo->numOfChannels == 0)
16715 {
16716
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016717 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16718 * Give Preference to INI Channels.*/
16719 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16720 {
16721 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16722 /*The INI channels need to be filtered with respect to the current
16723 * band that is supported.*/
16724 eBand = pMac->roam.configParam.bandCapability;
16725 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016726 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016727 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16728 "Invalid band, No operation carried out (Band %d)", eBand);
16729 vos_mem_free(pRequestBuf);
16730 return eHAL_STATUS_FAILURE;
16731 }
16732 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16733 {
16734 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16735 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16736 (eCSR_BAND_ALL == eBand))
16737 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016738 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
16739 ((pMac->roam.configParam.allowDFSChannelRoam) ||
16740 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
16741 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016742 {
16743 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16744 }
16745 }
16746 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016747 }
16748 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16749 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016750 }
16751 else
16752 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016753 ChannelList = pMac->scan.occupiedChannels.channelList;
16754 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16755 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016756 /*Allow DFS channels only if the DFS channel roam flag is enabled */
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016757 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016758 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016759 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016760 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016761 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016762 }
16763 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016764 }
16765 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16766 /* If the profile changes as to what it was earlier, inform the FW through
16767 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16768 * for the earlier profile and try to learn them afresh.*/
16769 if (reason == REASON_FLUSH_CHANNEL_LIST)
16770 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16771 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016772 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16773 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16774 else
16775 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016776 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016777 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016778 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016779#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016780 else
16781 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016782 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016783 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016784 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016785 if (currChannelListInfo->numOfChannels != 0)
16786 {
16787 ChannelList = currChannelListInfo->ChannelList;
16788 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016789 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016790 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
16791 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
16792 {
16793 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
16794 *ChannelList;
16795 }
16796 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016797 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016798 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16799 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16800 }
16801 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016802#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016803 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
16804 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016805 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016806 if (j < sizeof(ChannelCacheStr))
16807 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016808 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16809 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016810 }
16811 else
16812 {
16813 break;
16814 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016815 }
16816 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16817 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16818 pRequestBuf->ChannelCacheType,
16819 pRequestBuf->ConnectedNetwork.ChannelCount,
16820 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016821 num_channels = 0;
16822 ChannelList = NULL;
16823
16824 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016825 host_channels = sizeof(pMac->roam.validChannelList);
16826 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016827 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016828 ChannelList = pMac->roam.validChannelList;
16829 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016830 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016831 else
16832 {
16833 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16834 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016835 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016836 return eHAL_STATUS_FAILURE;
16837 }
16838 for(i=0; i<pMac->roam.numValidChannels; i++)
16839 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016840 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
16841 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
Srinivas Girigowda56076852013-08-20 14:00:50 -070016842 {
16843 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16844 }
16845 ChannelList++;
16846 }
16847 pRequestBuf->ValidChannelCount = num_channels;
16848
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016849 pRequestBuf->MDID.mdiePresent =
16850 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16851 pRequestBuf->MDID.mobilityDomain =
16852 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016853 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16854
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016855 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016856 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16857 * where RFS is the RF Switching time. It is twice RFS to consider the
16858 * time to go off channel and return to the home channel. */
16859 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16860 {
16861 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16862 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16863 " Hence enforcing home away time to disable (0)",
16864 __func__, pRequestBuf->HomeAwayTime,
16865 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16866 pRequestBuf->HomeAwayTime = 0;
16867 }
16868 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016869
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016870 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16871 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16872 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16873 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16874 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16875
16876 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16877 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016878send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016879 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016880 msg.reserved = 0;
16881 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053016882 MTRACE(vos_trace(VOS_MODULE_ID_SME,
16883 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016884 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16885 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016886 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16887 vos_mem_free(pRequestBuf);
16888 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016889 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016890 else
16891 {
16892 if (ROAM_SCAN_OFFLOAD_START == command)
16893 bRoamScanOffloadStarted = VOS_TRUE;
16894 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16895 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053016896
16897 /*update the last sent cmd*/
16898 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016899 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016900
16901 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16902 return status;
16903}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016904
16905eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16906{
16907 switch(reason)
16908 {
16909 case 0:
16910 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16911 break;
16912 case REASON_OS_REQUESTED_ROAMING_NOW:
16913 csrNeighborRoamProceedWithHandoffReq(pMac);
16914 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016915 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16916 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16917 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016918 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016919 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 -070016920 }
16921 return eHAL_STATUS_SUCCESS;
16922}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016923#endif
16924
Jeff Johnson295189b2012-06-20 16:38:30 -070016925tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16926 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16927{
16928 tANI_BOOLEAN found = FALSE;
16929 eHalStatus status = eHAL_STATUS_SUCCESS;
16930 tCsrPeStatsReqInfo staEntry;
16931 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16932 tListElem *pStaEntry = NULL;
16933 VOS_STATUS vosStatus;
16934 tPmcPowerState powerState;
16935 *pFound = FALSE;
16936
16937 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16938 if(pStaEntry)
16939 {
16940 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16941 if(pTempStaEntry->periodicity)
16942 {
16943 pTempStaEntry->periodicity =
16944 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16945 }
16946 else
16947 {
16948 pTempStaEntry->periodicity = periodicity;
16949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016950 pTempStaEntry->numClient++;
16951 found = TRUE;
16952 }
16953 else
16954 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016955 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016956 staEntry.numClient = 1;
16957 staEntry.periodicity = periodicity;
16958 staEntry.pMac = pMac;
16959 staEntry.rspPending = FALSE;
16960 staEntry.staId = staId;
16961 staEntry.statsMask = statsMask;
16962 staEntry.timerRunning = FALSE;
16963 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16964 if(!pTempStaEntry)
16965 {
16966 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016967 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016968 return NULL;
16969 }
16970 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016971 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16972 if(ePMC_FULL_POWER == powerState)
16973 {
16974 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16975 {
16976 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16977 }
16978 }
16979 else
16980 {
16981 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16982 {
16983 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16984 }
16985 }
16986 if(!pTempStaEntry->timerRunning)
16987 {
16988 //send down a req in case of one time req, for periodic ones wait for timer to expire
16989 if(!pTempStaEntry->rspPending &&
16990 !pTempStaEntry->periodicity)
16991 {
16992 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16993 if(!HAL_STATUS_SUCCESS(status))
16994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016995 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016996 }
16997 else
16998 {
16999 pTempStaEntry->rspPending = TRUE;
17000 }
17001 }
17002 if(pTempStaEntry->periodicity)
17003 {
17004 if(!found)
17005 {
17006
17007 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
17008 csrRoamPeStatsTimerHandler, pTempStaEntry );
17009 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017011 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017012 return NULL;
17013 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017014 }
17015 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017016 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070017017 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
17018 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017020 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017021 return NULL;
17022 }
17023 pTempStaEntry->timerRunning = TRUE;
17024 }
17025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017026 *pFound = found;
17027 return pTempStaEntry;
17028}
17029
Jeff Johnson295189b2012-06-20 16:38:30 -070017030/*
17031 pStaEntry is no longer invalid upon the return of this function.
17032*/
17033static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
17034{
17035 if(pEntry)
17036 {
17037 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
17038 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017039 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070017040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017041 }
17042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017043
17044void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
17045{
17046 tListElem *pEntry;
17047 tCsrPeStatsReqInfo *pTempStaEntry;
17048 VOS_STATUS vosStatus;
17049 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017050 if(!pEntry)
17051 {
17052 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017053 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017054 return;
17055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017056 while( pEntry )
17057 {
17058 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
17060 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017061 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017062 if(pTempStaEntry->timerRunning)
17063 {
17064 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
17065 /* If we are not able to stop the timer here, just remove
17066 * the entry from the linked list. Destroy the timer object
17067 * and free the memory in the timer CB
17068 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017069 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070017070 {
17071 /* the timer is successfully stopped */
17072 pTempStaEntry->timerRunning = FALSE;
17073
17074 /* Destroy the timer */
17075 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
17076 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017078 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017079 }
17080 }
17081 else
17082 {
17083 // the timer could not be stopped. Hence destroy and free the
17084 // memory for the PE stat entry in the timer CB.
17085 pTempStaEntry->timerStopFailed = TRUE;
17086 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017088
17089 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
17090 {
17091 // Only free the memory if we could stop the timer successfully
17092 if(!pTempStaEntry->timerStopFailed)
17093 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017094 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070017095 pTempStaEntry = NULL;
17096 }
17097 break;
17098 }
17099
17100 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
17101 }
17102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017103 return;
17104}
17105
17106
Jeff Johnsone7245742012-09-05 17:12:55 -070017107void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017108{
17109
Jeff Johnsone7245742012-09-05 17:12:55 -070017110 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
17111 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
17112 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
17113 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
17114 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
17115 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
17116 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070017117 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070017118 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
17119 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
17120 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
17121 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
17122 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
17123 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070017124 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070017125 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
17126 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070017127
17128}
17129
Jeff Johnson295189b2012-06-20 16:38:30 -070017130void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
17131 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
17132{
17133 tANI_U8 stats[500];
17134 tANI_U8 *pStats = NULL;
17135 tANI_U32 tempMask = 0;
17136 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017137 if(!callback)
17138 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017139 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017140 return;
17141 }
17142 if(!statsMask)
17143 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017144 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017145 return;
17146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017147 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017148 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070017149 while(tempMask)
17150 {
17151 if(tempMask & 1)
17152 {
17153 //new stats info from PE, fill up the stats strucutres in PMAC
17154 switch(counter)
17155 {
17156 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017157 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017158 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
17159 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017160 pStats += sizeof(tCsrSummaryStatsInfo);
17161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017162 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017163 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017164 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
17165 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017166 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017168 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017169 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017170 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
17171 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017172 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017173 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017174 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017175 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017176 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
17177 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017178 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017180 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017181 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017182 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
17183 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017184 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017185 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017186 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017187 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017188 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
17189 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017190 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017191 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017192 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017193 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070017194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017195 }
17196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017197 tempMask >>=1;
17198 counter++;
17199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017200 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070017201}
17202
Jeff Johnson295189b2012-06-20 16:38:30 -070017203eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
17204{
17205 tListElem *pEntry = NULL;
17206 tListElem *pPrevEntry = NULL;
17207 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
17208 eHalStatus status = eHAL_STATUS_SUCCESS;
17209 VOS_STATUS vosStatus;
17210 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017211 if(!pEntry)
17212 {
17213 //list empty
17214 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017215 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 return status;
17217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017218 while( pEntry )
17219 {
17220 if(pPrevEntry)
17221 {
17222 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17223 //send up the stats report
17224 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17225 pTempStaEntry->staId, pTempStaEntry->pContext);
17226 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017228 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070017229 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
17230 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017231 pTempStaEntry->pPeStaEntry->numClient--;
17232 //check if we need to delete the entry from peStatsReqList too
17233 if(!pTempStaEntry->pPeStaEntry->numClient)
17234 {
17235 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
17236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017238 //check if we need to stop the tl stats timer too
17239 pMac->roam.tlStatsReqInfo.numClient--;
17240 if(!pMac->roam.tlStatsReqInfo.numClient)
17241 {
17242 if(pMac->roam.tlStatsReqInfo.timerRunning)
17243 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017244 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17245 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017247 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017248 //we will continue
17249 }
17250 }
17251 pMac->roam.tlStatsReqInfo.periodicity = 0;
17252 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017254 if (pTempStaEntry->periodicity)
17255 {
17256 //While creating StaEntry in csrGetStatistics,
17257 //Initializing and starting timer only when periodicity is set.
17258 //So Stop and Destroy timer only when periodicity is set.
17259
Jeff Johnsone7245742012-09-05 17:12:55 -070017260 vos_timer_stop( &pTempStaEntry->timer );
17261 // Destroy the vos timer...
17262 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
17263 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017265 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017267 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017268
Jeff Johnson295189b2012-06-20 16:38:30 -070017269
17270 pPrevEntry = pEntry;
17271 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
17272 }
17273 //the last one
17274 if(pPrevEntry)
17275 {
17276 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17277 //send up the stats report
17278 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17279 pTempStaEntry->staId, pTempStaEntry->pContext);
17280 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17281 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017282 return status;
17283
17284}
17285
Jeff Johnson295189b2012-06-20 16:38:30 -070017286eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
17287 tRequestFullPowerReason *pReason,
17288 tANI_BOOLEAN *pfNeedPower )
17289{
17290 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17291 tRequestFullPowerReason reason = eSME_REASON_OTHER;
17292 tPmcState pmcState;
17293 eHalStatus status = eHAL_STATUS_SUCCESS;
17294 // TODO : Session info unavailable
17295 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017296 if( pfNeedPower )
17297 {
17298 *pfNeedPower = eANI_BOOLEAN_FALSE;
17299 }
17300 //We only handle CSR commands
17301 if( !(eSmeCsrCommandMask & pCommand->command) )
17302 {
17303 return eHAL_STATUS_SUCCESS;
17304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017305 //Check PMC state first
17306 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017307 switch( pmcState )
17308 {
17309 case REQUEST_IMPS:
17310 case IMPS:
17311 if( eSmeCommandScan == pCommand->command )
17312 {
17313 switch( pCommand->u.scanCmd.reason )
17314 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017315#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17316 case eCsrScanGetLfrResult:
17317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017318 case eCsrScanGetResult:
17319 case eCsrScanBGScanAbort:
17320 case eCsrScanBGScanEnable:
17321 case eCsrScanGetScanChnInfo:
17322 //Internal process, no need for full power
17323 fNeedFullPower = eANI_BOOLEAN_FALSE;
17324 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017325 default:
17326 //Other scans are real scan, ask for power
17327 fNeedFullPower = eANI_BOOLEAN_TRUE;
17328 break;
17329 } //switch
17330 }
17331 else
17332 {
17333 //ask for power for roam and status change
17334 fNeedFullPower = eANI_BOOLEAN_TRUE;
17335 }
17336 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017337 case REQUEST_BMPS:
17338 case BMPS:
17339 case REQUEST_START_UAPSD:
17340 case UAPSD:
17341 //We treat WOWL same as BMPS
17342 case REQUEST_ENTER_WOWL:
17343 case WOWL:
17344 if( eSmeCommandRoam == pCommand->command )
17345 {
17346 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
17347 tCsrScanResult *pScanResult;
17348 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070017349 switch ( pCommand->u.roamCmd.roamReason )
17350 {
17351 case eCsrForcedDisassoc:
17352 case eCsrForcedDisassocMICFailure:
17353 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17354 fNeedFullPower = eANI_BOOLEAN_TRUE;
17355 break;
17356 case eCsrSmeIssuedDisassocForHandoff:
17357 case eCsrForcedDeauth:
17358 case eCsrHddIssuedReassocToSameAP:
17359 case eCsrSmeIssuedReassocToSameAP:
17360 fNeedFullPower = eANI_BOOLEAN_TRUE;
17361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017362 case eCsrCapsChange:
17363 fNeedFullPower = eANI_BOOLEAN_TRUE;
17364 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017365 default:
17366 //Check whether the profile is already connected. If so, no need for full power
17367 //Note: IBSS is ignored for now because we don't support powersave in IBSS
17368 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
17369 {
17370 //Only need to check the first one
17371 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
17372 if( pEntry )
17373 {
17374 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17375#if 0
17376 // TODO : Session Specific info pConnectBssDesc
17377 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17378 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17379 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17380 {
17381 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17382 // with Authenticating first. To force this, stop the current association (Disassociate) and
17383 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17384 // a new Association.
17385 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17386 {
17387 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17388 {
17389 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17390 //No need for full power
17391 //Set the flag so the code later can avoid to do the above
17392 //check again.
17393 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17394 break;
17395 }
17396 }
17397 }
17398#endif
17399 }
17400 }
17401 //If we are here, full power is needed
17402 fNeedFullPower = eANI_BOOLEAN_TRUE;
17403 break;
17404 }
17405 }
17406 else if( eSmeCommandWmStatusChange == pCommand->command )
17407 {
17408 //need full power for all
17409 fNeedFullPower = eANI_BOOLEAN_TRUE;
17410 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17411 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017412#ifdef FEATURE_WLAN_TDLS
17413 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17414 {
17415 //TDLS link is getting established. need full power
17416 fNeedFullPower = eANI_BOOLEAN_TRUE;
17417 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17418 }
17419#endif
mukul sharmabab477d2015-06-11 17:14:55 +053017420 else if (eSmeCommandDelStaSession == pCommand->command)
17421 {
17422 //need full power for all
17423 fNeedFullPower = eANI_BOOLEAN_TRUE;
17424 }
17425
Jeff Johnson295189b2012-06-20 16:38:30 -070017426 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017427 case REQUEST_STOP_UAPSD:
17428 case REQUEST_EXIT_WOWL:
17429 if( eSmeCommandRoam == pCommand->command )
17430 {
17431 fNeedFullPower = eANI_BOOLEAN_TRUE;
17432 switch ( pCommand->u.roamCmd.roamReason )
17433 {
17434 case eCsrForcedDisassoc:
17435 case eCsrForcedDisassocMICFailure:
17436 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17437 break;
17438 default:
17439 break;
17440 }
17441 }
17442 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017443 case STOPPED:
17444 case REQUEST_STANDBY:
17445 case STANDBY:
17446 case LOW_POWER:
17447 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017448 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17449 " stopped/standby state %s (%d)" ),
17450 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017451 status = eHAL_STATUS_FAILURE;
17452 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017453 case FULL_POWER:
17454 case REQUEST_FULL_POWER:
17455 default:
17456 //No need to ask for full power. This has to be FULL_POWER state
17457 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017458 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017459 if( pReason )
17460 {
17461 *pReason = reason;
17462 }
17463 if( pfNeedPower )
17464 {
17465 *pfNeedPower = fNeedFullPower;
17466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017467 return ( status );
17468}
17469
Jeff Johnson295189b2012-06-20 16:38:30 -070017470static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17471{
17472 eHalStatus status = eHAL_STATUS_SUCCESS;
17473 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17474 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017475 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017476 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17477 {
17478 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017480 return ( status );
17481}
17482
Jeff Johnson295189b2012-06-20 16:38:30 -070017483tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17484{
17485 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017486 if( pCmd )
17487 {
17488 pMac->roam.sPendingCommands++;
17489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017490 return ( pCmd );
17491}
17492
Jeff Johnson295189b2012-06-20 16:38:30 -070017493void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17494{
17495 if (pMac->roam.sPendingCommands > 0)
17496 {
17497 //All command allocated through csrGetCommandBuffer need to
17498 //decrement the pending count when releasing.
17499 pMac->roam.sPendingCommands--;
17500 smeReleaseCommand( pMac, pCommand );
17501 }
17502 else
17503 {
17504 smsLog(pMac, LOGE, FL( "no pending commands"));
17505 VOS_ASSERT(0);
17506 }
17507}
17508
Jeff Johnson295189b2012-06-20 16:38:30 -070017509//Return SUCCESS is the command is queued, failed
17510eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17511{
17512 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053017513
17514 if (!SME_IS_START(pMac))
17515 {
17516 smsLog( pMac, LOGE, FL("Sme in stop state"));
17517 return eHAL_STATUS_FAILURE;
17518 }
17519
Jeff Johnson295189b2012-06-20 16:38:30 -070017520 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17521 {
17522 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17523 pCommand->u.scanCmd.reason);
17524 return eHAL_STATUS_CSR_WRONG_STATE;
17525 }
17526
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017527 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17528 {
17529 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17530 &pCommand->Link, LL_ACCESS_LOCK);
17531 // process the command queue...
17532 smeProcessPendingQueue(pMac);
17533 status = eHAL_STATUS_SUCCESS;
17534 goto end;
17535 }
17536
Jeff Johnson295189b2012-06-20 16:38:30 -070017537 //We can call request full power first before putting the command into pending Q
17538 //because we are holding SME lock at this point.
17539 status = csrRequestFullPower( pMac, pCommand );
17540 if( HAL_STATUS_SUCCESS( status ) )
17541 {
17542 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017543 //make sure roamCmdPendingList is not empty first
17544 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17545 if( fNoCmdPending )
17546 {
17547 smePushCommand( pMac, pCommand, fHighPriority );
17548 }
17549 else
17550 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017551 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017552 //no list lock is needed since SME lock is held
17553 if( !fHighPriority )
17554 {
17555 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17556 }
17557 else {
17558 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17559 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017561 }
17562 else if( eHAL_STATUS_PMC_PENDING == status )
17563 {
17564 //no list lock is needed since SME lock is held
17565 if( !fHighPriority )
17566 {
17567 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17568 }
17569 else {
17570 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17571 }
17572 //Let caller know the command is queue
17573 status = eHAL_STATUS_SUCCESS;
17574 }
17575 else
17576 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017577 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017578 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017579 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017580 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017581end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017582 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017583}
Jeff Johnson295189b2012-06-20 16:38:30 -070017584eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17585{
17586 eHalStatus status = eHAL_STATUS_SUCCESS;
17587 tSirUpdateAPWPSIEsReq *pMsg;
17588 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17589
17590 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17591 if (NULL == pSession)
17592 {
17593 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17594 return eHAL_STATUS_FAILURE;
17595 }
17596
Jeff Johnson295189b2012-06-20 16:38:30 -070017597 do
17598 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017599 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17600 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17601 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017602 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17603
17604 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017605 VOS_ASSERT(pBuf);
17606
Jeff Johnson295189b2012-06-20 16:38:30 -070017607 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017608 // transactionId
17609 *pBuf = 0;
17610 *( pBuf + 1 ) = 0;
17611 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017612 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017613 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17614 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017615 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017616 //sessionId
17617 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017618 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017619 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017620 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017621 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017622 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017623 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017624 return ( status );
17625}
Jeff Johnson295189b2012-06-20 16:38:30 -070017626eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17627{
17628 eHalStatus status = eHAL_STATUS_SUCCESS;
17629 tSirUpdateAPWPARSNIEsReq *pMsg;
17630 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017631 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17632 if (NULL == pSession)
17633 {
17634 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17635 return eHAL_STATUS_FAILURE;
17636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017637 do
17638 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017639 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17640 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17641 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017642 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017643 pBuf = (tANI_U8 *)&pMsg->transactionId;
17644 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017645 // transactionId
17646 *pBuf = 0;
17647 *( pBuf + 1 ) = 0;
17648 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017649 VOS_ASSERT(pBuf);
17650
Jeff Johnson295189b2012-06-20 16:38:30 -070017651 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017652 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17653 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017654 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017655 // sessionId
17656 *pBuf++ = (tANI_U8)sessionId;
17657
17658 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017659 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017660 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017661 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017662 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017663 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017664 return ( status );
17665}
Jeff Johnson295189b2012-06-20 16:38:30 -070017666
17667#ifdef WLAN_FEATURE_VOWIFI_11R
17668//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17669eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17670{
17671 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17672 tpSirFTPreAuthReq pftPreAuthReq;
17673 tANI_U16 auth_req_len = 0;
17674 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017675 auth_req_len = sizeof(tSirFTPreAuthReq);
17676 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017677 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017678 {
17679 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17680 return eHAL_STATUS_RESOURCES;
17681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017682 // Save the SME Session ID here. We need it while processing the preauth response
17683 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017684 vos_mem_zero(pftPreAuthReq, auth_req_len);
17685
17686 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17687 sizeof(pBssDescription->length) + pBssDescription->length);
17688
17689 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17690
17691 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17692
Kiet Lam64c1b492013-07-12 13:56:44 +053017693 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17694 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17695 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17696 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017697
Jeff Johnson295189b2012-06-20 16:38:30 -070017698#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017699 if (csrRoamIs11rAssoc(pMac) &&
17700 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017701 {
17702 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017703 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17704 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017705 }
17706 else
17707#endif
17708 {
17709 pftPreAuthReq->ft_ies_length = 0;
17710 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017711 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17712 sizeof(pBssDescription->length) + pBssDescription->length);
17713 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017714 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17715}
Jeff Johnson295189b2012-06-20 16:38:30 -070017716/*--------------------------------------------------------------------------
17717 * This will receive and process the FT Pre Auth Rsp from the current
17718 * associated ap.
17719 *
17720 * This will invoke the hdd call back. This is so that hdd can now
17721 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17722 ------------------------------------------------------------------------*/
17723void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17724{
17725 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17726 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017727#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017728 tCsrRoamInfo roamInfo;
17729#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017730 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017731
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017732#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017733 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017734 if (status != eHAL_STATUS_SUCCESS) {
17735 /*
17736 * Bail out if pre-auth was not even processed.
17737 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017738 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17739 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017740 return;
17741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017742#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017743 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17744 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17745 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017746 // Implies a success
17747 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017748 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17749 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017750 /* No need to notify qos module if this is a non 11r & ESE roam*/
17751 if (csrRoamIs11rAssoc(pMac)
17752#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17753 || csrRoamIsESEAssoc(pMac)
17754#endif
17755 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017756 {
17757 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17758 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053017759 if (pMac->roam.configParam.roamDelayStatsEnabled)
17760 {
17761 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017763 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17764 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017765 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17766 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053017767 if (pMac->roam.configParam.roamDelayStatsEnabled)
17768 {
17769 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017771 if (eHAL_STATUS_SUCCESS != status)
17772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017773 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017774 return;
17775 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017776 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017777 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17778 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017779 if (csrRoamIs11rAssoc(pMac))
17780 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17781 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17782
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017783#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17784 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017785 {
17786 /* read TSF */
17787 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17788
17789 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017790 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017791 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17792 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017793#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017794#ifdef FEATURE_WLAN_LFR
17795 // If Legacy Fast Roaming is enabled, signal the supplicant
17796 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017797 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017798 {
17799 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017800 vos_mem_copy((void *)&roamInfo.bssid,
17801 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017802 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17803 }
17804
17805#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017806
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017807 // If its an Open Auth, FT IEs are not provided by supplicant
17808 // Hence populate them here
17809 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17810 pMac->ft.ftSmeContext.addMDIE = FALSE;
17811 if( csrRoamIs11rAssoc(pMac) &&
17812 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17813 {
17814 tANI_U16 ft_ies_length;
17815 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17816
17817 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17818 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17819 {
17820 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17821 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17822 }
17823
17824 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17825 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17826 {
17827 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17828 }
17829 else
17830 {
17831 // Copy the RIC IEs to reassoc IEs
17832 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17833 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17834 pFTPreAuthRsp->ric_ies_length);
17835 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17836 pMac->ft.ftSmeContext.addMDIE = TRUE;
17837 }
17838 }
17839
Jeff Johnson295189b2012-06-20 16:38:30 -070017840 // Done with it, init it.
17841 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17842}
17843#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017844
Jeff Johnson295189b2012-06-20 16:38:30 -070017845#ifdef FEATURE_WLAN_BTAMP_UT_RF
17846void csrRoamJoinRetryTimerHandler(void *pv)
17847{
17848 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17849 tpAniSirGlobal pMac = pInfo->pMac;
17850 tANI_U32 sessionId = pInfo->sessionId;
17851 tCsrRoamSession *pSession;
17852
17853 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017855 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017856 pSession = CSR_GET_SESSION( pMac, sessionId );
17857 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17858 {
17859 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017861 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017862 }
17863 }
17864 }
17865}
Jeff Johnson295189b2012-06-20 16:38:30 -070017866eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17867{
17868 eHalStatus status = eHAL_STATUS_FAILURE;
17869 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17870
17871 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17872 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017873 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017874 pSession->maxRetryCount--;
17875 pSession->joinRetryTimerInfo.pMac = pMac;
17876 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017877 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17878 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017880 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017881 }
17882 }
17883 else
17884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017885 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017886 pSession->maxRetryCount);
17887 }
17888
17889 return (status);
17890}
Jeff Johnson295189b2012-06-20 16:38:30 -070017891eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17892{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017893 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017894 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17895 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017896 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017897 }
17898
17899 return eHAL_STATUS_SUCCESS;
17900}
17901#endif
17902
17903
17904/*
17905 pBuf points to the beginning of the message
17906 LIM packs disassoc rsp as below,
17907 messageType - 2 bytes
17908 messageLength - 2 bytes
17909 sessionId - 1 byte
17910 transactionId - 2 bytes (tANI_U16)
17911 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17912 peerMacAddr - 6 bytes
17913 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17914*/
17915static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17916{
17917 if(pBuf && pRsp)
17918 {
17919 pBuf += 4; //skip type and length
17920 pRsp->sessionId = *pBuf++;
17921 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17922 pBuf += 2;
17923 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17924 pBuf += 4;
17925 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17926 }
17927}
17928
Jeff Johnsond13512a2012-07-17 11:42:19 -070017929eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17930{
17931 static uNvTables nvTables;
17932 eHalStatus status = eHAL_STATUS_SUCCESS;
17933 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17934
17935 /* read the country code from NV and use it */
17936 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17937 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017938 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17939 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017940 return status;
17941 }
17942 else
17943 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017944 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017945 status = eHAL_STATUS_FAILURE;
17946 return status;
17947 }
17948}
17949
17950eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17951{
Kiet Lam64c1b492013-07-12 13:56:44 +053017952 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017953 return eHAL_STATUS_SUCCESS;
17954}
schang86c22c42013-03-13 18:41:24 -070017955
17956eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17957{
17958 tSirSetTxPowerReq *pMsg = NULL;
17959 eHalStatus status = eHAL_STATUS_SUCCESS;
17960 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17961
17962 if (!pSession)
17963 {
17964 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17965 return eHAL_STATUS_FAILURE;
17966 }
17967
Kiet Lam64c1b492013-07-12 13:56:44 +053017968 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17969 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17970 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17971 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17972 pMsg->length = sizeof(tSirSetTxPowerReq);
17973 pMsg->mwPower = mW;
17974 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17975 sizeof(tSirMacAddr));
17976 status = palSendMBMessage(pMac->hHdd, pMsg);
17977 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017978 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017979 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17980 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017981 }
17982 return status;
17983}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017984
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017985eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17986{
17987 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17988 eHalStatus status = eHAL_STATUS_SUCCESS;
17989 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17990
17991 if (!pSession)
17992 {
17993 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17994 return eHAL_STATUS_FAILURE;
17995 }
17996 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17997 {
17998 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017999
18000 if( NULL == pMsg )
18001 {
18002 smsLog(pMac, LOGE, FL("PMsg is NULL "));
18003 return eHAL_STATUS_FAILURE;
18004 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053018005 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
18006 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
18007 pMsg->length = sizeof(tANI_U8);
18008 pMsg->seesionId = sessionId;
18009 status = palSendMBMessage(pMac->hHdd, pMsg);
18010 if (!HAL_STATUS_SUCCESS(status))
18011 {
18012 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
18013 //pMsg is freed by palSendMBMessage
18014 }
18015 }
18016 else
18017 {
18018 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
18019 status = eHAL_STATUS_FAILURE;
18020 }
18021 return status;
18022}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018023/* Returns whether a session is in VOS_STA_MODE...or not */
18024tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
18025{
18026 tCsrRoamSession *pSession = NULL;
18027 pSession = CSR_GET_SESSION ( pMac, sessionId );
18028 if(!pSession)
18029 {
18030 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
18031 return eANI_BOOLEAN_FALSE;
18032 }
18033 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
18034 {
18035 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
18036 return eANI_BOOLEAN_FALSE;
18037 }
18038 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
18039 {
18040 return eANI_BOOLEAN_FALSE;
18041 }
18042 /* There is a possibility that the above check may fail,because
18043 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
18044 * when it is connected.So,we may sneak through the above check even
18045 * if we are not a STA mode INFRA station. So, if we sneak through
18046 * the above condition, we can use the following check if we are
18047 * really in STA Mode.*/
18048
18049 if ( NULL != pSession->pCurRoamProfile )
18050 {
18051 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
18052 {
18053 return eANI_BOOLEAN_TRUE;
18054 } else {
18055 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
18056 return eANI_BOOLEAN_FALSE;
18057 }
18058 }
18059
18060 return eANI_BOOLEAN_FALSE;
18061}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018062
18063#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18064eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
18065 tCsrHandoffRequest *pHandoffInfo)
18066{
18067 eHalStatus status = eHAL_STATUS_SUCCESS;
18068 vos_msg_t msg;
18069
18070 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053018071 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
18072 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018073 {
18074 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053018075 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018076 }
18077 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
18078 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
18079 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
18080 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053018081 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018082 pHandoffInfo->bssid,
18083 6);
18084 msg.type = eWNI_SME_HANDOFF_REQ;
18085 msg.bodyptr = pMsg;
18086 msg.reserved = 0;
18087 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
18088 {
18089 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053018090 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018091 status = eHAL_STATUS_FAILURE;
18092 }
18093 return status;
18094}
18095#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018096
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018097
18098#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018099/* ---------------------------------------------------------------------------
18100 \fn csrSetCCKMIe
18101 \brief This function stores the CCKM IE passed by the supplicant in a place holder
18102 data structure and this IE will be packed inside reassociation request
18103 \param pMac - pMac global structure
18104 \param sessionId - Current session id
18105 \param pCckmIe - pointer to CCKM IE data
18106 \param ccKmIeLen - length of the CCKM IE
18107 \- return Success or failure
18108 -------------------------------------------------------------------------*/
18109VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
18110 const tANI_U8 *pCckmIe,
18111 const tANI_U8 ccKmIeLen)
18112{
18113 eHalStatus status = eHAL_STATUS_SUCCESS;
18114 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18115
18116 if (!pSession)
18117 {
18118 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18119 return eHAL_STATUS_FAILURE;
18120 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053018121 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018122 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
18123 return status;
18124}
18125
18126/* ---------------------------------------------------------------------------
18127 \fn csrRoamReadTSF
18128 \brief This function reads the TSF; and also add the time elapsed since last beacon or
18129 probe response reception from the hand off AP to arrive at the latest TSF value.
18130 \param pMac - pMac global structure
18131 \param pTimestamp - output TSF timestamp
18132 \- return Success or failure
18133 -------------------------------------------------------------------------*/
18134VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
18135{
18136 eHalStatus status = eHAL_STATUS_SUCCESS;
18137 tCsrNeighborRoamBSSInfo handoffNode;
18138 tANI_U32 timer_diff = 0;
18139 tANI_U32 timeStamp[2];
18140 tpSirBssDescription pBssDescription = NULL;
18141
18142 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
18143 pBssDescription = handoffNode.pBssDescription;
18144
18145 // Get the time diff in milli seconds
18146 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
18147 // Convert msec to micro sec timer
18148 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
18149
18150 timeStamp[0] = pBssDescription->timeStamp[0];
18151 timeStamp[1] = pBssDescription->timeStamp[1];
18152
18153 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
18154
Kiet Lamf2f201e2013-11-16 21:24:16 +053018155 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018156 sizeof (tANI_U32) * 2);
18157 return status;
18158}
18159
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018160#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018161
Agarwal Ashish738843c2014-09-25 12:27:56 +053018162/* ---------------------------------------------------------------------------
18163 \fn csrDisableDfsChannel
18164 \brief This function will call csrApplyChannelPowerCountryInfo to
18165 \ to trim the list on basis of NO_DFS flag.
18166 \param pMac - pMac global structure
18167 \- return void
18168 -------------------------------------------------------------------------*/
18169void csrDisableDfsChannel(tpAniSirGlobal pMac)
18170{
18171 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
18172 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
18173}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053018174
18175/* ---------------------------------------------------------------------------
18176 \fn csrGetStaticUapsdMask
18177 \brief This function will get the static uapsd settings for an existing
18178 \ Infra session.
18179 \param pMac - pMac global structure
18180 \- return void
18181 -------------------------------------------------------------------------*/
18182void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
18183{
18184 tANI_S8 sessionId;
18185 tCsrRoamSession *pSession = NULL;
18186
18187 *staticUapsdMask = 0;
18188 sessionId = csrGetInfraSessionId(pMac);
18189 if(sessionId == -1)
18190 smsLog(pMac, LOGE, FL("Valid session not present."));
18191 else
18192 pSession = CSR_GET_SESSION(pMac, sessionId);
18193
18194 if(!pSession || !pSession->pCurRoamProfile)
18195 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
18196 " pSession:%p"), pSession);
18197 else
18198 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
18199}
18200