blob: 7e1a3785aeb2fa1af74e3cddef4f8cf96dd6659e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
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"
61#include "logDump.h"
62#include "smeQosInternal.h"
63#include "wlan_qct_tl.h"
64#include "smeInside.h"
65#include "vos_diag_core_event.h"
66#include "vos_diag_core_log.h"
67#include "csrApi.h"
68#include "pmc.h"
69#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053070#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
72#include "csrNeighborRoam.h"
73#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080074#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
75#include "csrEse.h"
76#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053077#include "vos_utils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070078#define CSR_NUM_IBSS_START_CHANNELS_50 4
79#define CSR_NUM_IBSS_START_CHANNELS_24 3
80#define CSR_DEF_IBSS_START_CHANNEL_50 36
81#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080082#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 -070083#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
84/*---------------------------------------------------------------------------
85 OBIWAN recommends [8 10]% : pick 9%
86---------------------------------------------------------------------------*/
87#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070088/*---------------------------------------------------------------------------
89 OBIWAN recommends -85dBm
90---------------------------------------------------------------------------*/
91#define CSR_VCC_RSSI_THRESHOLD 80
92#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
93#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
94#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
95#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070096//We use constatnt 4 here
97//This macro returns true when higher AC parameter is bigger than lower AC for a difference
98//The bigger the number, the less chance of TX
99//It must put lower AC as the first parameter.
100#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700101//Flag to send/do not send disassoc frame over the air
102#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700103#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700104#define MAX_CB_VALUE_IN_INI (2)
105
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700106#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
107static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
108#endif
109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110/*--------------------------------------------------------------------------
111 Static Type declarations
112 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800113static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800114
Jeff Johnson295189b2012-06-20 16:38:30 -0700115/*--------------------------------------------------------------------------
116 Type declarations
117 ------------------------------------------------------------------------*/
118#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700119int diagAuthTypeFromCSRType(eCsrAuthType authType)
120{
121 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700122 switch(authType)
123 {
124 case eCSR_AUTH_TYPE_SHARED_KEY:
125 n = AUTH_SHARED;
126 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 case eCSR_AUTH_TYPE_WPA:
128 n = AUTH_WPA_EAP;
129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 case eCSR_AUTH_TYPE_WPA_PSK:
131 n = AUTH_WPA_PSK;
132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700133 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530134#ifdef WLAN_FEATURE_11W
135 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
136#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 n = AUTH_WPA2_EAP;
138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700140#ifdef WLAN_FEATURE_11W
141 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 n = AUTH_WPA2_PSK;
144 break;
145#ifdef FEATURE_WLAN_WAPI
146 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
147 n = AUTH_WAPI_CERT;
148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
150 n = AUTH_WAPI_PSK;
151 break;
152#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 default:
154 break;
155 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 return (n);
157}
Jeff Johnson295189b2012-06-20 16:38:30 -0700158int diagEncTypeFromCSRType(eCsrEncryptionType encType)
159{
160 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 switch(encType)
162 {
163 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
164 case eCSR_ENCRYPT_TYPE_WEP40:
165 n = ENC_MODE_WEP40;
166 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
168 case eCSR_ENCRYPT_TYPE_WEP104:
169 n = ENC_MODE_WEP104;
170 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 case eCSR_ENCRYPT_TYPE_TKIP:
172 n = ENC_MODE_TKIP;
173 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 case eCSR_ENCRYPT_TYPE_AES:
175 n = ENC_MODE_AES;
176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177#ifdef FEATURE_WLAN_WAPI
178 case eCSR_ENCRYPT_TYPE_WPI:
179 n = ENC_MODE_SMS4;
180 break;
181#endif /* FEATURE_WLAN_WAPI */
182 default:
183 break;
184 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 return (n);
186}
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700188static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
189static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static void initConfigParam(tpAniSirGlobal pMac);
191static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
192 eCsrRoamCompleteResult Result, void *Context );
193static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
194 tCsrRoamProfile *pProfile,
195 tANI_BOOLEAN *pfSameIbss );
196static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
197static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700198 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
199static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700200eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
201static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
202eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
203eHalStatus csrRoamClose(tpAniSirGlobal pMac);
204void csrRoamMICErrorTimerHandler(void *pv);
205void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
206tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
207
208static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
209static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
210static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700211eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
212eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
213static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700214static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700215static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
217eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
218 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
219 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
220 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
221 tANI_U8 *pKeyRsc );
222static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
223 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
224 tCsrRoamProfile *pProfile );
225void csrRoamStatisticsTimerHandler(void *pv);
226void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700227static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
228VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
229 v_U8_t rssiNotification,
230 void * context);
231static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
232void csrRoamVccTrigger(tpAniSirGlobal pMac);
233eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
234/*
235 pStaEntry is no longer invalid upon the return of this function.
236*/
237static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700238static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700239static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
241 tDblLinkList *pStaList,
242 tCsrStatsClientReqInfo *pStaEntry);
243void csrRoamStatsClientTimerHandler(void *pv);
244tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
245 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
246void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
247 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700248void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700249void csrRoamTlStatsTimerHandler(void *pv);
250void csrRoamPeStatsTimerHandler(void *pv);
251tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
252void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
253tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
254eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
255static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
256static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
257static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
258static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
259 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
260//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
261static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
262void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
263#ifdef FEATURE_WLAN_BTAMP_UT_RF
264void csrRoamJoinRetryTimerHandler(void *pv);
265#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530266void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700267extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700268extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700269static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700270void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
272//Initialize global variables
273static void csrRoamInitGlobals(tpAniSirGlobal pMac)
274{
275 if(pMac)
276 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800277 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
278 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 }
280 return;
281}
282
Jeff Johnson295189b2012-06-20 16:38:30 -0700283static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
284{
285 if(pMac)
286 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800287 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 }
289 return;
290}
Jeff Johnson295189b2012-06-20 16:38:30 -0700291eHalStatus csrOpen(tpAniSirGlobal pMac)
292{
293 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530294#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 static uNvTables nvTables;
296 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 tANI_U32 i;
300
301 do
302 {
303 /* Initialize CSR Roam Globals */
304 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
306 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
307
308 initConfigParam(pMac);
309 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
310 break;
311 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
312 break;
313 pMac->roam.nextRoamId = 1; //Must not be 0
314 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
315 break;
316 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
317 break;
318 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
319 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530320
321#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
323 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
324 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530325 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
326 WNI_CFG_COUNTRY_CODE_LEN);
327 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 }
329 else
330 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800331 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700332 //hardcoded for now
333 pMac->scan.countryCodeDefault[0] = 'U';
334 pMac->scan.countryCodeDefault[1] = 'S';
335 pMac->scan.countryCodeDefault[2] = 'I';
336 //status = eHAL_STATUS_SUCCESS;
337 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700338 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530339
340 if (!('0' == pMac->scan.countryCodeDefault[0] &&
341 '0' == pMac->scan.countryCodeDefault[1]))
342 {
343 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
344 &regId, COUNTRY_NV);
345 }
346 else
347 {
348 regId = REGDOMAIN_WORLD;
349 }
Abhishek Singha306a442013-11-07 18:39:01 +0530350 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 pMac->scan.domainIdDefault = regId;
352 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530353 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
354 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 return (status);
360}
361
Mihir Shetee1093ba2014-01-21 20:13:32 +0530362/* --------------------------------------------------------------------------
363 \fn csrInitChannels
364 \brief This function must be called to initialize CSR channel lists
365 \return eHalStatus
366 ----------------------------------------------------------------------------*/
367eHalStatus csrInitChannels(tpAniSirGlobal pMac)
368{
369 eHalStatus status = eHAL_STATUS_SUCCESS;
370 static uNvTables nvTables;
371 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530372 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530373
374 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
375 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
376 {
377 vos_mem_copy(pMac->scan.countryCodeDefault,
378 nvTables.defaultCountryTable.countryCode,
379 WNI_CFG_COUNTRY_CODE_LEN);
380 }
381 else
382 {
383 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
384 //hardcoded for now
385 pMac->scan.countryCodeDefault[0] = 'U';
386 pMac->scan.countryCodeDefault[1] = 'S';
387 pMac->scan.countryCodeDefault[2] = 'I';
388 }
389 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
390
Mihir Shetee1093ba2014-01-21 20:13:32 +0530391 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
392 pMac->scan.domainIdDefault = regId;
393 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
394 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
395 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530396 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
397 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530398 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
399 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530400 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530401 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530402
403 return status;
404}
405
Mihir Shete04206452014-11-20 17:50:58 +0530406#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530407eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530408{
409 eHalStatus status = eHAL_STATUS_SUCCESS;
410 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530411 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530412
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530413 /* In case of driver load ; driver need to get channel
414 * list with default Countrycode.
415 * In case of SSR; driver need to get channel list
416 * with old country code. 0 is for init and
417 * 1 is for reinit
418 */
419 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530420 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530421 case INIT:
422 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
423 WNI_CFG_COUNTRY_CODE_LEN);
424 if (!('0' == cc[0] &&
425 '0' == cc[1]))
426 {
427 csrGetRegulatoryDomainForCountry(pMac, cc,
428 &regId, COUNTRY_NV);
429 }
430 else
431 {
432 return status;
433 }
434 pMac->scan.domainIdDefault = regId;
435 break;
436 case REINIT:
437 vos_getCurrentCountryCode(&cc[0]);
438 status = csrGetRegulatoryDomainForCountry(pMac,
439 cc, &regId, COUNTRY_QUERY);
440 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530441 }
442 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530443 pMac->scan.domainIdCurrent = regId;
444 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530445 WNI_CFG_COUNTRY_CODE_LEN);
446 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530447
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530448 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
449 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
450 pMac->scan.countryCodeCurrent[1]);
451
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530452 /* reset info based on new cc, and we are done */
453 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
454 csrScanFilterResults(pMac);
455
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530456 return status;
457}
Mihir Shete04206452014-11-20 17:50:58 +0530458#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
461{
462 eHalStatus status = eHAL_STATUS_SUCCESS;
463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
464 v_REGDOMAIN_t regId;
465 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 if(NULL == apCntryCode)
467 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530468 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 return eHAL_STATUS_FAILURE;
470 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530471 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 /* To get correct Regulatory domain from NV table
473 * 2 character Country code should be used
474 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700475 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
476/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700478
479 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800481 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700482 return eHAL_STATUS_FAILURE;
483 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700484*/
Kiet Lam6c583332013-10-14 05:37:09 +0530485 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
486 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 if (status != eHAL_STATUS_SUCCESS)
488 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700489 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 return status;
491 }
Abhishek Singha306a442013-11-07 18:39:01 +0530492 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 if (status != eHAL_STATUS_SUCCESS)
494 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700495 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 return status;
497 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 pMac->scan.domainIdDefault = regId;
499 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530501 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530504 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* If 2 bytes country code, 3rd byte must be filled with space */
507 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
508 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530509 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
512 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 return status;
515}
Jeff Johnson295189b2012-06-20 16:38:30 -0700516eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
517{
518 eHalStatus status = eHAL_STATUS_SUCCESS;
519 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
520 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530521 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
522 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
524 {
525 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
526 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
527 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
528 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
529 }
530 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
531
532 return status;
533}
Jeff Johnson295189b2012-06-20 16:38:30 -0700534eHalStatus csrClose(tpAniSirGlobal pMac)
535{
536 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800537
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 csrRoamClose(pMac);
539 csrScanClose(pMac);
540 csrLLClose(&pMac->roam.statsClientReqList);
541 csrLLClose(&pMac->roam.peStatsReqList);
542 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 /* DeInit Globals */
544 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return (status);
546}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530547
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800548eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549{
550 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800551 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530552 tANI_U32 numChan = 0;
553 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530554 vos_msg_t msg;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530555 tANI_U8 i, j;
556 tANI_U8 num_channel = 0;
557 tANI_U8 channel_state;
558 tANI_U8 cfgnumChannels = 0;
559 tANI_U8 *cfgChannelList = NULL;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530560
Atul Mittalb849d5a2014-07-29 12:08:39 +0530561 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530562 numChan = sizeof(pMac->roam.validChannelList);
563
564 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
565 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
566 {
567 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
568 return eHAL_STATUS_FAILED_ALLOC;
569 }
570
571 bufLen = sizeof(tSirUpdateChanList) +
572 (sizeof(tSirUpdateChanParam) * (numChan - 1));
573
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530574 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
575 if (!pChanList)
576 {
577 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
578 "Failed to allocate memory for tSirUpdateChanList");
579 return eHAL_STATUS_FAILED_ALLOC;
580 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530581 vos_mem_zero(pChanList, bufLen);
582
583 smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"),
584 pMac->scan.fEnableDFSChnlScan);
585
586 for (i = 0; i < numChan; i++)
587 {
588 channel_state =
589 vos_nv_getChannelEnabledState(pMac->roam.validChannelList[i]);
590
591 if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
592 && (channel_state == NV_CHANNEL_DFS))
593 {
594 continue;
595 }
596 pChanList->chanParam[num_channel].chanId =
597 pMac->roam.validChannelList[i];
598 pChanList->chanParam[num_channel].pwr =
599 cfgGetRegulatoryMaxTransmitPower(pMac,
600 pScan->defaultPowerTable[i].chanId);
Sushant Kaushikece4b562015-04-09 18:27:33 +0530601 if (!pChanList->chanParam[num_channel].pwr)
602 {
603 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
604 "setting to default %d"),
605 pChanList->chanParam[num_channel].chanId,
606 TX_POWER_DEFAULT);
607 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
608 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530609 if (channel_state == NV_CHANNEL_DFS)
610 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
611 else
612 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
613
614 /* When DFS mode is 2, mark static channels as active */
615 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
616 {
617 cfgnumChannels =
618 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
619 cfgChannelList =
620 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
621
622 if (cfgChannelList)
623 {
624 for(j=0; j< cfgnumChannels; j++)
625 {
626 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
627 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
628 {
629 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
630 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
631 "%s Marked DFS ch %d as active\n", __func__,
632 cfgChannelList[j]);
633 }
634 }
635 }
636 else
637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
638 "%s cfgChannelList is NULL \n", __func__);
639 }
640
641 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
642 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
643 pChanList->chanParam[num_channel].chanId,
644 pChanList->chanParam[num_channel].dfsSet,
645 pChanList->chanParam[num_channel].pwr);
646 num_channel++;
647 }
648 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530649
650 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
651 msg.reserved = 0;
652 msg.bodyptr = pChanList;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530653 pChanList->numChan = num_channel;
654
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530655 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
656 {
657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
658 "%s: Failed to post msg to WDA", __func__);
659 vos_mem_free(pChanList);
660 return eHAL_STATUS_FAILURE;
661 }
662
663 return eHAL_STATUS_SUCCESS;
664}
665
Jeff Johnson295189b2012-06-20 16:38:30 -0700666eHalStatus csrStart(tpAniSirGlobal pMac)
667{
668 eHalStatus status = eHAL_STATUS_SUCCESS;
669 tANI_U32 i;
670
671 do
672 {
673 //save the global vos context
674 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
675 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
676 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
677
678 status = csrRoamStart(pMac);
679 if(!HAL_STATUS_SUCCESS(status)) break;
680 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
681 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
682 if(!HAL_STATUS_SUCCESS(status)) break;
683 pMac->roam.sPendingCommands = 0;
684 csrScanEnable(pMac);
685#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
686 status = csrNeighborRoamInit(pMac);
687#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
688 pMac->roam.tlStatsReqInfo.numClient = 0;
689 pMac->roam.tlStatsReqInfo.periodicity = 0;
690 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
691 //init the link quality indication also
692 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
693 if(!HAL_STATUS_SUCCESS(status))
694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800695 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 break;
697 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530698
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700#if defined(ANI_LOGDUMP)
701 csrDumpInit(pMac);
702#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 return (status);
704}
705
Kiet Lama72a2322013-11-15 11:18:11 +0530706eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700707{
708 tANI_U32 sessionId;
709 tANI_U32 i;
710
711 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
712 {
713 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
714 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 csrScanDisable(pMac);
716 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
717 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
719
720#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
721 csrNeighborRoamClose(pMac);
722#endif
723 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 // deregister from PMC since we register during csrStart()
725 // (ignore status since there is nothing we can do if it fails)
726 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 //Reset the domain back to the deault
728 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800729 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700730
731 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
732 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530733 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
735 }
736
Kiet Lama72a2322013-11-15 11:18:11 +0530737#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
738 /* When HAL resets all the context information
739 * in HAL is lost, so we might need to send the
740 * scan offload request again when it comes
741 * out of reset for scan offload to be functional
742 */
743 if (HAL_STOP_TYPE_SYS_RESET == stopType)
744 {
745 bRoamScanOffloadStarted = VOS_FALSE;
746 }
747#endif
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 return (eHAL_STATUS_SUCCESS);
750}
751
Jeff Johnson295189b2012-06-20 16:38:30 -0700752eHalStatus csrReady(tpAniSirGlobal pMac)
753{
754 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 csrScanGetSupportedChannels( pMac );
756 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
757 //use it to init the background scan list
758 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 //Store the AC weights in TL for later use
760 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 status = csrInitChannelList( pMac );
762 if ( ! HAL_STATUS_SUCCESS( status ) )
763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800764 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 status );
766 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return (status);
768}
Jeff Johnson295189b2012-06-20 16:38:30 -0700769void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
770{
771 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
773 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
774}
Jeff Johnson295189b2012-06-20 16:38:30 -0700775void csrSetGlobalCfgs( tpAniSirGlobal pMac )
776{
Jeff Johnsone7245742012-09-05 17:12:55 -0700777
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
779 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
780 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
781 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
782 NULL, eANI_BOOLEAN_FALSE);
783 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700784 /* 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
785 * Once session is established we will use the session related params stored in PE session for CB mode
786 */
787 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
789
790 //Update the operating mode to configured value during initialization,
791 //So that client can advertise full capabilities in Probe request frame.
792 csrSetDefaultDot11Mode( pMac );
793}
794
Jeff Johnson295189b2012-06-20 16:38:30 -0700795eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
796{
797 eHalStatus status = eHAL_STATUS_SUCCESS;
798 tANI_U32 i;
799 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 do
801 {
802 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
803 {
804 pSession = CSR_GET_SESSION( pMac, i );
805 pSession->roamingTimerInfo.pMac = pMac;
806 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
807 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
809 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530810 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
811 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530813 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800815 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 break;
817 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530818 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
819 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
820 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800822 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 return eHAL_STATUS_FAILURE;
824 }
825 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 return (status);
827}
828
Jeff Johnson295189b2012-06-20 16:38:30 -0700829eHalStatus csrRoamClose(tpAniSirGlobal pMac)
830{
831 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
833 {
834 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
835 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530836 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
837 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
838 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
839 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 return (eHAL_STATUS_SUCCESS);
841}
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843eHalStatus csrRoamStart(tpAniSirGlobal pMac)
844{
845 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 return (eHAL_STATUS_SUCCESS);
847}
848
Jeff Johnson295189b2012-06-20 16:38:30 -0700849void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
850{
851 csrRoamStopRoamingTimer(pMac, sessionId);
852 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
853 csrRoamDeregStatisticsReq(pMac);
854}
Jeff Johnson295189b2012-06-20 16:38:30 -0700855eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
856{
857 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800858 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 {
860 status = eHAL_STATUS_SUCCESS;
861 *pState = pMac->roam.roamSession[sessionId].connectState;
862 }
863 return (status);
864}
865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
867{
868 eHalStatus status = eHAL_STATUS_FAILURE;
869 tANI_U32 size = 0;
870 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700871
872 if(!pSession)
873 {
874 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
875 return eHAL_STATUS_FAILURE;
876 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
878 if(pProfile)
879 {
880 if(pSession->pConnectBssDesc)
881 {
882 do
883 {
884 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
885 if(size)
886 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530887 pProfile->pBssDesc = vos_mem_malloc(size);
888 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530890 vos_mem_copy(pProfile->pBssDesc,
891 pSession->pConnectBssDesc, size);
892 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 }
894 else
895 break;
896 }
897 else
898 {
899 pProfile->pBssDesc = NULL;
900 }
901 pProfile->AuthType = pSession->connectedProfile.AuthType;
902 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
903 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
904 pProfile->BSSType = pSession->connectedProfile.BSSType;
905 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
906 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530907 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
908 sizeof(tCsrBssid));
909 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
910 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700911#ifdef WLAN_FEATURE_VOWIFI_11R
912 if (pSession->connectedProfile.MDID.mdiePresent)
913 {
914 pProfile->MDID.mdiePresent = 1;
915 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
916 }
917 else
918 {
919 pProfile->MDID.mdiePresent = 0;
920 pProfile->MDID.mobilityDomain = 0;
921 }
922#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800923#ifdef FEATURE_WLAN_ESE
924 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
925 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800927 vos_mem_copy (pProfile->eseCckmInfo.krk,
928 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530929 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800930 pProfile->eseCckmInfo.reassoc_req_num=
931 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
932 pProfile->eseCckmInfo.krk_plumbed =
933 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 }
935#endif
936 }while(0);
937 }
938 }
939
940 return (status);
941}
942
Jeff Johnson295189b2012-06-20 16:38:30 -0700943eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
944{
945 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700946
947 if((csrIsConnStateConnected(pMac, sessionId)) ||
948 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 {
950 if(pProfile)
951 {
952 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
953 }
954 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 return (status);
956}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700957
Jeff Johnson295189b2012-06-20 16:38:30 -0700958eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
959{
960 eHalStatus status = eHAL_STATUS_SUCCESS;
961
Kiet Lam64c1b492013-07-12 13:56:44 +0530962 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530964 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530966 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700967 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530968 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700969 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530970 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
971
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
973 return (status);
974}
975
Jeff Johnson295189b2012-06-20 16:38:30 -0700976static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
977{
978 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 if( pConnectedInfo->pbFrames )
980 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530981 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 pConnectedInfo->pbFrames = NULL;
983 }
984 pConnectedInfo->nBeaconLength = 0;
985 pConnectedInfo->nAssocReqLength = 0;
986 pConnectedInfo->nAssocRspLength = 0;
987 pConnectedInfo->staId = 0;
988#ifdef WLAN_FEATURE_VOWIFI_11R
989 pConnectedInfo->nRICRspLength = 0;
990#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800991#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 pConnectedInfo->nTspecIeLength = 0;
993#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 return ( status );
995}
996
Jeff Johnson295189b2012-06-20 16:38:30 -0700997
998
Jeff Johnsone7245742012-09-05 17:12:55 -0700999
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001000void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1001{
1002 csrReinitPreauthCmd(pMac, pCommand);
1003 csrReleaseCommand( pMac, pCommand );
1004}
1005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1007{
1008 csrReinitRoamCmd(pMac, pCommand);
1009 csrReleaseCommand( pMac, pCommand );
1010}
1011
Jeff Johnson295189b2012-06-20 16:38:30 -07001012void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1013{
1014 csrReinitScanCmd(pMac, pCommand);
1015 csrReleaseCommand( pMac, pCommand );
1016}
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1019{
1020 csrReinitWmStatusChangeCmd(pMac, pCommand);
1021 csrReleaseCommand( pMac, pCommand );
1022}
1023
Jeff Johnson295189b2012-06-20 16:38:30 -07001024void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1025{
Kiet Lam64c1b492013-07-12 13:56:44 +05301026 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001027}
1028
Jeff Johnson295189b2012-06-20 16:38:30 -07001029void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1030{
Kiet Lam64c1b492013-07-12 13:56:44 +05301031 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032}
1033
Jeff Johnson295189b2012-06-20 16:38:30 -07001034void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1035{
1036 csrReinitSetKeyCmd(pMac, pCommand);
1037 csrReleaseCommand( pMac, pCommand );
1038}
Jeff Johnson295189b2012-06-20 16:38:30 -07001039void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1040{
1041 csrReinitRemoveKeyCmd(pMac, pCommand);
1042 csrReleaseCommand( pMac, pCommand );
1043}
Jeff Johnson295189b2012-06-20 16:38:30 -07001044void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1045{
1046
1047 if( eSmeCsrCommandMask & pCommand->command )
1048 {
1049 switch (pCommand->command)
1050 {
1051 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001052 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001053 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1054 __func__, pCommand->u.scanCmd.reason,
1055 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 if (NULL != pCommand->u.scanCmd.callback)
1057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001058 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1060 }
1061 csrReleaseCommandScan( pMac, pCommand );
1062 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 case eSmeCommandRoam:
1064 csrReleaseCommandRoam( pMac, pCommand );
1065 break;
1066
1067 case eSmeCommandWmStatusChange:
1068 csrReleaseCommandWmStatusChange( pMac, pCommand );
1069 break;
1070
1071 case eSmeCommandSetKey:
1072 csrReleaseCommandSetKey( pMac, pCommand );
1073 break;
1074
1075 case eSmeCommandRemoveKey:
1076 csrReleaseCommandRemoveKey( pMac, pCommand );
1077 break;
1078
1079 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001080 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 csrReleaseCommand( pMac, pCommand );
1082 break;
1083 }
1084 }
1085}
1086
Jeff Johnson295189b2012-06-20 16:38:30 -07001087void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1088{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301089 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1090 macTraceGetcsrRoamSubState(NewSubstate),
1091 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001092
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1094 {
1095 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 pMac->roam.curSubState[sessionId] = NewSubstate;
1098}
1099
Jeff Johnson295189b2012-06-20 16:38:30 -07001100eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1101{
1102 eCsrRoamState PreviousState;
1103
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301104 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1105 macTraceGetcsrRoamState(NewRoamState),
1106 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001107
1108 PreviousState = pMac->roam.curState[sessionId];
1109
1110 if ( NewRoamState != pMac->roam.curState[sessionId] )
1111 {
1112 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1113 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1114 {
1115 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1116 }
1117
1118 pMac->roam.curState[sessionId] = NewRoamState;
1119 }
1120 return( PreviousState );
1121}
1122
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001123void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001124{
1125 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 if(catOffset)
1127 {
1128 pMac->roam.configParam.bCatRssiOffset = catOffset;
1129 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1130 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001131 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 -07001132 }
1133 }
1134}
1135
Jeff Johnson295189b2012-06-20 16:38:30 -07001136static void initConfigParam(tpAniSirGlobal pMac)
1137{
1138 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301140 pMac->roam.configParam.channelBondingMode24GHz =
1141 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1142 pMac->roam.configParam.channelBondingMode5GHz =
1143 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1145 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1146 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1147 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1148 pMac->roam.configParam.HeartbeatThresh24 = 40;
1149 pMac->roam.configParam.HeartbeatThresh50 = 40;
1150 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1151 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1152 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001153 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 pMac->roam.configParam.RTSThreshold = 2346;
1155 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1156 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1157 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1158 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1159 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1160 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1161 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1162 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1163 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1164 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1165 {
1166 pMac->roam.configParam.BssPreferValue[i] = i;
1167 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001168 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1170 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1171 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1173 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301174 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1176 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1177 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1178 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001179 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1180 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001181 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001182#ifdef WLAN_AP_STA_CONCURRENCY
1183 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1184 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1185 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1186 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1187 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001188 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1189 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1192 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1193 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1194 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001195#ifdef WLAN_FEATURE_VOWIFI_11R
1196 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1197#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001198#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1199 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1200 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1201 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1202 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1203 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1204 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1205 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1206 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1207 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1208 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1209 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001210 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301211 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001212#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001213#ifdef WLAN_FEATURE_11AC
1214 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
1217 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1218 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001219
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001220 //Remove this code once SLM_Sessionization is supported
1221 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001222 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001223
Jeff Johnsone7245742012-09-05 17:12:55 -07001224}
Jeff Johnson295189b2012-06-20 16:38:30 -07001225eCsrBand csrGetCurrentBand(tHalHandle hHal)
1226{
1227 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1228 return pMac->roam.configParam.bandCapability;
1229}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001230
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001231
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001232#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001233/*
1234 This function flushes the roam scan cache
1235*/
1236eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1237{
1238 eHalStatus status = eHAL_STATUS_SUCCESS;
1239 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1240
1241 /* Free up the memory first (if required) */
1242 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1243 {
1244 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1245 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1246 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1247 }
1248 return status;
1249}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001250#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001251
1252
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001253#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001254/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001255 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001256*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001257eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001258{
1259 eHalStatus status = eHAL_STATUS_SUCCESS;
1260 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1261
1262 /* Free up the memory first (if required) */
1263 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1264 {
1265 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1266 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001267 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001268 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001269 return status;
1270}
1271
1272
1273
1274/*
1275 This function flushes the roam scan cache and creates fresh cache
1276 based on the input channel list
1277*/
1278eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1279 const tANI_U8 *pChannelList,
1280 const tANI_U8 numChannels)
1281{
1282 eHalStatus status = eHAL_STATUS_SUCCESS;
1283 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1284
Srinivas Girigowdade697412013-02-14 16:31:48 -08001285 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1286
1287 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1288 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1289
1290 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1291 {
1292 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1293 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1294 return eHAL_STATUS_RESOURCES;
1295 }
1296
1297 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301298 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1299 pChannelList,
1300 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001301 return status;
1302}
1303
1304/* This function modifies the bgscan channel list set via config ini or
1305 runtime, whenever the band changes.
1306 if the band is auto, then no operation is performed on the channel list
1307 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1308 if the band is 5G, then make sure channel list contains only 5G valid channels
1309*/
1310eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1311 eCsrBand eBand)
1312{
1313 eHalStatus status = eHAL_STATUS_SUCCESS;
1314 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1315 tANI_U8 outNumChannels = 0;
1316 tANI_U8 inNumChannels = 0;
1317 tANI_U8 *inPtr = NULL;
1318 tANI_U8 i = 0;
1319 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1320
1321 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1322
1323 {
1324 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1325 "No update required for channel list "
1326 "either cfg.ini channel list is not set up or "
1327 "auto band (Band %d)", eBand);
1328 return status;
1329 }
1330
1331 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1332 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1333 if (eCSR_BAND_24 == eBand)
1334 {
1335 for (i = 0; i < inNumChannels; i++)
1336 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001337 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001338 {
1339 ChannelList[outNumChannels++] = inPtr[i];
1340 }
1341 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001342 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001343 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001344 }
1345 else if (eCSR_BAND_5G == eBand)
1346 {
1347 for (i = 0; i < inNumChannels; i++)
1348 {
1349 /* Add 5G Non-DFS channel */
1350 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001351 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001352 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1353 {
1354 ChannelList[outNumChannels++] = inPtr[i];
1355 }
1356 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001357 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001358 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001359 }
1360 else if (eCSR_BAND_ALL == eBand)
1361 {
1362 for (i = 0; i < inNumChannels; i++)
1363 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001364 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001365 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1366 {
1367 ChannelList[outNumChannels++] = inPtr[i];
1368 }
1369 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001370 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001371 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001372 }
1373 else
1374 {
1375 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1376 "Invalid band, No operation carried out (Band %d)", eBand);
1377 status = eHAL_STATUS_INVALID_PARAMETER;
1378 }
1379
1380 return status;
1381}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001382#endif
1383
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001384#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001385/* This function modifies the roam scan channel list as per AP neighbor
1386 report; AP neighbor report may be empty or may include only other AP
1387 channels; in any case, we merge the channel list with the learned occupied
1388 channels list.
1389 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1390 if the band is 5G, then make sure channel list contains only 5G valid channels
1391*/
1392eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1393 tANI_U8 *pChannelList,
1394 tANI_U8 numChannels,
1395 const eCsrBand eBand)
1396{
1397 eHalStatus status = eHAL_STATUS_SUCCESS;
1398 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1399 tANI_U8 outNumChannels = 0;
1400 tANI_U8 inNumChannels = numChannels;
1401 tANI_U8 *inPtr = pChannelList;
1402 tANI_U8 i = 0;
1403 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1404 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1405 tANI_U8 mergedOutputNumOfChannels = 0;
1406 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1407
1408 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1409 * report Channels. This increases the chances of the DUT to get a candidate AP while
1410 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1411 if (pMac->scan.occupiedChannels.numChannels)
1412 {
1413 csrNeighborRoamMergeChannelLists(pMac,
1414 &pMac->scan.occupiedChannels.channelList[0],
1415 pMac->scan.occupiedChannels.numChannels,
1416 inPtr,
1417 inNumChannels,
1418 &mergedOutputNumOfChannels);
1419 inNumChannels = mergedOutputNumOfChannels;
1420 }
1421
1422 if (eCSR_BAND_24 == eBand)
1423 {
1424 for (i = 0; i < inNumChannels; i++)
1425 {
1426 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1427 {
1428 ChannelList[outNumChannels++] = inPtr[i];
1429 }
1430 }
1431 }
1432 else if (eCSR_BAND_5G == eBand)
1433 {
1434 for (i = 0; i < inNumChannels; i++)
1435 {
1436 /* Add 5G Non-DFS channel */
1437 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1438 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1439 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1440 {
1441 ChannelList[outNumChannels++] = inPtr[i];
1442 }
1443 }
1444 }
1445 else if (eCSR_BAND_ALL == eBand)
1446 {
1447 for (i = 0; i < inNumChannels; i++)
1448 {
1449 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1450 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1451 {
1452 ChannelList[outNumChannels++] = inPtr[i];
1453 }
1454 }
1455 }
1456 else
1457 {
1458 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1459 "Invalid band, No operation carried out (Band %d)", eBand);
1460 return eHAL_STATUS_INVALID_PARAMETER;
1461 }
1462
1463 /* if roaming within band is enabled, then select only the
1464 in band channels .
1465 This is required only if the band capability is set to ALL,
1466 E.g., if band capability is only 2.4G then all the channels in the
1467 list are already filtered for 2.4G channels, hence ignore this check*/
1468
1469 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1470 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301471 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001472 pMac,
1473 ChannelList,
1474 outNumChannels,
1475 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301476 &outNumChannels,
1477 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301478 vos_mem_copy(ChannelList,
1479 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001480 }
1481
1482 /* Prepare final roam scan channel list */
1483 if(outNumChannels)
1484 {
1485 /* Clear the channel list first */
1486 if (NULL != currChannelListInfo->ChannelList)
1487 {
1488 vos_mem_free(currChannelListInfo->ChannelList);
1489 currChannelListInfo->ChannelList = NULL;
1490 currChannelListInfo->numOfChannels = 0;
1491 }
1492
1493 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1494 if (NULL == currChannelListInfo->ChannelList)
1495 {
1496 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1497 "Failed to allocate memory for roam scan channel list");
1498 currChannelListInfo->numOfChannels = 0;
1499 return VOS_STATUS_E_RESOURCES;
1500 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301501 vos_mem_copy(currChannelListInfo->ChannelList,
1502 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001503 }
1504 return status;
1505}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001506#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1509{
1510 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1511 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1513 (eBand == eCSR_BAND_24))
1514 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001515 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001518 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 pMac->roam.configParam.uCfgDot11Mode, eBand);
1520 return eHAL_STATUS_INVALID_PARAMETER;
1521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1523 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1524 (eBand == eCSR_BAND_5G))
1525 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001526 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001528 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001529 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 pMac->roam.configParam.uCfgDot11Mode, eBand);
1531 return eHAL_STATUS_INVALID_PARAMETER;
1532 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001533 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001534 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001535 pMac->roam.configParam.eBand = eBand;
1536 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001538#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001539 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1540 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001541#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 status = csrInitGetChannels( pMac );
1543 if (eHAL_STATUS_SUCCESS == status)
1544 csrInitChannelList( hHal );
1545 return status;
1546}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001547
1548
Jeff Johnsone7245742012-09-05 17:12:55 -07001549/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1550 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1551 * Ideally we should have kept the ini value and enum value same and representing the same
1552 * cb values as in 11n standard i.e.
1553 * Set to 1 (SCA) if the secondary channel is above the primary channel
1554 * Set to 3 (SCB) if the secondary channel is below the primary channel
1555 * Set to 0 (SCN) if no secondary channel is present
1556 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1557 * 0 - secondary none
1558 * 1 - secondary LOW
1559 * 2 - secondary HIGH
1560 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1561 * The enum values are as follows:
1562 * PHY_SINGLE_CHANNEL_CENTERED = 0
1563 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1564 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1565 */
1566ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1567{
1568
1569 ePhyChanBondState phyCbState;
1570 switch (cbIniValue) {
1571 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301572 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001573 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1574 break;
1575 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301576 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001577 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1578 break;
1579 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301580 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1582 break;
1583#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301584 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1585 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301587 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001588 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1589 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301590 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1591 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1592 break;
1593 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001594 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1595 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301596 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001597 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301598 break;
1599 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001600 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1601 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301602 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001603 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301604 break;
1605#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001606 default:
1607 // If an invalid value is passed, disable CHANNEL BONDING
1608 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1609 break;
1610 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301611
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 return phyCbState;
1613}
1614
1615v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1616{
1617
1618 v_U32_t cbIniValue;
1619 switch (phyCbState) {
1620 // secondary none
1621 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301622 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001623 break;
1624 // secondary LOW
1625 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301626 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001627 break;
1628 // secondary HIGH
1629 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301630 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001631 break;
1632#ifdef WLAN_FEATURE_11AC
1633 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301634 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001635 break;
1636 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301637 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001638 break;
1639 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301640 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001641 break;
1642 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301643 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 break;
1645 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301646 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 break;
1648 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301649 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001650 break;
1651 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301652 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001653 break;
1654#endif
1655 default:
1656 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301657 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001658 break;
1659 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301660
Jeff Johnsone7245742012-09-05 17:12:55 -07001661 return cbIniValue;
1662}
Jeff Johnson295189b2012-06-20 16:38:30 -07001663
1664eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1665{
1666 eHalStatus status = eHAL_STATUS_SUCCESS;
1667
1668 if(pParam)
1669 {
1670 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1671 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1672 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1673 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1674 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1675 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1676
1677 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001678 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1679
Jeff Johnsone7245742012-09-05 17:12:55 -07001680 /* channelBondingMode5GHz plays a dual role right now
1681 * 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
1682 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1683 */
1684 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001686 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001687 }
1688 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1689 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001691 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001692 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301693#ifdef WLAN_FEATURE_AP_HT40_24G
1694 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1695#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001696 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1698 pMac->roam.configParam.phyMode = pParam->phyMode;
1699 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1700 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1701 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1702 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1703 pMac->roam.configParam.TxRate = pParam->TxRate;
1704 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1705 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1706 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1707 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1708 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001709 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 //if HDD passed down non zero values then only update,
1711 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301712 if (pParam->nInitialDwellTime)
1713 {
1714 pMac->roam.configParam.nInitialDwellTime =
1715 pParam->nInitialDwellTime;
1716 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001717 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 {
1719 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301720 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1721 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001723 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 {
1725 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301726 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1727 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001729 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 {
1731 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301732 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1733 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001735 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 {
1737 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301738 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1739 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301741 if (pParam->nOBSSScanWidthTriggerInterval)
1742 {
1743 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1744 pParam->nOBSSScanWidthTriggerInterval;
1745 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1746 pParam->nOBSSScanWidthTriggerInterval);
1747 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001748 if (pParam->nActiveMaxChnTimeBtc)
1749 {
1750 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1751 }
1752 if (pParam->nActiveMinChnTimeBtc)
1753 {
1754 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1755 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001756#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001757 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001758 {
1759 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1760 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001761 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001762 {
1763 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1764 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001765 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001766 {
1767 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1768 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001769 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001770 {
1771 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1772 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001773 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001774 {
1775 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1776 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001777 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001778 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001779 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1780 }
1781 if (pParam->nNumP2PChanCombinedConc)
1782 {
1783 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001784 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001785#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001787 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 {
1789 //Change the unit from second to microsecond
1790 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1792 {
1793 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1794 }
1795 else
1796 {
1797 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1798 }
1799 }
1800 else
1801 {
1802 pMac->roam.configParam.impsSleepTime = 0;
1803 }
1804 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1806 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 //if HDD passed down non zero values for age params, then only update,
1808 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001809 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 {
1811 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 if(pParam->scanAgeTimeNCNPS)
1814 {
1815 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 if(pParam->scanAgeTimeNCPS)
1818 {
1819 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 if(pParam->scanAgeTimeCNPS)
1822 {
1823 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1824 }
1825 if(pParam->scanAgeTimeCPS)
1826 {
1827 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1828 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301829 if (pParam->initialScanSkipDFSCh)
1830 {
1831 pMac->roam.configParam.initialScanSkipDFSCh =
1832 pParam->initialScanSkipDFSCh;
1833 }
1834
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001835 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1837 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1838 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1839 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1840 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1842 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1844 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1845 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1846 //Assign this before calling CsrInit11dInfo
1847 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 if( csrIs11dSupported( pMac ) )
1849 {
1850 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1851 }
1852 else
1853 {
1854 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1855 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001856
1857 /* Initialize the power + channel information if 11h is enabled.
1858 If 11d is enabled this information has already been initialized */
1859 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1860 {
1861 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1862 }
1863
1864
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301865#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301866 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1867 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001868 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001869#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001870#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001872 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001873 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001874 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001875 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001876 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001877 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001878 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001879 pMac->roam.configParam.nProbes = pParam->nProbes;
1880 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001882#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1883 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001884 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001885#endif
1886#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001887 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001888 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001889#endif
1890
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001891#ifdef FEATURE_WLAN_ESE
1892 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001894#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301895 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1896 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001897 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1898 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1899 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1900 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1901 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1902 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1903 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1904 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301905 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 {
1907 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001908 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 -07001909 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1910 {
1911 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 }
1914#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1916 pMac->scan.fValidateList = pParam->fValidateList;
1917 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1918 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001919 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001921 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301922 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001923 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1924 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1925 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1926 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1927 * single session
1928 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001929 //Remove this code once SLM_Sessionization is supported
1930 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001931 pMac->roam.configParam.doBMPSWorkaround = 0;
1932
Jeff Johnsone7245742012-09-05 17:12:55 -07001933#ifdef WLAN_FEATURE_11AC
1934 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001935 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001936 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001937 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301938 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1939 if ( pParam->enableTxBF )
1940 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1941 else
1942 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001943#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001944 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001945
1946 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001947 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05301948 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
krunal sonie9002db2013-11-25 14:24:17 -08001949 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1950 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301951 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301952 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301953#ifdef WLAN_FEATURE_AP_HT40_24G
1954 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
1955#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05301956 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 }
1958
1959 return status;
1960}
1961
Jeff Johnson295189b2012-06-20 16:38:30 -07001962eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1963{
1964 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 if(pParam)
1966 {
1967 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1968 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1969 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1970 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1971 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1972 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001973 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301974#ifdef WLAN_FEATURE_AP_HT40_24G
1975 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
1976#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001977 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1979 pParam->phyMode = pMac->roam.configParam.phyMode;
1980 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1981 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1982 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1983 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1984 pParam->TxRate = pMac->roam.configParam.TxRate;
1985 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1986 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1987 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1988 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1989 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1991 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1992 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1993 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001994 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1995 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1996 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001997#ifdef WLAN_AP_STA_CONCURRENCY
1998 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1999 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2000 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2001 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2002 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002003 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2004 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002005#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 //Change the unit from microsecond to second
2007 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2008 pParam->eBand = pMac->roam.configParam.eBand;
2009 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2010 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2011 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2012 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2013 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2014 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2015 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2016 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2017 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2018 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2019 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2020 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2021 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2023 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2024 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2025 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2027 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2028 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2029 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
2030 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002031 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002032 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002033 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002034 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302035 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002036#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302037 vos_mem_copy(&pParam->neighborRoamConfig,
2038 &pMac->roam.configParam.neighborRoamConfig,
2039 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002040#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002041#ifdef WLAN_FEATURE_11AC
2042 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002043 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002044 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002045 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302046 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2047 if ( pParam->enableTxBF )
2048 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2049 else
2050 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002051#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002052#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302053 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2054 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002055#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002056#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002057 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2058 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2059 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2060 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2061 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002062 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002063 pParam->nProbes = pMac->roam.configParam.nProbes;
2064 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002065#endif
2066#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2067 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2068 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
2069#endif
2070#ifdef FEATURE_WLAN_LFR
2071 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2072#endif
2073
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002074#ifdef FEATURE_WLAN_ESE
2075 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002076#endif
2077#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302078 vos_mem_copy(&pParam->neighborRoamConfig,
2079 &pMac->roam.configParam.neighborRoamConfig,
2080 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002081 {
2082 int i;
2083 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2084 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2085 {
2086 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2087 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002088 }
2089#endif
2090
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002091 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002092
krunal soni5afa96c2013-09-06 22:19:02 -07002093 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002094 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302095 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
krunal soni5afa96c2013-09-06 22:19:02 -07002096
krunal sonie9002db2013-11-25 14:24:17 -08002097 pParam->isCoalesingInIBSSAllowed =
2098 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302099 pParam->allowDFSChannelRoam =
2100 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302101 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302103#ifdef WLAN_FEATURE_AP_HT40_24G
2104 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2105#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002106
2107 status = eHAL_STATUS_SUCCESS;
2108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 return (status);
2110}
2111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2113{
2114 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2115 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2116 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2117 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 do
2119 {
2120 if(eCSR_BAND_24 == eBand)
2121 {
2122 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2123 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2124 }
2125 if(eCSR_BAND_5G == eBand)
2126 {
2127 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2128 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2129 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2130 )
2131 {
2132 break;
2133 }
2134 }
2135 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2136 {
2137 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2138 }
2139 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2140 {
2141 newPhyMode = eCSR_DOT11_MODE_AUTO;
2142 }
2143 else
2144 {
2145 //Check for dual band and higher capability first
2146 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2147 {
2148 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2149 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2150 }
2151 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2152 {
2153 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2154 if(eCSR_BAND_24 == eBand) break;
2155 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2156 eBand = eCSR_BAND_5G;
2157 }
2158 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2159 {
2160 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2161 if(eCSR_BAND_5G == eBand) break;
2162 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2163 eBand = eCSR_BAND_24;
2164 }
2165 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2166 {
2167 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2168 if(eCSR_BAND_5G == eBand) break;
2169 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2170 eBand = eCSR_BAND_24;
2171 }
2172 else if(eCSR_DOT11_MODE_11n & phyMode)
2173 {
2174 newPhyMode = eCSR_DOT11_MODE_11n;
2175 }
2176 else if(eCSR_DOT11_MODE_abg & phyMode)
2177 {
2178 newPhyMode = eCSR_DOT11_MODE_abg;
2179 }
2180 else if(eCSR_DOT11_MODE_11a & phyMode)
2181 {
2182 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2183 {
2184 if(eCSR_BAND_ALL == eBand)
2185 {
2186 newPhyMode = eCSR_DOT11_MODE_abg;
2187 }
2188 else
2189 {
2190 //bad setting
2191 break;
2192 }
2193 }
2194 else
2195 {
2196 newPhyMode = eCSR_DOT11_MODE_11a;
2197 eBand = eCSR_BAND_5G;
2198 }
2199 }
2200 else if(eCSR_DOT11_MODE_11g & phyMode)
2201 {
2202 newPhyMode = eCSR_DOT11_MODE_11g;
2203 eBand = eCSR_BAND_24;
2204 }
2205 else if(eCSR_DOT11_MODE_11b & phyMode)
2206 {
2207 newPhyMode = eCSR_DOT11_MODE_11b;
2208 eBand = eCSR_BAND_24;
2209 }
2210 else
2211 {
2212 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002213 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 newPhyMode = eCSR_DOT11_MODE_AUTO;
2215 }
2216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 //Done validating
2218 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 //Now we need to check whether a restart is needed.
2220 if(eBand != pMac->roam.configParam.eBand)
2221 {
2222 fRestartNeeded = eANI_BOOLEAN_TRUE;
2223 break;
2224 }
2225 if(newPhyMode != pMac->roam.configParam.phyMode)
2226 {
2227 fRestartNeeded = eANI_BOOLEAN_TRUE;
2228 break;
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 if(HAL_STATUS_SUCCESS(status))
2232 {
2233 pMac->roam.configParam.eBand = eBand;
2234 pMac->roam.configParam.phyMode = newPhyMode;
2235 if(pfRestartNeeded)
2236 {
2237 *pfRestartNeeded = fRestartNeeded;
2238 }
2239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 return (status);
2241}
2242
Jeff Johnson295189b2012-06-20 16:38:30 -07002243void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2244{
2245 tANI_U8 Index;
2246 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 // for dual band NICs, don't need to trim the channel list....
2248 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2249 {
2250 // 2.4 GHz band operation requires the channel list to be trimmed to
2251 // the 2.4 GHz channels only...
2252 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2253 {
2254 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2255 Index++ )
2256 {
2257 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2258 {
2259 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2260 cChannels++;
2261 }
2262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2264 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2265 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2266 // only if we need to.
2267 //
2268 // The amount of memory to clear is the number of channesl that we trimmed
2269 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2270
2271 if ( pChannelList->numChannels > cChannels )
2272 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302273 vos_mem_set(&pChannelList->channelList[ cChannels ],
2274 sizeof( pChannelList->channelList[ 0 ] ) *
2275 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 }
2277
2278 pChannelList->numChannels = cChannels;
2279 }
2280 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2281 {
2282 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2283 {
2284 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2285 {
2286 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2287 cChannels++;
2288 }
2289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2291 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2292 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2293 // only if we need to.
2294 //
2295 // The amount of memory to clear is the number of channesl that we trimmed
2296 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2297 if ( pChannelList->numChannels > cChannels )
2298 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302299 vos_mem_set(&pChannelList->channelList[ cChannels ],
2300 sizeof( pChannelList->channelList[ 0 ] ) *
2301 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 }
2303
2304 pChannelList->numChannels = cChannels;
2305 }
2306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002307}
Jeff Johnson295189b2012-06-20 16:38:30 -07002308#define INFRA_AP_DEFAULT_CHANNEL 6
2309eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2310{
2311 tANI_U8 index= 0;
2312 eHalStatus status = eHAL_STATUS_FAILURE;
2313 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2314 {
2315 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2316 status = eHAL_STATUS_SUCCESS;
2317 break;
2318 }
2319 }
2320 return status;
2321}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002322
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002323
Jeff Johnson295189b2012-06-20 16:38:30 -07002324eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2325{
2326 eHalStatus status = eHAL_STATUS_SUCCESS;
2327 tANI_U8 num20MHzChannelsFound = 0;
2328 VOS_STATUS vosStatus;
2329 tANI_U8 Index = 0;
2330 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002331
Jeff Johnson295189b2012-06-20 16:38:30 -07002332
2333 //TODO: this interface changed to include the 40MHz channel list
2334 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2335 // Read the scan channel list (including the power limit) from EEPROM
2336 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2337 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2338 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002340 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 status = eHAL_STATUS_FAILURE;
2342 }
2343 else
2344 {
2345 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2346 {
2347 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2348 }
2349 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2350 // Move the channel list to the global data
2351 // structure -- this will be used as the scan list
2352 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2353 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2357 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2358 {
2359 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2360 }
2361 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2362 {
2363 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2364 }
2365 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 return (status);
2368}
Jeff Johnson295189b2012-06-20 16:38:30 -07002369eHalStatus csrInitChannelList( tHalHandle hHal )
2370{
2371 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2372 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2374 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002375 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2376 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002378 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302379 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 return (status);
2381}
Jeff Johnson295189b2012-06-20 16:38:30 -07002382eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2383 tCsrUpdateConfigParam *pUpdateConfigParam)
2384{
2385 eHalStatus status = eHAL_STATUS_FAILURE;
2386 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2388 status = CsrInit11dInfo(pMac, ps11dinfo);
2389 return status;
2390}
2391
Jeff Johnson295189b2012-06-20 16:38:30 -07002392static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2393{
2394 eHalStatus status = eHAL_STATUS_FAILURE;
2395 tANI_U8 index;
2396 tANI_U32 count=0;
2397 tSirMacChanInfo *pChanInfo;
2398 tSirMacChanInfo *pChanInfoStart;
2399 tANI_BOOLEAN applyConfig = TRUE;
2400
Mihir Shetebc866f62014-02-13 16:08:53 +05302401 pMac->scan.currentCountryRSSI = -128;
2402
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 if(!ps11dinfo)
2404 {
2405 return (status);
2406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2408 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302409 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2410 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2411 ps11dinfo->Channels.channelList,
2412 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 }
2414 else
2415 {
2416 //No change
2417 return (eHAL_STATUS_SUCCESS);
2418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302420
2421 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2422 WNI_CFG_COUNTRY_CODE_LEN);
2423
2424
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 //Tush: at csropen get this initialized with default, during csr reset if this
2426 // already set with some value no need initilaize with default again
2427 if(0 == pMac->scan.countryCodeCurrent[0])
2428 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302429 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2430 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302433 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2434 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302436 vos_mem_set(pChanInfo,
2437 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2438 0);
2439
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002441 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2442 {
2443 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2444 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2445 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2446 pChanInfo++;
2447 count++;
2448 }
2449 if(count)
2450 {
2451 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2452 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302453 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002454 }
2455 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2456 if( HAL_STATUS_SUCCESS(status) )
2457 {
2458 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2459 {
2460 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2461 {
2462 applyConfig = FALSE;
2463 }
2464 }
2465
2466 if(TRUE == applyConfig)
2467 {
2468 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002469 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002470 }
2471
2472 }
2473 return (status);
2474}
2475/* Initialize the Channel + Power List in the local cache and in the CFG */
2476eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2477{
2478 tANI_U8 index;
2479 tANI_U32 count=0;
2480 tSirMacChanInfo *pChanInfo;
2481 tSirMacChanInfo *pChanInfoStart;
2482
2483 if(!ps11dinfo || !pMac)
2484 {
2485 return eHAL_STATUS_FAILURE;
2486 }
2487
Kiet Lam64c1b492013-07-12 13:56:44 +05302488 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2489 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002490 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302491 vos_mem_set(pChanInfo,
2492 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2493 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002494 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002495
2496 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2497 {
2498 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2499 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2500 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2501 pChanInfo++;
2502 count++;
2503 }
2504 if(count)
2505 {
2506 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2507 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302508 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
2510
Jeff Johnsone7245742012-09-05 17:12:55 -07002511 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002512}
2513
2514//pCommand may be NULL
2515//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2516void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2517{
2518 tListElem *pEntry, *pNextEntry;
2519 tSmeCmd *pDupCommand;
2520 tDblLinkList localList;
2521
2522 vos_mem_zero(&localList, sizeof(tDblLinkList));
2523 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2524 {
2525 smsLog(pMac, LOGE, FL(" failed to open list"));
2526 return;
2527 }
2528 csrLLLock( &pMac->sme.smeCmdPendingList );
2529 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2530 while( pEntry )
2531 {
2532 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2533 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 // Remove the previous command if..
2535 // - the new roam command is for the same RoamReason...
2536 // - the new roam command is a NewProfileList.
2537 // - the new roam command is a Forced Dissoc
2538 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2539 if (
2540 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2541 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002542 /* This peermac check is requried for Softap/GO scenarios
2543 * For STA scenario below OR check will suffice as pCommand will
2544 * always be NULL for STA scenarios
2545 */
2546 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2548 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2549 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2550 ||
2551 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002552 ( (sessionId == pDupCommand->sessionId) &&
2553 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 ((eCsrForcedDisassoc == eRoamReason) ||
2555 (eCsrHddIssued == eRoamReason))
2556 )
2557 )
2558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002559 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 // Remove the 'stale' roam command from the pending list...
2561 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2562 {
2563 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2564 }
2565 }
2566 pEntry = pNextEntry;
2567 }
2568 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2569
2570 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2571 {
2572 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2573 //Tell caller that the command is cancelled
2574 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2575 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2576 csrReleaseCommandRoam(pMac, pDupCommand);
2577 }
2578 csrLLClose(&localList);
2579}
Jeff Johnson295189b2012-06-20 16:38:30 -07002580eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2581 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2582{
2583 eHalStatus status = eHAL_STATUS_SUCCESS;
2584#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2585 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2586#endif
2587 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2589 {
2590 pSession = CSR_GET_SESSION( pMac, sessionId );
2591 }
2592 else
2593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002594 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 VOS_ASSERT(0);
2596 return eHAL_STATUS_FAILURE;
2597 }
krunal soni587bf012014-02-04 12:35:11 -08002598
2599 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2600 {
2601 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2602 return eHAL_STATUS_FAILURE;
2603 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002604
krunal soni587bf012014-02-04 12:35:11 -08002605 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2606
krunal soni7f7d2c92014-02-06 15:08:43 -08002607 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002609 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002611 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2612 /*
2613 * Decrement bRefAssocStartCnt for FT reassoc failure.
2614 * Reason: For FT reassoc failures, we first call
2615 * csrRoamCallCallback before notifying a failed roam
2616 * completion through csrRoamComplete. The latter in
2617 * turn calls csrRoamProcessResults which tries to
2618 * once again call csrRoamCallCallback if bRefAssocStartCnt
2619 * is non-zero. Since this is redundant for FT reassoc
2620 * failure, decrement bRefAssocStartCnt.
2621 */
2622 pSession->bRefAssocStartCnt--;
2623 }
2624
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 if(NULL != pSession->callback)
2626 {
2627 if( pRoamInfo )
2628 {
2629 pRoamInfo->sessionId = (tANI_U8)sessionId;
2630 }
2631
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302632 /* avoid holding the global lock when making the roaming callback, original change came
2633 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2634 is possible on other OS ports where the callback may need to take locks to protect
2635 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2637 that may actually depend on the lock being held */
2638 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2639 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2640 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2641 }
2642 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2643 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2644#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302645 vos_mem_set(&connectionStatus,
2646 sizeof(vos_event_wlan_status_payload_type), 0);
2647
krunal soni7f7d2c92014-02-06 15:08:43 -08002648 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 {
2650 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2651 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2652 if(NULL != pRoamInfo->pBssDesc)
2653 {
2654 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2655 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2658 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2659 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302660 vos_mem_copy(connectionStatus.ssid,
2661 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2662
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2664 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2667 {
2668 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2669 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2670 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 if(eCSR_ROAM_RESULT_FORCED == u2)
2673 {
2674 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2675 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2676 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2679 {
2680 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2681 connectionStatus.reason = eCSR_REASON_DISASSOC;
2682 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2685 {
2686 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2687 connectionStatus.reason = eCSR_REASON_DEAUTH;
2688 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002690#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2691
2692 return (status);
2693}
Jeff Johnson295189b2012-06-20 16:38:30 -07002694// Returns whether handoff is currently in progress or not
2695tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2696{
2697#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2698 return csrNeighborRoamIsHandoffInProgress(pMac);
2699#else
2700 return eANI_BOOLEAN_FALSE;
2701#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002702}
Jeff Johnson295189b2012-06-20 16:38:30 -07002703eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2704 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2705{
2706 eHalStatus status = eHAL_STATUS_SUCCESS;
2707 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2708 tANI_U16 reasonCode;
2709 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002710
2711 if(!pSession)
2712 {
2713 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2714 return eHAL_STATUS_FAILURE;
2715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002716
2717 //Restore AC weight in case we change it
2718 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2719 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002720 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 -07002721 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2722 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2723 }
2724
2725 if ( fMICFailure )
2726 {
2727 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2728 }
2729 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2730 {
2731 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002732 }
2733 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 {
2735 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002737#ifdef WLAN_FEATURE_VOWIFI_11R
2738 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2739 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2740 {
2741 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302742 vos_mem_copy(&bssId,
2743 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2744 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002745 }
2746 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002747#endif
2748 if(pSession->pConnectBssDesc)
2749 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302750 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002752
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302754 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2755 " subState = %s reason=%d"),
2756 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2757 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002758
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2760
2761 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2762
2763 if(HAL_STATUS_SUCCESS(status))
2764 {
2765 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002766#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2767 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2768 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2769 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002770 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2772 }
2773#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002774 }
2775 else
2776 {
2777 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2778 }
2779
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 return (status);
2781}
Jeff Johnson295189b2012-06-20 16:38:30 -07002782
Jeff Johnson295189b2012-06-20 16:38:30 -07002783/* ---------------------------------------------------------------------------
2784 \fn csrRoamIssueDisassociateStaCmd
2785 \brief csr function that HDD calls to disassociate a associated station
2786 \param sessionId - session Id for Soft AP
2787 \param pPeerMacAddr - MAC of associated station to delete
2788 \param reason - reason code, be one of the tSirMacReasonCodes
2789 \return eHalStatus
2790 ---------------------------------------------------------------------------*/
2791eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2792 tANI_U32 sessionId,
2793 tANI_U8 *pPeerMacAddr,
2794 tANI_U32 reason)
2795{
2796 eHalStatus status = eHAL_STATUS_SUCCESS;
2797 tSmeCmd *pCommand;
2798
2799 do
2800 {
2801 pCommand = csrGetCommandBuffer( pMac );
2802 if ( !pCommand )
2803 {
2804 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2805 status = eHAL_STATUS_RESOURCES;
2806 break;
2807 }
2808 pCommand->command = eSmeCommandRoam;
2809 pCommand->sessionId = (tANI_U8)sessionId;
2810 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2811 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2812 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2813 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2814 if( !HAL_STATUS_SUCCESS( status ) )
2815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002816 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 csrReleaseCommandRoam( pMac, pCommand );
2818 }
2819 }while(0);
2820
2821 return status;
2822}
2823
2824
Jeff Johnson295189b2012-06-20 16:38:30 -07002825/* ---------------------------------------------------------------------------
2826 \fn csrRoamIssueDeauthSta
2827 \brief csr function that HDD calls to delete a associated station
2828 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302829 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 \return eHalStatus
2831 ---------------------------------------------------------------------------*/
2832eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302833 tANI_U32 sessionId,
2834 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002835{
2836 eHalStatus status = eHAL_STATUS_SUCCESS;
2837 tSmeCmd *pCommand;
2838
2839 do
2840 {
2841 pCommand = csrGetCommandBuffer( pMac );
2842 if ( !pCommand )
2843 {
2844 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2845 status = eHAL_STATUS_RESOURCES;
2846 break;
2847 }
2848 pCommand->command = eSmeCommandRoam;
2849 pCommand->sessionId = (tANI_U8)sessionId;
2850 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302851 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2852 sizeof(tSirMacAddr));
2853 pCommand->u.roamCmd.reason =
2854 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2856 if( !HAL_STATUS_SUCCESS( status ) )
2857 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002858 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 csrReleaseCommandRoam( pMac, pCommand );
2860 }
2861 }while(0);
2862
2863 return status;
2864}
Jeff Johnson295189b2012-06-20 16:38:30 -07002865eHalStatus
2866csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2867 tANI_BOOLEAN bEnable )
2868{
2869 eHalStatus status = eHAL_STATUS_FAILURE;
2870 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2871 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 if (!pSession)
2873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002874 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 return (status);
2876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 if (pSession->pConnectBssDesc)
2878 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302879 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 }
2881 else
2882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002883 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 return (status);
2885 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002886 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2887 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2889 return (status);
2890}
Jeff Johnson295189b2012-06-20 16:38:30 -07002891eHalStatus
2892csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2893 VOS_MODULE_ID modId, void *pUsrContext,
2894 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2895{
2896 eHalStatus status = eHAL_STATUS_SUCCESS;
2897 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2898 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 if (!pSession)
2900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002901 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 return (status);
2903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 if(pSession->pConnectBssDesc)
2905 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302906 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 }
2908 else
2909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002910 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 return (status);
2912 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002913 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2914 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2916 return (status);
2917}
Jeff Johnson295189b2012-06-20 16:38:30 -07002918eHalStatus
2919csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2920 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2921{
2922 eHalStatus status = eHAL_STATUS_SUCCESS;
2923 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2924 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2925
2926 if (!pSession)
2927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002928 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 return (status);
2930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 if(pSession->pConnectBssDesc)
2932 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302933 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 }
2935 else
2936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002937 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 return (status);
2939 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002940 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2941 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002942
2943 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2944
2945 return (status);
2946}
Jeff Johnson295189b2012-06-20 16:38:30 -07002947eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2948{
2949 eHalStatus status = eHAL_STATUS_SUCCESS;
2950 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2951 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002952
2953 if (!pSession)
2954 {
2955 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2956 return eHAL_STATUS_FAILURE;
2957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002958
2959 if(pSession->pConnectBssDesc)
2960 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302961 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002963 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2964 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2966
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302967 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302968 if(HAL_STATUS_SUCCESS(status))
2969 {
2970 csrRoamLinkDown(pMac, sessionId);
2971 }
2972 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002973 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302974 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2975 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002976 }
2977
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 return (status);
2979}
2980
Jeff Johnson295189b2012-06-20 16:38:30 -07002981eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2982{
2983 eHalStatus status = eHAL_STATUS_SUCCESS;
2984 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2985 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002986
2987 if(!pSession)
2988 {
2989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2990 return eHAL_STATUS_FAILURE;
2991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002992
2993 // If no BSS description was found in this connection (happens with start IBSS), then
2994 // nix the BSS description that we keep around for the connected BSS) and get out...
2995 if(NULL == pBssDesc)
2996 {
2997 csrFreeConnectBssDesc(pMac, sessionId);
2998 }
2999 else
3000 {
3001 size = pBssDesc->length + sizeof( pBssDesc->length );
3002 if(NULL != pSession->pConnectBssDesc)
3003 {
3004 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3005 {
3006 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3007 csrFreeConnectBssDesc(pMac, sessionId);
3008 }
3009 }
3010 if(NULL == pSession->pConnectBssDesc)
3011 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303012 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003013 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303014 if (NULL == pSession->pConnectBssDesc)
3015 status = eHAL_STATUS_FAILURE;
3016 else
3017 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 return (status);
3020}
3021
Jeff Johnson295189b2012-06-20 16:38:30 -07003022eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3023 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3024 tDot11fBeaconIEs *pIes)
3025{
3026 eHalStatus status = eHAL_STATUS_SUCCESS;
3027 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303029 if (pIes == NULL)
3030 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003031
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 do
3033 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303034 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3035 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 //get qos
3037 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3038 //get SSID
3039 if(pIes->SSID.present)
3040 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303041 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3043 }
3044 else
3045 pBssConfig->SSID.length = 0;
3046 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003048 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 //Return failed if profile doesn't have an SSID either.
3050 if(pProfile->SSIDs.numOfSSIDs == 0)
3051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003052 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 status = eHAL_STATUS_FAILURE;
3054 break;
3055 }
3056 }
3057 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3058 {
3059 pBssConfig->eBand = eCSR_BAND_5G;
3060 }
3061 else
3062 {
3063 pBssConfig->eBand = eCSR_BAND_24;
3064 }
3065 //phymode
3066 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3067 {
3068 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3069 }
3070 else
3071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003072 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 //force it
3074 if(eCSR_BAND_24 == pBssConfig->eBand)
3075 {
3076 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3077 }
3078 else
3079 {
3080 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3081 }
3082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 //Qos
3084 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3085 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3086 {
3087 //Joining BSS is not 11n capable and WMM is disabled on client.
3088 //Disable QoS and WMM
3089 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3090 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303091
3092 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303093 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303094 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3095 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3096 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3097 {
3098 //Joining BSS is 11n capable and WMM is disabled on AP.
3099 //Assume all HT AP's are QOS AP's and enable WMM
3100 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3101 }
3102
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 //auth type
3104 switch( pProfile->negotiatedAuthType )
3105 {
3106 default:
3107 case eCSR_AUTH_TYPE_WPA:
3108 case eCSR_AUTH_TYPE_WPA_PSK:
3109 case eCSR_AUTH_TYPE_WPA_NONE:
3110 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3111 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 case eCSR_AUTH_TYPE_SHARED_KEY:
3114 pBssConfig->authType = eSIR_SHARED_KEY;
3115 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 case eCSR_AUTH_TYPE_AUTOSWITCH:
3117 pBssConfig->authType = eSIR_AUTO_SWITCH;
3118 break;
3119 }
3120 //short slot time
3121 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3122 {
3123 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3124 }
3125 else
3126 {
3127 pBssConfig->uShortSlotTime = 0;
3128 }
3129 if(pBssConfig->BssCap.ibss)
3130 {
3131 //We don't support 11h on IBSS
3132 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3133 }
3134 else
3135 {
3136 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3137 }
3138 //power constraint
3139 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3140 //heartbeat
3141 if ( CSR_IS_11A_BSS( pBssDesc ) )
3142 {
3143 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3144 }
3145 else
3146 {
3147 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3148 }
3149 //Join timeout
3150 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003151 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 if ( pBssDesc->beaconInterval )
3153 {
3154 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003155 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 }
3157 else
3158 {
3159 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3160 }
3161 //validate CB
3162 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303163 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3164 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 return (status);
3167}
3168
Jeff Johnson295189b2012-06-20 16:38:30 -07003169static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3170 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3171{
3172 eHalStatus status = eHAL_STATUS_SUCCESS;
3173 tANI_U8 operationChannel = 0;
3174 tANI_U8 qAPisEnabled = FALSE;
3175 //SSID
3176 pBssConfig->SSID.length = 0;
3177 if(pProfile->SSIDs.numOfSSIDs)
3178 {
3179 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303180 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3181 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 }
3183 else
3184 {
3185 //SSID must present
3186 return eHAL_STATUS_FAILURE;
3187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 //Settomg up the capabilities
3189 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3190 {
3191 pBssConfig->BssCap.ibss = 1;
3192 }
3193 else
3194 {
3195 pBssConfig->BssCap.ess = 1;
3196 }
3197 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3198 {
3199 pBssConfig->BssCap.privacy = 1;
3200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 pBssConfig->eBand = pMac->roam.configParam.eBand;
3202 //phymode
3203 if(pProfile->ChannelInfo.ChannelList)
3204 {
3205 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3208 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 //QOS
3210 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 if ( pBssConfig->BssCap.ess == 1 )
3212 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 /*For Softap case enable WMM*/
3214 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3215 qAPisEnabled = TRUE;
3216 }
3217 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3219 qAPisEnabled = TRUE;
3220 } else {
3221 qAPisEnabled = FALSE;
3222 }
3223 } else {
3224 qAPisEnabled = TRUE;
3225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3227 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3228 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3229 )
3230 {
3231 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3232 } else {
3233 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3234 }
3235
3236 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003237 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 {
3239 default:
3240 case eCSR_AUTH_TYPE_WPA:
3241 case eCSR_AUTH_TYPE_WPA_PSK:
3242 case eCSR_AUTH_TYPE_WPA_NONE:
3243 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3244 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3245 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 case eCSR_AUTH_TYPE_SHARED_KEY:
3247 pBssConfig->authType = eSIR_SHARED_KEY;
3248 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 case eCSR_AUTH_TYPE_AUTOSWITCH:
3250 pBssConfig->authType = eSIR_AUTO_SWITCH;
3251 break;
3252 }
3253 //short slot time
3254 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3255 {
3256 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3257 }
3258 else
3259 {
3260 pBssConfig->uShortSlotTime = 0;
3261 }
3262 //power constraint. We don't support 11h on IBSS
3263 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3264 pBssConfig->uPowerLimit = 0;
3265 //heartbeat
3266 if ( eCSR_BAND_5G == pBssConfig->eBand )
3267 {
3268 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3269 }
3270 else
3271 {
3272 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3273 }
3274 //Join timeout
3275 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003276
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 return (status);
3278}
Jeff Johnson295189b2012-06-20 16:38:30 -07003279static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3280{
3281 eHalStatus status = eHAL_STATUS_FAILURE;
3282 tDot11fBeaconIEs *pIes = NULL;
3283
3284 do
3285 {
3286 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3287 {
3288 //err msg
3289 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003290 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 break;
3292 }
3293 //check if the AP is QAP & it supports APSD
3294 if( CSR_IS_QOS_BSS(pIes) )
3295 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303296 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 }
3298 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303299
3300 if (NULL != pIes)
3301 {
3302 vos_mem_free(pIes);
3303 }
3304
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 return status;
3306}
3307
Jeff Johnson295189b2012-06-20 16:38:30 -07003308void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3309{
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3311 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3312 // See !!Note: below in this function...
3313 tANI_U32 PrivacyEnabled = 0;
3314 tANI_U32 RsnEnabled = 0;
3315 tANI_U32 WepDefaultKeyId = 0;
3316 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3317 tANI_U32 Key0Length = 0;
3318 tANI_U32 Key1Length = 0;
3319 tANI_U32 Key2Length = 0;
3320 tANI_U32 Key3Length = 0;
3321
3322 // Reserve for the biggest key
3323 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3324 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3325 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3326 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3327
3328 switch ( pProfile->negotiatedUCEncryptionType )
3329 {
3330 case eCSR_ENCRYPT_TYPE_NONE:
3331
3332 // for NO encryption, turn off Privacy and Rsn.
3333 PrivacyEnabled = 0;
3334 RsnEnabled = 0;
3335
3336 // WEP key length and Wep Default Key ID don't matter in this case....
3337
3338 // clear out the WEP keys that may be hanging around.
3339 Key0Length = 0;
3340 Key1Length = 0;
3341 Key2Length = 0;
3342 Key3Length = 0;
3343
3344 break;
3345
3346 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303347 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
3349 // Privacy is ON. NO RSN for Wep40 static key.
3350 PrivacyEnabled = 1;
3351 RsnEnabled = 0;
3352
3353 // Set the Wep default key ID.
3354 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 // Wep key size if 5 bytes (40 bits).
3356 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3357
3358 // set encryption keys in the CFG database or clear those that are not present in this profile.
3359 if ( pProfile->Keys.KeyLength[0] )
3360 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303361 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3362 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3364 }
3365 else
3366 {
3367 Key0Length = 0;
3368 }
3369
3370 if ( pProfile->Keys.KeyLength[1] )
3371 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303372 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3373 WNI_CFG_WEP_KEY_LENGTH_5);
3374 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 }
3376 else
3377 {
3378 Key1Length = 0;
3379 }
3380
3381 if ( pProfile->Keys.KeyLength[2] )
3382 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303383 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3384 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3386 }
3387 else
3388 {
3389 Key2Length = 0;
3390 }
3391
3392 if ( pProfile->Keys.KeyLength[3] )
3393 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303394 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3395 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3397 }
3398 else
3399 {
3400 Key3Length = 0;
3401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 break;
3403
3404 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303405 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003406
3407 // Privacy is ON. NO RSN for Wep40 static key.
3408 PrivacyEnabled = 1;
3409 RsnEnabled = 0;
3410
3411 // Set the Wep default key ID.
3412 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3413
3414 // Wep key size if 13 bytes (104 bits).
3415 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3416
3417 // set encryption keys in the CFG database or clear those that are not present in this profile.
3418 if ( pProfile->Keys.KeyLength[0] )
3419 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303420 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3421 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3423 }
3424 else
3425 {
3426 Key0Length = 0;
3427 }
3428
3429 if ( pProfile->Keys.KeyLength[1] )
3430 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303431 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3432 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3434 }
3435 else
3436 {
3437 Key1Length = 0;
3438 }
3439
3440 if ( pProfile->Keys.KeyLength[2] )
3441 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303442 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3443 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3445 }
3446 else
3447 {
3448 Key2Length = 0;
3449 }
3450
3451 if ( pProfile->Keys.KeyLength[3] )
3452 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303453 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3454 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3456 }
3457 else
3458 {
3459 Key3Length = 0;
3460 }
3461
3462 break;
3463
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 case eCSR_ENCRYPT_TYPE_TKIP:
3465 case eCSR_ENCRYPT_TYPE_AES:
3466#ifdef FEATURE_WLAN_WAPI
3467 case eCSR_ENCRYPT_TYPE_WPI:
3468#endif /* FEATURE_WLAN_WAPI */
3469 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3470 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3471 PrivacyEnabled = (0 != fPrivacy);
3472
3473 // turn on RSN enabled for WPA associations
3474 RsnEnabled = 1;
3475
3476 // WEP key length and Wep Default Key ID don't matter in this case....
3477
3478 // clear out the static WEP keys that may be hanging around.
3479 Key0Length = 0;
3480 Key1Length = 0;
3481 Key2Length = 0;
3482 Key3Length = 0;
3483
3484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 default:
3486 PrivacyEnabled = 0;
3487 RsnEnabled = 0;
3488 break;
3489 }
3490
3491 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3492 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3493 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3494 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3495 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3496 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3497 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3498 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3499}
3500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3502{
3503 tANI_U32 len = 0;
3504 if(pSSID->length <= WNI_CFG_SSID_LEN)
3505 {
3506 len = pSSID->length;
3507 }
3508 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3509}
3510
Jeff Johnson295189b2012-06-20 16:38:30 -07003511eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3512{
3513 eHalStatus status = eHAL_STATUS_SUCCESS;
3514 tANI_U32 QoSEnabled;
3515 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 // set the CFG enable/disable variables based on the qosType being configured...
3517 switch( qosType )
3518 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3520 QoSEnabled = FALSE;
3521 WmeEnabled = TRUE;
3522 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3524 QoSEnabled = FALSE;
3525 WmeEnabled = TRUE;
3526 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3528 QoSEnabled = FALSE;
3529 WmeEnabled = TRUE;
3530 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3532 QoSEnabled = TRUE;
3533 WmeEnabled = FALSE;
3534 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 case eCSR_MEDIUM_ACCESS_11e_HCF:
3536 QoSEnabled = TRUE;
3537 WmeEnabled = FALSE;
3538 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 default:
3540 case eCSR_MEDIUM_ACCESS_DCF:
3541 QoSEnabled = FALSE;
3542 WmeEnabled = FALSE;
3543 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 }
3545 //save the WMM setting for later use
3546 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303547 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 return (status);
3549}
Jeff Johnson295189b2012-06-20 16:38:30 -07003550static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303551 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003552{
3553 eHalStatus status = eHAL_STATUS_FAILURE;
3554 int i;
3555 eCsrCfgDot11Mode cfgDot11Mode;
3556 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303557 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303558 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3559 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003561
3562 if( NULL != pIes )
3563 {
3564 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 // Originally, we thought that for 11a networks, the 11a rates are always
3566 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3567 // appear in the Operational Rate set. Consequently, in either case, we
3568 // would blindly put the rates we support into our Operational Rate set
3569 // (including the basic rates, which we have already verified are
3570 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 // However, it turns out that this is not always the case. Some AP's
3572 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3573 // too. Now, we're a little more careful:
3574 pDstRate = pOpRateSet->rate;
3575 if(pIes->SuppRates.present)
3576 {
3577 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3578 {
3579 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3580 {
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303581 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003583 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 }
3585 }
3586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3588 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3589 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
Masti, Narayanraddia51f7882015-03-31 11:05:48 +05303590 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode ||
3591#ifdef WLAN_FEATURE_11AC
3592 eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode
3593#endif
3594 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 {
3596 // If there are Extended Rates in the beacon, we will reflect those
3597 // extended rates that we support in out Extended Operational Rate
3598 // set:
3599 pDstRate = pExRateSet->rate;
3600 if(pIes->ExtSuppRates.present)
3601 {
3602 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3603 {
3604 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3605 {
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303606 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[ i ], rateBitmap))
3607 {
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303608 csrAddRateBitmap(pIes->ExtSuppRates.rates[ i ], &rateBitmap);
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303609 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3610 pExRateSet->numRates++;
3611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 }
3613 }
3614 }
3615 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303616 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 }//Parsing BSSDesc
3618 else
3619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003620 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 }
3622 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3623 return status;
3624}
3625
3626static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3627 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3628{
3629 int i;
3630 tANI_U8 *pDstRate;
3631 eCsrCfgDot11Mode cfgDot11Mode;
3632 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3633 tANI_U32 OperationalRatesLength = 0;
3634 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3635 tANI_U32 ExtendedOperationalRatesLength = 0;
3636 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3637 tANI_U32 ProprietaryOperationalRatesLength = 0;
3638 tANI_U32 PropRatesEnable = 0;
3639 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3640 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 if( NULL != pIes )
3643 {
3644 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 // Originally, we thought that for 11a networks, the 11a rates are always
3646 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3647 // appear in the Operational Rate set. Consequently, in either case, we
3648 // would blindly put the rates we support into our Operational Rate set
3649 // (including the basic rates, which we have already verified are
3650 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 // However, it turns out that this is not always the case. Some AP's
3652 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3653 // too. Now, we're a little more careful:
3654 pDstRate = OperationalRates;
3655 if(pIes->SuppRates.present)
3656 {
3657 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3658 {
3659 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3660 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3661 {
3662 *pDstRate++ = pIes->SuppRates.rates[ i ];
3663 OperationalRatesLength++;
3664 }
3665 }
3666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3668 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3669 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3670 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3671 {
3672 // If there are Extended Rates in the beacon, we will reflect those
3673 // extended rates that we support in out Extended Operational Rate
3674 // set:
3675 pDstRate = ExtendedOperationalRates;
3676 if(pIes->ExtSuppRates.present)
3677 {
3678 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3679 {
3680 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3681 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3682 {
3683 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3684 ExtendedOperationalRatesLength++;
3685 }
3686 }
3687 }
3688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 // Enable proprietary MAC features if peer node is Airgo node and STA
3690 // user wants to use them
3691 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3692 {
3693 PropRatesEnable = 1;
3694 }
3695 else
3696 {
3697 PropRatesEnable = 0;
3698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 // For ANI network companions, we need to populate the proprietary rate
3700 // set with any proprietary rates we found in the beacon, only if user
3701 // allows them...
3702 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3703 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3704 {
3705 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3706 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3707 {
3708 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3709 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303710 vos_mem_copy(ProprietaryOperationalRates,
3711 pIes->Airgo.PropSuppRates.rates,
3712 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 }
3714 else {
3715 // No proprietary modes...
3716 ProprietaryOperationalRatesLength = 0;
3717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 /* Get MCS Rate */
3719 pDstRate = MCSRateIdxSet;
3720 if ( pIes->HTCaps.present )
3721 {
3722 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3723 {
3724 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3725 {
3726 MCSRateLength++;
3727 *pDstRate++ = i;
3728 }
3729 }
3730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 // Set the operational rate set CFG variables...
3732 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3733 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3734 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3735 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3736 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3737 ProprietaryOperationalRates,
3738 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3739 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3740 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3741 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3742 }//Parsing BSSDesc
3743 else
3744 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003745 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 }
3747}
3748
Jeff Johnson295189b2012-06-20 16:38:30 -07003749static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3750 tCsrRoamProfile *pProfile )
3751{
3752 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3753 { 8,
3754 { SIR_MAC_RATE_6,
3755 SIR_MAC_RATE_9,
3756 SIR_MAC_RATE_12,
3757 SIR_MAC_RATE_18,
3758 SIR_MAC_RATE_24,
3759 SIR_MAC_RATE_36,
3760 SIR_MAC_RATE_48,
3761 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3763 { 4,
3764 { SIR_MAC_RATE_1,
3765 SIR_MAC_RATE_2,
3766 SIR_MAC_RATE_5_5,
3767 SIR_MAC_RATE_11 } } };
3768
3769
3770 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3771 { SIR_MAC_RATE_72,
3772 SIR_MAC_RATE_96,
3773 SIR_MAC_RATE_108 } };
3774 eCsrCfgDot11Mode cfgDot11Mode;
3775 eCsrBand eBand;
3776 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3777 tANI_U32 OperationalRatesLength = 0;
3778 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3779 tANI_U32 ExtendedOperationalRatesLength = 0;
3780 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3781 tANI_U32 ProprietaryOperationalRatesLength = 0;
3782 tANI_U32 PropRatesEnable = 0;
3783 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 if(pProfile->ChannelInfo.ChannelList)
3785 {
3786 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3790 // networks, the 11b rates appear in the Operational Rate set. In either case,
3791 // we can blindly put the rates we support into our Operational Rate set
3792 // (including the basic rates, which we have already verified are supported
3793 // earlier in the roaming decision).
3794 if ( eCSR_BAND_5G == eBand )
3795 {
3796 // 11a rates into the Operational Rate Set.
3797 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3798 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303799 vos_mem_copy(OperationalRates,
3800 DefaultSupportedRates11a.supportedRateSet.rate,
3801 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003802
3803 // Nothing in the Extended rate set.
3804 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 // populate proprietary rates if user allows them
3806 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3807 {
3808 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3809 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303810 vos_mem_copy(ProprietaryOperationalRates,
3811 DefaultSupportedPropRates.propRate,
3812 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 }
3814 else
3815 {
3816 // No proprietary modes
3817 ProprietaryOperationalRatesLength = 0;
3818 }
3819 }
3820 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3821 {
3822 // 11b rates into the Operational Rate Set.
3823 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3824 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303825 vos_mem_copy(OperationalRates,
3826 DefaultSupportedRates11b.supportedRateSet.rate,
3827 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 // Nothing in the Extended rate set.
3829 ExtendedOperationalRatesLength = 0;
3830 // No proprietary modes
3831 ProprietaryOperationalRatesLength = 0;
3832 }
3833 else
3834 {
3835 // 11G
3836
3837 // 11b rates into the Operational Rate Set.
3838 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3839 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303840 vos_mem_copy(OperationalRates,
3841 DefaultSupportedRates11b.supportedRateSet.rate,
3842 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003843
3844 // 11a rates go in the Extended rate set.
3845 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3846 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303847 vos_mem_copy(ExtendedOperationalRates,
3848 DefaultSupportedRates11a.supportedRateSet.rate,
3849 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003850
3851 // populate proprietary rates if user allows them
3852 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3853 {
3854 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3855 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303856 vos_mem_copy(ProprietaryOperationalRates,
3857 DefaultSupportedPropRates.propRate,
3858 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 }
3860 else
3861 {
3862 // No proprietary modes
3863 ProprietaryOperationalRatesLength = 0;
3864 }
3865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3867 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3868 {
3869 PropRatesEnable = 1;
3870 }
3871 else
3872 {
3873 PropRatesEnable = 0;
3874 }
3875
3876 // Set the operational rate set CFG variables...
3877 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3878 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3879 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3880 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3881 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3882 ProprietaryOperationalRates,
3883 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3884 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003885}
Jeff Johnson295189b2012-06-20 16:38:30 -07003886void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3887{
3888 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003889
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3891 tANI_U32 sessionId;
3892 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 if(NULL == pEntry)
3894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003895 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 return;
3897 }
3898 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3899 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303900 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3901 " current state : %d sub state : %d "),
3902 result, pMac->roam.curState[sessionId],
3903 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3905 {
3906 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3907 }
3908}
3909
Jeff Johnson295189b2012-06-20 16:38:30 -07003910//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3911tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3912{
3913 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3914 {
3915 return (WNI_CFG_PHY_MODE_11B);
3916 }
3917 else
3918 {
3919 if(eCSR_BAND_24 == band)
3920 return (WNI_CFG_PHY_MODE_11G);
3921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 return (WNI_CFG_PHY_MODE_11A);
3923}
Jeff Johnson295189b2012-06-20 16:38:30 -07003924
Jeff Johnsone7245742012-09-05 17:12:55 -07003925
3926#ifdef WLAN_FEATURE_11AC
3927ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3928{
3929 switch ( aniCBMode )
3930 {
3931 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3932 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3933 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3934 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3935 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3936 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3937 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3938 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3939 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003940 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003941 return PHY_SINGLE_CHANNEL_CENTERED;
3942 }
3943}
3944#endif
3945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946//pIes may be NULL
3947eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3948 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303949 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003950{
3951 eHalStatus status = eHAL_STATUS_SUCCESS;
3952 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3953 tANI_U8 channel = 0;
3954 //Make sure we have the domain info for the BSS we try to connect to.
3955 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303956 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303958 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 {
3960 //Make sure the 11d info from this BSSDesc can be applied
3961 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303962 if (VOS_TRUE == resetCountry)
3963 {
3964 csrApplyCountryInformation(pMac, FALSE);
3965 }
3966 else
3967 {
3968 csrApplyCountryInformation(pMac, TRUE);
3969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
Kiran4a17ebe2013-01-31 10:43:43 -08003971 if ((csrIs11dSupported (pMac)) && pIes)
3972 {
3973 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003974 {
Kiran4a17ebe2013-01-31 10:43:43 -08003975 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003976 }
3977 else
3978 {
3979 //Let's also update the below to make sure we don't update CC while
3980 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303981 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003982 pBssDesc->bssId, sizeof(tSirMacAddr));
3983 }
Kiran4a17ebe2013-01-31 10:43:43 -08003984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 //Qos
3987 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3988 //SSID
3989 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3990 //fragment threshold
3991 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3992 //RTS threshold
3993 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3994
3995 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 //Auth type
3997 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3998 //encryption type
3999 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4000 //short slot time
4001 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 //11d
4003 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4004 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4005 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 /*//11h
4007 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4008 */
4009 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4010 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004011
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004012 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 {
4014 channel = pProfile->operationChannel;
4015 }
4016 else
4017 {
4018 if(pBssDesc)
4019 {
4020 channel = pBssDesc->channelId;
4021 }
4022 }
4023 if(0 != channel)
4024 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304025 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4026 !pMac->roam.configParam.channelBondingMode24GHz &&
4027 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4028 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304030 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4031 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4032 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }
4034 else
4035 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004036 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 }
4038 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004039#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004040 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4041 // in function csrConvertCBIniValueToPhyCBState()
4042 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4043 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004044 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004045 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004046 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004047 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304048 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004049 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004050 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004051 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004052 }
4053 else
4054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4056 //Rate
4057 //Fixed Rate
4058 if(pBssDesc)
4059 {
4060 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4061 }
4062 else
4063 {
4064 csrSetCfgRateSetFromProfile(pMac, pProfile);
4065 }
4066 //Make this the last CFG to set. The callback will trigger a join_req
4067 //Join time out
4068 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4069
4070 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 return (status);
4072}
4073
Jeff Johnson295189b2012-06-20 16:38:30 -07004074eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4075 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4076{
4077 eHalStatus status;
4078 tBssConfigParam *pBssConfig;
4079 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004080
4081 if(!pSession)
4082 {
4083 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4084 return eHAL_STATUS_FAILURE;
4085 }
4086
Kiet Lam64c1b492013-07-12 13:56:44 +05304087 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4088 if ( NULL == pBssConfig )
4089 status = eHAL_STATUS_FAILURE;
4090 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304092 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4094 if(HAL_STATUS_SUCCESS(status))
4095 {
4096 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004097 /* This will allow to pass cbMode during join req */
4098 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 //For IBSS, we need to prepare some more information
4100 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 )
4103 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004104 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 }
4106 // If we are in an IBSS, then stop the IBSS...
4107 ////Not worry about WDS connection for now
4108 if ( csrIsConnStateIbss( pMac, sessionId ) )
4109 {
4110 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4111 }
4112 else
4113 {
4114 // if we are in an Infrastructure association....
4115 if ( csrIsConnStateInfra( pMac, sessionId ) )
4116 {
4117 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4118 // across SSIDs (roaming to a new SSID)... //
4119 //Not worry about WDS connection for now
4120 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304121 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 {
4123 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304124 status = csrRoamIssueDisassociate( pMac, sessionId,
4125 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304127 else
4128 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4130 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304131 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304133 // Set parameters for this Bss.
4134 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4135 pBssDesc, pBssConfig,
4136 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304140 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 {
4142 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4143 // Nothing to stop.
4144 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304146 )
4147 {
4148 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4149 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4150 // Set parameters for this Bss.
4151 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4152 pBssDesc, pBssConfig,
4153 pIes, is11rRoamingFlag);
4154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 }
4156 }
4157 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304158 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 return (status);
4161}
4162
Jeff Johnson295189b2012-06-20 16:38:30 -07004163eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4164 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4165{
4166 eCsrJoinState eRoamState = eCsrContinueRoaming;
4167 eHalStatus status;
4168 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4169 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4170 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004171
4172 if(!pSession)
4173 {
4174 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4175 return (eCsrStopRoaming);
4176 }
4177
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 if( CSR_IS_WDS_STA( pProfile ) )
4179 {
4180 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4181 if( !HAL_STATUS_SUCCESS( status ) )
4182 {
4183 eRoamState = eCsrStopRoaming;
4184 }
4185 }
4186 else
4187 {
4188 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4189 {
4190 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4191 return (eCsrStopRoaming);
4192 }
4193 if ( csrIsInfraBssDesc( pBssDesc ) )
4194 {
4195 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4196 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4197 // have changed and handle the changes (without disturbing the current association).
4198
4199 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4200 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4201 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4202 )
4203 {
4204 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4205 // with Authenticating first. To force this, stop the current association (Disassociate) and
4206 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4207 // a new Association.
4208 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4209 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004210 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4212 {
4213 eRoamState = eCsrReassocToSelfNoCapChange;
4214 }
4215 else
4216 {
4217 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304219 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4221 if(HAL_STATUS_SUCCESS(status))
4222 {
4223 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004224 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304226 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4227 pBssDesc, &bssConfig,
4228 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 if(!HAL_STATUS_SUCCESS(status))
4230 {
4231 eRoamState = eCsrStopRoaming;
4232 }
4233 }
4234 else
4235 {
4236 eRoamState = eCsrStopRoaming;
4237 }
4238 }//same profile
4239 }
4240 else
4241 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304242 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4244 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304245 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4246 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304250 }
4251 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 {
4253 // 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 -07004254 // stop the existing network before attempting to join the new network...
4255 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4256 {
4257 eRoamState = eCsrStopRoaming;
4258 }
4259 }
4260 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304261 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 {
4263 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4264 {
4265 eRoamState = eCsrStopRoaming;
4266 }
4267 }
4268 if( pIesLocal && !pScanResult->pvIes )
4269 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304270 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 }
4272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 return( eRoamState );
4274}
4275
Jeff Johnson295189b2012-06-20 16:38:30 -07004276eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4277 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4278{
4279 eHalStatus status = eHAL_STATUS_SUCCESS;
4280 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304281 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 roamInfo.pBssDesc = pBssDesc;
4283 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4284 return (status);
4285}
Jeff Johnson295189b2012-06-20 16:38:30 -07004286//In case no matching BSS is found, use whatever default we can find
4287static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4288{
4289 //Need to get all negotiated types in place first
4290 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004291 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 {
4293 default:
4294 case eCSR_AUTH_TYPE_WPA:
4295 case eCSR_AUTH_TYPE_WPA_PSK:
4296 case eCSR_AUTH_TYPE_WPA_NONE:
4297 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4298 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4299 break;
4300
4301 case eCSR_AUTH_TYPE_SHARED_KEY:
4302 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4303 break;
4304
4305 case eCSR_AUTH_TYPE_AUTOSWITCH:
4306 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4307 break;
4308 }
4309 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4310 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4311 //In this case, the multicast encryption needs to follow the uncast ones.
4312 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4313 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4314}
4315
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004316
4317static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4318{
4319 switch(pCommand->u.roamCmd.roamReason)
4320 {
4321 case eCsrLostLink1:
4322 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4323 break;
4324 case eCsrLostLink2:
4325 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4326 break;
4327 case eCsrLostLink3:
4328 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4329 break;
4330 default:
4331 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4332 pCommand->u.roamCmd.roamReason);
4333 break;
4334 }
4335}
4336
Jeff Johnson295189b2012-06-20 16:38:30 -07004337static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4338{
4339 eHalStatus status;
4340 tCsrScanResult *pScanResult = NULL;
4341 eCsrJoinState eRoamState = eCsrStopRoaming;
4342 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4343 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4344 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4345#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4346 v_U8_t acm_mask = 0;
4347#endif
4348 tANI_U32 sessionId = pCommand->sessionId;
4349 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4350 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4351 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004352
4353 if(!pSession)
4354 {
4355 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4356 return (eCsrStopRoaming);
4357 }
4358
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 do
4360 {
4361 // Check for Cardbus eject condition, before trying to Roam to any BSS
4362 //***if( !balIsCardPresent(pAdapter) ) break;
4363
Kiet Lam64c1b492013-07-12 13:56:44 +05304364 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304365 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 if(NULL != pBSSList)
4367 {
4368 // When handling AP's capability change, continue to associate to
4369 // same BSS and make sure pRoamBssEntry is not Null.
4370 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4371 {
4372 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4373 {
4374 //Try the first BSS
4375 pCommand->u.roamCmd.pLastRoamBss = NULL;
4376 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4377 }
4378 else
4379 {
4380 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4381 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4382 {
4383 //Done with all the BSSs
4384 //In this case, will tell HDD the completion
4385 break;
4386 }
4387 else
4388 {
4389 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304390 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4392 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4393 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4394 pRoamInfo = &roamInfo;
4395 }
4396 }
4397 while(pCommand->u.roamCmd.pRoamBssEntry)
4398 {
4399 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 /*If concurrency enabled take the concurrent connected channel first. */
4401 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304402 if (vos_concurrent_open_sessions_running() &&
4403 !csrIsValidMcConcurrentSession(pMac, sessionId,
4404 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 {
4406 concurrentChannel =
4407 csrGetConcurrentOperationChannel(pMac);
4408 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004409 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 if ((concurrentChannel) &&
4411 (concurrentChannel ==
4412 pScanResult->Result.BssDescriptor.channelId))
4413 {
4414 //make this 0 because we do not want the
4415 //below check to pass as we don't want to
4416 //connect on other channel
4417 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4418 FL("Concurrent channel match =%d"),
4419 concurrentChannel);
4420 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 }
4422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004423
4424 if (!concurrentChannel)
4425 {
4426
4427 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4428 sessionId, &pScanResult->Result.BssDescriptor,
4429 pCommand->u.roamCmd.roamId)))
4430 {
4431 //Ok to roam this
4432 break;
4433 }
4434 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004435 else
4436 {
4437 eRoamState = eCsrStopRoamingDueToConcurrency;
4438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4440 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4441 {
4442 //Done with all the BSSs
4443 fDone = eANI_BOOLEAN_TRUE;
4444 break;
4445 }
4446 }
4447 if(fDone)
4448 {
4449 break;
4450 }
4451 }
4452 }
4453 //We have something to roam, tell HDD when it is infra.
4454 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4455 //For WDS, the indication is eCSR_ROAM_WDS_IND
4456 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4457 {
4458 if(pRoamInfo)
4459 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004460 if(pSession->bRefAssocStartCnt)
4461 {
4462 pSession->bRefAssocStartCnt--;
4463 //Complete the last association attemp because a new one is about to be tried
4464 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4465 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004467 }
4468 }
4469 /* If the roaming has stopped, not to continue the roaming command*/
4470 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4471 {
4472 //No need to complete roaming here as it already completes
4473 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4474 pCommand->u.roamCmd.roamReason);
4475 eRoamState = eCsrStopRoaming;
4476 csrSetAbortRoamingCommand(pMac, pCommand);
4477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304479 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 if(pScanResult)
4481 {
4482 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004485 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 fDone = eANI_BOOLEAN_TRUE;
4487 eRoamState = eCsrStopRoaming;
4488 break;
4489 }
4490 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4491 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4492 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4493 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4494 CSR_IS_QOS_BSS(pIesLocal) &&
4495 CSR_IS_UAPSD_BSS(pIesLocal) )
4496 {
4497#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4499 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004500#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 }
4502 else
4503 {
4504 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4505 }
4506 if( pIesLocal && !pScanResult->Result.pvIes)
4507 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304508 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 }
4510 }
4511 else
4512 {
4513 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4514 }
4515 roamInfo.pProfile = pProfile;
4516 pSession->bRefAssocStartCnt++;
4517 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4518 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4521 {
4522 // If this is a start IBSS profile, then we need to start the IBSS.
4523 if ( CSR_IS_START_IBSS(pProfile) )
4524 {
4525 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 // Attempt to start this IBSS...
4527 csrRoamAssignDefaultParam( pMac, pCommand );
4528 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4529 if(HAL_STATUS_SUCCESS(status))
4530 {
4531 if ( fSameIbss )
4532 {
4533 eRoamState = eCsrStartIbssSameIbss;
4534 }
4535 else
4536 {
4537 eRoamState = eCsrContinueRoaming;
4538 }
4539 }
4540 else
4541 {
4542 //it somehow fail need to stop
4543 eRoamState = eCsrStopRoaming;
4544 }
4545 break;
4546 }
4547 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 )
4550 {
4551 // Attempt to start this WDS...
4552 csrRoamAssignDefaultParam( pMac, pCommand );
4553 /* For AP WDS, we dont have any BSSDescription */
4554 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4555 if(HAL_STATUS_SUCCESS(status))
4556 {
4557 eRoamState = eCsrContinueRoaming;
4558 }
4559 else
4560 {
4561 //it somehow fail need to stop
4562 eRoamState = eCsrStopRoaming;
4563 }
4564 }
4565 else
4566 {
4567 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004568 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 eRoamState = eCsrStopRoaming;
4570 break;
4571 }
4572 }
4573 else //We have BSS
4574 {
4575 //Need to assign these value because they are used in csrIsSameProfile
4576 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004577 /* The OSEN IE doesn't provide the cipher suite.
4578 * Therefore set to constant value of AES */
4579 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4580 {
4581 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4582 eCSR_ENCRYPT_TYPE_AES;
4583 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4584 eCSR_ENCRYPT_TYPE_AES;
4585 }
4586 else
4587 {
4588 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4589 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4590 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4591 pScanResult->mcEncryptionType;
4592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4594 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4595 {
4596 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4597 {
4598 eRoamState = eCsrStartIbssSameIbss;
4599 break;
4600 }
4601 }
4602 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4603 {
4604 //trying to connect to the one already connected
4605 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4606 eRoamState = eCsrReassocToSelfNoCapChange;
4607 break;
4608 }
4609 // Attempt to Join this Bss...
4610 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4611 break;
4612 }
4613
4614 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4616 {
4617 //Need to indicate association_completion if association_start has been done
4618 if(pSession->bRefAssocStartCnt > 0)
4619 {
4620 pSession->bRefAssocStartCnt--;
4621 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004622 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4624 eCSR_ROAM_ASSOCIATION_COMPLETION,
4625 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4626 }
4627 }
4628
4629 return( eRoamState );
4630}
4631
Jeff Johnson295189b2012-06-20 16:38:30 -07004632static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4633{
4634 eHalStatus status = eHAL_STATUS_SUCCESS;
4635 eCsrJoinState RoamState;
4636 tANI_U32 sessionId = pCommand->sessionId;
4637
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 //***if( hddIsRadioStateOn( pAdapter ) )
4639 {
4640 // Attept to join a Bss...
4641 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004642
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004644 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 {
4646 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 // and if connected in Infrastructure mode...
4648 if ( csrIsConnStateInfra(pMac, sessionId) )
4649 {
4650 //... then we need to issue a disassociation
4651 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4652 if(!HAL_STATUS_SUCCESS(status))
4653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004654 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 //roam command is completed by caller in the failed case
4656 fComplete = eANI_BOOLEAN_TRUE;
4657 }
4658 }
4659 else if( csrIsConnStateIbss(pMac, sessionId) )
4660 {
4661 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4662 if(!HAL_STATUS_SUCCESS(status))
4663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004664 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 //roam command is completed by caller in the failed case
4666 fComplete = eANI_BOOLEAN_TRUE;
4667 }
4668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4670 {
4671 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4672 if(!HAL_STATUS_SUCCESS(status))
4673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004674 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 //roam command is completed by caller in the failed case
4676 fComplete = eANI_BOOLEAN_TRUE;
4677 }
4678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 else
4680 {
4681 fComplete = eANI_BOOLEAN_TRUE;
4682 }
4683 if(fComplete)
4684 {
4685 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004686 if(eCsrStopRoamingDueToConcurrency == RoamState)
4687 {
4688 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4689 }
4690 else
4691 {
4692 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 }
4695 }
4696 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4697 {
4698 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4699 }
4700 else if ( eCsrStartIbssSameIbss == RoamState )
4701 {
4702 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4703 }
4704 }//hddIsRadioStateOn
4705
4706 return status;
4707}
Jeff Johnson295189b2012-06-20 16:38:30 -07004708eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4709{
4710 tANI_U32 sessionId;
4711 tCsrRoamSession *pSession;
4712 tCsrScanResult *pScanResult = NULL;
4713 tSirBssDescription *pBssDesc = NULL;
4714 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 sessionId = pCommand->sessionId;
4716 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004717
4718 if(!pSession)
4719 {
4720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4721 return eHAL_STATUS_FAILURE;
4722 }
4723
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4725 {
4726 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004727 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4729 return eHAL_STATUS_FAILURE;
4730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 if (pCommand->u.roamCmd.pRoamBssEntry)
4732 {
4733 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4734 pBssDesc = &pScanResult->Result.BssDescriptor;
4735 }
4736 else
4737 {
4738 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004739 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4741 return eHAL_STATUS_FAILURE;
4742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4744 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4745 return status;
4746}
4747
Jeff Johnson295189b2012-06-20 16:38:30 -07004748eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4749{
4750 eHalStatus status = eHAL_STATUS_SUCCESS;
4751 tCsrRoamInfo roamInfo;
4752 tANI_U32 sessionId = pCommand->sessionId;
4753 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004754
4755 if(!pSession)
4756 {
4757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4758 return eHAL_STATUS_FAILURE;
4759 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304760 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
4761 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 switch ( pCommand->u.roamCmd.roamReason )
4763 {
4764 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004766 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 case eCsrSmeIssuedDisassocForHandoff:
4769 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4770#if 0 // TODO : Confirm this change
4771 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4772#else
4773 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4774#endif
4775
4776 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004779 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004783 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 case eCsrHddIssuedReassocToSameAP:
4786 case eCsrSmeIssuedReassocToSameAP:
4787 {
4788 tDot11fBeaconIEs *pIes = NULL;
4789
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 if( pSession->pConnectBssDesc )
4791 {
4792 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4793 if(!HAL_STATUS_SUCCESS(status) )
4794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004795 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 }
4797 else
4798 {
4799 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4800 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4801 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4803 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4804 pSession->bRefAssocStartCnt++;
4805 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4806 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4807
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004808 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004809 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4810 &pCommand->u.roamCmd.roamProfile );
4811 if(!HAL_STATUS_SUCCESS(status))
4812 {
4813 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004814 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004815 }
4816
Kiet Lam64c1b492013-07-12 13:56:44 +05304817 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 pIes = NULL;
4819 }
4820 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304821 else
4822 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 break;
4824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004826 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4828 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4829 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004831 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4833 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004834
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 case eCsrStopBss:
4836 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4837 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4838 break;
4839
4840 case eCsrForcedDisassocSta:
4841 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4842 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4843 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4844 pCommand->u.roamCmd.reason);
4845 break;
4846
4847 case eCsrForcedDeauthSta:
4848 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4849 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4850 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4851 pCommand->u.roamCmd.reason);
4852 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004853
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004854 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004855 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004856 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4857 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004859
4860 default:
4861 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4862
4863 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4864 {
4865 //Remember the roaming profile
4866 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304867 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4868 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304870 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4872 }
4873 }
4874
4875 //At this point, original uapsd_mask is saved in pCurRoamProfile
4876 //uapsd_mask in the pCommand may change from this point on.
4877
4878 // Attempt to roam with the new scan results (if we need to..)
4879 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004880 if(!HAL_STATUS_SUCCESS(status))
4881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004882 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 break;
4885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 return (status);
4887}
4888
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004889void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4890{
4891 pCommand->u.roamCmd.pLastRoamBss = NULL;
4892 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4893 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304894 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004895}
4896
Jeff Johnson295189b2012-06-20 16:38:30 -07004897void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4898{
4899 if(pCommand->u.roamCmd.fReleaseBssList)
4900 {
4901 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4902 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4903 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4904 }
4905 if(pCommand->u.roamCmd.fReleaseProfile)
4906 {
4907 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4908 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4909 }
4910 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4911 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304912 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004913}
4914
Jeff Johnson295189b2012-06-20 16:38:30 -07004915void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4916{
Kiet Lam64c1b492013-07-12 13:56:44 +05304917 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004918}
Jeff Johnson295189b2012-06-20 16:38:30 -07004919void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4920{
4921 tListElem *pEntry;
4922 tSmeCmd *pCommand;
4923 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004924 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4926 if ( pEntry )
4927 {
4928 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 // If the head of the queue is Active and it is a ROAM command, remove
4930 // and put this on the Free queue.
4931 if ( eSmeCommandRoam == pCommand->command )
4932 {
4933 //we need to process the result first before removing it from active list because state changes
4934 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4935 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4936 if( fReleaseCommand )
4937 {
4938 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4939 {
4940 csrReleaseCommandRoam( pMac, pCommand );
4941 }
4942 else
4943 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004944 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004945 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 }
4947 }
4948 else
4949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004950 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004951 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 }
4953 }
4954 else
4955 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004956 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 }
4958 }
4959 else
4960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004961 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 if( fReleaseCommand )
4964 {
4965 smeProcessPendingQueue( pMac );
4966 }
4967}
4968
Jeff Johnson295189b2012-06-20 16:38:30 -07004969void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4970{
4971 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004972 if(!pSession)
4973 {
4974 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4975 return;
4976 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304977 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4978 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 pSession->NumPmkidCandidate = 0;
4980}
Jeff Johnson295189b2012-06-20 16:38:30 -07004981#ifdef FEATURE_WLAN_WAPI
4982void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4983{
4984 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004985 if(!pSession)
4986 {
4987 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4988 return;
4989 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4991 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 pSession->NumBkidCandidate = 0;
4993}
4994#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004995extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4996
Jeff Johnson295189b2012-06-20 16:38:30 -07004997static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4998 tSirBssDescription *pSirBssDesc,
4999 tDot11fBeaconIEs *pIes)
5000{
5001 eHalStatus status = eHAL_STATUS_SUCCESS;
5002 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5003 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005004
5005 if(!pSession)
5006 {
5007 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5008 return eHAL_STATUS_FAILURE;
5009 }
5010
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 if((eCSR_AUTH_TYPE_WPA == authType) ||
5012 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5013 (eCSR_AUTH_TYPE_RSN == authType) ||
5014 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5015#if defined WLAN_FEATURE_VOWIFI_11R
5016 ||
5017 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5018 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5019#endif /* FEATURE_WLAN_WAPI */
5020#ifdef FEATURE_WLAN_WAPI
5021 ||
5022 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5023 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5024#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005025#ifdef WLAN_FEATURE_11W
5026 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305027 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5028 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005029#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 )
5031 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005034 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 }
5036 if( pIesLocal )
5037 {
5038 tANI_U32 nIeLen;
5039 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 if((eCSR_AUTH_TYPE_RSN == authType) ||
5041#if defined WLAN_FEATURE_VOWIFI_11R
5042 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5043 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5044#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005045#if defined WLAN_FEATURE_11W
5046 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305047 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005048#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5050 {
5051 if(pIesLocal->RSN.present)
5052 {
5053 //Calculate the actual length
5054 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5055 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5056 + 2 //akm_suite_count
5057 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5058 + 2; //reserved
5059 if( pIesLocal->RSN.pmkid_count )
5060 {
5061 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5062 }
5063 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305064 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5065 if (NULL == pSession->pWpaRsnRspIE)
5066 status = eHAL_STATUS_FAILURE;
5067 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305069 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5071 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5072 //copy upto akm_suites
5073 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305074 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5075 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005076 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305077 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5078 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005079 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305080 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5081 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005082 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 if( pIesLocal->RSN.pwise_cipher_suite_count )
5084 {
5085 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305086 vos_mem_copy(pIeBuf,
5087 pIesLocal->RSN.pwise_cipher_suites,
5088 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5090 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305091 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 pIeBuf += 2;
5093 if( pIesLocal->RSN.akm_suite_count )
5094 {
5095 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305096 vos_mem_copy(pIeBuf,
5097 pIesLocal->RSN.akm_suites,
5098 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5100 }
5101 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305102 vos_mem_copy(pIeBuf,
5103 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5104 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5106 }
5107 }
5108 }
5109 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5110 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5111 {
5112 if(pIesLocal->WPA.present)
5113 {
5114 //Calculate the actual length
5115 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5116 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5117 + 2 //auth_suite_count
5118 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5119 // The WPA capabilities follows the Auth Suite (two octects)--
5120 // this field is optional, and we always "send" zero, so just
5121 // remove it. This is consistent with our assumptions in the
5122 // frames compiler; c.f. bug 15234:
5123 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305124
5125 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5126 if ( NULL == pSession->pWpaRsnRspIE )
5127 status = eHAL_STATUS_FAILURE;
5128 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 {
5130 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5131 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5132 pIeBuf = pSession->pWpaRsnRspIE + 2;
5133 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305134 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305136 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5137 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305139 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5140 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5142 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5143 }
5144 }
5145 }
5146#ifdef FEATURE_WLAN_WAPI
5147 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5148 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5149 {
5150 if(pIesLocal->WAPI.present)
5151 {
5152 //Calculate the actual length
5153 nIeLen = 4 //version + akm_suite_count
5154 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5155 + 2 //pwise_cipher_suite_count
5156 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5157 + 6; //gp_cipher_suite + preauth + reserved
5158 if( pIesLocal->WAPI.bkid_count )
5159 {
5160 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5161 }
5162
5163 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305164 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5165 if ( NULL == pSession->pWapiRspIE )
5166 status = eHAL_STATUS_FAILURE;
5167 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 {
5169 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5170 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5171 pIeBuf = pSession->pWapiRspIE + 2;
5172 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305173 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 pIeBuf += 4;
5175 if( pIesLocal->WAPI.akm_suite_count )
5176 {
5177 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305178 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5179 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305181 }
5182 vos_mem_copy(pIeBuf,
5183 &pIesLocal->WAPI.unicast_cipher_suite_count,
5184 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5187 {
5188 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305189 vos_mem_copy( pIeBuf,
5190 pIesLocal->WAPI.unicast_cipher_suites,
5191 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5193 }
lukez3c809222013-05-03 10:23:02 -07005194 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305195 vos_mem_copy(pIeBuf,
5196 pIesLocal->WAPI.multicast_cipher_suite,
5197 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005198 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305199 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305200 vos_mem_copy(pIeBuf,
5201 pIesLocal->WAPI.multicast_cipher_suite + 4,
5202 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005203 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305204 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305206 //bkid_count
5207 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5208 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305210 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5211 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5213 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305214 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 }
5217 }
5218#endif /* FEATURE_WLAN_WAPI */
5219 if( !pIes )
5220 {
5221 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305222 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 }
5224 }
5225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 return (status);
5227}
5228
Jeff Johnson295189b2012-06-20 16:38:30 -07005229static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5230{
5231 v_U8_t bACWeights[WLANTL_MAX_AC];
5232 v_U8_t paramBk, paramBe, paramVi, paramVo;
5233 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5235 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5236 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5237 //This doesn't address the case where the lower AC needs a real higher weight
5238 if( pIEs->WMMParams.present )
5239 {
5240 //no change to the lowest ones
5241 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5242 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5243 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5244 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5245 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5246 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5247 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5248 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5249 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5250 {
5251 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5252 fWeightChange = VOS_TRUE;
5253 }
5254 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5255 {
5256 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5257 fWeightChange = VOS_TRUE;
5258 }
5259 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5260 {
5261 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5262 fWeightChange = VOS_TRUE;
5263 }
5264 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5265 {
5266 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5267 fWeightChange = VOS_TRUE;
5268 }
5269 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5270 {
5271 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5272 fWeightChange = VOS_TRUE;
5273 }
5274 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5275 {
5276 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5277 fWeightChange = VOS_TRUE;
5278 }
5279 if(fWeightChange)
5280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005281 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 bACWeights[2], bACWeights[3]);
5283 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5284 }
5285 }
5286}
Jeff Johnson295189b2012-06-20 16:38:30 -07005287#ifdef WLAN_FEATURE_VOWIFI_11R
5288//Returns whether the current association is a 11r assoc or not
5289tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5290{
5291#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5292 return csrNeighborRoamIs11rAssoc(pMac);
5293#else
5294 return eANI_BOOLEAN_FALSE;
5295#endif
5296}
5297#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005298#ifdef FEATURE_WLAN_ESE
5299//Returns whether the current association is a ESE assoc or not
5300tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005301{
5302#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005303 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005304#else
5305 return eANI_BOOLEAN_FALSE;
5306#endif
5307}
5308#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005309#ifdef FEATURE_WLAN_LFR
5310//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305311tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005312{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305313 tCsrRoamSession *pSession = NULL;
5314
5315 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5316 {
5317 pSession = CSR_GET_SESSION( pMac, sessionId );
5318 if (NULL != pSession->pCurRoamProfile)
5319 {
5320 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5321 {
5322 return eANI_BOOLEAN_FALSE;
5323 }
5324 }
5325 }
5326
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005327#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5328 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5329 {
5330 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5331 }
5332 else
5333#endif
5334 {
5335 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005336 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005337 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005338}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005339
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005340#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005341/* ---------------------------------------------------------------------------
5342
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005343 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005344
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005345 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005346
5347 \param pMac - The handle returned by macOpen.
5348
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005349 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005350
5351---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005352tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005353{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005354 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005355}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005356#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005357
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005358#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5359//Returns whether "FW based BG scan" is currently enabled...or not
5360tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5361{
5362 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5363}
5364#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005365#endif
5366
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005367#if defined(FEATURE_WLAN_ESE)
5368tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005369{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005370 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005371}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005372#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005373
Jeff Johnson295189b2012-06-20 16:38:30 -07005374//Return true means the command can be release, else not
5375static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5376 eCsrRoamCompleteResult Result, void *Context )
5377{
5378 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5379 tSirBssDescription *pSirBssDesc = NULL;
5380 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5381 tCsrScanResult *pScanResult = NULL;
5382 tCsrRoamInfo roamInfo;
5383 sme_QosAssocInfo assocInfo;
5384 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5385 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5386 tDot11fBeaconIEs *pIes = NULL;
5387 tANI_U32 sessionId = pCommand->sessionId;
5388 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5389 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5390 eRoamCmdStatus roamStatus;
5391 eCsrRoamResult roamResult;
5392 eHalStatus status;
5393 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005395
Jeff Johnson32d95a32012-09-10 13:15:23 -07005396 if(!pSession)
5397 {
5398 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5399 return eANI_BOOLEAN_FALSE;
5400 }
5401
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005402 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 switch( Result )
5404 {
5405 case eCsrJoinSuccess:
5406 // reset the IDLE timer
5407 // !!
5408 // !! fall through to the next CASE statement here is intentional !!
5409 // !!
5410 case eCsrReassocSuccess:
5411 if(eCsrReassocSuccess == Result)
5412 {
5413 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5414 }
5415 else
5416 {
5417 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5418 }
5419 // Success Join Response from LIM. Tell NDIS we are connected and save the
5420 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005421 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305422 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 //always free the memory here
5424 if(pSession->pWpaRsnRspIE)
5425 {
5426 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305427 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 pSession->pWpaRsnRspIE = NULL;
5429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005430#ifdef FEATURE_WLAN_WAPI
5431 if(pSession->pWapiRspIE)
5432 {
5433 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305434 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 pSession->pWapiRspIE = NULL;
5436 }
5437#endif /* FEATURE_WLAN_WAPI */
5438#ifdef FEATURE_WLAN_BTAMP_UT_RF
5439 //Reset counter so no join retry is needed.
5440 pSession->maxRetryCount = 0;
5441 csrRoamStopJoinRetryTimer(pMac, sessionId);
5442#endif
5443 /* This creates problem since we have not saved the connected profile.
5444 So moving this after saving the profile
5445 */
5446 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305447
5448 /* Reset remainInPowerActiveTillDHCP as it might have been set
5449 * by last failed secured connection.
5450 * It should be set only for secured connection.
5451 */
5452 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5454 {
5455 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5456 }
5457 else
5458 {
5459 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 //Use the last connected bssdesc for reassoc-ing to the same AP.
5462 //NOTE: What to do when reassoc to a different AP???
5463 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5464 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5465 {
5466 pSirBssDesc = pSession->pConnectBssDesc;
5467 if(pSirBssDesc)
5468 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305469 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5470 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 }
5472 }
5473 else
5474 {
5475
5476 if(pCommand->u.roamCmd.pRoamBssEntry)
5477 {
5478 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5479 if(pScanResult != NULL)
5480 {
5481 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5482 //this can be NULL
5483 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305484 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5485 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 }
5487 }
5488 }
5489 if( pSirBssDesc )
5490 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5493 //Save WPA/RSN IE
5494 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005495#ifdef FEATURE_WLAN_ESE
5496 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005497#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305498#ifdef WLAN_FEATURE_VOWIFI_11R
5499 if (pSirBssDesc->mdiePresent)
5500 {
5501 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5502#ifdef FEATURE_WLAN_ESE
5503 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5504 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5505#endif
5506 )
5507 {
5508 // is11Rconnection;
5509 roamInfo.is11rAssoc = VOS_TRUE;
5510 }
5511 else
5512 {
5513 // is11Rconnection;
5514 roamInfo.is11rAssoc = VOS_FALSE;
5515 }
5516 }
5517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5519 // substate change.
5520 // Moving even save profile above so that below mentioned conditon is also met.
5521 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5522 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5524 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5525 // will be dropped for the security context may not be set properly.
5526 //
5527 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5528 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5529 //
5530 // this reordering was done on titan_prod_usb branch and is being replicated here.
5531 //
5532
5533 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5534 !pProfile->bWPSAssociation)
5535 {
5536 // Issue the set Context request to LIM to establish the Unicast STA context
5537 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5538 pProfile->negotiatedUCEncryptionType,
5539 pSirBssDesc, &(pSirBssDesc->bssId),
5540 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005542 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5544 }
5545 // Issue the set Context request to LIM to establish the Broadcast STA context
5546 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5547 pSirBssDesc, &BroadcastMac,
5548 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5549 }
5550 else
5551 {
5552 //Need to wait for supplicant authtication
5553 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 //Set the subestate to WaitForKey in case authentiation is needed
5555 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5556
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 if(pProfile->bWPSAssociation)
5558 {
5559 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5560 }
5561 else
5562 {
5563 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5564 }
5565
5566 //Save sessionId in case of timeout
5567 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5568 //This time should be long enough for the rest of the process plus setting key
5569 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5570 {
5571 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005572 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5574 }
5575 }
5576
5577 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5578 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 if(Context)
5580 {
5581 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5582 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5584 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5585#ifdef WLAN_FEATURE_VOWIFI_11R
5586 len += pJoinRsp->parsedRicRspLen;
5587#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005588#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 len += pJoinRsp->tspecIeLen;
5590#endif
5591 if(len)
5592 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305593 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5594 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305596 vos_mem_copy(pSession->connectedInfo.pbFrames,
5597 pJoinRsp->frames, len);
5598 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5599 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5600 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005601#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305602 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005603#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005604#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305605 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005606#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305607 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5608 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5609 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5610 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 }
5612 }
5613 if(pCommand->u.roamCmd.fReassoc)
5614 {
5615 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5616 }
5617 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5618 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5619 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5620 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305621 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 }
5623 else
5624 {
5625 if(pCommand->u.roamCmd.fReassoc)
5626 {
5627 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5628 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5629 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5630 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5631 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5632 }
5633 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305634 /* Update the staId from the previous connected profile info
5635 as the reassociation is triggred at SME/HDD */
5636 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5637 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5638 {
5639 roamInfo.staId = pSession->connectedInfo.staId;
5640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005641#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5642 // Indicate SME-QOS with reassoc success event, only after
5643 // copying the frames
5644 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 roamInfo.pBssDesc = pSirBssDesc;
5647 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5648 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5649#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5650 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5651#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5652 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5654 //It may be better to let QoS do this????
5655 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5656 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005657 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5659 pmcStartUapsd( pMac, NULL, NULL );
5660 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305661 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5663 if( pSession->bRefAssocStartCnt > 0 )
5664 {
5665 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005666 //Remove this code once SLM_Sessionization is supported
5667 //BMPS_WORKAROUND_NOT_NEEDED
5668 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005669 {
5670 pMac->roam.configParam.doBMPSWorkaround = 1;
5671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5673 }
5674
5675 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 // reset the PMKID candidate list
5677 csrResetPMKIDCandidateList( pMac, sessionId );
5678 //Update TL's AC weight base on the current EDCA parameters
5679 //These parameters may change in the course of the connection, that sictuation
5680 //is not taken care here. This change is mainly to address a WIFI WMM test where
5681 //BE has a equal or higher TX priority than VI.
5682 //We only do this for infra link
5683 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5684 {
5685 csrCheckAndUpdateACWeight(pMac, pIes);
5686 }
5687#ifdef FEATURE_WLAN_WAPI
5688 // reset the BKID candidate list
5689 csrResetBKIDCandidateList( pMac, sessionId );
5690#endif /* FEATURE_WLAN_WAPI */
5691 }
5692 else
5693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005694 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 csrScanCancelIdleScan(pMac);
5697 //Not to signal link up because keys are yet to be set.
5698 //The linkup function will overwrite the sub-state that we need to keep at this point.
5699 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5700 {
5701 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5704 //enough to let security and DHCP handshake succeed before entry into BMPS
5705 if (pmcShouldBmpsTimerRun(pMac))
5706 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305707 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5708 * until keys are set before going into BMPS.
5709 */
5710 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5711 {
5712 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5713 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5714 "to make sure we wait until keys are set before"
5715 " going to BMPS"));
5716 }
5717
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5719 != eHAL_STATUS_SUCCESS)
5720 {
5721 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5722 }
5723 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 break;
5726
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 case eCsrStartBssSuccess:
5728 // on the StartBss Response, LIM is returning the Bss Description that we
5729 // are beaconing. Add this Bss Description to our scan results and
5730 // chain the Profile to this Bss Description. On a Start BSS, there was no
5731 // detected Bss description (no partner) so we issued the Start Bss to
5732 // start the Ibss without any Bss description. Lim was kind enough to return
5733 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005734 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305737 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 if( CSR_IS_IBSS( pProfile ) )
5739 {
5740 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 else if (CSR_IS_INFRA_AP(pProfile))
5743 {
5744 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 else
5747 {
5748 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5749 }
5750 if( !CSR_IS_WDS_STA( pProfile ) )
5751 {
5752 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5755 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305756 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 roamInfo.pBssDesc = pSirBssDesc;
5758 //We need to associate_complete it first, becasue Associate_start already indicated.
5759 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5760 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5761 break;
5762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005765 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 }
5767 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5768 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5769 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5770 if(pSirBssDesc)
5771 {
5772 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305773 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5774 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 }
5776 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305777 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005778#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5779 {
5780 vos_log_ibss_pkt_type *pIbssLog;
5781 tANI_U32 bi;
5782
5783 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5784 if(pIbssLog)
5785 {
5786 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5787 {
5788 //We start the IBSS (didn't find any matched IBSS out there)
5789 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5790 }
5791 else
5792 {
5793 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5794 }
5795 if(pSirBssDesc)
5796 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305797 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5799 }
5800 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5801 {
5802 //***U8 is not enough for beacon interval
5803 pIbssLog->beaconInterval = (v_U8_t)bi;
5804 }
5805 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5806 }
5807 }
5808#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5809 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5810 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5812 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5814 csrRoamIssueSetContextReq( pMac, sessionId,
5815 pProfile->negotiatedMCEncryptionType,
5816 pSirBssDesc, &BroadcastMac,
5817 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5818 }
5819 }
5820 else
5821 {
5822 //Keep the state to eCSR_ROAMING_STATE_JOINING
5823 //Need to send join_req.
5824 if(pCommand->u.roamCmd.pRoamBssEntry)
5825 {
5826 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5827 {
5828 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5829 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5830 // Set the roaming substate to 'join attempt'...
5831 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005832 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 }
5834 }
5835 else
5836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005837 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 VOS_ASSERT( 0 );
5839 }
5840 }
5841 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5842 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5843 //trigger the connection start indication in Vista
5844 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5845 {
5846 roamStatus = eCSR_ROAM_IBSS_IND;
5847 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5848 if( CSR_IS_WDS( pProfile ) )
5849 {
5850 roamStatus = eCSR_ROAM_WDS_IND;
5851 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 if( CSR_IS_INFRA_AP( pProfile ) )
5854 {
5855 roamStatus = eCSR_ROAM_INFRA_IND;
5856 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005858
5859 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5860 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5861 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305862 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5864 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005865 //We start the IBSS (didn't find any matched IBSS out there)
5866 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305868 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5869 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005870 //Remove this code once SLM_Sessionization is supported
5871 //BMPS_WORKAROUND_NOT_NEEDED
5872 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005873 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005874 {
5875 pMac->roam.configParam.doBMPSWorkaround = 1;
5876 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005877
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5879 }
5880
5881 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005882
5883 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 {
5885 //need to send stop BSS because we fail to send join_req
5886 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5887 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5888 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 case eCsrStartBssFailure:
5892#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5893 {
5894 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5896 if(pIbssLog)
5897 {
5898 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5899 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5900 }
5901 }
5902#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 roamStatus = eCSR_ROAM_IBSS_IND;
5904 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5905 if( CSR_IS_WDS( pProfile ) )
5906 {
5907 roamStatus = eCSR_ROAM_WDS_IND;
5908 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 if( CSR_IS_INFRA_AP( pProfile ) )
5911 {
5912 roamStatus = eCSR_ROAM_INFRA_IND;
5913 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 if(Context)
5916 {
5917 pSirBssDesc = (tSirBssDescription *)Context;
5918 }
5919 else
5920 {
5921 pSirBssDesc = NULL;
5922 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305923 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 roamInfo.pBssDesc = pSirBssDesc;
5925 //We need to associate_complete it first, becasue Associate_start already indicated.
5926 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5927 csrSetDefaultDot11Mode( pMac );
5928 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 case eCsrSilentlyStopRoaming:
5930 // We are here because we try to start the same IBSS
5931 //No message to PE
5932 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005933 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5935 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305936 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5938 if( roamInfo.pBssDesc )
5939 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305940 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5941 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 }
5943 //Since there is no change in the current state, simply pass back no result otherwise
5944 //HDD may be mistakenly mark to disconnected state.
5945 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5946 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 case eCsrSilentlyStopRoamingSaveState:
5949 //We are here because we try to connect to the same AP
5950 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005951 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305952 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005953
5954 //to aviod resetting the substate to NONE
5955 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5956 //No need to change substate to wai_for_key because there is no state change
5957 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5958 if( roamInfo.pBssDesc )
5959 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305960 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5961 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5964 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5965 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5966 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5967 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5968 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5969 roamInfo.staId = pSession->connectedInfo.staId;
5970 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 pSession->bRefAssocStartCnt--;
5973 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5974 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5975 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5976 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 case eCsrReassocFailure:
5978#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5979 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5980#endif
5981 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005982 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 csrFreeConnectBssDesc(pMac, sessionId);
5984 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5985 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305986 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5988 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5989 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5990 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5991 eCSR_ROAM_WDS_IND,
5992 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5993 //Need to issue stop_bss
5994 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 case eCsrJoinFailure:
5996 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005997 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 default:
5999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006000 smsLog(pMac, LOGW, FL("receives no association indication"));
6001 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006002 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6004 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6005 {
6006 //do not free for the other profiles as we need to send down stop BSS later
6007 csrFreeConnectBssDesc(pMac, sessionId);
6008 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6009 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6010 csrSetDefaultDot11Mode( pMac );
6011 }
6012
6013 switch( pCommand->u.roamCmd.roamReason )
6014 {
6015 // If this transition is because of an 802.11 OID, then we transition
6016 // back to INIT state so we sit waiting for more OIDs to be issued and
6017 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006018 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 case eCsrSmeIssuedAssocToSimilarAP:
6020 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006021 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306023 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6025 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6026 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306027 vos_mem_copy(&roamInfo.bssid,
6028 &pSession->joinFailStatusCode.bssId,
6029 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006030
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 /* Defeaturize this later if needed */
6032#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6033 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6034 if (csrRoamIsHandoffInProgress(pMac))
6035 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 /* Should indicate neighbor roam algorithm about the connect failure here */
6037 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006039#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 if(pSession->bRefAssocStartCnt > 0)
6041 {
6042 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006043 if(eCsrJoinFailureDueToConcurrency == Result)
6044 {
6045 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6046 eCSR_ROAM_ASSOCIATION_COMPLETION,
6047 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6048 }
6049 else
6050 {
6051 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 eCSR_ROAM_ASSOCIATION_COMPLETION,
6053 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006056 else
6057 {
6058 /* bRefAssocStartCnt is not incremented when
6059 * eRoamState == eCsrStopRoamingDueToConcurrency
6060 * in csrRoamJoinNextBss API. so handle this in
6061 * else case by sending assoc failure
6062 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006063 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006064 pCommand->u.scanCmd.roamId,
6065 eCSR_ROAM_ASSOCIATION_FAILURE,
6066 eCSR_ROAM_RESULT_FAILURE);
6067 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006068 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006069#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306070 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6072#endif
6073 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6074 csrScanStartIdleScan(pMac);
6075#ifdef FEATURE_WLAN_BTAMP_UT_RF
6076 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6077 //BT activity and not able to recevie WLAN traffic. Retry the join
6078 if( CSR_IS_WDS_STA(pProfile) )
6079 {
6080 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6081 }
6082#endif
6083 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 case eCsrHddIssuedReassocToSameAP:
6085 case eCsrSmeIssuedReassocToSameAP:
6086 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6087
6088 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6089#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6090 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6091#endif
6092 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6093 csrScanStartIdleScan(pMac);
6094 break;
6095 case eCsrForcedDisassoc:
6096 case eCsrForcedDeauth:
6097 case eCsrSmeIssuedIbssJoinFailure:
6098 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6099
6100 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6101 {
6102 // Notify HDD that IBSS join failed
6103 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6104 }
6105 else
6106 {
6107 csrRoamCallCallback(pMac, sessionId, NULL,
6108 pCommand->u.roamCmd.roamId,
6109 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6110 }
6111#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6112 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6113#endif
6114 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006115 /*
6116 *DelSta not done FW still in conneced state so dont
6117 *issue IMPS req
6118 */
6119 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6120 {
6121 smsLog(pMac, LOGW, FL("FW still in connected state "));
6122 break;
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 csrScanStartIdleScan(pMac);
6125 break;
6126 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306127 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 csrRoamCallCallback(pMac, sessionId, NULL,
6129 pCommand->u.roamCmd.roamId,
6130 eCSR_ROAM_IBSS_LEAVE,
6131 eCSR_ROAM_RESULT_IBSS_STOP);
6132 break;
6133 case eCsrForcedDisassocMICFailure:
6134 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6135
6136 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6137#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6138 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6139#endif
6140 csrScanStartIdleScan(pMac);
6141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 case eCsrStopBss:
6143 csrRoamCallCallback(pMac, sessionId, NULL,
6144 pCommand->u.roamCmd.roamId,
6145 eCSR_ROAM_INFRA_IND,
6146 eCSR_ROAM_RESULT_INFRA_STOPPED);
6147 break;
6148 case eCsrForcedDisassocSta:
6149 case eCsrForcedDeauthSta:
6150 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6151 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6152 {
6153 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006154
6155 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6156 {
6157 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306158 vos_mem_copy(roamInfo.peerMac,
6159 pCommand->u.roamCmd.peerMac,
6160 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6162 roamInfo.statusCode = eSIR_SME_SUCCESS;
6163 status = csrRoamCallCallback(pMac, sessionId,
6164 &roamInfo, pCommand->u.roamCmd.roamId,
6165 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6166 }
6167 }
6168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 case eCsrLostLink1:
6170 // if lost link roam1 failed, then issue lost link Scan2 ...
6171 csrScanRequestLostLink2(pMac, sessionId);
6172 break;
6173 case eCsrLostLink2:
6174 // if lost link roam2 failed, then issue lost link scan3 ...
6175 csrScanRequestLostLink3(pMac, sessionId);
6176 break;
6177 case eCsrLostLink3:
6178 default:
6179 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6180
6181 //We are done with one round of lostlink roaming here
6182 csrScanHandleFailedLostlink3(pMac, sessionId);
6183 break;
6184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 break;
6186 }
6187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 return ( fReleaseCommand );
6189}
6190
Jeff Johnson295189b2012-06-20 16:38:30 -07006191eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6192{
6193 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 return (status);
6195}
6196
Jeff Johnson295189b2012-06-20 16:38:30 -07006197eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6198{
6199 eHalStatus status = eHAL_STATUS_SUCCESS;
6200 tANI_U32 size = 0;
6201
6202 do
6203 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306204 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6206 {
6207 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306208 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6209 if ( NULL == pDstProfile->BSSIDs.bssid )
6210 status = eHAL_STATUS_FAILURE;
6211 else
6212 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 if(!HAL_STATUS_SUCCESS(status))
6214 {
6215 break;
6216 }
6217 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306218 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6219 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 }
6221 if(pSrcProfile->SSIDs.numOfSSIDs)
6222 {
6223 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306224 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6225 if ( NULL == pDstProfile->SSIDs.SSIDList )
6226 status = eHAL_STATUS_FAILURE;
6227 else
6228 status = eHAL_STATUS_SUCCESS;
6229 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 {
6231 break;
6232 }
6233 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306234 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6235 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 }
6237 if(pSrcProfile->nWPAReqIELength)
6238 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306239 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6240 if ( NULL == pDstProfile->pWPAReqIE )
6241 status = eHAL_STATUS_FAILURE;
6242 else
6243 status = eHAL_STATUS_SUCCESS;
6244
6245 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 {
6247 break;
6248 }
6249 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306250 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6251 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 }
6253 if(pSrcProfile->nRSNReqIELength)
6254 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306255 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6256 if ( NULL == pDstProfile->pRSNReqIE )
6257 status = eHAL_STATUS_FAILURE;
6258 else
6259 status = eHAL_STATUS_SUCCESS;
6260
6261 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 {
6263 break;
6264 }
6265 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306266 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6267 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 }
6269#ifdef FEATURE_WLAN_WAPI
6270 if(pSrcProfile->nWAPIReqIELength)
6271 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306272 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6273 if ( NULL == pDstProfile->pWAPIReqIE )
6274 status = eHAL_STATUS_FAILURE;
6275 else
6276 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 if(!HAL_STATUS_SUCCESS(status))
6278 {
6279 break;
6280 }
6281 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306282 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6283 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 }
6285#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 if(pSrcProfile->nAddIEScanLength)
6287 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306288 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6289 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306291 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306292 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306293 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6294 }
6295 else
6296 {
6297 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6298 FL(" AddIEScanLength is not valid %u"),
6299 pSrcProfile->nAddIEScanLength);
6300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 if(pSrcProfile->nAddIEAssocLength)
6303 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306304 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6305 if ( NULL == pDstProfile->pAddIEAssoc )
6306 status = eHAL_STATUS_FAILURE;
6307 else
6308 status = eHAL_STATUS_SUCCESS;
6309
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 if(!HAL_STATUS_SUCCESS(status))
6311 {
6312 break;
6313 }
6314 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306315 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6316 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 if(pSrcProfile->ChannelInfo.ChannelList)
6319 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306320 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6321 pSrcProfile->ChannelInfo.numOfChannels);
6322 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6323 status = eHAL_STATUS_FAILURE;
6324 else
6325 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 if(!HAL_STATUS_SUCCESS(status))
6327 {
6328 break;
6329 }
6330 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306331 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6332 pSrcProfile->ChannelInfo.ChannelList,
6333 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 pDstProfile->AuthType = pSrcProfile->AuthType;
6336 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6337 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6338 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6339 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6340 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006341#ifdef WLAN_FEATURE_11W
6342 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6343 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6344 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 pDstProfile->BSSType = pSrcProfile->BSSType;
6347 pDstProfile->phyMode = pSrcProfile->phyMode;
6348 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6349
6350#ifdef FEATURE_WLAN_WAPI
6351 if(csrIsProfileWapi(pSrcProfile))
6352 {
6353 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6354 {
6355 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6356 }
6357 }
6358#endif /* FEATURE_WLAN_WAPI */
6359 pDstProfile->CBMode = pSrcProfile->CBMode;
6360 /*Save the WPS info*/
6361 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006362 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 pDstProfile->privacy = pSrcProfile->privacy;
6366 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6367 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6368 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6369 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6370 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6371 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6372 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6373 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6374 pDstProfile->wps_state = pSrcProfile->wps_state;
6375 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306376 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6377 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006378#ifdef WLAN_FEATURE_VOWIFI_11R
6379 if (pSrcProfile->MDID.mdiePresent)
6380 {
6381 pDstProfile->MDID.mdiePresent = 1;
6382 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6383 }
6384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 }while(0);
6386
6387 if(!HAL_STATUS_SUCCESS(status))
6388 {
6389 csrReleaseProfile(pMac, pDstProfile);
6390 pDstProfile = NULL;
6391 }
6392
6393 return (status);
6394}
Jeff Johnson295189b2012-06-20 16:38:30 -07006395eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6396{
6397 eHalStatus status = eHAL_STATUS_SUCCESS;
6398 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6399 do
6400 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306401 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 if(pSrcProfile->bssid)
6403 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306404 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6405 if ( NULL == pDstProfile->BSSIDs.bssid )
6406 status = eHAL_STATUS_FAILURE;
6407 else
6408 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 if(!HAL_STATUS_SUCCESS(status))
6410 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306411 smsLog( pMac, LOGE,
6412 FL("failed to allocate memory for BSSID"
6413 "%02x:%02x:%02x:%02x:%02x:%02x"),
6414 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6415 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 break;
6417 }
6418 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306419 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6420 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 }
6422 if(pSrcProfile->SSID.ssId)
6423 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306424 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6425 if ( NULL == pDstProfile->SSIDs.SSIDList )
6426 status = eHAL_STATUS_FAILURE;
6427 else
6428 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 if(!HAL_STATUS_SUCCESS(status))
6430 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306431 smsLog( pMac, LOGE,
6432 FL("failed to allocate memory for SSIDList"
6433 "%02x:%02x:%02x:%02x:%02x:%02x"),
6434 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6435 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 break;
6437 }
6438 pDstProfile->SSIDs.numOfSSIDs = 1;
6439 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6440 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306441 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6442 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006444 if(pSrcProfile->nAddIEAssocLength)
6445 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306446 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6447 if ( NULL == pDstProfile->pAddIEAssoc)
6448 status = eHAL_STATUS_FAILURE;
6449 else
6450 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006451 if(!HAL_STATUS_SUCCESS(status))
6452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006453 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006454 break;
6455 }
6456 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306457 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6458 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006459 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306460 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6461 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6462 status = eHAL_STATUS_FAILURE;
6463 else
6464 status = eHAL_STATUS_SUCCESS;
6465
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 if(!HAL_STATUS_SUCCESS(status))
6467 {
6468 break;
6469 }
6470 pDstProfile->ChannelInfo.numOfChannels = 1;
6471 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 pDstProfile->AuthType.numEntries = 1;
6473 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6474 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6475 pDstProfile->EncryptionType.numEntries = 1;
6476 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6477 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6478 pDstProfile->mcEncryptionType.numEntries = 1;
6479 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6480 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6481 pDstProfile->BSSType = pSrcProfile->BSSType;
6482 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306483 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6484 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306485#ifdef WLAN_FEATURE_11W
6486 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6487 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6488 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6489#endif
6490
Jeff Johnson295189b2012-06-20 16:38:30 -07006491#ifdef WLAN_FEATURE_VOWIFI_11R
6492 if (pSrcProfile->MDID.mdiePresent)
6493 {
6494 pDstProfile->MDID.mdiePresent = 1;
6495 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6496 }
6497#endif
6498
6499 }while(0);
6500
6501 if(!HAL_STATUS_SUCCESS(status))
6502 {
6503 csrReleaseProfile(pMac, pDstProfile);
6504 pDstProfile = NULL;
6505 }
6506
6507 return (status);
6508}
6509
Jeff Johnson295189b2012-06-20 16:38:30 -07006510eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6511 tScanResultHandle hBSSList,
6512 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6513 tANI_BOOLEAN fClearScan)
6514{
6515 eHalStatus status = eHAL_STATUS_SUCCESS;
6516 tSmeCmd *pCommand;
6517
6518 pCommand = csrGetCommandBuffer(pMac);
6519 if(NULL == pCommand)
6520 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006521 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 status = eHAL_STATUS_RESOURCES;
6523 }
6524 else
6525 {
6526 if( fClearScan )
6527 {
6528 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306529 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 }
6531 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6532 if(NULL == pProfile)
6533 {
6534 //We can roam now
6535 //Since pProfile is NULL, we need to build our own profile, set everything to default
6536 //We can only support open and no encryption
6537 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6538 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6539 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6540 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6541 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6542 }
6543 else
6544 {
6545 //make a copy of the profile
6546 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6547 if(HAL_STATUS_SUCCESS(status))
6548 {
6549 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6550 }
6551 }
6552 pCommand->command = eSmeCommandRoam;
6553 pCommand->sessionId = (tANI_U8)sessionId;
6554 pCommand->u.roamCmd.hBSSList = hBSSList;
6555 pCommand->u.roamCmd.roamId = roamId;
6556 pCommand->u.roamCmd.roamReason = reason;
6557 //We need to free the BssList when the command is done
6558 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6559 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6561 FL("CSR PERSONA=%d"),
6562 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6564 if( !HAL_STATUS_SUCCESS( status ) )
6565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006566 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 csrReleaseCommandRoam( pMac, pCommand );
6568 }
6569 }
6570
6571 return (status);
6572}
Jeff Johnson295189b2012-06-20 16:38:30 -07006573eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6574 tCsrRoamModifyProfileFields *pMmodProfileFields,
6575 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6576{
6577 eHalStatus status = eHAL_STATUS_SUCCESS;
6578 tSmeCmd *pCommand;
6579
6580 pCommand = csrGetCommandBuffer(pMac);
6581 if(NULL == pCommand)
6582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006583 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 status = eHAL_STATUS_RESOURCES;
6585 }
6586 else
6587 {
6588 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306589 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 if(pProfile)
6591 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 //This is likely trying to reassoc to different profile
6593 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6594 //make a copy of the profile
6595 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6596 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 }
6598 else
6599 {
6600 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6601 //how to update WPA/WPA2 info in roamProfile??
6602 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 if(HAL_STATUS_SUCCESS(status))
6605 {
6606 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6607 }
6608 pCommand->command = eSmeCommandRoam;
6609 pCommand->sessionId = (tANI_U8)sessionId;
6610 pCommand->u.roamCmd.roamId = roamId;
6611 pCommand->u.roamCmd.roamReason = reason;
6612 //We need to free the BssList when the command is done
6613 //For reassoc there is no BSS list, so the boolean set to false
6614 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6615 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6616 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6618 if( !HAL_STATUS_SUCCESS( status ) )
6619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006620 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6622 csrReleaseCommandRoam( pMac, pCommand );
6623 }
6624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 return (status);
6626}
6627
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006628eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6629 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306630// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006631{
6632 eHalStatus status = eHAL_STATUS_SUCCESS;
6633 tSmeCmd *pCommand;
6634
6635 pCommand = csrGetCommandBuffer(pMac);
6636 if(NULL == pCommand)
6637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006638 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006639 status = eHAL_STATUS_RESOURCES;
6640 }
6641 else
6642 {
6643 if(pBssDescription)
6644 {
6645 //copy over the parameters we need later
6646 pCommand->command = eSmeCommandRoam;
6647 pCommand->sessionId = (tANI_U8)sessionId;
6648 pCommand->u.roamCmd.roamReason = reason;
6649 //this is the important parameter
6650 //in this case we are using this field for the "next" BSS
6651 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6652 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6653 if( !HAL_STATUS_SUCCESS( status ) )
6654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006655 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006656 csrReleaseCommandPreauth( pMac, pCommand );
6657 }
6658 }
6659 else
6660 {
6661 //Return failure
6662 status = eHAL_STATUS_RESOURCES;
6663 }
6664 }
6665 return (status);
6666}
6667
6668eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6669{
6670 tListElem *pEntry;
6671 tSmeCmd *pCommand;
6672 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6673 if ( pEntry )
6674 {
6675 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6676 if ( (eSmeCommandRoam == pCommand->command) &&
6677 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6678 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006679 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006680 pCommand->command, pCommand->u.roamCmd.roamReason);
6681 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6682 csrReleaseCommandPreauth( pMac, pCommand );
6683 }
6684 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006685 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006686 pCommand->command, pCommand->u.roamCmd.roamReason);
6687 }
6688 }
6689 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006690 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006691 }
6692 smeProcessPendingQueue( pMac );
6693 return eHAL_STATUS_SUCCESS;
6694}
6695
Jeff Johnson295189b2012-06-20 16:38:30 -07006696eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6697 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6698{
6699 eHalStatus status = eHAL_STATUS_FAILURE;
6700 tScanResultHandle hBSSList;
6701 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6703 if(HAL_STATUS_SUCCESS(status))
6704 {
6705 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6706 if(pRoamId)
6707 {
6708 *pRoamId = roamId;
6709 }
6710 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6711 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6712 if(!HAL_STATUS_SUCCESS(status))
6713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006714 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 csrScanResultPurge(pMac, hBSSList);
6716 }
6717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 return (status);
6719}
6720
Jeff Johnson295189b2012-06-20 16:38:30 -07006721eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6722 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6723{
6724 eHalStatus status = eHAL_STATUS_SUCCESS;
6725 tScanResultHandle hBSSList;
6726 tCsrScanResultFilter *pScanFilter;
6727 tANI_U32 roamId = 0;
6728 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6729 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 if (NULL == pProfile)
6731 {
6732 smsLog(pMac, LOGP, FL("No profile specified"));
6733 return eHAL_STATUS_FAILURE;
6734 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306735 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6736 "encryType = %d"),
6737 lim_BssTypetoString(pProfile->BSSType),
6738 pProfile->BSSType,
6739 pProfile->AuthType.authType[0],
6740 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 if( CSR_IS_WDS( pProfile ) &&
6742 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006744 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006745 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 return status;
6747 }
6748 csrRoamCancelRoaming(pMac, sessionId);
6749 csrScanRemoveFreshScanCommand(pMac, sessionId);
6750 csrScanCancelIdleScan(pMac);
6751 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306752 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306753
6754 if (!vos_concurrent_open_sessions_running() &&
6755 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306757 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 csrScanDisable(pMac);
6759 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306760
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6762 //Check whether ssid changes
6763 if(csrIsConnStateConnected(pMac, sessionId))
6764 {
6765 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6766 {
6767 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6768 }
6769 }
6770#ifdef FEATURE_WLAN_BTAMP_UT_RF
6771 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6772#endif
6773 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006775 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6777 if(pRoamId)
6778 {
6779 roamId = *pRoamId;
6780 }
6781 if(!HAL_STATUS_SUCCESS(status))
6782 {
6783 fCallCallback = eANI_BOOLEAN_TRUE;
6784 }
6785 }
6786 else
6787 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306788 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6789 if ( NULL == pScanFilter )
6790 status = eHAL_STATUS_FAILURE;
6791 else
6792 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 if(HAL_STATUS_SUCCESS(status))
6794 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306795 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 //Try to connect to any BSS
6797 if(NULL == pProfile)
6798 {
6799 //No encryption
6800 pScanFilter->EncryptionType.numEntries = 1;
6801 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6802 }//we don't have a profile
6803 else
6804 {
6805 //Here is the profile we need to connect to
6806 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6807 }//We have a profile
6808 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6809 if(pRoamId)
6810 {
6811 *pRoamId = roamId;
6812 }
6813
6814 if(HAL_STATUS_SUCCESS(status))
6815 {
6816 /*Save the WPS info*/
6817 if(NULL != pProfile)
6818 {
6819 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006820 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 }
6822 else
6823 {
6824 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006825 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 do
6828 {
6829 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 )
6832 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006833 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6835 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6836 if(!HAL_STATUS_SUCCESS(status))
6837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006838 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 fCallCallback = eANI_BOOLEAN_TRUE;
6840 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006841 else
6842 {
6843 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 break;
6846 }
6847 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006848 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 if(HAL_STATUS_SUCCESS(status))
6850 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6852 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6853 if(!HAL_STATUS_SUCCESS(status))
6854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006855 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 csrScanResultPurge(pMac, hBSSList);
6857 fCallCallback = eANI_BOOLEAN_TRUE;
6858 }
6859 }//Have scan result
6860 else if(NULL != pProfile)
6861 {
6862 //Check whether it is for start ibss
6863 if(CSR_IS_START_IBSS(pProfile))
6864 {
6865 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6866 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6867 if(!HAL_STATUS_SUCCESS(status))
6868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006869 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 fCallCallback = eANI_BOOLEAN_TRUE;
6871 }
6872 }
6873 else
6874 {
6875 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006876 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 if(!HAL_STATUS_SUCCESS(status))
6878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006879 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 fCallCallback = eANI_BOOLEAN_TRUE;
6881 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006882 else
6883 {
6884 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 }
6887 }
6888 else
6889 {
6890 fCallCallback = eANI_BOOLEAN_TRUE;
6891 }
6892 } while (0);
6893 if(NULL != pProfile)
6894 {
6895 //we need to free memory for filter if profile exists
6896 csrFreeScanFilter(pMac, pScanFilter);
6897 }
6898 }//Got the scan filter from profile
6899
Kiet Lam64c1b492013-07-12 13:56:44 +05306900 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 }//allocated memory for pScanFilter
6902 }//No Bsslist coming in
6903 //tell the caller if we fail to trigger a join request
6904 if( fCallCallback )
6905 {
6906 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6907 }
6908
6909 return (status);
6910}
Jeff Johnson295189b2012-06-20 16:38:30 -07006911eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6912 tCsrRoamModifyProfileFields modProfileFields,
6913 tANI_U32 *pRoamId)
6914{
6915 eHalStatus status = eHAL_STATUS_SUCCESS;
6916 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6917 tANI_U32 roamId = 0;
6918 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 if (NULL == pProfile)
6920 {
6921 smsLog(pMac, LOGP, FL("No profile specified"));
6922 return eHAL_STATUS_FAILURE;
6923 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306924 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6925 "encryType = %d"),
6926 lim_BssTypetoString(pProfile->BSSType),
6927 pProfile->BSSType,
6928 pProfile->AuthType.authType[0],
6929 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 csrRoamCancelRoaming(pMac, sessionId);
6931 csrScanRemoveFreshScanCommand(pMac, sessionId);
6932 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306933 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 if(csrIsConnStateConnected(pMac, sessionId))
6936 {
6937 if(pProfile)
6938 {
6939 if(pProfile->SSIDs.numOfSSIDs &&
6940 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6941 {
6942 fCallCallback = eANI_BOOLEAN_FALSE;
6943 }
6944 else
6945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006946 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 }
6948 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306949 else if (!vos_mem_compare(&modProfileFields,
6950 &pSession->connectedProfile.modifyProfileFields,
6951 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 {
6953 fCallCallback = eANI_BOOLEAN_FALSE;
6954 }
6955 else
6956 {
6957 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006958 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 }
6960 }
6961 else
6962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006963 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 if(!fCallCallback)
6966 {
6967 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6968 if(pRoamId)
6969 {
6970 *pRoamId = roamId;
6971 }
6972
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6974 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 }
6976 else
6977 {
6978 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6979 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 return status;
6982}
Jeff Johnson295189b2012-06-20 16:38:30 -07006983eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6984{
6985 eHalStatus status = eHAL_STATUS_FAILURE;
6986 tScanResultHandle hBSSList = NULL;
6987 tCsrScanResultFilter *pScanFilter = NULL;
6988 tANI_U32 roamId;
6989 tCsrRoamProfile *pProfile = NULL;
6990 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006991
6992 if(!pSession)
6993 {
6994 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6995 return eHAL_STATUS_FAILURE;
6996 }
6997
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 do
6999 {
7000 if(pSession->pCurRoamProfile)
7001 {
7002 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307003 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307005 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7006 if ( NULL == pProfile )
7007 status = eHAL_STATUS_FAILURE;
7008 else
7009 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 if(!HAL_STATUS_SUCCESS(status))
7011 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307012 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307014 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307016 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7017 if ( NULL == pScanFilter )
7018 status = eHAL_STATUS_FAILURE;
7019 else
7020 status = eHAL_STATUS_SUCCESS;
7021
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 if(!HAL_STATUS_SUCCESS(status))
7023 {
7024 break;
7025 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307026 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7028 if(!HAL_STATUS_SUCCESS(status))
7029 {
7030 break;
7031 }
7032 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7033 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7034 if(HAL_STATUS_SUCCESS(status))
7035 {
7036 //we want to put the last connected BSS to the very beginning, if possible
7037 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7038 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7039 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7040 if(!HAL_STATUS_SUCCESS(status))
7041 {
7042 csrScanResultPurge(pMac, hBSSList);
7043 break;
7044 }
7045 }
7046 else
7047 {
7048 //Do a scan on this profile
7049 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007050 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 if(!HAL_STATUS_SUCCESS(status))
7052 {
7053 break;
7054 }
7055 }
7056 }//We have a profile
7057 else
7058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007059 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 break;
7061 }
7062 }while(0);
7063 if(pScanFilter)
7064 {
7065 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307066 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 }
7068 if(NULL != pProfile)
7069 {
7070 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307071 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 return (status);
7074}
Jeff Johnson295189b2012-06-20 16:38:30 -07007075eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7076{
7077 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 if(csrIsConnStateConnected(pMac, sessionId))
7079 {
7080 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7081 if(HAL_STATUS_SUCCESS(status))
7082 {
7083 status = csrRoamJoinLastProfile(pMac, sessionId);
7084 }
7085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 return (status);
7087}
7088
Jeff Johnson295189b2012-06-20 16:38:30 -07007089eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7090{
7091 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007092 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 csrRoamCancelRoaming(pMac, sessionId);
7094 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7095 if(csrIsConnStateDisconnected(pMac, sessionId))
7096 {
7097 status = csrRoamJoinLastProfile(pMac, sessionId);
7098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 return (status);
7100}
7101
Jeff Johnson295189b2012-06-20 16:38:30 -07007102eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7103{
7104 eHalStatus status = eHAL_STATUS_SUCCESS;
7105 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7106 eCsrRoamSubState NewSubstate;
7107 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307108
7109 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7110 {
7111 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7112 " eCSR_ROAM_SUBSTATE_NONE"));
7113 csrRoamStopWaitForKeyTimer( pMac );
7114 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 // change state to 'Roaming'...
7117 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7118
7119 if ( csrIsConnStateIbss( pMac, sessionId ) )
7120 {
7121 // If we are in an IBSS, then stop the IBSS...
7122 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7123 fComplete = (!HAL_STATUS_SUCCESS(status));
7124 }
7125 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007127 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 -07007128 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7129 //Restore AC weight in case we change it
7130 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7131 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7132 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7133 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7134 {
7135 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7136 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307137 else
7138 {
7139 // If we are in neighbor preauth done state then on receiving
7140 // disassoc or deauth we dont roam instead we just disassoc
7141 // from current ap and then go to disconnected state
7142 // This happens for ESE and 11r FT connections ONLY.
7143#ifdef WLAN_FEATURE_VOWIFI_11R
7144 if (csrRoamIs11rAssoc(pMac) &&
7145 (csrNeighborRoamStatePreauthDone(pMac)))
7146 {
7147 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7148 }
7149#endif
7150#ifdef FEATURE_WLAN_ESE
7151 if (csrRoamIsESEAssoc(pMac) &&
7152 (csrNeighborRoamStatePreauthDone(pMac)))
7153 {
7154 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7155 }
7156#endif
7157#ifdef FEATURE_WLAN_LFR
7158 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7159 (csrNeighborRoamStatePreauthDone(pMac)))
7160 {
7161 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7162 }
7163#endif
7164 }
7165
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 if( fDisassoc )
7167 {
7168 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307169 if (pMac->roam.configParam.roamDelayStatsEnabled)
7170 {
7171 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 }
7174 else
7175 {
7176 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7177 }
7178 fComplete = (!HAL_STATUS_SUCCESS(status));
7179 }
7180 else if ( csrIsConnStateWds( pMac, sessionId ) )
7181 {
7182 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7183 {
7184 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7185 fComplete = (!HAL_STATUS_SUCCESS(status));
7186 }
7187 //This has to be WDS station
7188 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7189 {
7190
7191 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7192 if( fDisassoc )
7193 {
7194 status = csrRoamIssueDisassociate( pMac, sessionId,
7195 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7196 fComplete = (!HAL_STATUS_SUCCESS(status));
7197 }
7198 }
7199 } else {
7200 // we got a dis-assoc request while not connected to any peer
7201 // just complete the command
7202 fComplete = eANI_BOOLEAN_TRUE;
7203 status = eHAL_STATUS_FAILURE;
7204 }
7205 if(fComplete)
7206 {
7207 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7208 }
7209
7210 if(HAL_STATUS_SUCCESS(status))
7211 {
7212 if ( csrIsConnStateInfra( pMac, sessionId ) )
7213 {
7214 //Set the state to disconnect here
7215 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307216#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7217 //we don't need to run this timer any more
7218 if (VOS_TIMER_STATE_RUNNING ==
7219 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7220 {
7221 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7222 if (status != eHAL_STATUS_SUCCESS)
7223 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7224 }
7225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 }
7227 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007228 else
7229 {
7230 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 return (status);
7233}
7234
Jeff Johnson295189b2012-06-20 16:38:30 -07007235/* This is been removed from latest code base */
7236/*
7237static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7238{
7239 eHalStatus status;
7240 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7242 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 return ( status );
7244}
7245*/
7246
Jeff Johnson295189b2012-06-20 16:38:30 -07007247eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7248{
7249 eHalStatus status = eHAL_STATUS_SUCCESS;
7250 tSmeCmd *pCommand;
7251 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 do
7253 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 pCommand = csrGetCommandBuffer( pMac );
7255 if ( !pCommand )
7256 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007257 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 status = eHAL_STATUS_RESOURCES;
7259 break;
7260 }
7261 //Change the substate in case it is wait-for-key
7262 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7263 {
7264 csrRoamStopWaitForKeyTimer( pMac );
7265 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7266 }
7267 pCommand->command = eSmeCommandRoam;
7268 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307269 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7270 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 switch ( reason )
7272 {
7273 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7274 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7275 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 case eCSR_DISCONNECT_REASON_DEAUTH:
7277 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7278 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 case eCSR_DISCONNECT_REASON_HANDOFF:
7280 fHighPriority = eANI_BOOLEAN_TRUE;
7281 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7282 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7284 case eCSR_DISCONNECT_REASON_DISASSOC:
7285 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7288 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7289 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7291 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7292 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 default:
7294 break;
7295 }
7296 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7297 if( !HAL_STATUS_SUCCESS( status ) )
7298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007299 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 csrReleaseCommandRoam( pMac, pCommand );
7301 }
7302 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007303 return( status );
7304}
7305
Jeff Johnson295189b2012-06-20 16:38:30 -07007306eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7307{
7308 eHalStatus status = eHAL_STATUS_SUCCESS;
7309 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 pCommand = csrGetCommandBuffer( pMac );
7311 if ( NULL != pCommand )
7312 {
7313 //Change the substate in case it is wait-for-key
7314 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7315 {
7316 csrRoamStopWaitForKeyTimer( pMac );
7317 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7318 }
7319 pCommand->command = eSmeCommandRoam;
7320 pCommand->sessionId = (tANI_U8)sessionId;
7321 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7322 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7323 if( !HAL_STATUS_SUCCESS( status ) )
7324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007325 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 csrReleaseCommandRoam( pMac, pCommand );
7327 }
7328 }
7329 else
7330 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007331 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 status = eHAL_STATUS_RESOURCES;
7333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 return ( status );
7335}
7336
Jeff Johnson295189b2012-06-20 16:38:30 -07007337eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7338{
7339 eHalStatus status = eHAL_STATUS_SUCCESS;
7340 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007341
7342 if(!pSession)
7343 {
7344 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7345 return eHAL_STATUS_FAILURE;
7346 }
7347
Jeff Johnson295189b2012-06-20 16:38:30 -07007348#ifdef FEATURE_WLAN_BTAMP_UT_RF
7349 //Stop te retry
7350 pSession->maxRetryCount = 0;
7351 csrRoamStopJoinRetryTimer(pMac, sessionId);
7352#endif
7353 //Not to call cancel roaming here
7354 //Only issue disconnect when necessary
7355 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7356 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7357 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7358
7359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007360 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7362 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307363 else
7364 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307365 csrScanAbortScanForSSID(pMac, sessionId);
7366 status = eHAL_STATUS_CMD_NOT_QUEUED;
7367 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7368 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 return (status);
7371}
7372
Jeff Johnson295189b2012-06-20 16:38:30 -07007373eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7374{
7375 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007376
7377 if(!pSession)
7378 {
7379 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7380 return eHAL_STATUS_FAILURE;
7381 }
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7385
7386 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7387}
7388
Jeff Johnson295189b2012-06-20 16:38:30 -07007389eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7390 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7391{
7392 eHalStatus status = eHAL_STATUS_SUCCESS;
7393 tDot11fBeaconIEs *pIesTemp = pIes;
7394 tANI_U8 index;
7395 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7396 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007397
7398 if(!pSession)
7399 {
7400 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7401 return eHAL_STATUS_FAILURE;
7402 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007403 if(pConnectProfile->pAddIEAssoc)
7404 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307405 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007406 pConnectProfile->pAddIEAssoc = NULL;
7407 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307408 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7410 pConnectProfile->AuthInfo = pProfile->AuthType;
7411 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7412 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7413 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7414 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7415 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7416 pConnectProfile->BSSType = pProfile->BSSType;
7417 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7418 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007419 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307420 if (!pConnectProfile->beaconInterval)
7421 {
7422 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7423 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307424 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007425 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7426 if(pProfile->nAddIEAssocLength)
7427 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307428 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7429 if ( NULL == pConnectProfile->pAddIEAssoc )
7430 status = eHAL_STATUS_FAILURE;
7431 else
7432 status = eHAL_STATUS_SUCCESS;
7433 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007434 {
7435 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7436 return eHAL_STATUS_FAILURE;
7437 }
7438 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307439 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7440 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007441 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307442
7443#ifdef WLAN_FEATURE_11W
7444 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7445 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7446 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7447#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007448
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 //Save bssid
7450 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7451#ifdef WLAN_FEATURE_VOWIFI_11R
7452 if (pSirBssDesc->mdiePresent)
7453 {
7454 pConnectProfile->MDID.mdiePresent = 1;
7455 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7456 }
7457#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007458 if( NULL == pIesTemp )
7459 {
7460 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7461 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007462#ifdef FEATURE_WLAN_ESE
7463 if ((csrIsProfileESE(pProfile) ||
7464 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307465 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7466 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7467 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7468 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7469#ifdef WLAN_FEATURE_11W
7470 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307471 || (pProfile->negotiatedAuthType ==
7472 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307473#endif
7474 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007475 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007477 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 }
7479#endif
7480 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 if(HAL_STATUS_SUCCESS(status))
7482 {
7483 if(pIesTemp->SSID.present)
7484 {
7485 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307486 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7487 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 }
7489
7490 //Save the bss desc
7491 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307492
7493 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307495 //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 -07007496 pConnectProfile->qap = TRUE;
7497 }
7498 else
7499 {
7500 pConnectProfile->qap = FALSE;
7501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 if ( NULL == pIes )
7503 {
7504 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307505 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 }
7507 }
7508 //Save Qos connection
7509 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7510
7511 if(!HAL_STATUS_SUCCESS(status))
7512 {
7513 csrFreeConnectBssDesc(pMac, sessionId);
7514 }
7515 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7516 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307517 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7518 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7519 pConnectProfile->SSID.ssId,
7520 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 {
7522 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7523 break;
7524 }
7525 pConnectProfile->handoffPermitted = FALSE;
7526 }
7527
7528 return (status);
7529}
7530
Jeff Johnson295189b2012-06-20 16:38:30 -07007531static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7532{
7533 tListElem *pEntry = NULL;
7534 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 //The head of the active list is the request we sent
7536 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7537 if(pEntry)
7538 {
7539 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7542 {
7543 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7544 {
7545#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7546 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7547#endif
7548 }
7549 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7550 }
7551 else
7552 {
7553 tANI_U32 roamId = 0;
7554 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007555 if(!pSession)
7556 {
7557 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7558 return;
7559 }
7560
Jeff Johnson295189b2012-06-20 16:38:30 -07007561
7562 //The head of the active list is the request we sent
7563 //Try to get back the same profile and roam again
7564 if(pCommand)
7565 {
7566 roamId = pCommand->u.roamCmd.roamId;
7567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7569 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007570 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007571#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7572 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7573 if (csrRoamIsHandoffInProgress(pMac))
7574 {
7575 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7576 /* Should indicate neighbor roam algorithm about the connect failure here */
7577 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7578 }
7579#endif
7580 if (pCommand)
7581 {
7582 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7583 {
7584 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7585 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7586 csrRoamReissueRoamCommand(pMac);
7587 }
7588 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7589 {
7590 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7591 }
7592 else
7593 {
7594 csrRoam(pMac, pCommand);
7595 }
7596 }
7597 else
7598 {
7599 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7600 }
7601 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7602}
7603
Jeff Johnson295189b2012-06-20 16:38:30 -07007604eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7605 tDot11fBeaconIEs *pIes,
7606 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7607{
7608 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007609 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7610 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007611
7612 // Set the roaming substate to 'join attempt'...
7613 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007615 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 return (status);
7617}
7618
Jeff Johnson295189b2012-06-20 16:38:30 -07007619static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7620 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7621{
7622 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 // Set the roaming substate to 'join attempt'...
7624 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7625
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307626 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7627 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307628 if (pMac->roam.configParam.roamDelayStatsEnabled)
7629 {
7630 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7631 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007634 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007635}
7636
Jeff Johnson295189b2012-06-20 16:38:30 -07007637void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7638{
7639 tListElem *pEntry;
7640 tSmeCmd *pCommand;
7641 tCsrRoamInfo roamInfo;
7642 tANI_U32 sessionId;
7643 tCsrRoamSession *pSession;
7644
7645 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7646 if(pEntry)
7647 {
7648 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7649 if ( eSmeCommandRoam == pCommand->command )
7650 {
7651 sessionId = pCommand->sessionId;
7652 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007653
7654 if(!pSession)
7655 {
7656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7657 return;
7658 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307659 /* While switching between two AP, csr will reissue roam command again
7660 to the nextbss if it was interrupted by the dissconnect req for the
7661 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7662 so reset the bRefAssocStartCnt.
7663 */
7664 if(pSession->bRefAssocStartCnt > 0)
7665 {
7666 pSession->bRefAssocStartCnt--;
7667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 if( pCommand->u.roamCmd.fStopWds )
7669 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307670 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7672 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7673 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007675 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7676 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7677 eCSR_ROAM_WDS_IND,
7678 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7680 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7681 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7682 eCSR_ROAM_INFRA_IND,
7683 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7684 }
7685
Jeff Johnson295189b2012-06-20 16:38:30 -07007686
Jeff Johnson295189b2012-06-20 16:38:30 -07007687 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007689 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7691 }
7692 }
7693 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007695 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7697 }
7698 }
7699 else
7700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007701 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 }
7703 }
7704 else
7705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007706 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 }
7708}
7709
Jeff Johnson295189b2012-06-20 16:38:30 -07007710tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7711{
7712 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7713 tListElem *pEntry;
7714 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 //alwasy lock active list before locking pending list
7716 csrLLLock( &pMac->sme.smeCmdActiveList );
7717 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7718 if(pEntry)
7719 {
7720 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7721 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7722 {
7723 fRet = eANI_BOOLEAN_TRUE;
7724 }
7725 }
7726 if(eANI_BOOLEAN_FALSE == fRet)
7727 {
7728 csrLLLock(&pMac->sme.smeCmdPendingList);
7729 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7730 while(pEntry)
7731 {
7732 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7733 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7734 {
7735 fRet = eANI_BOOLEAN_TRUE;
7736 break;
7737 }
7738 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7739 }
7740 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7741 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307742 if (eANI_BOOLEAN_FALSE == fRet)
7743 {
7744 csrLLLock(&pMac->roam.roamCmdPendingList);
7745 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7746 while (pEntry)
7747 {
7748 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7749 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7750 {
7751 fRet = eANI_BOOLEAN_TRUE;
7752 break;
7753 }
7754 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7755 }
7756 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 return (fRet);
7760}
7761
Jeff Johnson295189b2012-06-20 16:38:30 -07007762tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7763{
7764 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7765 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7767 {
7768 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7769 {
7770 break;
7771 }
7772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 return ( fRet );
7774}
7775
Jeff Johnson295189b2012-06-20 16:38:30 -07007776tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7777{
7778 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 //alwasy lock active list before locking pending list
7780 csrLLLock( &pMac->sme.smeCmdActiveList );
7781 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7782 if(eANI_BOOLEAN_FALSE == fRet)
7783 {
7784 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7785 }
7786 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 return (fRet);
7788}
7789
Jeff Johnson295189b2012-06-20 16:38:30 -07007790tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7791{
7792 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7793 tListElem *pEntry;
7794 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 //alwasy lock active list before locking pending list
7796 csrLLLock( &pMac->sme.smeCmdActiveList );
7797 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7798 if( pEntry )
7799 {
7800 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7801 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7802 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7803 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7804 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7805 {
7806 fRet = eANI_BOOLEAN_TRUE;
7807 }
7808 }
7809 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 return (fRet);
7811}
Jeff Johnson295189b2012-06-20 16:38:30 -07007812eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7813{
7814 eHalStatus status = eHAL_STATUS_SUCCESS;
7815 tSmeCmd *pCommand = NULL;
7816 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7817 tANI_BOOLEAN fRemoveCmd = FALSE;
7818 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 // Delete the old assoc command. All is setup for reassoc to be serialized
7820 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7821 if ( pEntry )
7822 {
7823 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7824 if ( !pCommand )
7825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007826 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 return eHAL_STATUS_RESOURCES;
7828 }
7829 if ( eSmeCommandRoam == pCommand->command )
7830 {
7831 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7832 {
7833 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7834 }
7835 else
7836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007837 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 }
7839 if (fRemoveCmd == FALSE)
7840 {
7841 // Implies we did not get the serialized assoc command we
7842 // were expecting
7843 pCommand = NULL;
7844 }
7845 }
7846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 if(NULL == pCommand)
7848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007849 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 return eHAL_STATUS_RESOURCES;
7851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 do
7853 {
7854 //Change the substate in case it is wait-for-key
7855 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7856 {
7857 csrRoamStopWaitForKeyTimer( pMac );
7858 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7859 }
7860 pCommand->command = eSmeCommandRoam;
7861 pCommand->sessionId = (tANI_U8)sessionId;
7862 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7864 if( !HAL_STATUS_SUCCESS( status ) )
7865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007866 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 csrReleaseCommandRoam( pMac, pCommand );
7868 }
7869 } while( 0 );
7870
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 return( status );
7872}
7873static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7874{
7875 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7876 tCsrScanResult *pScanResult = NULL;
7877 tSirBssDescription *pBssDesc = NULL;
7878 tSmeCmd *pCommand = NULL;
7879 tANI_U32 sessionId;
7880 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007881 if(NULL == pEntry)
7882 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307883 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 return;
7885 }
7886 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7887 sessionId = pCommand->sessionId;
7888 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007889
7890 if(!pSession)
7891 {
7892 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7893 return;
7894 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307895 smsLog(pMac, LOG1, FL("CFG return value is %d "
7896 " current state is : %d substate is : %d "),
7897 result, pMac->roam.curState[sessionId],
7898 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7900 {
7901 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007902 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7904 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007905 /* If the roaming has stopped, not to continue the roaming command*/
7906 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7907 {
7908 //No need to complete roaming here as it already completes
7909 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7910 pCommand->u.roamCmd.roamReason);
7911 csrSetAbortRoamingCommand( pMac, pCommand );
7912 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 else
7915 {
7916 if ( CCM_IS_RESULT_SUCCESS(result) )
7917 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307918 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 // Successfully set the configuration parameters for the new Bss. Attempt to
7920 // join the roaming Bss.
7921 if(pCommand->u.roamCmd.pRoamBssEntry)
7922 {
7923 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7924 pBssDesc = &pScanResult->Result.BssDescriptor;
7925 }
7926 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7927 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 )
7930 {
7931 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7932 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7933 pBssDesc, pCommand->u.roamCmd.roamId )))
7934 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307935 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 //We need to complete the command
7937 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7938 }
7939 }
7940 else
7941 {
7942 if (!pCommand->u.roamCmd.pRoamBssEntry)
7943 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307944 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 //We need to complete the command
7946 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7947 return;
7948 }
7949 // If we are roaming TO an Infrastructure BSS...
7950 VOS_ASSERT(pScanResult != NULL);
7951 if ( csrIsInfraBssDesc( pBssDesc ) )
7952 {
7953 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307954 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7956 {
7957 // ..and currently in an Infrastructure connection....
7958 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7959 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307960 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 // ...and the SSIDs are equal, then we Reassoc.
7962 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7963 pIesLocal ) )
7964 // ..and currently in an infrastructure connection
7965 {
7966 // then issue a Reassoc.
7967 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7968 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7969 &pCommand->u.roamCmd.roamProfile );
7970 }
7971 else
7972 {
7973
7974 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7975 // previously associated AP.
7976 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7977 pIesLocal,
7978 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7979 {
7980 //try something else
7981 csrRoam( pMac, pCommand );
7982 }
7983 }
7984 }
7985 else
7986 {
7987 eHalStatus status = eHAL_STATUS_SUCCESS;
7988
7989 /* We need to come with other way to figure out that this is because of HO in BMP
7990 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007991 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 * use join request */
7993#ifdef WLAN_FEATURE_VOWIFI_11R
7994 if (csrRoamIsHandoffInProgress(pMac) &&
7995 csrRoamIs11rAssoc(pMac))
7996 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307997 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7999 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8000 }
8001 else
8002#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008003#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008005 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308007 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 // Now serialize the reassoc command.
8009 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8010 }
8011 else
8012#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008013#ifdef FEATURE_WLAN_LFR
8014 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308015 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008016 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308017 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008018 // Now serialize the reassoc command.
8019 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8020 }
8021 else
8022#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 // else we are not connected and attempting to Join. Issue the
8024 // Join request.
8025 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308026 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8028 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8029 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8030 }
8031 if(!HAL_STATUS_SUCCESS(status))
8032 {
8033 //try something else
8034 csrRoam( pMac, pCommand );
8035 }
8036 }
8037 if( !pScanResult->Result.pvIes )
8038 {
8039 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308040 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 }
8043 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8044 else
8045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008046 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 }
8048 }//else
8049 }//if ( WNI_CFG_SUCCESS == result )
8050 else
8051 {
8052 // In the event the configuration failed, for infra let the roam processor
8053 //attempt to join something else...
8054 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8055 {
8056 csrRoam(pMac, pCommand);
8057 }
8058 else
8059 {
8060 //We need to complete the command
8061 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8062 {
8063 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8064 }
8065 else
8066 {
8067 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8068 }
8069 }
8070 }
8071 }//we have active entry
8072}
8073
Jeff Johnson295189b2012-06-20 16:38:30 -07008074static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8075{
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008078 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8080 // join the new one...
8081 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8083 }
8084 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008085 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 /***profHandleLostLinkAfterReset(pAdapter);
8087 // In the event the authenticate fails, let the roam processor attempt to join something else...
8088 roamRoam( pAdapter );***/
8089 }
8090}
8091
Jeff Johnson295189b2012-06-20 16:38:30 -07008092static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8093{
8094 eCsrRoamCompleteResult result;
8095 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8096 tCsrRoamInfo roamInfo;
8097 tANI_U32 roamId = 0;
8098
8099 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
8100 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008101 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008103 /* Defeaturize this part later if needed */
8104#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8105 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8106 * we need the response contents while processing the result in csrRoamProcessResults() */
8107 if (csrRoamIsHandoffInProgress(pMac))
8108 {
8109 /* Need to dig more on indicating events to SME QoS module */
8110 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8111 csrRoamComplete( pMac, result, pSmeJoinRsp);
8112 }
8113 else
8114#endif
8115 {
8116 csrRoamComplete( pMac, result, NULL );
8117 }
8118 }
8119 /* Should we handle this similar to handling the join failure? Is it ok
8120 * to call csrRoamComplete() with state as CsrJoinFailure */
8121 else
8122 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008123 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 result = eCsrReassocFailure;
8125#ifdef WLAN_FEATURE_VOWIFI_11R
8126 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308127 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8128 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 {
8130 // Inform HDD to turn off FT flag in HDD
8131 if (pNeighborRoamInfo)
8132 {
8133 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8134 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8135 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008136 /*
8137 * Since the above callback sends a disconnect
8138 * to HDD, we should clean-up our state
8139 * machine as well to be in sync with the upper
8140 * layers. There is no need to send a disassoc
8141 * since: 1) we will never reassoc to the current
8142 * AP in LFR, and 2) there is no need to issue a
8143 * disassoc to the AP with which we were trying
8144 * to reassoc.
8145 */
8146 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8147 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 }
8149 }
8150#endif
8151 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8152 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8153 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8154 //The disassoc rsp message will remove the command from active list
8155 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8156 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8157 {
8158 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8159 }
8160 }
8161}
8162
Jeff Johnson295189b2012-06-20 16:38:30 -07008163static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8164{
Jeff Johnson295189b2012-06-20 16:38:30 -07008165#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8166 {
8167 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8169 if(pIbssLog)
8170 {
8171 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8172 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8173 {
8174 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8175 }
8176 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8177 }
8178 }
8179#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8181 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8182 {
8183 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8184 }
8185 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8186 {
8187 csrRoamReissueRoamCommand(pMac);
8188 }
8189}
8190
Jeff Johnson295189b2012-06-20 16:38:30 -07008191void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8192{
8193 tSirResultCodes statusCode;
8194#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8195 tScanResultHandle hBSSList;
8196 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8197 eHalStatus status;
8198 tCsrRoamInfo roamInfo;
8199 tCsrScanResultFilter *pScanFilter = NULL;
8200 tANI_U32 roamId = 0;
8201 tCsrRoamProfile *pCurRoamProfile = NULL;
8202 tListElem *pEntry = NULL;
8203 tSmeCmd *pCommand = NULL;
8204#endif
8205 tANI_U32 sessionId;
8206 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008207
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 tSirSmeDisassocRsp SmeDisassocRsp;
8209
8210 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8211 sessionId = SmeDisassocRsp.sessionId;
8212 statusCode = SmeDisassocRsp.statusCode;
8213
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008214 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008215
8216 if ( csrIsConnStateInfra( pMac, sessionId ) )
8217 {
8218 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008221
8222 if(!pSession)
8223 {
8224 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8225 return;
8226 }
8227
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8229 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308230 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8232 }
8233 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8234 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8235 {
8236 if ( eSIR_SME_SUCCESS == statusCode )
8237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008238 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8240 }
8241 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8244 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308245 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8246 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008247#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008248 /*
8249 * First ensure if the roam profile is in the scan cache.
8250 * If not, post a reassoc failure and disconnect.
8251 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308252 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8253 if ( NULL == pScanFilter )
8254 status = eHAL_STATUS_FAILURE;
8255 else
8256 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008257 if(HAL_STATUS_SUCCESS(status))
8258 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308259 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008260 status = csrRoamPrepareFilterFromProfile(pMac,
8261 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8262 if(!HAL_STATUS_SUCCESS(status))
8263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008264 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008265 __func__, status);
8266 goto POST_ROAM_FAILURE;
8267 }
8268 else
8269 {
8270 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8271 if (!HAL_STATUS_SUCCESS(status))
8272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008273 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008274 __func__, status);
8275 goto POST_ROAM_FAILURE;
8276 }
8277 }
8278 }
8279 else
8280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008281 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008282 __func__, status);
8283 goto POST_ROAM_FAILURE;
8284 }
8285
8286 /*
8287 * After ensuring that the roam profile is in the scan result list,
8288 * dequeue the command from the active list.
8289 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8291 if ( pEntry )
8292 {
8293 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008294 /* If the head of the queue is Active and it is a ROAM command, remove
8295 * and put this on the Free queue.
8296 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 if ( eSmeCommandRoam == pCommand->command )
8298 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008299
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008300 /*
8301 * we need to process the result first before removing it from active list
8302 * because state changes still happening insides roamQProcessRoamResults so
8303 * no other roam command should be issued.
8304 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8306 if(pCommand->u.roamCmd.fReleaseProfile)
8307 {
8308 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8309 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 else
8314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008315 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008316 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 }
8318 }
8319 else
8320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008321 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 }
8323 }
8324 else
8325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008326 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008328
8329 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8331
Kiet Lam64c1b492013-07-12 13:56:44 +05308332 vos_mem_copy(roamInfo.bssid,
8333 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8334 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008335
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008336 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8337 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008338
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008339 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308340 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8341 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308343 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008344 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8345 //make sure to put it at the head of the cmd queue
8346 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8347 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8348 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8349
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 if(!HAL_STATUS_SUCCESS(status))
8351 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008352 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008353 __func__, status);
8354 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 }
8356
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008357 /* Notify sub-modules like QoS etc. that handoff happening */
8358 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308359 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008360 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308361 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308363 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008364 return;
8365 }
8366
8367POST_ROAM_FAILURE:
8368 if (pScanFilter)
8369 {
8370 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308371 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008372 }
8373 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308374 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008375
8376 /* Inform the upper layers that the reassoc failed */
8377 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8378 csrRoamCallCallback(pMac, sessionId,
8379 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8380
8381 /*
8382 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8383 * Upon success, we would re-enter this routine after receiving the disassoc
8384 * response and will fall into the reassoc fail sub-state. And, eventually
8385 * call csrRoamComplete which would remove the roam command from SME active
8386 * queue.
8387 */
8388 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8389 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008391 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008392 __func__, status);
8393 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008395#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008396
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8398 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8399 {
8400 // Disassoc due to Reassoc failure falls into this codepath....
8401 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8402 }
8403 else
8404 {
8405 if ( eSIR_SME_SUCCESS == statusCode )
8406 {
8407 // Successfully disassociated from the 'old' Bss...
8408 //
8409 // We get Disassociate response in three conditions.
8410 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8411 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8412 // Infrastructure network.
8413 // - Third is where we are doing an Infra to Infra roam between networks with different
8414 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8415
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008416 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008417 }
8418 else
8419 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008420 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 }
8422 //We are not done yet. Get the data and continue roaming
8423 csrRoamReissueRoamCommand(pMac);
8424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008425}
8426
Jeff Johnson295189b2012-06-20 16:38:30 -07008427static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8428{
8429 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008431 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8433 {
8434 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8435 }
8436 else
8437 {
8438 if ( eSIR_SME_SUCCESS == statusCode )
8439 {
8440 // Successfully deauth from the 'old' Bss...
8441 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008442 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 }
8444 else
8445 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008446 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 }
8448 //We are not done yet. Get the data and continue roaming
8449 csrRoamReissueRoamCommand(pMac);
8450 }
8451}
8452
Jeff Johnson295189b2012-06-20 16:38:30 -07008453static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8454{
8455 eCsrRoamCompleteResult result;
8456
8457 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008459 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 result = eCsrStartBssSuccess;
8461 }
8462 else
8463 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008464 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 //Let csrRoamComplete decide what to do
8466 result = eCsrStartBssFailure;
8467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008469}
8470
Jeff Johnson295189b2012-06-20 16:38:30 -07008471/*
8472 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8473 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8474 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8475 For the messages where sender allocates memory for specific structures, then it can be
8476 cast accordingly.
8477*/
8478void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8479{
8480 tSirSmeRsp *pSmeRsp;
8481 tSmeIbssPeerInd *pIbssPeerInd;
8482 tCsrRoamInfo roamInfo;
8483 // TODO Session Id need to be acquired in this function
8484 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308486 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8487 pSmeRsp->messageType, pSmeRsp->messageType,
8488 macTraceGetcsrRoamSubState(
8489 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 pSmeRsp->messageType = (pSmeRsp->messageType);
8491 pSmeRsp->length = (pSmeRsp->length);
8492 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 switch (pSmeRsp->messageType)
8494 {
8495
8496 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8497 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8498 {
8499 //We sent a JOIN_REQ
8500 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8501 }
8502 break;
8503
8504 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8505 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8506 {
8507 //We sent a AUTH_REQ
8508 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8509 }
8510 break;
8511
8512 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8513 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8514 {
8515 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8516 }
8517 break;
8518
8519 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8520 {
8521 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8522 }
8523 break;
8524
8525 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8526 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8527 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8528 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8529 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8530 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8531//HO
8532 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8533 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308534 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8535 macTraceGetcsrRoamSubState(
8536 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308538 if (pMac->roam.configParam.roamDelayStatsEnabled)
8539 {
8540 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 }
8543 break;
8544
8545 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8546 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8547 {
8548 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8549 }
8550 break;
8551
8552 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8553 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8554 {
8555 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8556 }
8557 break;
8558
8559 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8560 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8561 {
8562 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8566 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8567 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008568 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308569 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8570 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8572 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308573 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8574 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8576 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8577 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308580 smsLog(pMac, LOG1,
8581 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8582 pSmeRsp->messageType, pSmeRsp->messageType,
8583 macTraceGetcsrRoamSubState(
8584 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008585
8586 //If we are connected, check the link status change
8587 if(!csrIsConnStateDisconnected(pMac, sessionId))
8588 {
8589 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8590 }
8591 break;
8592 }
8593}
8594
Jeff Johnson295189b2012-06-20 16:38:30 -07008595void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8596{
8597 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008598 switch (pSirMsg->messageType)
8599 {
8600 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008601 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 csrRoamStatsRspProcessor( pMac, pSirMsg );
8603 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008604 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8605 {
8606 tCsrRoamSession *pSession;
8607 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8608 tCsrRoamInfo roamInfo;
8609 tCsrRoamInfo *pRoamInfo = NULL;
8610 tANI_U32 sessionId;
8611 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008612 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308613 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8616 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8617 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008618
8619 if(!pSession)
8620 {
8621 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8622 return;
8623 }
8624
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8626 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8628 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8629 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8631 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308632 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8633 sizeof(tSirMacAddr));
8634 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8635 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308637#ifdef WLAN_FEATURE_AP_HT40_24G
8638 pRoamInfo->HT40MHzIntoEnabledSta =
8639 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8640 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8641 pRoamInfo->HT40MHzIntoEnabledSta);
8642#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8644 {
8645 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8646 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8647 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8648 }
8649 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8650 {
8651 vos_sleep( 100 );
8652 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8653 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8654 }
8655
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 }
8657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 default:
8659 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8660 break;
8661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008662}
8663
Jeff Johnson295189b2012-06-20 16:38:30 -07008664eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8665 tSirBssDescription *pBssDescription,
8666 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8667 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8668 tANI_U8 keyId, tANI_U16 keyLength,
8669 tANI_U8 *pKey, tANI_U8 paeRole )
8670{
8671 eHalStatus status = eHAL_STATUS_SUCCESS;
8672 tAniEdType edType;
8673
8674 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8675 {
8676 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8677 }
8678
8679 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8680
8681 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8682 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8683 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8684 addKey )
8685 {
8686 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 setKey.encType = EncryptType;
8688 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308689 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 setKey.paeRole = paeRole; //0 for supplicant
8691 setKey.keyId = keyId; // Kye index
8692 setKey.keyLength = keyLength;
8693 if( keyLength )
8694 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308695 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 }
8697 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 return (status);
8700}
8701
Jeff Johnson295189b2012-06-20 16:38:30 -07008702static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8703 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8704{
8705 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8706 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008707#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008709#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008710
8711 do
8712 {
8713 pCommand = csrGetCommandBuffer(pMac);
8714 if(NULL == pCommand)
8715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008716 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 status = eHAL_STATUS_RESOURCES;
8718 break;
8719 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308720 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 pCommand->command = eSmeCommandSetKey;
8722 pCommand->sessionId = (tANI_U8)sessionId;
8723 // validate the key length, Adjust if too long...
8724 // for static WEP the keys are not set thru' SetContextReq
8725 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8726 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8727 {
8728 //KeyLength maybe 0 for static WEP
8729 if( pSetKey->keyLength )
8730 {
8731 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008733 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 break;
8735 }
8736
8737 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308738 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8739 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 }
8741 }
8742 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8743 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8744 {
8745 //KeyLength maybe 0 for static WEP
8746 if( pSetKey->keyLength )
8747 {
8748 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008750 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 break;
8752 }
8753
8754 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308755 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8756 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 }
8758 }
8759 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8760 {
8761 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008763 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 break;
8765 }
8766 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308767 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8768 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 }
8770 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8771 {
8772 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008774 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008775 break;
8776 }
8777 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308778 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8779 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 }
8781#ifdef FEATURE_WLAN_WAPI
8782 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8783 {
8784 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008786 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 break;
8788 }
8789 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308790 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8791 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008792 }
8793#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008794#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8796 {
8797 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008799 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 break;
8801 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008802 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308803 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008804 pSession->eseCckmInfo.reassoc_req_num=1;
8805 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 status = eHAL_STATUS_SUCCESS;
8807 break;
8808 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008809#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008810
Jeff Johnson295189b2012-06-20 16:38:30 -07008811#ifdef WLAN_FEATURE_11W
8812 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008813 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008815 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008817 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 break;
8819 }
8820 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308821 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 }
8823#endif
8824 status = eHAL_STATUS_SUCCESS;
8825 pCommand->u.setKeyCmd.roamId = roamId;
8826 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8827 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308828 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8829 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8831 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308832 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 //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
8834
8835 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8836 if( !HAL_STATUS_SUCCESS( status ) )
8837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008838 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 }
8840 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008842 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008843 if ( ( NULL != pCommand ) &&
8844 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008845#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008847#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008848 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 {
8850 csrReleaseCommandSetKey( pMac, pCommand );
8851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008852 return( status );
8853}
8854
Jeff Johnson295189b2012-06-20 16:38:30 -07008855eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8856 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8857{
8858 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8859 tSmeCmd *pCommand = NULL;
8860 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 do
8862 {
8863 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8864 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008865 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 status = eHAL_STATUS_CSR_WRONG_STATE;
8867 break;
8868 }
8869 pCommand = csrGetCommandBuffer(pMac);
8870 if(NULL == pCommand)
8871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008872 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 status = eHAL_STATUS_RESOURCES;
8874 break;
8875 }
8876 pCommand->command = eSmeCommandRemoveKey;
8877 pCommand->sessionId = (tANI_U8)sessionId;
8878 pCommand->u.removeKeyCmd.roamId = roamId;
8879 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308880 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8881 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8883 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8884 {
8885 //in this case, put it to the end of the Q incase there is a set key pending.
8886 fImediate = eANI_BOOLEAN_FALSE;
8887 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008888 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008890 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8892 if( !HAL_STATUS_SUCCESS( status ) )
8893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008894 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 break;
8896 }
8897 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8899 {
8900 csrReleaseCommandRemoveKey( pMac, pCommand );
8901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 return (status );
8903}
8904
Jeff Johnson295189b2012-06-20 16:38:30 -07008905eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8906{
8907 eHalStatus status;
8908 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8909 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8910 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8911 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008912#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8913 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8914 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308915 if(!pSession)
8916 {
8917 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8918 return eHAL_STATUS_FAILURE;
8919 }
lukez3c809222013-05-03 10:23:02 -07008920 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308922 vos_mem_set(&setKeyEvent,
8923 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8925 {
8926 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8927 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8928 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8929 }
8930 else
8931 {
8932 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8933 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8934 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8935 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308936 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008937 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 {
8939 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 //It has to be static WEP here
8941 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8942 {
8943 setKeyEvent.keyId = (v_U8_t)defKeyId;
8944 }
8945 }
8946 else
8947 {
8948 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8949 }
8950 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8951 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8952 }
8953#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 if( csrIsSetKeyAllowed(pMac, sessionId) )
8955 {
8956 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8957 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8958 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8959 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8960 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8961 pCommand->u.setKeyCmd.keyRsc);
8962 }
8963 else
8964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008965 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 //Set this status so the error handling take care of the case.
8967 status = eHAL_STATUS_CSR_WRONG_STATE;
8968 }
8969 if( !HAL_STATUS_SUCCESS(status) )
8970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008971 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008973#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008974 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 {
8976 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8977 {
8978 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8979 }
8980 else
8981 {
8982 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8983 }
8984 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8985 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8986 }
8987#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 return ( status );
8990}
8991
Jeff Johnson295189b2012-06-20 16:38:30 -07008992eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8993{
8994 eHalStatus status;
8995 tpSirSmeRemoveKeyReq pMsg = NULL;
8996 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8997 tANI_U8 *p;
8998 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008999#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9000 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9001 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309002 if(!pSession)
9003 {
9004 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9005 return eHAL_STATUS_FAILURE;
9006 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309007 vos_mem_set(&removeKeyEvent,
9008 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9010 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9011 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309012 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9014 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9015 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9016#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 if( csrIsSetKeyAllowed(pMac, sessionId) )
9018 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309019 pMsg = vos_mem_malloc(wMsgLen);
9020 if ( NULL == pMsg )
9021 status = eHAL_STATUS_FAILURE;
9022 else
9023 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 }
9025 else
9026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009027 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 //Set the error status so error handling kicks in below
9029 status = eHAL_STATUS_CSR_WRONG_STATE;
9030 }
9031 if( HAL_STATUS_SUCCESS( status ) )
9032 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309033 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9035 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009036 pMsg->sessionId = (tANI_U8)sessionId;
9037 pMsg->transactionId = 0;
9038 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9039 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9040 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309041 vos_mem_copy(p,
9042 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9043 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009044 p += sizeof(tSirMacAddr);
9045 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309046 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 p += sizeof(tSirMacAddr);
9048 // edType
9049 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9050 p++;
9051 // weptype
9052 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9053 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9054 {
9055 *p = (tANI_U8)eSIR_WEP_STATIC;
9056 }
9057 else
9058 {
9059 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9060 }
9061 p++;
9062 //keyid
9063 *p = pCommand->u.removeKeyCmd.keyId;
9064 p++;
9065 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 status = palSendMBMessage(pMac->hHdd, pMsg);
9067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 if( !HAL_STATUS_SUCCESS( status ) )
9069 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009070 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009071#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9072 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009073 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9075#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 return ( status );
9079}
9080
Jeff Johnson295189b2012-06-20 16:38:30 -07009081eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9082{
9083 eHalStatus status;
9084
9085 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9086 {
9087 status = eHAL_STATUS_CSR_WRONG_STATE;
9088 }
9089 else
9090 {
9091 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 return ( status );
9094}
9095
Jeff Johnson295189b2012-06-20 16:38:30 -07009096/*
9097 Prepare a filter base on a profile for parsing the scan results.
9098 Upon successful return, caller MUST call csrFreeScanFilter on
9099 pScanFilter when it is done with the filter.
9100*/
9101eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9102 tCsrScanResultFilter *pScanFilter)
9103{
9104 eHalStatus status = eHAL_STATUS_SUCCESS;
9105 tANI_U32 size = 0;
9106 tANI_U8 index = 0;
9107
9108 do
9109 {
9110 if(pProfile->BSSIDs.numOfBSSIDs)
9111 {
9112 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309113 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9114 if ( NULL == pScanFilter->BSSIDs.bssid )
9115 status = eHAL_STATUS_FAILURE;
9116 else
9117 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 if(!HAL_STATUS_SUCCESS(status))
9119 {
9120 break;
9121 }
9122 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309123 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 }
9125 if(pProfile->SSIDs.numOfSSIDs)
9126 {
9127 if( !CSR_IS_WDS_STA( pProfile ) )
9128 {
9129 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9130 }
9131 else
9132 {
9133 //For WDS station
9134 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9135 pScanFilter->SSIDs.numOfSSIDs = 1;
9136 }
9137 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309138 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9139 if ( NULL == pScanFilter->SSIDs.SSIDList )
9140 status = eHAL_STATUS_FAILURE;
9141 else
9142 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 if(!HAL_STATUS_SUCCESS(status))
9144 {
9145 break;
9146 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309147 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9148 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 }
9150 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9151 {
9152 pScanFilter->ChannelInfo.numOfChannels = 0;
9153 pScanFilter->ChannelInfo.ChannelList = NULL;
9154 }
9155 else if(pProfile->ChannelInfo.numOfChannels)
9156 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309157 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9158 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9159 pProfile->ChannelInfo.numOfChannels);
9160 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9161 status = eHAL_STATUS_FAILURE;
9162 else
9163 status = eHAL_STATUS_SUCCESS;
9164
Jeff Johnson295189b2012-06-20 16:38:30 -07009165 pScanFilter->ChannelInfo.numOfChannels = 0;
9166 if(HAL_STATUS_SUCCESS(status))
9167 {
9168 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9169 {
9170 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9171 {
9172 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9173 = pProfile->ChannelInfo.ChannelList[index];
9174 pScanFilter->ChannelInfo.numOfChannels++;
9175 }
9176 else
9177 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009178 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009180 }
9181 }
9182 else
9183 {
9184 break;
9185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 }
9187 else
9188 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309189 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 status = eHAL_STATUS_FAILURE;
9191 break;
9192 }
9193 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9194 pScanFilter->authType = pProfile->AuthType;
9195 pScanFilter->EncryptionType = pProfile->EncryptionType;
9196 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9197 pScanFilter->BSSType = pProfile->BSSType;
9198 pScanFilter->phyMode = pProfile->phyMode;
9199#ifdef FEATURE_WLAN_WAPI
9200 //check if user asked for WAPI with 11n or auto mode, in that case modify
9201 //the phymode to 11g
9202 if(csrIsProfileWapi(pProfile))
9203 {
9204 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9205 {
9206 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9207 }
9208 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9209 {
9210 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9211 }
9212 if(!pScanFilter->phyMode)
9213 {
9214 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9215 }
9216 }
9217#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 /*Save the WPS info*/
9219 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009220 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 if( pProfile->countryCode[0] )
9222 {
9223 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309224 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9225 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
9227#ifdef WLAN_FEATURE_VOWIFI_11R
9228 if (pProfile->MDID.mdiePresent)
9229 {
9230 pScanFilter->MDID.mdiePresent = 1;
9231 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9232 }
9233#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309234
9235#ifdef WLAN_FEATURE_11W
9236 // Management Frame Protection
9237 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9238 pScanFilter->MFPRequired = pProfile->MFPRequired;
9239 pScanFilter->MFPCapable = pProfile->MFPCapable;
9240#endif
9241
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 }while(0);
9243
9244 if(!HAL_STATUS_SUCCESS(status))
9245 {
9246 csrFreeScanFilter(pMac, pScanFilter);
9247 }
9248
9249 return(status);
9250}
9251
Jeff Johnson295189b2012-06-20 16:38:30 -07009252tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9253 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9254{
9255 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9256 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 do
9258 {
9259 // Validate the type is ok...
9260 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9261 pCommand = csrGetCommandBuffer( pMac );
9262 if ( !pCommand )
9263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009264 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009265 break;
9266 }
9267 //Change the substate in case it is waiting for key
9268 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9269 {
9270 csrRoamStopWaitForKeyTimer( pMac );
9271 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9272 }
9273 pCommand->command = eSmeCommandWmStatusChange;
9274 pCommand->sessionId = (tANI_U8)sessionId;
9275 pCommand->u.wmStatusChangeCmd.Type = Type;
9276 if ( eCsrDisassociated == Type )
9277 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309278 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9279 pSmeRsp,
9280 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 }
9282 else
9283 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309284 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9285 pSmeRsp,
9286 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009287 }
9288 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9289 {
9290 fCommandQueued = eANI_BOOLEAN_TRUE;
9291 }
9292 else
9293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009294 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009295 csrReleaseCommandWmStatusChange( pMac, pCommand );
9296 }
9297
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9299 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 return( fCommandQueued );
9302}
9303
Jeff Johnson295189b2012-06-20 16:38:30 -07009304static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9305{
9306 v_S7_t rssi = 0;
9307 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9308 if(pGetRssiReq)
9309 {
9310 if(NULL != pGetRssiReq->pVosContext)
9311 {
9312 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9313 }
9314 else
9315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009316 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 return;
9318 }
9319
9320 if(NULL != pGetRssiReq->rssiCallback)
9321 {
9322 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9323 }
9324 else
9325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009326 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 return;
9328 }
9329 }
9330 else
9331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009332 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 }
9334 return;
9335}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309336
9337static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9338{
9339 tANI_S8 snr = 0;
9340 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9341
9342 if (pGetSnrReq)
9343 {
9344 if (VOS_STATUS_SUCCESS !=
9345 WDA_GetSnr(pGetSnrReq->staId, &snr))
9346 {
9347 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9348 return;
9349 }
9350
9351 if (pGetSnrReq->snrCallback)
9352 {
9353 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9354 pGetSnrReq->pDevContext);
9355 }
9356 else
9357 {
9358 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9359 return;
9360 }
9361 }
9362 else
9363 {
9364 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9365 }
9366 return;
9367}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009368#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009369void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9370{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009371 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9372
Jeff Johnson36d483b2013-04-08 11:08:53 -07009373 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009374 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009375 /* Get roam Rssi request is backed up and passed back to the response,
9376 Extract the request message to fetch callback */
9377 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9378 v_S7_t rssi = pRoamRssiRsp->rssi;
9379
9380 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009381 {
9382 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9383 reqBkp->rssiCallback = NULL;
9384 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009385 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009386 }
9387 else
9388 {
9389 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9390 if (NULL != reqBkp)
9391 {
9392 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009393 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009394 }
9395 }
9396 }
9397 else
9398 {
9399 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9400 }
9401 return;
9402}
9403#endif
9404
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009405
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009406#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009407void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9408{
9409 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9410
9411 if (NULL != pTsmStatsRsp)
9412 {
9413 /* Get roam Rssi request is backed up and passed back to the response,
9414 Extract the request message to fetch callback */
9415 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9416
9417 if (NULL != reqBkp)
9418 {
9419 if (NULL != reqBkp->tsmStatsCallback)
9420 {
9421 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9422 pTsmStatsRsp->staId, reqBkp->pDevContext);
9423 reqBkp->tsmStatsCallback = NULL;
9424 }
9425 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009426 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009427 }
9428 else
9429 {
9430 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9431 if (NULL != reqBkp)
9432 {
9433 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009434 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009435 }
9436 }
9437 }
9438 else
9439 {
9440 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9441 }
9442 return;
9443}
9444
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009445void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009446{
9447 tANI_U32 roamTS2 = 0;
9448 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009449 tpPESession pSessionEntry = NULL;
9450 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009451
9452 if (NULL == pSession)
9453 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009454 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009455 return;
9456 }
9457
9458 roamTS2 = vos_timer_get_system_time();
9459 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009460 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9461 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009462 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009463
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009464 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9465 if (NULL == pSessionEntry)
9466 {
9467 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9468 return;
9469 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009470 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009471 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009472 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009473}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009474#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009475
Jeff Johnsone7245742012-09-05 17:12:55 -07009476static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9477{
9478 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9479 if(pTlRssiInd)
9480 {
9481 if(NULL != pTlRssiInd->tlCallback)
9482 {
9483 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009484 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009485 }
9486 else
9487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009488 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009489 }
9490 }
9491 else
9492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009493 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009494 }
9495 return;
9496}
Jeff Johnson295189b2012-06-20 16:38:30 -07009497
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309498eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9499{
9500 tpSirResetAPCapsChange pMsg;
9501 tANI_U16 len;
9502 eHalStatus status = eHAL_STATUS_SUCCESS;
9503
9504 /* Create the message and send to lim */
9505 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309506 pMsg = vos_mem_malloc(len);
9507 if ( NULL == pMsg )
9508 status = eHAL_STATUS_FAILURE;
9509 else
9510 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309511 if (HAL_STATUS_SUCCESS(status))
9512 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309513 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309514 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9515 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309516 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009517 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9518 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309519 status = palSendMBMessage(pMac->hHdd, pMsg);
9520 }
9521 else
9522 {
9523 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9524 }
9525 return status;
9526}
9527
Jeff Johnson295189b2012-06-20 16:38:30 -07009528void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9529{
9530 tSirSmeAssocInd *pAssocInd;
9531 tSirSmeDisassocInd *pDisassocInd;
9532 tSirSmeDeauthInd *pDeauthInd;
9533 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9534 tSirSmeNewBssInfo *pNewBss;
9535 tSmeIbssPeerInd *pIbssPeerInd;
9536 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9537 tSirSmeApNewCaps *pApNewCaps;
9538 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9539 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9540 tCsrRoamInfo *pRoamInfo = NULL;
9541 tCsrRoamInfo roamInfo;
9542 eHalStatus status;
9543 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9544 tCsrRoamSession *pSession = NULL;
9545 tpSirSmeSwitchChannelInd pSwitchChnInd;
9546 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309547 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009548
9549
9550 if (NULL == pSirMsg)
9551 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9552 return;
9553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 switch( pSirMsg->messageType )
9555 {
9556 case eWNI_SME_ASSOC_IND:
9557 {
9558 tCsrRoamSession *pSession;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05309559 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9561 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9562 if( HAL_STATUS_SUCCESS( status ) )
9563 {
9564 pSession = CSR_GET_SESSION(pMac, sessionId);
9565
Jeff Johnson32d95a32012-09-10 13:15:23 -07009566 if(!pSession)
9567 {
9568 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9569 return;
9570 }
9571
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 pRoamInfo = &roamInfo;
9573
9574 // Required for indicating the frames to upper layer
9575 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9576 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9577
9578 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9579 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9580 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9581 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9582
9583 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9584 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9585 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9586
9587 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9588 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309589 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9590 sizeof(tSirMacAddr));
9591 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9592 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309594#ifdef WLAN_FEATURE_AP_HT40_24G
9595 pRoamInfo->HT40MHzIntoEnabledSta =
9596 pAssocInd->HT40MHzIntoEnabledSta;
9597 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9598 pRoamInfo->HT40MHzIntoEnabledSta);
9599#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9603 {
9604 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9605 {
9606 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9607 pSession->pConnectBssDesc,
9608 &(pRoamInfo->peerMac),
9609 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9610 pRoamInfo->fAuthRequired = FALSE;
9611 }
9612 else
9613 {
9614 pRoamInfo->fAuthRequired = TRUE;
9615 }
9616 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9617 if (!HAL_STATUS_SUCCESS(status))
9618 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 /* Send Association completion message to PE */
9621 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9622
9623 /* send a message to CSR itself just to avoid the EAPOL frames going
9624 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9626 {
9627 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9630 {
9631 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9632 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9633 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 }
9636 }
9637 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309640 // Check if AP dis-associated us because of MIC failure. If so,
9641 // then we need to take action immediately and not wait till the
9642 // the WmStatusChange requests is pushed and processed
9643 tSmeCmd *pCommand;
9644
9645 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9646 status = csrRoamGetSessionIdFromBSSID( pMac,
9647 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9648 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309650 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9651 " for session %d "), sessionId);
9652 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9653 MAC_ADDRESS_STR " "
9654 " reason = %d status = %d "),
9655 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9656 pDisassocInd->reasonCode,
9657 pDisassocInd->statusCode);
9658 // If we are in neighbor preauth done state then on receiving
9659 // disassoc or deauth we dont roam instead we just disassoc
9660 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009661 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309662#ifdef WLAN_FEATURE_VOWIFI_11R
9663 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9664 {
9665 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009667#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009668#ifdef FEATURE_WLAN_ESE
9669 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309670 {
9671 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009673#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009674#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309675 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9676 {
9677 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9678 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009679#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309680 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009681
Agarwal Ashish4f616132013-12-30 23:32:50 +05309682 if (!pSession)
9683 {
9684 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9685 return;
9686 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009687
Agarwal Ashish4f616132013-12-30 23:32:50 +05309688 if ( csrIsConnStateInfra( pMac, sessionId ) )
9689 {
9690 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009692#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309693 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009694#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309695 csrRoamLinkDown(pMac, sessionId);
9696 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9697 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9698 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309699 pRoamInfo = &roamInfo;
9700 pRoamInfo->statusCode = pDisassocInd->statusCode;
9701 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9702 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009703
Agarwal Ashish4f616132013-12-30 23:32:50 +05309704 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9705 sizeof(tSirMacAddr));
9706 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9707 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009708
Agarwal Ashish4f616132013-12-30 23:32:50 +05309709 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9710 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009711
Agarwal Ashish4f616132013-12-30 23:32:50 +05309712 /*
9713 * STA/P2P client got disassociated so remove any pending deauth
9714 * commands in sme pending list
9715 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309716 pCommand = csrGetCommandBuffer(pMac);
9717 if (NULL == pCommand)
9718 {
9719 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9720 status = eHAL_STATUS_RESOURCES;
9721 return;
9722 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309723 pCommand->command = eSmeCommandRoam;
9724 pCommand->sessionId = (tANI_U8)sessionId;
9725 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9726 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9727 pDisassocInd->peerMacAddr,
9728 sizeof(tSirMacAddr));
9729 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9730 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009731
Agarwal Ashish4f616132013-12-30 23:32:50 +05309732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309734 else
9735 {
9736 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9737 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9738 }
Kiet Lam82004c62013-11-11 13:24:28 +05309739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009742 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9744 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9745 if( HAL_STATUS_SUCCESS( status ) )
9746 {
9747 // If we are in neighbor preauth done state then on receiving
9748 // disassoc or deauth we dont roam instead we just disassoc
9749 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009750 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009751#ifdef WLAN_FEATURE_VOWIFI_11R
9752 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9753 {
9754 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9755 }
9756#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009757#ifdef FEATURE_WLAN_ESE
9758 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 {
9760 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9761 }
9762#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009763#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309764 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009765 {
9766 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9767 }
9768#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 pSession = CSR_GET_SESSION( pMac, sessionId );
9770
Jeff Johnson32d95a32012-09-10 13:15:23 -07009771 if(!pSession)
9772 {
9773 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9774 return;
9775 }
9776
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 if ( csrIsConnStateInfra( pMac, sessionId ) )
9778 {
9779 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009781#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9782 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9783#endif
9784 csrRoamLinkDown(pMac, sessionId);
9785 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9787 {
9788
9789 pRoamInfo = &roamInfo;
9790
9791 pRoamInfo->statusCode = pDeauthInd->statusCode;
9792 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9793
9794 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9795
Kiet Lam64c1b492013-07-12 13:56:44 +05309796 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9797 sizeof(tSirMacAddr));
9798 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9799 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009800
9801 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 }
9804 break;
9805
9806 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 -08009807 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9809 //Update with the new channel id.
9810 //The channel id is hidden in the statusCode.
9811 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9812 if( HAL_STATUS_SUCCESS( status ) )
9813 {
9814 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009815 if(!pSession)
9816 {
9817 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9818 return;
9819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9821 if(pSession->pConnectBssDesc)
9822 {
9823 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9824 }
9825 }
9826 break;
9827
9828 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009829 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 {
9831 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9832 sessionId = pDeauthRsp->sessionId;
9833 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9834 {
9835 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9837 {
9838 pRoamInfo = &roamInfo;
9839 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309840 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9841 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9843 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9844 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9845 }
9846 }
9847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009848 break;
9849
9850 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009851 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009852 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 {
9854 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9855 sessionId = pDisassocRsp->sessionId;
9856 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9857 {
9858 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9860 {
9861 pRoamInfo = &roamInfo;
9862 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309863 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9864 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9866 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9867 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9868 }
9869 }
9870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009871 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 case eWNI_SME_MIC_FAILURE_IND:
9873 {
9874 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9875 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9876 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009877
9878 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9879 if( HAL_STATUS_SUCCESS( status ) )
9880 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309881 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009882 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9883 pRoamInfo = &roamInfo;
9884 if(pMicInd->info.multicast)
9885 {
9886 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9887 }
9888 else
9889 {
9890 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9891 }
9892 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9893 }
9894
Jeff Johnson295189b2012-06-20 16:38:30 -07009895#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9896 {
lukez3c809222013-05-03 10:23:02 -07009897 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009899 if(!pSession)
9900 {
9901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9902 return;
9903 }
lukez3c809222013-05-03 10:23:02 -07009904
Kiet Lam64c1b492013-07-12 13:56:44 +05309905 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9907 secEvent.encryptionModeMulticast =
9908 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9909 secEvent.encryptionModeUnicast =
9910 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9911 secEvent.authMode =
9912 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309913 vos_mem_copy(secEvent.bssid,
9914 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9916 }
9917#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 }
9919 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9921 {
9922 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9923 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009924 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009925
9926 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9927 if( HAL_STATUS_SUCCESS( status ) )
9928 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309929 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9931 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9932 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9933 }
9934 }
9935 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009936
Jeff Johnson295189b2012-06-20 16:38:30 -07009937 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9938 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9939 switch( pStatusChangeMsg->statusChangeCode )
9940 {
9941 case eSIR_SME_IBSS_ACTIVE:
9942 sessionId = csrFindIbssSession( pMac );
9943 if( CSR_SESSION_ID_INVALID != sessionId )
9944 {
9945 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009946 if(!pSession)
9947 {
9948 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9949 return;
9950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9952 if(pSession->pConnectBssDesc)
9953 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309954 vos_mem_copy(&roamInfo.bssid,
9955 pSession->pConnectBssDesc->bssId,
9956 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9958 pRoamInfo = &roamInfo;
9959 }
9960 else
9961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009962 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 }
9964 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9965 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9966 }
9967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 case eSIR_SME_IBSS_INACTIVE:
9969 sessionId = csrFindIbssSession( pMac );
9970 if( CSR_SESSION_ID_INVALID != sessionId )
9971 {
9972 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009973 if(!pSession)
9974 {
9975 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9976 return;
9977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9979 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9980 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9981 }
9982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9984 sessionId = csrFindIbssSession( pMac );
9985 if( CSR_SESSION_ID_INVALID != sessionId )
9986 {
9987 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009988 if(!pSession)
9989 {
9990 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9991 return;
9992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 // update the connection state information
9994 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009995#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9996 {
9997 vos_log_ibss_pkt_type *pIbssLog;
9998 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10000 if(pIbssLog)
10001 {
10002 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10003 if(pNewBss)
10004 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010005 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 if(pNewBss->ssId.length)
10007 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010008 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
10009 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 }
10011 pIbssLog->operatingChannel = pNewBss->channelNumber;
10012 }
10013 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10014 {
10015 //***U8 is not enough for beacon interval
10016 pIbssLog->beaconInterval = (v_U8_t)bi;
10017 }
10018 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10019 }
10020 }
10021#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010023
10024 if ((eCSR_ENCRYPT_TYPE_NONE ==
10025 pSession->connectedProfile.EncryptionType ))
10026 {
10027 csrRoamIssueSetContextReq( pMac, sessionId,
10028 pSession->connectedProfile.EncryptionType,
10029 pSession->pConnectBssDesc,
10030 &Broadcastaddr,
10031 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10034 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010035 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10036 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 pRoamInfo = &roamInfo;
10038 //This BSSID is th ereal BSSID, let's save it
10039 if(pSession->pConnectBssDesc)
10040 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010041 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10042 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010044 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010045 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 // detection by LIM that the capabilities of the associated AP have changed.
10048 case eSIR_SME_AP_CAPS_CHANGED:
10049 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010050 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10052 if( HAL_STATUS_SUCCESS( status ) )
10053 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010054 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10055 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010056 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010057 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10058 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10059 )
10060 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010061 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10062 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010063 }
10064 else
10065 {
10066 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010067 FL("Skipping csrScanForCapabilityChange as "
10068 "CSR is in state %s and sub-state %s"),
10069 macTraceGetcsrRoamState(
10070 pMac->roam.curState[sessionId]),
10071 macTraceGetcsrRoamSubState(
10072 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010073 /* We ignore the caps change event if CSR is not in full connected state.
10074 * Send one event to PE to reset limSentCapsChangeNtf
10075 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10076 * otherwise lim cannot send any CAPS change events to SME */
10077 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 }
10080 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010081
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 default:
10083 roamStatus = eCSR_ROAM_FAILED;
10084 result = eCSR_ROAM_RESULT_NONE;
10085 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010086 } // end switch on statusChangeCode
10087 if(eCSR_ROAM_RESULT_NONE != result)
10088 {
10089 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10090 }
10091 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 case eWNI_SME_IBSS_NEW_PEER_IND:
10093 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010094#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10095 {
10096 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10098 if(pIbssLog)
10099 {
10100 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010101 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10103 }
10104 }
10105#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 sessionId = csrFindIbssSession( pMac );
10107 if( CSR_SESSION_ID_INVALID != sessionId )
10108 {
10109 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010110
10111 if(!pSession)
10112 {
10113 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10114 return;
10115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10117 if(pSession->pConnectBssDesc)
10118 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010119 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10120 sizeof(tCsrBssid));
10121 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10122 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10124 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010125 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10126 - sizeof(tSmeIbssPeerInd)));
10127 if ( NULL == roamInfo.pbFrames )
10128 status = eHAL_STATUS_FAILURE;
10129 else
10130 status = eHAL_STATUS_SUCCESS;
10131 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 {
10133 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010134 vos_mem_copy(roamInfo.pbFrames,
10135 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10136 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 }
10138 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10139 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10140 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010141 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10142 if ( NULL == roamInfo.pBssDesc )
10143 status = eHAL_STATUS_FAILURE;
10144 else
10145 status = eHAL_STATUS_SUCCESS;
10146 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010148 vos_mem_copy(roamInfo.pBssDesc,
10149 pSession->pConnectBssDesc,
10150 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 }
10152 if(HAL_STATUS_SUCCESS(status))
10153 {
10154 pRoamInfo = &roamInfo;
10155 }
10156 else
10157 {
10158 if(roamInfo.pbFrames)
10159 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010160 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 }
10162 if(roamInfo.pBssDesc)
10163 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010164 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 }
10166 }
10167 }
10168 else
10169 {
10170 pRoamInfo = &roamInfo;
10171 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010172 if ((eCSR_ENCRYPT_TYPE_NONE ==
10173 pSession->connectedProfile.EncryptionType ))
10174 {
10175 csrRoamIssueSetContextReq( pMac, sessionId,
10176 pSession->connectedProfile.EncryptionType,
10177 pSession->pConnectBssDesc,
10178 &(pIbssPeerInd->peerAddr),
10179 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10180 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 }
10182 else
10183 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010184 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 }
10186 //send up the sec type for the new peer
10187 if (pRoamInfo)
10188 {
10189 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10190 }
10191 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10192 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10193 if(pRoamInfo)
10194 {
10195 if(roamInfo.pbFrames)
10196 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010197 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 }
10199 if(roamInfo.pBssDesc)
10200 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010201 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 }
10203 }
10204 }
10205 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10207 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10208 sessionId = csrFindIbssSession( pMac );
10209 if( CSR_SESSION_ID_INVALID != sessionId )
10210 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010211#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10212 {
10213 vos_log_ibss_pkt_type *pIbssLog;
10214
10215 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10216 if(pIbssLog)
10217 {
10218 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10219 if(pIbssPeerInd)
10220 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010221 vos_mem_copy(pIbssLog->peerMacAddr,
10222 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 }
10224 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10225 }
10226 }
10227#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010228 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10230 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10231 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010232 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10233 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010234 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10235 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10236 }
10237 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 case eWNI_SME_SETCONTEXT_RSP:
10239 {
10240 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10241 tListElem *pEntry;
10242 tSmeCmd *pCommand;
10243
10244 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10245 if ( pEntry )
10246 {
10247 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10248 if ( eSmeCommandSetKey == pCommand->command )
10249 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010250 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010252
10253 if(!pSession)
10254 {
10255 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10256 return;
10257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010258
10259#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10260 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10261 {
10262 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010263 vos_mem_set(&setKeyEvent,
10264 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010265 if( pRsp->peerMacAddr[0] & 0x01 )
10266 {
10267 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10268 }
10269 else
10270 {
10271 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10272 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010273 if( pRsp->peerMacAddr[0] & 0x01 )
10274 {
10275 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
10276 smsLog(pMac, LOG1, FL("Reset"
10277 "remainInPowerActiveTillDHCP to allow BMPS"));
10278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 setKeyEvent.encryptionModeMulticast =
10280 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10281 setKeyEvent.encryptionModeUnicast =
10282 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010283 vos_mem_copy(setKeyEvent.bssid,
10284 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 setKeyEvent.authMode =
10286 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010287 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 {
10289 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10290 }
10291 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10292 }
10293#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10294 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10295 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010296 csrRoamStopWaitForKeyTimer( pMac );
10297
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 //We are done with authentication, whethere succeed or not
10299 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 //We do it here because this linkup function is not called after association
10301 //when a key needs to be set.
10302 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10303 {
10304 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10305 }
10306 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010307 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010309 vos_mem_copy(&roamInfo.peerMac,
10310 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010311 //Make sure we install the GTK before indicating to HDD as authenticated
10312 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010313 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10314 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010315 {
Yathish9f22e662012-12-10 14:21:35 -080010316#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10317 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10318 {
10319 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010320 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010321 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10322 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10323 pMsg->seesionId = sessionId;
10324 status = palSendMBMessage(pMac->hHdd, pMsg );
10325 }
10326#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010327 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +053010328 smsLog(pMac, LOG1, FL("Current channel is %d,"
10329 "OBSS cap is %d, Persona is %d"),
10330 pSession->connectedProfile.operationChannel,
10331 IS_HT40_OBSS_SCAN_FEATURE_ENABLE,
10332 pSession->pCurRoamProfile->csrPersona);
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010333 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010334 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010335 && (pSession->connectState ==
10336 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10337 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010338 && (VOS_P2P_GO_MODE !=
10339 pSession->pCurRoamProfile->csrPersona
10340 && VOS_STA_SAP_MODE !=
10341 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010342 {
10343 tpSirSmeHT40OBSSScanInd pMsg;
10344 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10345 pMsg->messageType =
10346 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10347 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010348 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10349 vos_mem_copy(pMsg->peerMacAddr,
10350 pSession->connectedProfile.bssid,
10351 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010352 status = palSendMBMessage(pMac->hHdd,
10353 pMsg );
10354 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010355 else
10356 {
10357 smsLog( pMac, LOG1,FL("OBSS SCAN"
10358 "Indication not sent to FW"
10359 "channel %d OBSS_SCAN: %d"),
10360 pSession->connectedProfile.
10361 operationChannel,
10362 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10363 smsLog( pMac, LOG1,FL("connectState %d"
10364 "pCurRoamProfile %p"),
10365 pSession->connectState,
10366 pSession->pCurRoamProfile);
10367 }
10368
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010369 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010370 }
10371 else
10372 {
10373 result = eCSR_ROAM_RESULT_NONE;
10374 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010375 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 }
10377 else
10378 {
10379 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010380 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10381 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10382 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 }
10384 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10385 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10387 // can go ahead and initiate the TSPEC if any are pending
10388 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010389#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 //Send Adjacent AP repot to new AP.
10391 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10392 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010393 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010394 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010395#ifdef FEATURE_WLAN_ESE_UPLOAD
10396 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010397#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010398 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010399#endif
10400 pSession->isPrevApInfoValid = FALSE;
10401 }
10402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10404 {
10405 csrReleaseCommandSetKey( pMac, pCommand );
10406 }
10407 }
10408 else
10409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010410 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 }
10412 }
10413 else
10414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010415 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 smeProcessPendingQueue( pMac );
10418 }
10419 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 case eWNI_SME_REMOVEKEY_RSP:
10421 {
10422 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10423 tListElem *pEntry;
10424 tSmeCmd *pCommand;
10425
10426 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10427 if ( pEntry )
10428 {
10429 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10430 if ( eSmeCommandRemoveKey == pCommand->command )
10431 {
10432 sessionId = pCommand->sessionId;
10433 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010434
10435 if(!pSession)
10436 {
10437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10438 return;
10439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010440#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10441 {
10442 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010443 vos_mem_set(&removeKeyEvent,
10444 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10446 removeKeyEvent.encryptionModeMulticast =
10447 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10448 removeKeyEvent.encryptionModeUnicast =
10449 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010450 vos_mem_copy( removeKeyEvent.bssid,
10451 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 removeKeyEvent.authMode =
10453 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010454 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 {
10456 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10457 }
10458 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10459 }
10460#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010461 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010463 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10464 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 result = eCSR_ROAM_RESULT_NONE;
10466 pRoamInfo = &roamInfo;
10467 }
10468 else
10469 {
10470 result = eCSR_ROAM_RESULT_FAILURE;
10471 }
10472 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10473 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10474 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10475 {
10476 csrReleaseCommandRemoveKey( pMac, pCommand );
10477 }
10478 }
10479 else
10480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010481 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010482 }
10483 }
10484 else
10485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010486 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010488 smeProcessPendingQueue( pMac );
10489 }
10490 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010492 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010493 csrRoamStatsRspProcessor( pMac, pSirMsg );
10494 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010495#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010496 case eWNI_SME_GET_ROAM_RSSI_RSP:
10497 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10498 csrRoamRssiRspProcessor( pMac, pSirMsg );
10499 break;
10500#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010501#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010502 case eWNI_SME_GET_TSM_STATS_RSP:
10503 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10504 csrTsmStatsRspProcessor( pMac, pSirMsg );
10505 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010506#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010507 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010508 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010509 csrUpdateRssi( pMac, pSirMsg );
10510 break;
10511
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010512 case eWNI_SME_GET_SNR_REQ:
10513 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10514 csrUpdateSnr(pMac, pSirMsg);
10515 break;
10516
Jeff Johnson295189b2012-06-20 16:38:30 -070010517#ifdef WLAN_FEATURE_VOWIFI_11R
10518 case eWNI_SME_FT_PRE_AUTH_RSP:
10519 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10520 break;
10521#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10523 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010524 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 -070010525 sessionId = pSmeMaxAssocInd->sessionId;
10526 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010527 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10528 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010529 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10530 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10531 break;
10532
10533 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010534 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 btampEstablishLogLinkHdlr( pSirMsg );
10536 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010537 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010538 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010539 csrRoamRssiIndHdlr( pMac, pSirMsg );
10540 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010541#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10542 case eWNI_SME_CANDIDATE_FOUND_IND:
10543 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10544 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10545 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010546 case eWNI_SME_HANDOFF_REQ:
10547 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10548 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10549 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010550#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010551
10552 default:
10553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010555}
10556
Jeff Johnson295189b2012-06-20 16:38:30 -070010557void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10558 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10559{
10560 if(pSession)
10561 {
10562 if(pSession->bRefAssocStartCnt)
10563 {
10564 pSession->bRefAssocStartCnt--;
10565 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10566 //Need to call association_completion because there is an assoc_start pending.
10567 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10568 eCSR_ROAM_ASSOCIATION_COMPLETION,
10569 eCSR_ROAM_RESULT_FAILURE);
10570 }
10571 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10572 }
10573 else
10574 {
10575 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10576 }
10577}
10578
10579
10580eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10581{
10582 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10584 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10585 {
10586 status = csrScanRequestLostLink1( pMac, sessionId );
10587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 return(status);
10589}
10590
Jeff Johnson295189b2012-06-20 16:38:30 -070010591//return a boolean to indicate whether roaming completed or continue.
10592tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10593 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10594{
10595 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10596 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10597 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10598 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010599 if(!pSession)
10600 {
10601 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10602 return eANI_BOOLEAN_FALSE;
10603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 //Check whether time is up
10605 if(pSession->fCancelRoaming || fForce ||
10606 ((curTime - pSession->roamingStartTime) > roamTime) ||
10607 eCsrReassocRoaming == pSession->roamingReason ||
10608 eCsrDynamicRoaming == pSession->roamingReason)
10609 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010610 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10612 {
10613 //roaming is cancelled, tell HDD to indicate disconnect
10614 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10615 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10616 //to be eSIR_BEACON_MISSED
10617 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10618 {
10619 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10620 }
10621 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10622 {
10623 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10624 }
10625 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10626 {
10627 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10628 }
10629 else
10630 {
10631 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10632 }
10633 }
10634 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10635 pSession->roamingReason = eCsrNotRoaming;
10636 }
10637 else
10638 {
10639 pSession->roamResult = roamResult;
10640 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10641 {
10642 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10643 pSession->roamingReason = eCsrNotRoaming;
10644 }
10645 else
10646 {
10647 fCompleted = eANI_BOOLEAN_FALSE;
10648 }
10649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 return(fCompleted);
10651}
10652
Jeff Johnson295189b2012-06-20 16:38:30 -070010653void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10654{
10655 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010656
10657 if(!pSession)
10658 {
10659 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10660 return;
10661 }
10662
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 if(CSR_IS_ROAMING(pSession))
10664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010665 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10667 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10668 {
10669 //No need to do anything in here because the handler takes care of it
10670 }
10671 else
10672 {
10673 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10674 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10675 //Roaming is stopped after here
10676 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10677 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010678 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 csrRoamStopRoamingTimer(pMac, sessionId);
10680 }
10681 }
10682}
10683
Jeff Johnson295189b2012-06-20 16:38:30 -070010684void csrRoamRoamingTimerHandler(void *pv)
10685{
10686 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10687 tpAniSirGlobal pMac = pInfo->pMac;
10688 tANI_U32 sessionId = pInfo->sessionId;
10689 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010690
10691 if(!pSession)
10692 {
10693 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10694 return;
10695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010696
10697 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10698 {
10699 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10700 {
10701 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10702 pSession->roamingReason = eCsrNotRoaming;
10703 }
10704 }
10705}
10706
Jeff Johnson295189b2012-06-20 16:38:30 -070010707eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10708{
10709 eHalStatus status;
10710 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010711
10712 if(!pSession)
10713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010714 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010715 return eHAL_STATUS_FAILURE;
10716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010717
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010718 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010720 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010721
10722 return (status);
10723}
10724
Jeff Johnson295189b2012-06-20 16:38:30 -070010725eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10726{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010727 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010728}
10729
Jeff Johnson295189b2012-06-20 16:38:30 -070010730void csrRoamWaitForKeyTimeOutHandler(void *pv)
10731{
10732 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10733 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010734 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010735 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010736
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010737 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10738 macTraceGetNeighbourRoamState(
10739 pMac->roam.neighborRoamInfo.neighborRoamState),
10740 macTraceGetcsrRoamSubState(
10741 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010742
Jeff Johnson295189b2012-06-20 16:38:30 -070010743 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10744 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010745#ifdef FEATURE_WLAN_LFR
10746 if (csrNeighborRoamIsHandoffInProgress(pMac))
10747 {
10748 /*
10749 * Enable heartbeat timer when hand-off is in progress
10750 * and Key Wait timer expired.
10751 */
10752 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010753 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010754 pMac->roam.configParam.HeartbeatThresh24);
10755 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10756 pMac->roam.configParam.HeartbeatThresh24,
10757 NULL, eANI_BOOLEAN_FALSE);
10758 }
10759#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010760 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010761
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010763 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10764 {
10765 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10766 pInfo->sessionId);
10767 }
10768
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010769 if (pSession)
10770 {
10771 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10772 {
10773 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10774 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010775 if( (pSession->connectedProfile.AuthType ==
10776 eCSR_AUTH_TYPE_SHARED_KEY) &&
10777 ( (pSession->connectedProfile.EncryptionType ==
10778 eCSR_ENCRYPT_TYPE_WEP40) ||
10779 (pSession->connectedProfile.EncryptionType ==
10780 eCSR_ENCRYPT_TYPE_WEP104) ))
10781 {
10782 status = sme_AcquireGlobalLock( &pMac->sme );
10783 if ( HAL_STATUS_SUCCESS( status ) )
10784 {
10785 csrRoamDisconnect( pMac, pInfo->sessionId,
10786 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10787 sme_ReleaseGlobalLock( &pMac->sme );
10788 }
10789 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010790 }
10791 else
10792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010793 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010794 __func__);
10795 }
10796 }
10797 else
10798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010799 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010800 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 }
10802
10803}
10804
Jeff Johnson295189b2012-06-20 16:38:30 -070010805eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10806{
10807 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010808#ifdef FEATURE_WLAN_LFR
10809 if (csrNeighborRoamIsHandoffInProgress(pMac))
10810 {
10811 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010812 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10813 macTraceGetNeighbourRoamState(
10814 pMac->roam.neighborRoamInfo.neighborRoamState),
10815 macTraceGetcsrRoamSubState(
10816 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10817 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010818 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10819 }
10820#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010821 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010822 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010823
10824 return (status);
10825}
10826
Jeff Johnson295189b2012-06-20 16:38:30 -070010827eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10828{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010829 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10830 macTraceGetNeighbourRoamState(
10831 pMac->roam.neighborRoamInfo.neighborRoamState),
10832 macTraceGetcsrRoamSubState(
10833 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010834#ifdef FEATURE_WLAN_LFR
10835 if (csrNeighborRoamIsHandoffInProgress(pMac))
10836 {
10837 /*
10838 * Enable heartbeat timer when hand-off is in progress
10839 * and Key Wait timer got stopped for some reason
10840 */
10841 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010842 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010843 pMac->roam.configParam.HeartbeatThresh24);
10844 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10845 pMac->roam.configParam.HeartbeatThresh24,
10846 NULL, eANI_BOOLEAN_FALSE);
10847 }
10848#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010849 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010850}
10851
Jeff Johnson295189b2012-06-20 16:38:30 -070010852void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10853 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10854{
10855 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10856 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010857 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10858 /* To silence the KW tool Null chaeck is added */
10859 if(!pSession)
10860 {
10861 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10862 return;
10863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010864
10865 if(pCommand)
10866 {
10867 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010870 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10871 {
10872 //if success, force roaming completion
10873 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10874 }
10875 else
10876 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010877 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010878 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10880 }
10881}
10882
Jeff Johnson295189b2012-06-20 16:38:30 -070010883eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10884{
10885 eHalStatus status = eHAL_STATUS_SUCCESS;
10886 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10887 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10888 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10889 tCsrRoamInfo *pRoamInfo = NULL;
10890 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010891 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010893 /* To silence the KW tool Null chaeck is added */
10894 if(!pSession)
10895 {
10896 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10897 return eHAL_STATUS_FAILURE;
10898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010899 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010900 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010901 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10902 if ( eWNI_SME_DISASSOC_IND == type )
10903 {
10904 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10905 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10906 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010907 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010908 }
10909 else if ( eWNI_SME_DEAUTH_IND == type )
10910 {
10911 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10912 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10913 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010914 /* Convert into proper reason code */
Deepthi Gowridf91a662014-12-17 17:14:35 +053010915 if ((pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ||
10916 (pDeauthIndMsg->reasonCode ==
10917 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON))
10918 pSession->joinFailStatusCode.reasonCode = 0;
10919 else
10920 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
10921
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010922 /* cfg layer expects 0 as reason code if
10923 the driver dosent know the reason code
10924 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010925 }
10926 else
10927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010928 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010929 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010930 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 }
10932
10933 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 {
10936 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10937 }
10938
10939 if ( eWNI_SME_DISASSOC_IND == type )
10940 {
10941 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10942 }
10943 else if ( eWNI_SME_DEAUTH_IND == type )
10944 {
10945 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 if(!HAL_STATUS_SUCCESS(status))
10948 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010949 //If fail to send confirmation to PE, not to trigger roaming
10950 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010951 }
10952
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010953 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010954 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10956 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 if( eWNI_SME_DISASSOC_IND == type)
10958 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010959 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010960 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10961 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010962 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 else if( eWNI_SME_DEAUTH_IND == type )
10965 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010966 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010967 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10968 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010969 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10970 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010971 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010972
10973 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10974 that we are roaming. But if we cannot possibly roam, or if we are unable to
10975 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 if(fToRoam)
10977 {
10978 //Only remove the connected BSS in infrastructure mode
10979 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10980 //Not to do anying for lostlink with WDS
10981 if( pMac->roam.configParam.nRoamingTime )
10982 {
10983 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10984 ( eWNI_SME_DEAUTH_IND == type ) ?
10985 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10986 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010987 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 //For IBSS, we need to give some more info to HDD
10989 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10990 {
10991 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10992 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10993 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10994 }
10995 else
10996 {
10997 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10998 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010999 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
11001 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
11002 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11003 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
11004 }
11005 else
11006 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011007 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 fToRoam = eANI_BOOLEAN_FALSE;
11009 }
11010 }
11011 else
11012 {
11013 //We are told not to roam, indicate lostlink
11014 fToRoam = eANI_BOOLEAN_FALSE;
11015 }
11016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 if(!fToRoam)
11018 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070011019 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011020 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011021 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011022 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
11023 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
11024 * csrRoamCheckForLinkStatusChange API.
11025 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011026 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
11027 }
11028
11029 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070011030 Still enable idle scan for polling in case concurrent sessions are running */
11031 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11032 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011033 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 }
11035 }
11036
11037 return (status);
11038}
11039
Jeff Johnson295189b2012-06-20 16:38:30 -070011040eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11041{
11042 eHalStatus status = eHAL_STATUS_SUCCESS;
11043 tListElem *pEntry = NULL;
11044 tSmeCmd *pCommand = NULL;
11045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011046
11047 if(!pSession)
11048 {
11049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11050 return eHAL_STATUS_FAILURE;
11051 }
11052
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 //Only remove the connected BSS in infrastructure mode
11055 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11056 if(pMac->roam.configParam.nRoamingTime)
11057 {
11058 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11059 {
11060 //before starting the lost link logic release the roam command for handoff
11061 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11062 if(pEntry)
11063 {
11064 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11065 }
11066 if(pCommand)
11067 {
11068 if (( eSmeCommandRoam == pCommand->command ) &&
11069 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11070 {
11071 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11072 {
11073 csrReleaseCommandRoam( pMac, pCommand );
11074 }
11075 }
11076 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011077 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011078 }
11079 }
11080 else
11081 {
11082 //We are told not to roam, indicate lostlink
11083 status = eHAL_STATUS_FAILURE;
11084 }
11085
11086 return (status);
11087}
Jeff Johnson295189b2012-06-20 16:38:30 -070011088void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11089{
11090 tListElem *pEntry;
11091 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011092 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11093 if ( pEntry )
11094 {
11095 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11096 if ( eSmeCommandWmStatusChange == pCommand->command )
11097 {
11098 // Nothing to process in a Lost Link completion.... It just kicks off a
11099 // roaming sequence.
11100 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11101 {
11102 csrReleaseCommandWmStatusChange( pMac, pCommand );
11103 }
11104 else
11105 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011106 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 }
11108
11109 }
11110 else
11111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011112 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 }
11114 }
11115 else
11116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011117 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 smeProcessPendingQueue( pMac );
11120}
11121
Jeff Johnson295189b2012-06-20 16:38:30 -070011122void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11123{
11124 eHalStatus status = eHAL_STATUS_FAILURE;
11125 tSirSmeRsp *pSirSmeMsg;
11126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011127
11128 if(!pSession)
11129 {
11130 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11131 return;
11132 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011133 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11134 pCommand->sessionId,
11135 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011136 switch ( pCommand->u.wmStatusChangeCmd.Type )
11137 {
11138 case eCsrDisassociated:
11139 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11140 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011142 case eCsrDeauthenticated:
11143 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11144 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011147 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011148 break;
11149 }
11150 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11151 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11152 {
11153 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11154 {
11155 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011156 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011157 }
11158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011159 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11160 // command here since there is nothing else to do.
11161 csrRoamWmStatusChangeComplete( pMac );
11162}
11163
Jeff Johnson295189b2012-06-20 16:38:30 -070011164//This function returns band and mode information.
11165//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11166//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011167static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11168 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011169{
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11171 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11172 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011173 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011174
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 //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 -070011176 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11177 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11178 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11179 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 {
11181 switch( pMac->roam.configParam.uCfgDot11Mode )
11182 {
11183 case eCSR_CFG_DOT11_MODE_11A:
11184 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11185 eBand = eCSR_BAND_5G;
11186 break;
11187 case eCSR_CFG_DOT11_MODE_11B:
11188 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11189 eBand = eCSR_BAND_24;
11190 break;
11191 case eCSR_CFG_DOT11_MODE_11G:
11192 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11193 eBand = eCSR_BAND_24;
11194 break;
11195 case eCSR_CFG_DOT11_MODE_11N:
11196 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011197 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11198 break;
11199#ifdef WLAN_FEATURE_11AC
11200 case eCSR_CFG_DOT11_MODE_11AC:
11201 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11202 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011203 /* If the operating channel is in 2.4 GHz band, check for
11204 * INI item to disable VHT operation in 2.4 GHz band
11205 */
11206 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11207 !pMac->roam.configParam.enableVhtFor24GHz)
11208 {
11209 /* Disable 11AC operation */
11210 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11211 }
11212 else
11213 {
11214 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11215 }
11216 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011217 }
11218 else
11219 {
11220 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11221 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11222 }
11223 break;
11224 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11225 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11226 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011227 /* If the operating channel is in 2.4 GHz band, check for
11228 * INI item to disable VHT operation in 2.4 GHz band
11229 */
11230 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11231 !pMac->roam.configParam.enableVhtFor24GHz)
11232 {
11233 /* Disable 11AC operation */
11234 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11235 }
11236 else
11237 {
11238 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11239 }
11240 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011241 }
11242 else
11243 {
11244 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11245 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11246 }
11247 break;
11248#endif
11249 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011250#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011251 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11252 {
11253 /* If the operating channel is in 2.4 GHz band, check for
11254 * INI item to disable VHT operation in 2.4 GHz band
11255 */
11256 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11257 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011258 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011259 /* Disable 11AC operation */
11260 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011261 }
11262 else
11263 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011264 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11265 }
11266 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11267 }
11268 else
11269 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011270 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11271 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011272 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011273#else
11274 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11275 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11276#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011277 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 default:
11279 // Global dot11 Mode setting is 11a/b/g.
11280 // use the channel number to determine the Mode setting.
11281 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11282 {
11283 eBand = pMac->roam.configParam.eBand;
11284 if(eCSR_BAND_24 == eBand)
11285 {
11286 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11287 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11288 }
11289 else
11290 {
11291 //prefer 5GHz
11292 eBand = eCSR_BAND_5G;
11293 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11294 }
11295 }
11296 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11297 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011298 // WiFi tests require IBSS networks to start in 11b mode
11299 // without any change to the default parameter settings
11300 // on the adapter. We use ACU to start an IBSS through
11301 // creation of a startIBSS profile. This startIBSS profile
11302 // has Auto MACProtocol and the adapter property setting
11303 // for dot11Mode is also AUTO. So in this case, let's
11304 // start the IBSS network in 11b mode instead of 11g mode.
11305 // So this is for Auto=profile->MacProtocol && Auto=Global.
11306 // dot11Mode && profile->channel is < 14, then start the IBSS
11307 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011309 // Note: we used to have this start as an 11g IBSS for best
11310 // performance... now to specify that the user will have to
11311 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011312 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11313 eBand = eCSR_BAND_24;
11314 }
11315 else
11316 {
11317 // else, it's a 5.0GHz channel. Set mode to 11a.
11318 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11319 eBand = eCSR_BAND_5G;
11320 }
11321 break;
11322 }//switch
11323 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11324 else
11325 {
11326 //dot11 mode is set, lets pick the band
11327 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11328 {
11329 // channel is Auto also.
11330 eBand = pMac->roam.configParam.eBand;
11331 if(eCSR_BAND_ALL == eBand)
11332 {
11333 //prefer 5GHz
11334 eBand = eCSR_BAND_5G;
11335 }
11336 }
11337 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11338 {
11339 eBand = eCSR_BAND_24;
11340 }
11341 else
11342 {
11343 eBand = eCSR_BAND_5G;
11344 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011346 if(pBand)
11347 {
11348 *pBand = eBand;
11349 }
11350
11351 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011352 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11354 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011355
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011356 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11357 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 -070011358 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011359#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011360 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011361#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011362 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11363 {
11364 //We cannot do 11n here
11365 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11366 {
11367 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11368 }
11369 else
11370 {
11371 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11372 }
11373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 return( cfgDot11Mode );
11375}
11376
Jeff Johnson295189b2012-06-20 16:38:30 -070011377eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11378{
11379 eHalStatus status;
11380 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011381
11382 if(!pSession)
11383 {
11384 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11385 return eHAL_STATUS_FAILURE;
11386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011387
11388#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11389 {
11390 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11392 if(pIbssLog)
11393 {
11394 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11395 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11396 }
11397 }
11398#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 // Set the roaming substate to 'stop Bss request'...
11400 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11401
11402 // attempt to stop the Bss (reason code is ignored...)
11403 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011404 if(!HAL_STATUS_SUCCESS(status))
11405 {
11406 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 return (status);
11409}
11410
Jeff Johnson295189b2012-06-20 16:38:30 -070011411//pNumChan is a caller allocated space with the sizeof pChannels
11412eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11413{
11414
11415 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11416 (tANI_U8 *)pChannels,
11417 pNumChan));
11418}
11419
Kiran4a17ebe2013-01-31 10:43:43 -080011420tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11421{
11422 tANI_U32 cfgLength = 0;
11423 tANI_U16 cfgId = 0;
11424 tPowerdBm maxTxPwr = 0;
11425 tANI_U8 *pCountryInfo = NULL;
11426 eHalStatus status;
11427 tANI_U8 count = 0;
11428 tANI_U8 firstChannel;
11429 tANI_U8 maxChannels;
11430
11431 if (CSR_IS_CHANNEL_5GHZ(channel))
11432 {
11433 cfgId = WNI_CFG_MAX_TX_POWER_5;
11434 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11435 }
11436 else if (CSR_IS_CHANNEL_24GHZ(channel))
11437 {
11438 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11439 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11440 }
11441 else
11442 return maxTxPwr;
11443
Kiet Lam64c1b492013-07-12 13:56:44 +053011444 pCountryInfo = vos_mem_malloc(cfgLength);
11445 if ( NULL == pCountryInfo )
11446 status = eHAL_STATUS_FAILURE;
11447 else
11448 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011449 if (status != eHAL_STATUS_SUCCESS)
11450 {
11451 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011452 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011453 __FUNCTION__, status);
11454 goto error;
11455 }
11456 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11457 if (status != eHAL_STATUS_SUCCESS)
11458 {
11459 goto error;
11460 }
11461 /* Identify the channel and maxtxpower */
11462 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11463 {
11464 firstChannel = pCountryInfo[count++];
11465 maxChannels = pCountryInfo[count++];
11466 maxTxPwr = pCountryInfo[count++];
11467
11468 if ((channel >= firstChannel) &&
11469 (channel < (firstChannel + maxChannels)))
11470 {
11471 break;
11472 }
11473 }
11474
11475error:
11476 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011477 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011478
11479 return maxTxPwr;
11480}
11481
11482
Jeff Johnson295189b2012-06-20 16:38:30 -070011483tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11484{
11485 tANI_BOOLEAN fValid = FALSE;
11486 tANI_U32 idxValidChannels;
11487 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11488
11489 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11490 {
11491 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11492 {
11493 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11494 {
11495 fValid = TRUE;
11496 break;
11497 }
11498 }
11499 }
11500 pMac->roam.numValidChannels = len;
11501 return fValid;
11502}
11503
Jeff Johnson295189b2012-06-20 16:38:30 -070011504tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11505{
11506 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11507 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011508 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11509 {
11510 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11511 {
11512 fValid = eANI_BOOLEAN_TRUE;
11513 break;
11514 }
11515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 return (fValid);
11517}
11518
Jeff Johnson295189b2012-06-20 16:38:30 -070011519//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011520 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011521{
Jeff Johnsone7245742012-09-05 17:12:55 -070011522 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 tANI_U8 centerChn;
11524 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011525
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11527 {
11528 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11529 }
11530 else
11531 {
11532 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11533 }
11534 //Figure what the other side's CB mode
11535 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11536 {
11537 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11538 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011539 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11540 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11541 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11542 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011543 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11544 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011545 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011546 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011547
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011548 {
11549 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11550 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11551 }
11552
11553 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011555 /* This is called during INFRA STA/CLIENT and should use the merged value of
11556 * supported channel width and recommended tx width as per standard
11557 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011558 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011559 pIes->HTCaps.supportedChannelWidthSet,
11560 pIes->HTInfo.recommendedTxWidthSet,
11561 pIes->HTInfo.secondaryChannelOffset);
11562
11563 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11564 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011566 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11567 switch (eRet) {
11568 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11569 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11570 break;
11571 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11572 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11573 break;
11574 case PHY_SINGLE_CHANNEL_CENTERED:
11575 default:
11576 centerChn = primaryChn;
11577 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011578 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011579 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011581 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011582 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011583 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053011584 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
11585 {
11586 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
11587 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 }
11590 }
11591 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 return eRet;
11593}
Jeff Johnson295189b2012-06-20 16:38:30 -070011594tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11595{
11596 tANI_BOOLEAN fFound = FALSE;
11597 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11599 {
11600 if( pCipherList->encryptionType[idx] == encryptionType )
11601 {
11602 fFound = TRUE;
11603 break;
11604 }
11605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 return fFound;
11607}
Jeff Johnson295189b2012-06-20 16:38:30 -070011608tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11609{
11610 tANI_BOOLEAN fFound = FALSE;
11611 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11613 {
11614 if( pAuthList->authType[idx] == authType )
11615 {
11616 fFound = TRUE;
11617 break;
11618 }
11619 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 return fFound;
11621}
Jeff Johnson295189b2012-06-20 16:38:30 -070011622tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11623{
11624 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11625 tCsrScanResultFilter *pScanFilter = NULL;
11626 eHalStatus status = eHAL_STATUS_SUCCESS;
11627
11628 if(pProfile1 && pProfile2)
11629 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011630 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11631 if ( NULL == pScanFilter )
11632 status = eHAL_STATUS_FAILURE;
11633 else
11634 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 if(HAL_STATUS_SUCCESS(status))
11636 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011637 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11639 if(HAL_STATUS_SUCCESS(status))
11640 {
11641 fCheck = eANI_BOOLEAN_FALSE;
11642 do
11643 {
11644 tANI_U32 i;
11645 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11646 {
11647 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11648 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11649 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11650 if ( fCheck ) break;
11651 }
11652 if(!fCheck)
11653 {
11654 break;
11655 }
11656 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11657 || pProfile2->BSSType != pProfile1->BSSType
11658 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11659 )
11660 {
11661 fCheck = eANI_BOOLEAN_FALSE;
11662 break;
11663 }
11664#ifdef WLAN_FEATURE_VOWIFI_11R
11665 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11666 {
11667 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11668 {
11669 fCheck = eANI_BOOLEAN_FALSE;
11670 break;
11671 }
11672 }
11673#endif
11674 //Match found
11675 fCheck = eANI_BOOLEAN_TRUE;
11676 }while(0);
11677 csrFreeScanFilter(pMac, pScanFilter);
11678 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011679 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 }
11681 }
11682
11683 return (fCheck);
11684}
11685
Jeff Johnson295189b2012-06-20 16:38:30 -070011686tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11687{
11688 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11689 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 do
11691 {
11692 //Only check for static WEP
11693 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11694 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11695 {
11696 fCheck = eANI_BOOLEAN_TRUE;
11697 break;
11698 }
11699 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11700 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11701 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11702 {
11703 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011704 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11705 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 {
11707 break;
11708 }
11709 }
11710 if( i == CSR_MAX_NUM_KEY)
11711 {
11712 fCheck = eANI_BOOLEAN_TRUE;
11713 }
11714 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 return (fCheck);
11716}
11717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718//IBSS
11719
Jeff Johnson295189b2012-06-20 16:38:30 -070011720tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11721{
11722 tANI_U8 channel = 0;
11723 tANI_U32 idx;
11724 tANI_U32 idxValidChannels;
11725 tANI_BOOLEAN fFound = FALSE;
11726 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11727
11728 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11729 {
11730 channel = pMac->roam.configParam.AdHocChannel5G;
11731 if(!csrRoamIsChannelValid(pMac, channel))
11732 {
11733 channel = 0;
11734 }
11735 }
11736 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11737 {
11738 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11739 {
11740 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11741 {
11742 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11743 {
11744 fFound = TRUE;
11745 channel = csrStartIbssChannels50[ idx ];
11746 }
11747 }
11748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11750 if (!fFound)
11751 {
11752 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11753 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011754 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011755 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011756 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 break;
11758 }
11759 }
11760 }
11761 }//if
11762
11763 return( channel );
11764}
11765
Jeff Johnson295189b2012-06-20 16:38:30 -070011766tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11767{
11768 tANI_U8 channel = 1;
11769 tANI_U32 idx;
11770 tANI_U32 idxValidChannels;
11771 tANI_BOOLEAN fFound = FALSE;
11772 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11773
11774 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11775 {
11776 channel = pMac->roam.configParam.AdHocChannel24;
11777 if(!csrRoamIsChannelValid(pMac, channel))
11778 {
11779 channel = 0;
11780 }
11781 }
11782
11783 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11784 {
11785 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11786 {
11787 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11788 {
11789 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11790 {
11791 fFound = TRUE;
11792 channel = csrStartIbssChannels24[ idx ];
11793 }
11794 }
11795 }
11796 }
11797
11798 return( channel );
11799}
11800
Jeff Johnson295189b2012-06-20 16:38:30 -070011801static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11802 tCsrRoamStartBssParams *pParam )
11803{
11804 eCsrCfgDot11Mode cfgDot11Mode;
11805 eCsrBand eBand;
11806 tANI_U8 channel = 0;
11807 tSirNwType nwType;
11808 tANI_U8 operationChannel = 0;
11809
11810 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11811 {
11812 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11813 }
11814
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011816
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11818 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11819 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11820 )
11821 {
11822 /* This should never happen */
11823 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011824 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 pProfile->csrPersona);
11826 VOS_ASSERT(0);
11827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011828 switch( cfgDot11Mode )
11829 {
11830 case eCSR_CFG_DOT11_MODE_11G:
11831 nwType = eSIR_11G_NW_TYPE;
11832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 case eCSR_CFG_DOT11_MODE_11B:
11834 nwType = eSIR_11B_NW_TYPE;
11835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 case eCSR_CFG_DOT11_MODE_11A:
11837 nwType = eSIR_11A_NW_TYPE;
11838 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 default:
11840 case eCSR_CFG_DOT11_MODE_11N:
11841 case eCSR_CFG_DOT11_MODE_TAURUS:
11842 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11843 if(eCSR_BAND_24 == eBand)
11844 {
11845 nwType = eSIR_11G_NW_TYPE;
11846 }
11847 else
11848 {
11849 nwType = eSIR_11A_NW_TYPE;
11850 }
11851 break;
11852 }
11853
11854 pParam->extendedRateSet.numRates = 0;
11855
11856 switch ( nwType )
11857 {
11858 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011859 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 case eSIR_11A_NW_TYPE:
11861
11862 pParam->operationalRateSet.numRates = 8;
11863
11864 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11865 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11866 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11867 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11868 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11869 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11870 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11871 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11872
11873 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11874 {
11875 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11876 if( 0 == channel &&
11877 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11878 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11879 )
11880 {
11881 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11882 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11883 nwType = eSIR_11B_NW_TYPE;
11884 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11885 pParam->operationalRateSet.numRates = 4;
11886 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11887 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11888 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11889 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11890 }
11891 }
11892 else
11893 {
11894 channel = operationChannel;
11895 }
11896 break;
11897
11898 case eSIR_11B_NW_TYPE:
11899 pParam->operationalRateSet.numRates = 4;
11900 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11901 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11902 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11903 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11905 {
11906 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11907 }
11908 else
11909 {
11910 channel = operationChannel;
11911 }
11912
11913 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 /* For P2P Client and P2P GO, disable 11b rates */
11916 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11917 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11918 )
11919 {
11920 pParam->operationalRateSet.numRates = 8;
11921
11922 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11923 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11924 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11925 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11926 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11927 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11928 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11929 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11930 }
11931 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 {
11933 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11935 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11936 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11937 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11938
11939 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11941 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11942 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11943 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11944 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11945 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11946 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11947 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11948 }
11949
11950 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11951 {
11952 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11953 }
11954 else
11955 {
11956 channel = operationChannel;
11957 }
11958
11959 break;
11960 }
11961 pParam->operationChn = channel;
11962 pParam->sirNwType = nwType;
11963}
11964
Jeff Johnson295189b2012-06-20 16:38:30 -070011965static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11966 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11967{
11968
11969 if( pParam )
11970 {
11971 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011972 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011973 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011974 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011975
11976 if( pIes )
11977 {
11978 if(pIes->SuppRates.present)
11979 {
11980 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11981 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011983 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 -070011984 pIes->SuppRates.num_rates);
11985 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11986 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011987 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11988 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011990 if (pIes->ExtSuppRates.present)
11991 {
11992 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011993 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011994 {
11995 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11996 SIR_MAC_RATESET_EID_MAX, resetting to \
11997 SIR_MAC_RATESET_EID_MAX"),
11998 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011999 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012000 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012001 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012002 pIes->ExtSuppRates.rates,
12003 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 if( pIes->SSID.present )
12006 {
12007 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012008 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12009 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 }
12011 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 }
12013 else
12014 {
12015 pParam->ssId.length = 0;
12016 pParam->operationalRateSet.numRates = 0;
12017 }
12018 }
12019}
12020
Jeff Johnson295189b2012-06-20 16:38:30 -070012021static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12022{
12023 tANI_U8 MaxRate = 0;
12024 tANI_U32 i;
12025 tANI_U8 *pRate;
12026
12027 pRate = pSirRateSet->rate;
12028 for ( i = 0; i < pSirRateSet->numRates; i++ )
12029 {
12030 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12031 }
12032
12033 // Save the max rate in the connected state information...
12034
12035 // modify LastRates variable as well
12036
12037 return;
12038}
12039
Jeff Johnson295189b2012-06-20 16:38:30 -070012040eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12041 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12042{
12043 eHalStatus status = eHAL_STATUS_SUCCESS;
12044 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 // Set the roaming substate to 'Start BSS attempt'...
12046 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012047#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12048 //Need to figure out whether we need to log WDS???
12049 if( CSR_IS_IBSS( pProfile ) )
12050 {
12051 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12053 if(pIbssLog)
12054 {
12055 if(pBssDesc)
12056 {
12057 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012058 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012059 }
12060 else
12061 {
12062 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12063 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012064 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012065 if(pProfile->ChannelInfo.numOfChannels == 0)
12066 {
12067 pIbssLog->channelSetting = AUTO_PICK;
12068 }
12069 else
12070 {
12071 pIbssLog->channelSetting = SPECIFIED;
12072 }
12073 pIbssLog->operatingChannel = pParam->operationChn;
12074 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12075 }
12076 }
12077#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12078 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012079 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12080 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012081
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 pParam->privacy = pProfile->privacy;
12083 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12084 pParam->authType = pProfile->csr80211AuthType;
12085 pParam->beaconInterval = pProfile->beaconInterval;
12086 pParam->dtimPeriod = pProfile->dtimPeriod;
12087 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12088 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12089 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12090 {
12091 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12092 {
12093 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12094 }
12095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 pParam->protEnabled = pProfile->protEnabled;
12097 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12098 pParam->ht_protection = pProfile->cfg_protection;
12099 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012100
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12102 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012104
12105#ifdef WLAN_FEATURE_11W
12106 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12107 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12108#endif
12109
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 // When starting an IBSS, start on the channel from the Profile.
12111 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 return (status);
12113}
12114
Jeff Johnson295189b2012-06-20 16:38:30 -070012115static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012116 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012117{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012118 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012119 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012121
12122 if(!pSession)
12123 {
12124 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12125 return;
12126 }
12127
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 if( pBssDesc )
12129 {
12130 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12131 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12132 //The following code has to be do after that.
12133 //For WDS station, use selfMac as the self BSSID
12134 if( CSR_IS_WDS_STA( pProfile ) )
12135 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012136 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12137 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 }
12139 }
12140 else
12141 {
12142 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 //Use the first SSID
12144 if(pProfile->SSIDs.numOfSSIDs)
12145 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012146 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12147 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012148 }
12149 //For WDS station, use selfMac as the self BSSID
12150 if( CSR_IS_WDS_STA( pProfile ) )
12151 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012152 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12153 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012154 }
12155 //Use the first BSSID
12156 else if( pProfile->BSSIDs.numOfBSSIDs )
12157 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012158 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12159 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 }
12161 else
12162 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012163 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 }
12165 }
12166 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 //Set operating channel in pProfile which will be used
12168 //in csrRoamSetBssConfigCfg() to determine channel bonding
12169 //mode and will be configured in CFG later
12170 pProfile->operationChannel = Channel;
12171
12172 if(Channel == 0)
12173 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012174 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 }
12176 else
12177 {
12178
12179 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012180 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012181 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012182 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012183 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012184#ifdef WLAN_FEATURE_AP_HT40_24G
12185 if (CSR_IS_INFRA_AP(pProfile))
12186 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12187 else
12188 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12189#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012190 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012191#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012192 }
12193 else
12194 {
12195 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12196 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012197 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012198 pBssConfig->cbMode = cbMode;
12199 pSession->bssParams.cbMode = cbMode;
12200 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 }
12202}
12203
Jeff Johnson295189b2012-06-20 16:38:30 -070012204static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12205 tANI_BOOLEAN *pfSameIbss )
12206{
12207 eHalStatus status = eHAL_STATUS_SUCCESS;
12208 tANI_BOOLEAN fSameIbss = FALSE;
12209
12210 if ( csrIsConnStateIbss( pMac, sessionId ) )
12211 {
12212 // Check if any profile parameter has changed ? If any profile parameter
12213 // has changed then stop old BSS and start a new one with new parameters
12214 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12215 {
12216 fSameIbss = TRUE;
12217 }
12218 else
12219 {
12220 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12221 }
12222 }
12223 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12224 {
12225 // Disassociate from the connected Infrastructure network...
12226 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12227 }
12228 else
12229 {
12230 tBssConfigParam *pBssConfig;
12231
Kiet Lam64c1b492013-07-12 13:56:44 +053012232 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12233 if ( NULL == pBssConfig )
12234 status = eHAL_STATUS_FAILURE;
12235 else
12236 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012237 if(HAL_STATUS_SUCCESS(status))
12238 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012239 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012240 // there is no Bss description before we start an IBSS so we need to adopt
12241 // all Bss configuration parameters from the Profile.
12242 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12243 if(HAL_STATUS_SUCCESS(status))
12244 {
12245 //save dotMode
12246 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12247 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012248 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012249 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12250 NULL, pBssConfig,
12251 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012252 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012253
12254 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 }//Allocate memory
12256 }
12257
12258 if(pfSameIbss)
12259 {
12260 *pfSameIbss = fSameIbss;
12261 }
12262 return( status );
12263}
12264
Jeff Johnson295189b2012-06-20 16:38:30 -070012265static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12266 tSirSmeNewBssInfo *pNewBss )
12267{
12268 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012269
12270 if(!pSession)
12271 {
12272 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12273 return;
12274 }
12275
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 if( pNewBss )
12277 {
12278 // Set the operating channel.
12279 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12280 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012281 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12282 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 return;
12285}
12286
Jeff Johnson295189b2012-06-20 16:38:30 -070012287#ifdef FEATURE_WLAN_WAPI
12288eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12289 tANI_U32 numItems )
12290{
12291 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12292 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012293 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012295 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 return status;
12297 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012298 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 pSession = CSR_GET_SESSION( pMac, sessionId );
12300 if(numItems <= CSR_MAX_BKID_ALLOWED)
12301 {
12302 status = eHAL_STATUS_SUCCESS;
12303 //numItems may be 0 to clear the cache
12304 pSession->NumBkidCache = (tANI_U16)numItems;
12305 if(numItems && pBKIDCache)
12306 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012307 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12308 sizeof(tBkidCacheInfo) * numItems);
12309 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 }
12311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 return (status);
12313}
Jeff Johnson295189b2012-06-20 16:38:30 -070012314eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12315 tBkidCacheInfo *pBkidCache)
12316{
12317 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12318 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012319 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012321 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 return status;
12323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 pSession = CSR_GET_SESSION( pMac, sessionId );
12325 if(pNum && pBkidCache)
12326 {
12327 if(pSession->NumBkidCache == 0)
12328 {
12329 *pNum = 0;
12330 status = eHAL_STATUS_SUCCESS;
12331 }
12332 else if(*pNum >= pSession->NumBkidCache)
12333 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012334 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012336 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 -070012337 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012338 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012340 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12341 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 *pNum = pSession->NumBkidCache;
12343 status = eHAL_STATUS_SUCCESS;
12344 }
12345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012347}
Jeff Johnson295189b2012-06-20 16:38:30 -070012348tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12349{
12350 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012351}
12352#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012353eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012354 tPmkidCacheInfo *pPMKIDCache,
12355 tANI_U32 numItems,
12356 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012357{
12358 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12359 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012360
12361 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012362 {
12363 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12364 return eHAL_STATUS_FAILURE;
12365 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012366
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012367 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012368
12369 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 {
12371#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12372 {
12373 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012374 vos_mem_set(&secEvent,
12375 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12377 secEvent.encryptionModeMulticast =
12378 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12379 secEvent.encryptionModeUnicast =
12380 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012381 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 secEvent.authMode =
12383 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12384 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12385 }
12386#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012388 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012389 if (numItems && pPMKIDCache)
12390 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012391 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012392 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12393 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012394 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012395 }
12396 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012397 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012398 tPmkidCacheInfo *pmksa;
12399
12400 for (i = 0; i < numItems; i++) {
12401 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012402
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012403 /* Delete the entry if present */
12404 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12405
12406 /* Add entry to the cache */
12407 vos_mem_copy(
12408 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12409 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12410 vos_mem_copy(
12411 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12412 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12413
12414 /* Increment the CSR local cache index */
12415 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12416 pSession->CurCacheIndex++;
12417 else
12418 pSession->CurCacheIndex = 0;
12419
12420 pSession->NumPmkidCache++;
12421 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12422 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 }
12425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 return (status);
12427}
12428
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012429eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012430 tANI_U8 *pBSSId,
12431 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012432{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012433 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12434 tANI_BOOLEAN fMatchFound = FALSE;
12435 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012436 tANI_U32 CurIndex;
12437 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012438
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012439 if(!pSession)
12440 {
12441 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12442 return eHAL_STATUS_FAILURE;
12443 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012444
12445 /* Check if there are no entries to delete */
12446 if (0 == pSession->NumPmkidCache) {
12447 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12448 return eHAL_STATUS_SUCCESS;
12449 }
12450
12451 if (!flush_cache) {
12452 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12453 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12454 pBSSId, VOS_MAC_ADDR_SIZE)) {
12455 fMatchFound = 1;
12456
12457 /* Clear this - the matched entry */
12458 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12459 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012460 break;
12461 }
12462 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012463
12464 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12465 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12466 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012467 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012468 else {
12469 /* Match Found */
12470 CurIndex = pSession->CurCacheIndex;
12471 if(Index < CurIndex) {
12472 for(i = Index; i < (CurIndex-1); i++) {
12473 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12474 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12475 }
12476 pSession->CurCacheIndex--;
12477 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12478 sizeof(tPmkidCacheInfo));
12479 } else if(Index > CurIndex) {
12480 for(i = Index; i > (CurIndex); i--) {
12481 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12482 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12483 }
12484 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12485 sizeof(tPmkidCacheInfo));
12486 }
12487 pSession->NumPmkidCache--;
12488 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012489 } else {
12490 /* Flush the entire cache */
12491 vos_mem_zero(pSession->PmkidCacheInfo,
12492 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12493 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012494 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012495 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012496
12497 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012498}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012499
Jeff Johnson295189b2012-06-20 16:38:30 -070012500tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12501{
12502 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12503}
12504
Jeff Johnson295189b2012-06-20 16:38:30 -070012505eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12506{
12507 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12508 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012509 tPmkidCacheInfo *pmksa;
12510 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012511
12512 if(!pSession)
12513 {
12514 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12515 return eHAL_STATUS_FAILURE;
12516 }
12517
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 if(pNum && pPmkidCache)
12519 {
12520 if(pSession->NumPmkidCache == 0)
12521 {
12522 *pNum = 0;
12523 status = eHAL_STATUS_SUCCESS;
12524 }
12525 else if(*pNum >= pSession->NumPmkidCache)
12526 {
12527 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012529 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 -070012530 pSession->NumPmkidCache);
12531 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12532 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012533
12534 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12535 pmksa = &pSession->PmkidCacheInfo[i];
12536 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12537 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
12538 pPmkidCache++;
12539 j++;
12540 }
12541 }
12542
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 *pNum = pSession->NumPmkidCache;
12544 status = eHAL_STATUS_SUCCESS;
12545 }
12546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 return (status);
12548}
12549
Jeff Johnson295189b2012-06-20 16:38:30 -070012550eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12551{
12552 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12553 tANI_U32 len;
12554 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012555
12556 if(!pSession)
12557 {
12558 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12559 return eHAL_STATUS_FAILURE;
12560 }
12561
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 if(pLen)
12563 {
12564 len = *pLen;
12565 *pLen = pSession->nWpaRsnReqIeLength;
12566 if(pBuf)
12567 {
12568 if(len >= pSession->nWpaRsnReqIeLength)
12569 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012570 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12571 pSession->nWpaRsnReqIeLength);
12572 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 }
12574 }
12575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 return (status);
12577}
12578
Jeff Johnson295189b2012-06-20 16:38:30 -070012579eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12580{
12581 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12582 tANI_U32 len;
12583 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012584
12585 if(!pSession)
12586 {
12587 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12588 return eHAL_STATUS_FAILURE;
12589 }
12590
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 if(pLen)
12592 {
12593 len = *pLen;
12594 *pLen = pSession->nWpaRsnRspIeLength;
12595 if(pBuf)
12596 {
12597 if(len >= pSession->nWpaRsnRspIeLength)
12598 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012599 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12600 pSession->nWpaRsnRspIeLength);
12601 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 }
12603 }
12604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 return (status);
12606}
Jeff Johnson295189b2012-06-20 16:38:30 -070012607#ifdef FEATURE_WLAN_WAPI
12608eHalStatus csrRoamGetWapiReqIE(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->nWapiReqIeLength;
12624 if(pBuf)
12625 {
12626 if(len >= pSession->nWapiReqIeLength)
12627 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012628 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12629 pSession->nWapiReqIeLength);
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}
Jeff Johnson295189b2012-06-20 16:38:30 -070012636eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12637{
12638 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12639 tANI_U32 len;
12640 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012641
12642 if(!pSession)
12643 {
12644 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12645 return eHAL_STATUS_FAILURE;
12646 }
12647
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 if(pLen)
12649 {
12650 len = *pLen;
12651 *pLen = pSession->nWapiRspIeLength;
12652 if(pBuf)
12653 {
12654 if(len >= pSession->nWapiRspIeLength)
12655 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012656 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12657 pSession->nWapiRspIeLength);
12658 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 }
12660 }
12661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 return (status);
12663}
12664#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012665eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12666{
12667 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12668 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012669
12670 if(!pSession)
12671 {
12672 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12673 return (retStatus);
12674 }
12675
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 if(CSR_IS_ROAMING(pSession))
12677 {
12678 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12679 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 return (retStatus);
12682}
12683
Jeff Johnson295189b2012-06-20 16:38:30 -070012684//This function remove the connected BSS from te cached scan result
12685eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12686 tCsrRoamConnectedProfile *pConnProfile)
12687{
12688 eHalStatus status = eHAL_STATUS_FAILURE;
12689 tCsrScanResultFilter *pScanFilter = NULL;
12690 tListElem *pEntry;
12691 tCsrScanResult *pResult;
12692 tDot11fBeaconIEs *pIes;
12693 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12695 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12696 {
12697 do
12698 {
12699 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012700 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12701 if ( NULL == pScanFilter )
12702 status = eHAL_STATUS_FAILURE;
12703 else
12704 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012705 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012706 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12707 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12708 if ( NULL == pScanFilter->BSSIDs.bssid )
12709 status = eHAL_STATUS_FAILURE;
12710 else
12711 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012713 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12714 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12716 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12717 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012718 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12719 if ( NULL == pScanFilter->SSIDs.SSIDList )
12720 status = eHAL_STATUS_FAILURE;
12721 else
12722 status = eHAL_STATUS_SUCCESS;
12723 if (!HAL_STATUS_SUCCESS(status)) break;
12724 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12725 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 }
12727 pScanFilter->authType.numEntries = 1;
12728 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12729 pScanFilter->BSSType = pConnProfile->BSSType;
12730 pScanFilter->EncryptionType.numEntries = 1;
12731 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12732 pScanFilter->mcEncryptionType.numEntries = 1;
12733 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12734 //We ignore the channel for now, BSSID should be enough
12735 pScanFilter->ChannelInfo.numOfChannels = 0;
12736 //Also ignore the following fields
12737 pScanFilter->uapsd_mask = 0;
12738 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012739 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 pScanFilter->countryCode[0] = 0;
12741 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 csrLLLock(&pMac->scan.scanResultList);
12743 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12744 while( pEntry )
12745 {
12746 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12747 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12748 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12749 pScanFilter, NULL, NULL, NULL, &pIes);
12750 //Release the IEs allocated by csrMatchBSS is needed
12751 if( !pResult->Result.pvIes )
12752 {
12753 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012754 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 }
12756 if(fMatch)
12757 {
12758 //We found the one
12759 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12760 {
12761 //Free the memory
12762 csrFreeScanResultEntry( pMac, pResult );
12763 }
12764 break;
12765 }
12766 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12767 }//while
12768 csrLLUnlock(&pMac->scan.scanResultList);
12769 }while(0);
12770 if(pScanFilter)
12771 {
12772 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012773 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 }
12775 }
12776 return (status);
12777}
12778
Jeff Johnson295189b2012-06-20 16:38:30 -070012779//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012780eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12781{
12782 eHalStatus status = eHAL_STATUS_SUCCESS;
12783 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12785 {
12786 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12787 {
12788 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12789 {
12790 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012791 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012792 status = eHAL_STATUS_CSR_WRONG_STATE;
12793 break;
12794 }
12795 if( csrIsConnStateInfra( pMac, sessionId ) )
12796 {
12797 if( chnId &&
12798 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012800 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12802 status = eHAL_STATUS_CSR_WRONG_STATE;
12803 break;
12804 }
12805 }
12806 }
12807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 return ( status );
12809}
12810
Jeff Johnson295189b2012-06-20 16:38:30 -070012811static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12812{
12813 eHalStatus status = eHAL_STATUS_SUCCESS;
12814 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12815 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012816
12817 if(!pSession)
12818 {
12819 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12820 return eHAL_STATUS_FAILURE;
12821 }
12822
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 if ( csrIsConnStateIbss( pMac, sessionId ) )
12824 {
12825 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12826 }
12827 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12828 {
12829 // Disassociate from the connected Infrastructure network...
12830 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12831 }
12832 else
12833 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12835 //Otherwise we need to add code to handle the
12836 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12837 //send stop_bss to PE, before we can continue.
12838 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012839 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012841 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12842 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 // there is no Bss description before we start an WDS so we need
12844 // to adopt all Bss configuration parameters from the Profile.
12845 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12846 if(HAL_STATUS_SUCCESS(status))
12847 {
12848 //Save profile for late use
12849 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012850 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12851 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012853 vos_mem_set(pSession->pCurRoamProfile,
12854 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012858 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012859 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12860 NULL, &bssConfig,
12861 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 }
12863 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012864
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 return( status );
12866}
12867
Jeff Johnson295189b2012-06-20 16:38:30 -070012868////////////////////Mail box
12869
Jeff Johnson295189b2012-06-20 16:38:30 -070012870//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12871//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012872static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12873 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12875{
12876 tCsrChannelSet channelGroup;
12877 tSirMacCapabilityInfo *pAP_capabilityInfo;
12878 tAniBool fTmp;
12879 tANI_BOOLEAN found = FALSE;
12880 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012881 tANI_S8 pwrLimit = 0;
12882 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012883 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12884 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12885 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12886 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 // 802.11h
12888 //We can do this because it is in HOST CPU order for now.
12889 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012890 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12891 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12892 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 fTmp = (tAniBool)pal_cpu_to_be32(1);
12894 }
12895 else
12896 fTmp = (tAniBool)0;
12897
12898 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012899 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 pBuf += sizeof(tAniBool);
12901 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012902 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 // This is required for 11k test VoWiFi Ent: Test 2.
12904 // We need the power capabilities for Assoc Req.
12905 // This macro is provided by the halPhyCfg.h. We pick our
12906 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012907 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12908 if (0 != pwrLimit)
12909 {
12910 *pBuf++ = pwrLimit;
12911 }
12912 else
12913 {
12914 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 size = sizeof(pMac->roam.validChannelList);
12917 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12918 {
12919 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12920 for ( i = 0; i < size; i++)
12921 {
12922 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12923
12924 }
12925 }
12926 else
12927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012928 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012929 *pBuf++ = 0; //tSirSupChnl->numChnl
12930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 //Check whether it is ok to enter UAPSD
12932#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12933 if( btcIsReadyForUapsd(pMac) )
12934#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12935 {
12936 *pBuf++ = uapsdMask;
12937 }
12938#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12939 else
12940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012941 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 *pBuf++ = 0;
12943 }
12944#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12945
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012947 vos_mem_copy(pBuf, pBssDescription,
12948 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12950}
12951
Jeff Johnson295189b2012-06-20 16:38:30 -070012952/*
12953 * The communication between HDD and LIM is thru mailbox (MB).
12954 * Both sides will access the data structure "tSirSmeJoinReq".
12955 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12956 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12957 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12958 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12959 */
12960eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012961 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012962{
12963 eHalStatus status = eHAL_STATUS_SUCCESS;
12964 tSirSmeJoinReq *pMsg;
12965 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012966 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 tANI_U16 msgLen, wTmp, ieLen;
12968 tSirMacRateSet OpRateSet;
12969 tSirMacRateSet ExRateSet;
12970 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12971 tANI_U32 dwTmp;
12972 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012973 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053012974 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053012975 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012976
12977 if(!pSession)
12978 {
12979 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12980 return eHAL_STATUS_FAILURE;
12981 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012982 /* To satisfy klockworks */
12983 if (NULL == pBssDescription)
12984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012985 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012986 return eHAL_STATUS_FAILURE;
12987 }
12988
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 do {
12990 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12991 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012992 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12994 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12995 // IE fields, but the length field in the bssDescription needs to be interpreted to
12996 // determine length of the IE fields.
12997 //
12998 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12999 // add in the length from the bssDescription (then add the size of the 'length' field
13000 // itself because that is NOT included in the length field).
13001 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13002 pBssDescription->length + sizeof( pBssDescription->length ) +
13003 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 +053013004 pMsg = vos_mem_malloc(msgLen);
13005 if (NULL == pMsg)
13006 status = eHAL_STATUS_FAILURE;
13007 else
13008 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013010 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013011 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 pMsg->length = pal_cpu_to_be16(msgLen);
13013 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 // sessionId
13015 *pBuf = (tANI_U8)sessionId;
13016 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 // transactionId
13018 *pBuf = 0;
13019 *( pBuf + 1 ) = 0;
13020 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 // ssId
13022 if( pIes->SSID.present && pIes->SSID.num_ssid )
13023 {
13024 // ssId len
13025 *pBuf = pIes->SSID.num_ssid;
13026 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013027 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 pBuf += pIes->SSID.num_ssid;
13029 }
13030 else
13031 {
13032 *pBuf = 0;
13033 pBuf++;
13034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013036 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13037 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 pBuf += sizeof(tSirMacAddr);
13039 // bsstype
13040 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13041 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013042 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 pBuf += sizeof(tSirBssType);
13044 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013045 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13046 if (pBssDescription->channelId <= 14 &&
13047 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13048 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13049 {
13050 //Need to disable VHT operation in 2.4 GHz band
13051 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13052 }
13053 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 //Persona
13056 *pBuf = (tANI_U8)pProfile->csrPersona;
13057 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013058 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13059 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013060 //CBMode
13061 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13062 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063
13064 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070013065 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
13066
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 // uapsdPerAcBitmask
13068 *pBuf = pProfile->uapsd_mask;
13069 pBuf++;
13070
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013071
13072
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013073 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013074 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 {
13076 // OperationalRateSet
13077 if (OpRateSet.numRates) {
13078 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013079 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 pBuf += OpRateSet.numRates;
13081 } else *pBuf++ = 0;
13082 // ExtendedRateSet
13083 if (ExRateSet.numRates) {
13084 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013085 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 pBuf += ExRateSet.numRates;
13087 } else *pBuf++ = 0;
13088 }
13089 else
13090 {
13091 *pBuf++ = 0;
13092 *pBuf++ = 0;
13093 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013094
13095 //rateBitmap
13096 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13097 pBuf += sizeof(tANI_U16);
13098
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 // rsnIE
13100 if ( csrIsProfileWpa( pProfile ) )
13101 {
13102 // Insert the Wpa IE into the join request
13103 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13104 (tCsrWpaIe *)( wpaRsnIE ) );
13105 }
13106 else if( csrIsProfileRSN( pProfile ) )
13107 {
13108 // Insert the RSN IE into the join request
13109 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13110 (tCsrRSNIe *)( wpaRsnIE ) );
13111 }
13112#ifdef FEATURE_WLAN_WAPI
13113 else if( csrIsProfileWapi( pProfile ) )
13114 {
13115 // Insert the WAPI IE into the join request
13116 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13117 (tCsrWapiIe *)( wpaRsnIE ) );
13118 }
13119#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 else
13121 {
13122 ieLen = 0;
13123 }
13124 //remember the IE for future use
13125 if( ieLen )
13126 {
13127 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013129 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 -070013130 ieLen = DOT11F_IE_RSN_MAX_LEN;
13131 }
13132#ifdef FEATURE_WLAN_WAPI
13133 if( csrIsProfileWapi( pProfile ) )
13134 {
13135 //Check whether we need to allocate more memory
13136 if(ieLen > pSession->nWapiReqIeLength)
13137 {
13138 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13139 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013140 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013142 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13143 if (NULL == pSession->pWapiReqIE)
13144 status = eHAL_STATUS_FAILURE;
13145 else
13146 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 if(!HAL_STATUS_SUCCESS(status)) break;
13148 }
13149 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013150 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013152 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013154 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 pBuf += ieLen;
13156 }
13157 else//should be WPA/WPA2 otherwise
13158#endif /* FEATURE_WLAN_WAPI */
13159 {
13160 //Check whether we need to allocate more memory
13161 if(ieLen > pSession->nWpaRsnReqIeLength)
13162 {
13163 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13164 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013165 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013167 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13168 if (NULL == pSession->pWpaRsnReqIE)
13169 status = eHAL_STATUS_FAILURE;
13170 else
13171 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 if(!HAL_STATUS_SUCCESS(status)) break;
13173 }
13174 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013175 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013177 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013179 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 pBuf += ieLen;
13181 }
13182 }
13183 else
13184 {
13185 //free whatever old info
13186 pSession->nWpaRsnReqIeLength = 0;
13187 if(pSession->pWpaRsnReqIE)
13188 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pSession->pWpaRsnReqIE = NULL;
13191 }
13192#ifdef FEATURE_WLAN_WAPI
13193 pSession->nWapiReqIeLength = 0;
13194 if(pSession->pWapiReqIE)
13195 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013196 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 pSession->pWapiReqIE = NULL;
13198 }
13199#endif /* FEATURE_WLAN_WAPI */
13200 //length is two bytes
13201 *pBuf = 0;
13202 *(pBuf + 1) = 0;
13203 pBuf += 2;
13204 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013205#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013206 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013208 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 //length is two bytes
13210 *pBuf = 0;
13211 *(pBuf + 1) = 0;
13212 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013213 }
13214 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013216 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013217 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013218 {
13219 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013220#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013221 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013222 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013223 pSession->suppCckmIeInfo.cckmIe, ieLen);
13224#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013225 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013226 pSession,
13227 pProfile,
13228 pBssDescription,
13229 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 pSession->nWpaRsnReqIeLength,
13231 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013232#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013233 }
13234 else
13235 {
13236 ieLen = 0;
13237 }
13238 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13239 if( ieLen )
13240 {
13241 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13242 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013243 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013244 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013245 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013246 pBuf += ieLen;
13247 }
13248 else
13249 {
13250 //Indicate you have no CCKM IE
13251 //length is two bytes
13252 *pBuf = 0;
13253 *(pBuf + 1) = 0;
13254 pBuf += 2;
13255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013257#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013259 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 {
13261 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013262 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013264 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013266 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013268 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 pBuf += ieLen;
13270 }
13271 else
13272 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013273 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 *pBuf = 0;
13276 *(pBuf + 1) = 0;
13277 pBuf += 2;
13278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 // addIEAssoc
13280 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13281 {
13282 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 if(ieLen > pSession->nAddIEAssocLength)
13284 {
13285 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013286 {
13287 vos_mem_free(pSession->pAddIEAssoc);
13288 }
13289 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13290 if (NULL == pSession->pAddIEAssoc)
13291 status = eHAL_STATUS_FAILURE;
13292 else
13293 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013297 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013299 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013301 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 pBuf += ieLen;
13303 }
13304 else
13305 {
13306 pSession->nAddIEAssocLength = 0;
13307 if(pSession->pAddIEAssoc)
13308 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013309 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 pSession->pAddIEAssoc = NULL;
13311 }
13312 *pBuf = 0;
13313 *(pBuf + 1) = 0;
13314 pBuf += 2;
13315 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013316
13317 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013319 //Unmask any AC in reassoc that is ACM-set
13320 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13321 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013323 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13324 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013325#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013326 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013327#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013328 }
13329 else
13330 {
13331 uapsd_mask = 0;
13332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 }
13334 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013335
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013337 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013338 pBuf += sizeof(tANI_U32);
13339
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013341 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013342 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013343#ifdef WLAN_FEATURE_11W
13344 //MgmtEncryption
13345 if (pProfile->MFPEnabled)
13346 {
13347 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13348 }
13349 else
13350 {
13351 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13352 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013353 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013354 pBuf += sizeof(tANI_U32);
13355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013356#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013357 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013358 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013359#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013360 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013361 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013362#endif
13363 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013364 {
13365 // is11Rconnection;
13366 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013367 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013368 pBuf += sizeof(tAniBool);
13369 }
13370 else
13371 {
13372 // is11Rconnection;
13373 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013374 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013375 pBuf += sizeof(tAniBool);
13376 }
13377#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013378#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013379
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013380 // isESEFeatureIniEnabled
13381 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013382 {
13383 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013384 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013385 pBuf += sizeof(tAniBool);
13386 }
13387 else
13388 {
13389 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013390 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013391 pBuf += sizeof(tAniBool);
13392 }
13393
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013394 /* A profile can not be both ESE and 11R. But an 802.11R AP
13395 * may be advertising support for ESE as well. So if we are
13396 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013397 * If we are associating explictly 11R only then we will get
13398 * 11R.
13399 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013400 if ((csrIsProfileESE(pProfile) ||
13401 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013402 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13403 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13404 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13405 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13406#ifdef WLAN_FEATURE_11W
13407 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013408 || (pProfile->negotiatedAuthType ==
13409 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013410#endif
13411 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013412 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013413 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013414 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013415 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013416 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013417 pBuf += sizeof(tAniBool);
13418 }
13419 else
13420 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013421 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013422 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013423 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013424 pBuf += sizeof(tAniBool);
13425 }
13426
13427 if (eWNI_SME_JOIN_REQ == messageType)
13428 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013429 tESETspecInfo eseTspec;
13430 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013431 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013432 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13433 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13434 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013435 }
13436 else if (eWNI_SME_REASSOC_REQ == messageType)
13437 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013438 if ((csrIsProfileESE(pProfile) ||
13439 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013440 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13441 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13442 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13443 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13444#ifdef WLAN_FEATURE_11W
13445 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013446 || (pProfile->negotiatedAuthType ==
13447 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013448#endif
13449 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013450 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013452 tESETspecInfo eseTspec;
13453 // ESE Tspec information
13454 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13455 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13456 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013459 if (eseTspec.numTspecs) {
13460 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13461 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013463 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013465 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013467 tESETspecInfo eseTspec;
13468 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013470 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13471 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13472 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 }
13474 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013475#endif // FEATURE_WLAN_ESE
13476#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013478 if (pMac->roam.configParam.isFastTransitionEnabled
13479#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013480 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013481#endif
13482 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013484 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013485 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013486 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 }
13488 else
13489 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013490 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013491 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013492 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 }
13494#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013495#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013496 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013497 {
13498 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013499 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013500 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013501 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013502 }
13503 else
13504 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013505 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013506 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013507 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013508 }
13509#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013510
13511 // txLdpcIniFeatureEnabled
13512 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13513 pBuf++;
13514
Kiran4a17ebe2013-01-31 10:43:43 -080013515 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13516 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13517 {
13518 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13519 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13520 csrApplyPower2Current(pMac);
13521 }
13522
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013523#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013524 // txBFIniFeatureEnabled
13525 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13526 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013527
13528 // txBFCsnValue
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013529 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13530 if (pIes->VHTCaps.present)
13531 {
13532 txBFCsnValue = CSR_ROAM_MIN(txBFCsnValue, pIes->VHTCaps.numSoundingDim);
13533 }
13534 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013535 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013536
13537 /* Only enable MuBf if no other MuBF session exist
13538 * and FW and HOST is MuBF capable.
13539 */
13540 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13541 {
13542 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13543 pBuf++;
13544 }
13545 else
13546 {
13547 *pBuf = 0;
13548 pBuf++;
13549 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013550#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013551 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13552 pBuf++;
13553
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013554 // WME
13555 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13556 {
13557 //WME enabled
13558 dwTmp = pal_cpu_to_be32(TRUE);
13559 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13560 pBuf += sizeof(tAniBool);
13561 }
13562 else
13563 {
13564 dwTmp = pal_cpu_to_be32(FALSE);
13565 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13566 pBuf += sizeof(tAniBool);
13567 }
13568
13569 // QOS
13570 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13571 {
13572 //QOS enabled
13573 dwTmp = pal_cpu_to_be32(TRUE);
13574 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13575 pBuf += sizeof(tAniBool);
13576 }
13577 else
13578 {
13579 dwTmp = pal_cpu_to_be32(FALSE);
13580 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13581 pBuf += sizeof(tAniBool);
13582 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013583 //BssDesc
13584 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13585 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013586
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013587 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013588 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13589 pMsg = NULL;
13590
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013591 if(!HAL_STATUS_SUCCESS(status))
13592 {
13593 break;
13594 }
13595 else
13596 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013597#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013598 if (eWNI_SME_JOIN_REQ == messageType)
13599 {
13600 //Tush-QoS: notify QoS module that join happening
13601 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13602 }
13603 else if (eWNI_SME_REASSOC_REQ == messageType)
13604 {
13605 //Tush-QoS: notify QoS module that reassoc happening
13606 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013608#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013611
13612 if (pMsg != NULL)
13613 {
13614 vos_mem_free( pMsg );
13615 }
13616
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013618}
13619
Jeff Johnson295189b2012-06-20 16:38:30 -070013620//
13621eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13622{
13623 eHalStatus status = eHAL_STATUS_SUCCESS;
13624 tSirSmeDisassocReq *pMsg;
13625 tANI_U8 *pBuf;
13626 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13628 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13629 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13632 if (NULL == pMsg)
13633 status = eHAL_STATUS_FAILURE;
13634 else
13635 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013637 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13639 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 pBuf = &pMsg->sessionId;
13641 // sessionId
13642 *pBuf++ = (tANI_U8)sessionId;
13643 // transactionId
13644 *pBuf = 0;
13645 *( pBuf + 1 ) = 0;
13646 pBuf += sizeof(tANI_U16);
13647
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013648 if ( (pSession->pCurRoamProfile != NULL) &&
13649 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13650 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 {
13652 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013653 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13654 sizeof( tSirMacAddr ));
13655 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013658 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13659 //perMacAddr is passed as bssId for softAP
13660 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 pBuf = pBuf + sizeof ( tSirMacAddr );
13662 }
13663 else
13664 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013666 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13667 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013669 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13670 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 if(!HAL_STATUS_SUCCESS(status))
13674 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013675 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 break;
13677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 // reasonCode
13679 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013680 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13681 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 if(!HAL_STATUS_SUCCESS(status))
13683 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013684 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 break;
13686 }
13687 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13689 Here we should not send the disassoc over the air to the AP */
13690 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13691#ifdef WLAN_FEATURE_VOWIFI_11R
13692 && csrRoamIs11rAssoc(pMac)
13693#endif
13694 )
13695 {
13696 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13697 }
13698 pBuf += sizeof(tANI_U8);
13699 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 return( status );
13702}
Jeff Johnson295189b2012-06-20 16:38:30 -070013703eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13704{
13705 eHalStatus status = eHAL_STATUS_SUCCESS;
13706 tSirSmeTkipCntrMeasReq *pMsg;
13707 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013708 do
13709 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013710 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13711 if ( NULL == pMsg )
13712 status = eHAL_STATUS_FAILURE;
13713 else
13714 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013716 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13718 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 pBuf = &pMsg->sessionId;
13720 // sessionId
13721 *pBuf++ = (tANI_U8)sessionId;
13722 // transactionId
13723 *pBuf = 0;
13724 *( pBuf + 1 ) = 0;
13725 pBuf += sizeof(tANI_U16);
13726 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013727 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13728 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 pBuf = pBuf + sizeof ( tSirMacAddr );
13730 // bEnable
13731 *pBuf = (tANI_BOOLEAN)bEnable;
13732 if(!HAL_STATUS_SUCCESS(status))
13733 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013734 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 break;
13736 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 return( status );
13740}
Jeff Johnson295189b2012-06-20 16:38:30 -070013741eHalStatus
13742csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13743 VOS_MODULE_ID modId, tSirMacAddr bssId,
13744 void *pUsrContext, void *pfnSapEventCallback,
13745 tANI_U8 *pAssocStasBuf )
13746{
13747 eHalStatus status = eHAL_STATUS_SUCCESS;
13748 tSirSmeGetAssocSTAsReq *pMsg;
13749 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13750 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 do
13752 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013753 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13754 if ( NULL == pMsg )
13755 status = eHAL_STATUS_FAILURE;
13756 else
13757 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013758 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013759 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 pBuf = (tANI_U8 *)&pMsg->bssId;
13762 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013764 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 // modId
13767 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013771 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13772 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013774 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13775 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013777 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13778 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 status = palSendMBMessage( pMac->hHdd, pMsg );
13781 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 return( status );
13783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013784eHalStatus
13785csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13786 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13787 {
13788 eHalStatus status = eHAL_STATUS_SUCCESS;
13789 tSirSmeGetWPSPBCSessionsReq *pMsg;
13790 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013791
Jeff Johnson295189b2012-06-20 16:38:30 -070013792 do
13793 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013794 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13795 if ( NULL == pMsg )
13796 status = eHAL_STATUS_FAILURE;
13797 else
13798 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013800 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013803 VOS_ASSERT(pBuf);
13804
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013807 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13808 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013810 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13811 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013813 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 return( status );
13822}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013823
13824eHalStatus
13825csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13826{
13827 tpSirChangeBIParams pMsg;
13828 tANI_U16 len = 0;
13829 eHalStatus status = eHAL_STATUS_SUCCESS;
13830 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13831
13832 if(!pSession)
13833 {
13834 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13835 return eHAL_STATUS_FAILURE;
13836 }
13837
13838 //NO need to update the Beacon Params if update beacon parameter flag is not set
13839 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13840 return eHAL_STATUS_SUCCESS;
13841
13842 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13843
13844 /* Create the message and send to lim */
13845 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013846 pMsg = vos_mem_malloc(len);
13847 if ( NULL == pMsg )
13848 status = eHAL_STATUS_FAILURE;
13849 else
13850 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013851 if(HAL_STATUS_SUCCESS(status))
13852 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013854 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13855 pMsg->length = len;
13856
13857 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013858 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13859 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013860 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13861 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013862 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013863 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013864 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13865 status = palSendMBMessage(pMac->hHdd, pMsg);
13866 }
13867 return status;
13868}
13869
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053013870#ifdef WLAN_FEATURE_AP_HT40_24G
13871eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
13872{
13873 tpSirSetHT2040Mode pMsg;
13874 tANI_U16 len = 0;
13875 eHalStatus status = eHAL_STATUS_SUCCESS;
13876 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13877
13878 if(!pSession)
13879 {
13880 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13881 return eHAL_STATUS_FAILURE;
13882 }
13883
13884 /* Create the message and send to lim */
13885 len = sizeof(tSirSetHT2040Mode);
13886 pMsg = vos_mem_malloc(len);
13887
13888 if ( NULL == pMsg )
13889 {
13890 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
13891 status = eHAL_STATUS_FAILURE;
13892 }
13893 else
13894 status = eHAL_STATUS_SUCCESS;
13895
13896 if(HAL_STATUS_SUCCESS(status))
13897 {
13898 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
13899 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
13900 pMsg->length = len;
13901
13902 // bssId
13903 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13904 sizeof(tSirMacAddr));
13905
13906 smsLog( pMac, LOGW, FL("CSR Attempting to set "
13907 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
13908 MAC_ADDR_ARRAY(pMsg->bssId));
13909
13910 pMsg->sessionId = sessionId;
13911 pMsg->cbMode = cbMode;
13912
13913 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
13914 sessionId, cbMode);
13915
13916 status = palSendMBMessage(pMac->hHdd, pMsg);
13917 }
13918 return status;
13919}
13920#endif
13921
Jeff Johnson295189b2012-06-20 16:38:30 -070013922eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13923{
13924 eHalStatus status = eHAL_STATUS_SUCCESS;
13925 tSirSmeDeauthReq *pMsg;
13926 tANI_U8 *pBuf;
13927 tANI_U16 wTmp;
13928 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13929 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13930 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013932 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13933 if ( NULL == pMsg )
13934 status = eHAL_STATUS_FAILURE;
13935 else
13936 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013937 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013938 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13940 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13941 //sessionId
13942 pBuf = &pMsg->sessionId;
13943 *pBuf++ = (tANI_U8)sessionId;
13944
13945 //tansactionId
13946 *pBuf = 0;
13947 *(pBuf + 1 ) = 0;
13948 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013951 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13952 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013953 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13954 sizeof( pMsg->peerMacAddr ) );
13955 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 pBuf = pBuf + sizeof(tSirMacAddr);
13957 }
13958 else
13959 {
13960 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013961 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13962 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 }
13965 if(!HAL_STATUS_SUCCESS(status))
13966 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013967 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 break;
13969 }
13970 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013971 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13972 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 pBuf = pBuf + sizeof(tSirMacAddr);
13974 if(!HAL_STATUS_SUCCESS(status))
13975 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013976 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 break;
13978 }
13979 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013980 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13981 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 if(!HAL_STATUS_SUCCESS(status))
13983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013984 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 break;
13986 }
13987 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 return( status );
13990}
13991
Jeff Johnson295189b2012-06-20 16:38:30 -070013992eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13993{
13994 eHalStatus status = eHAL_STATUS_SUCCESS;
13995 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013997 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13998 if ( NULL == pMsg )
13999 status = eHAL_STATUS_FAILURE;
14000 else
14001 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014003 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
14005 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14006 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053014007 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
14008 sizeof(pMsg->peerMacAddr));
14009 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 if(!HAL_STATUS_SUCCESS(status))
14011 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014012 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 break;
14014 }
14015//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053014016 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
14017 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 if(!HAL_STATUS_SUCCESS(status))
14019 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014020 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 break;
14022 }
14023//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 return( status );
14027}
14028
Jeff Johnson295189b2012-06-20 16:38:30 -070014029eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
14030{
14031 eHalStatus status = eHAL_STATUS_SUCCESS;
14032 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014034 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
14035 if ( NULL == pMsg )
14036 status = eHAL_STATUS_FAILURE;
14037 else
14038 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014040 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
14042 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14043 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053014044 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
14045 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 if(!HAL_STATUS_SUCCESS(status))
14047 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014048 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 break;
14050 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014051 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
14052 sizeof(pMsg->peerMacAddr));
14053 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 if(!HAL_STATUS_SUCCESS(status))
14055 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014056 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014057 break;
14058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 return( status );
14062}
Jeff Johnson295189b2012-06-20 16:38:30 -070014063eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
14064{
14065 eHalStatus status = eHAL_STATUS_SUCCESS;
14066 tSirSmeAssocCnf *pMsg;
14067 tANI_U8 *pBuf;
14068 tSirResultCodes statusCode;
14069 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053014070
14071 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
14072 "HalStatus : %d"),
14073 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014075 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
14076 if ( NULL == pMsg )
14077 status = eHAL_STATUS_FAILURE;
14078 else
14079 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014081 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
14083 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 pBuf = (tANI_U8 *)&pMsg->statusCode;
14085 if(HAL_STATUS_SUCCESS(Halstatus))
14086 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14087 else
14088 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014089 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 pBuf += sizeof(tSirResultCodes);
14091 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014092 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14093 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 pBuf += sizeof (tSirMacAddr);
14095 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014096 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14097 sizeof(tSirMacAddr));
14098 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 pBuf += sizeof (tSirMacAddr);
14100 // aid
14101 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053014102 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 pBuf += sizeof (tANI_U16);
14104 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014105 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14106 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 pBuf += sizeof (tSirMacAddr);
14108 // alternateChannelId
14109 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 status = palSendMBMessage( pMac->hHdd, pMsg );
14111 if(!HAL_STATUS_SUCCESS(status))
14112 {
14113 //pMsg is freed by palSendMBMessage
14114 break;
14115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 return( status );
14118}
Jeff Johnson295189b2012-06-20 16:38:30 -070014119eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
14120 tpSirSmeAssocInd pAssocInd,
14121 eHalStatus Halstatus,
14122 tANI_U8 sessionId)
14123{
14124 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 tSirSmeAssocIndToUpperLayerCnf *pMsg;
14126 tANI_U8 *pBuf;
14127 tSirResultCodes statusCode;
14128 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014130 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14131 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14132 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070014133
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
14135 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14136
14137 pMsg->sessionId = sessionId;
14138
14139 pBuf = (tANI_U8 *)&pMsg->statusCode;
14140 if(HAL_STATUS_SUCCESS(Halstatus))
14141 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14142 else
14143 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014144 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 pBuf += sizeof(tSirResultCodes);
14146 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014147 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 pBuf += sizeof (tSirMacAddr);
14149 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014150 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14151 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 pBuf += sizeof (tSirMacAddr);
14153 // StaId
14154 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014155 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 pBuf += sizeof (tANI_U16);
14157 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014158 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 pBuf += sizeof (tSirMacAddr);
14160 // alternateChannelId
14161 *pBuf = 11;
14162 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014163 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 //Wmm
14165 *pBuf = pAssocInd->wmmEnabledSta;
14166 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014168 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014171 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 //reassocReq
14174 *pBuf = pAssocInd->reassocReq;
14175 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053014176#ifdef WLAN_FEATURE_AP_HT40_24G
14177 // 40 MHz Intolerant
14178 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
14179 pBuf += sizeof (tANI_U8);
14180#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14182 msgQ.bodyptr = pMsg;
14183 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053014186 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070014187}
Jeff Johnson295189b2012-06-20 16:38:30 -070014188
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014189eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
14191 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
14192 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
14193 tANI_U8 *pKeyRsc )
14194{
14195 tSirSmeSetContextReq *pMsg;
14196 tANI_U16 msgLen;
14197 eHalStatus status = eHAL_STATUS_FAILURE;
14198 tAniEdType tmpEdType;
14199 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053014200 tANI_U8 *pBuf = NULL;
14201 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053014203 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14204 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014206 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
14208 // key set. Since we only support upto one key, we always allocate memory for 1 key
14209 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
14210 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
14211 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
14212 ( sizeof( pMsg->keyMaterial.key ) );
14213
Kiet Lam64c1b492013-07-12 13:56:44 +053014214 pMsg = vos_mem_malloc(msgLen);
14215 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14216 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
14218 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 //sessionId
14220 pBuf = &pMsg->sessionId;
14221 *pBuf = (tANI_U8)sessionId;
14222 pBuf++;
14223 // transactionId
14224 *pBuf = 0;
14225 *(pBuf + 1) = 0;
14226 pBuf += sizeof(tANI_U16);
14227 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014228 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014229
14230 pBuf += sizeof(tSirMacAddr);
14231
14232 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014233 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14234 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014235
14236 pBuf += sizeof(tSirMacAddr);
14237
14238 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14240 // in the tSirKeyMaterial keyMaterial; field).
14241 //
14242 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14243 // shorter than this max size. Is LIM interpreting this ok ?
14244 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 -070014245 // set pMsg->keyMaterial.edType
14246 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014247 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 // set the pMsg->keyMaterial.numKeys field
14250 *p = numKeys;
14251 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 // set pSirKey->keyId = keyId;
14253 *p = keyId;
14254 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 // set pSirKey->unicast = (tANI_U8)fUnicast;
14256 *p = (tANI_U8)fUnicast;
14257 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 // set pSirKey->keyDirection = aniKeyDirection;
14259 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014260 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 p += sizeof(tAniKeyDirection);
14262 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014263 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 // set pSirKey->paeRole
14266 *p = paeRole; // 0 is Supplicant
14267 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 // set pSirKey->keyLength = keyLength;
14269 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 if ( keyLength && pKey )
14271 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014272 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 if(keyLength == 16)
14274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014275 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 -070014276 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14277 pKey[5], pKey[6], pKey[7], pKey[8],
14278 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14279 }
14280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014282 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 return( status );
14284}
14285
Jeff Johnson295189b2012-06-20 16:38:30 -070014286eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14287 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14288{
14289 eHalStatus status;
14290 tSirSmeStartBssReq *pMsg;
14291 tANI_U8 *pBuf = NULL;
14292 tANI_U8 *wTmpBuf = NULL;
14293 tANI_U16 msgLen, wTmp;
14294 tANI_U32 dwTmp;
14295 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014296 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014299
14300 if(!pSession)
14301 {
14302 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14303 return eHAL_STATUS_FAILURE;
14304 }
14305
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 do {
14307 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14308 pSession->joinFailStatusCode.reasonCode = 0;
14309 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014310 pMsg = vos_mem_malloc(msgLen);
14311 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14312 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014316 //sessionId
14317 *pBuf = (tANI_U8)sessionId;
14318 pBuf++;
14319 // transactionId
14320 *pBuf = 0;
14321 *(pBuf + 1) = 0;
14322 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014324 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 pBuf += sizeof(tSirMacAddr);
14326 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014327 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 pBuf += sizeof(tSirMacAddr);
14329 // beaconInterval
14330 if( pBssDesc && pBssDesc->beaconInterval )
14331 {
14332 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14333 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 else if(pParam->beaconInterval)
14335 {
14336 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 else
14339 {
14340 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14341 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014342 if(csrIsconcurrentsessionValid (pMac, sessionId,
14343 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014344 == eHAL_STATUS_SUCCESS )
14345 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014346 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014347 pParam->bssPersona);
14348 //Update the beacon Interval
14349 pParam->beaconInterval = wTmp;
14350 }
14351 else
14352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014353 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014354 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014355 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014356 return status;
14357 }
14358
Kiet Lam64c1b492013-07-12 13:56:44 +053014359 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 pBuf += sizeof(tANI_U16);
14361 // dot11mode
14362 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14363 pBuf += 1;
14364 // bssType
14365 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014366 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 pBuf += sizeof(tSirBssType);
14368 // ssId
14369 if( pParam->ssId.length )
14370 {
14371 // ssId len
14372 *pBuf = pParam->ssId.length;
14373 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014374 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 pBuf += pParam->ssId.length;
14376 }
14377 else
14378 {
14379 *pBuf = 0;
14380 pBuf++;
14381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 // set the channel Id
14383 *pBuf = pParam->operationChn;
14384 pBuf++;
14385 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014386 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014387 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014388 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014389
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 // Set privacy
14391 *pBuf = pParam->privacy;
14392 pBuf++;
14393
14394 //Set Uapsd
14395 *pBuf = pParam->ApUapsdEnable;
14396 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 //Set SSID hidden
14398 *pBuf = pParam->ssidHidden;
14399 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14401 pBuf++;
14402
14403 //Ht protection Enable/Disable
14404 *pBuf = (tANI_U8)pParam->protEnabled;
14405 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014406 //Enable Beacons to Receive for OBSS protection Enable/Disable
14407 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14408 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 //set cfg related to protection
14410 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014411 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 // Set Auth type
14414 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014415 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 // Set DTIM
14418 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014419 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014420 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 // Set wps_state
14422 *pBuf = pParam->wps_state;
14423 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014424 // set isCoalesingInIBSSAllowed
14425 *pBuf = pMac->isCoalesingInIBSSAllowed;
14426 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014427 //Persona
14428 *pBuf = (tANI_U8)pParam->bssPersona;
14429 pBuf++;
14430
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014431 //txLdpcIniFeatureEnabled
14432 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14433 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014434
Chet Lanctot8cecea22014-02-11 19:09:36 -080014435#ifdef WLAN_FEATURE_11W
14436 // Set MFP capable/required
14437 *pBuf = (tANI_U8)pParam->mfpCapable;
14438 pBuf++;
14439 *pBuf = (tANI_U8)pParam->mfpRequired;
14440 pBuf++;
14441#endif
14442
krunal soni4f087d22013-07-29 16:32:26 -070014443 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014444 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14445 {
14446 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014447 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 break;
14449 }
14450 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014451 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014452 pBuf += sizeof(tANI_U16);
14453 if( wTmp )
14454 {
14455 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014456 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 pBuf += wTmp;
14458 }
14459 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014460 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014461 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14463 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014464 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14465 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 pBuf += pParam->operationalRateSet.numRates ;
14467 *pBuf++ = pParam->extendedRateSet.numRates;
14468 if(0 != pParam->extendedRateSet.numRates)
14469 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014470 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14471 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014472 pBuf += pParam->extendedRateSet.numRates;
14473 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014474#ifdef WLAN_FEATURE_AP_HT40_24G
14475 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14476#endif
krunal sonie9002db2013-11-25 14:24:17 -080014477
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14479 pMsg->length = pal_cpu_to_be16(msgLen);
14480
14481 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 return( status );
14484}
14485
Jeff Johnson295189b2012-06-20 16:38:30 -070014486eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14487{
14488 eHalStatus status = eHAL_STATUS_FAILURE;
14489 tSirSmeStopBssReq *pMsg;
14490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14491 tANI_U8 *pBuf;
14492 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014493
14494 if(!pSession)
14495 {
14496 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14497 return eHAL_STATUS_FAILURE;
14498 }
14499
Abhishek Singhe2bb7842015-03-12 17:34:03 +053014500 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14501 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14502 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
14503 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14504 pBuf = &pMsg->sessionId;
14505 //sessionId
14506 *pBuf = (tANI_U8)sessionId;
14507 pBuf++;
14508 // transactionId
14509 *pBuf = 0;
14510 pBuf += sizeof(tANI_U16);
14511 //reason code
14512 *pBuf = 0;
14513 pBuf += sizeof(tSirResultCodes);
14514 // bssid
14515 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14516 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14517 {
14518 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14519 sizeof(tSirMacAddr));
14520 }
14521 else
14522 {
14523 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14524 sizeof(tSirMacAddr));
14525 }
14526 pBuf += sizeof(tSirMacAddr);
14527 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14528 pMsg->length = pal_cpu_to_be16(msgLen);
14529 status = palSendMBMessage( pMac->hHdd, pMsg );
14530
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 return( status );
14532}
14533
Jeff Johnson295189b2012-06-20 16:38:30 -070014534eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14535 tCsrRoamModifyProfileFields *pModProfileFields,
14536 tANI_U32 *pRoamId, v_BOOL_t fForce)
14537{
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 eHalStatus status = eHAL_STATUS_FAILURE;
14539 tANI_U32 roamId = 0;
14540 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014542 (fForce || (!vos_mem_compare( &pModProfileFields,
14543 &pSession->connectedProfile.modifyProfileFields,
14544 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 {
14546 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14547 if(pRoamId)
14548 {
14549 *pRoamId = roamId;
14550 }
14551
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14553 eCsrSmeIssuedReassocToSameAP, roamId,
14554 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014556 return status;
14557}
Jeff Johnson295189b2012-06-20 16:38:30 -070014558static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14559{
14560 eHalStatus status = eHAL_STATUS_SUCCESS;
14561 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014562 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14564 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14565 return (status);
14566}
Jeff Johnson295189b2012-06-20 16:38:30 -070014567eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14568{
14569 eHalStatus status = eHAL_STATUS_SUCCESS;
14570 tListElem *pEntry = NULL;
14571 tSmeCmd *pCommand = NULL;
14572 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 do
14574 {
14575 if(pMsg == NULL)
14576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014577 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014578 status = eHAL_STATUS_FAILURE;
14579 break;
14580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14582 if(pEntry)
14583 {
14584 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14585 if(eSmeCommandAddStaSession == pCommand->command)
14586 {
14587 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014588 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014589 if (pRsp->status == eSIR_FAILURE) {
14590 VOS_ASSERT( 0 );
14591 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014593 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 //Remove this command out of the active list
14595 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14596 {
14597 //Now put this command back on the avilable command list
14598 csrReleaseCommand(pMac, pCommand);
14599 }
14600 smeProcessPendingQueue( pMac );
14601 }
14602 else
14603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014604 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 -070014605 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 status = eHAL_STATUS_FAILURE;
14607 break;
14608 }
14609 }
14610 else
14611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014612 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 -070014613 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014614 status = eHAL_STATUS_FAILURE;
14615 break;
14616 }
14617 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014619}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014620eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14621 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014622{
14623 tSirSmeAddStaSelfReq *pMsg;
14624 tANI_U16 msgLen;
14625 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014626 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014627 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014628 pMsg = vos_mem_malloc(msgLen);
14629 if ( NULL == pMsg ) break;
14630 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14632 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014633 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014634 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014635 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14636
14637 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14638
Arif Hussain24bafea2013-11-15 15:10:03 -080014639 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14640 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014643 return( status );
14644}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014645eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14646 tANI_U32 sessionId,
14647 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014648{
14649 eHalStatus status = eHAL_STATUS_SUCCESS;
14650 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 pCommand = csrGetCommandBuffer(pMac);
14652 if(NULL == pCommand)
14653 {
14654 status = eHAL_STATUS_RESOURCES;
14655 }
14656 else
14657 {
14658 pCommand->command = eSmeCommandAddStaSession;
14659 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014660 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14661 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014662 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014663 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14664 if( !HAL_STATUS_SUCCESS( status ) )
14665 {
14666 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014667 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 }
14669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014670 return (status);
14671}
Jeff Johnson295189b2012-06-20 16:38:30 -070014672eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14673{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014674 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014675}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014676eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14677 csrRoamCompleteCallback callback,
14678 void *pContext, tANI_U8 *pSelfMacAddr,
14679 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014680{
14681 eHalStatus status = eHAL_STATUS_SUCCESS;
14682 tANI_U32 i;
14683 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 *pbSessionId = CSR_SESSION_ID_INVALID;
14685 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14686 {
14687 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14688 {
14689 pSession = CSR_GET_SESSION( pMac, i );
14690 status = eHAL_STATUS_SUCCESS;
14691 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14692 pSession->sessionId = (tANI_U8)i;
14693 pSession->callback = callback;
14694 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014695 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014697 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14698 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014700 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014702 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 break;
14704 }
14705#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014706 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14707 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014709 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014711 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 break;
14713 }
14714#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014715 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 break;
14717 }
14718 }
14719 if( CSR_ROAM_SESSION_MAX == i )
14720 {
14721 //No session is available
14722 status = eHAL_STATUS_RESOURCES;
14723 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014724 return ( status );
14725}
Jeff Johnson295189b2012-06-20 16:38:30 -070014726eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14727{
14728 eHalStatus status = eHAL_STATUS_SUCCESS;
14729 tListElem *pEntry = NULL;
14730 tSmeCmd *pCommand = NULL;
14731 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 do
14733 {
14734 if(pMsg == NULL)
14735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014736 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014737 status = eHAL_STATUS_FAILURE;
14738 break;
14739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014740 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14741 if(pEntry)
14742 {
14743 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14744 if(eSmeCommandDelStaSession == pCommand->command)
14745 {
14746 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014748 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 //This session is done.
14750 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 if(pCommand->u.delStaSessionCmd.callback)
14752 {
14753
14754 status = sme_ReleaseGlobalLock( &pMac->sme );
14755 if ( HAL_STATUS_SUCCESS( status ) )
14756 {
14757 pCommand->u.delStaSessionCmd.callback(
14758 pCommand->u.delStaSessionCmd.pContext);
14759 status = sme_AcquireGlobalLock( &pMac->sme );
14760 if (! HAL_STATUS_SUCCESS( status ) )
14761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014762 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014763 return status;
14764 }
14765 }
14766 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014767 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 }
14769 }
14770
14771 //Remove this command out of the active list
14772 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14773 {
14774 //Now put this command back on the avilable command list
14775 csrReleaseCommand(pMac, pCommand);
14776 }
14777 smeProcessPendingQueue( pMac );
14778 }
14779 else
14780 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014781 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 -070014782 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 status = eHAL_STATUS_FAILURE;
14784 break;
14785 }
14786 }
14787 else
14788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014789 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 -070014790 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014791 status = eHAL_STATUS_FAILURE;
14792 break;
14793 }
14794 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014795 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014796}
Jeff Johnson295189b2012-06-20 16:38:30 -070014797eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14798{
14799 tSirSmeDelStaSelfReq *pMsg;
14800 tANI_U16 msgLen;
14801 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14804 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014805 pMsg = vos_mem_malloc(msgLen);
14806 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14807 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014808 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14809 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014810 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014811 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14812 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 return( status );
14816}
Jeff Johnson295189b2012-06-20 16:38:30 -070014817eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14818 tSirMacAddr sessionMacAddr,
14819 csrRoamSessionCloseCallback callback,
14820 void *pContext)
14821{
14822 eHalStatus status = eHAL_STATUS_SUCCESS;
14823 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014824 pCommand = csrGetCommandBuffer(pMac);
14825 if(NULL == pCommand)
14826 {
14827 status = eHAL_STATUS_RESOURCES;
14828 }
14829 else
14830 {
14831 pCommand->command = eSmeCommandDelStaSession;
14832 pCommand->sessionId = (tANI_U8)sessionId;
14833 pCommand->u.delStaSessionCmd.callback = callback;
14834 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014835 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14836 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14838 if( !HAL_STATUS_SUCCESS( status ) )
14839 {
14840 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014841 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014842 }
14843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 return (status);
14845}
Jeff Johnson295189b2012-06-20 16:38:30 -070014846eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14847{
14848 return csrSendMBDelSelfStaReqMsg( pMac,
14849 pCommand->u.delStaSessionCmd.selfMacAddr );
14850}
Jeff Johnson295189b2012-06-20 16:38:30 -070014851static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14852{
14853 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14854 tListElem *pEntry, *pNext;
14855 tSmeCmd *pCommand;
14856 tDblLinkList localList;
14857
14858 vos_mem_zero(&localList, sizeof(tDblLinkList));
14859 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14860 {
14861 smsLog(pMac, LOGE, FL(" failed to open list"));
14862 return;
14863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 csrLLLock(pList);
14865 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14866 while(pEntry != NULL)
14867 {
14868 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14869 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14870 if(pCommand->sessionId == sessionId)
14871 {
14872 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14873 {
14874 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14875 }
14876 }
14877 pEntry = pNext;
14878 }
14879 csrLLUnlock(pList);
14880
14881 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14882 {
14883 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14884 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14885 }
14886 csrLLClose(&localList);
14887}
14888
Jeff Johnson295189b2012-06-20 16:38:30 -070014889void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14890{
14891 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14892 {
14893 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 csrRoamStop(pMac, sessionId);
14895 csrFreeConnectBssDesc(pMac, sessionId);
14896 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14897 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014898 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014899#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014900 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014901#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014902 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14903 if (pMac->fScanOffload)
14904 {
14905 purgeSmeSessionCmdList(pMac, sessionId,
14906 &pMac->sme.smeScanCmdPendingList);
14907 }
14908
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 purgeCsrSessionCmdList(pMac, sessionId);
14910 csrInitSession(pMac, sessionId);
14911 }
14912}
14913
Jeff Johnson295189b2012-06-20 16:38:30 -070014914eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14915 tANI_BOOLEAN fSync,
14916 csrRoamSessionCloseCallback callback,
14917 void *pContext )
14918{
14919 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14921 {
14922 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14923 if(fSync)
14924 {
14925 csrCleanupSession(pMac, sessionId);
14926 }
14927 else
14928 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014929 purgeSmeSessionCmdList(pMac, sessionId,
14930 &pMac->sme.smeCmdPendingList);
14931 if (pMac->fScanOffload)
14932 {
14933 purgeSmeSessionCmdList(pMac, sessionId,
14934 &pMac->sme.smeScanCmdPendingList);
14935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 purgeCsrSessionCmdList(pMac, sessionId);
14937 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14938 pSession->selfMacAddr, callback, pContext);
14939 }
14940 }
14941 else
14942 {
14943 status = eHAL_STATUS_INVALID_PARAMETER;
14944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 return ( status );
14946}
14947
Jeff Johnson295189b2012-06-20 16:38:30 -070014948static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14949{
14950 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014951
14952 if(!pSession)
14953 {
14954 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14955 return;
14956 }
14957
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14959 pSession->sessionId = CSR_SESSION_ID_INVALID;
14960 pSession->callback = NULL;
14961 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14963 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14964 csrFreeRoamProfile( pMac, sessionId );
14965 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14966 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14967 csrFreeConnectBssDesc(pMac, sessionId);
14968 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014969 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14970 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014971 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014972 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 pSession->pWpaRsnReqIE = NULL;
14974 }
14975 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014976 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014978 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 pSession->pWpaRsnRspIE = NULL;
14980 }
14981 pSession->nWpaRsnRspIeLength = 0;
14982#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014983 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014985 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 pSession->pWapiReqIE = NULL;
14987 }
14988 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014989 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014991 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 pSession->pWapiRspIE = NULL;
14993 }
14994 pSession->nWapiRspIeLength = 0;
14995#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014996 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014998 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 }
15000 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015001
Kiet Lam64c1b492013-07-12 13:56:44 +053015002 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015004 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015008}
15009
Jeff Johnson295189b2012-06-20 16:38:30 -070015010eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
15011{
15012 eHalStatus status = eHAL_STATUS_FAILURE;
15013 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15015 {
15016 if( CSR_IS_SESSION_VALID( pMac, i ) )
15017 {
15018 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
15019 {
15020 //Found it
15021 status = eHAL_STATUS_SUCCESS;
15022 *pSessionId = i;
15023 break;
15024 }
15025 }
15026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 return( status );
15028}
15029
Jeff Johnson295189b2012-06-20 16:38:30 -070015030//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
15031//session because for IBSS, the bssid changes.
15032static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
15033{
15034 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
15035 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070015036 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15037 {
15038 if( CSR_IS_SESSION_VALID( pMac, i ) )
15039 {
15040 pSession = CSR_GET_SESSION( pMac, i );
15041 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
15042 {
15043 //Found it
15044 nRet = i;
15045 break;
15046 }
15047 }
15048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 return (nRet);
15050}
Jeff Johnson295189b2012-06-20 16:38:30 -070015051static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
15052{
Mukul Sharma20aa6582014-08-07 21:36:12 +053015053 VOS_STATUS status = VOS_STATUS_SUCCESS;
15054
15055 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070015056 profile info from pmac global structure */
15057
Arif Hussain24bafea2013-11-15 15:10:03 -080015058 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
15059 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015060 /* Check for user misconfig of RSSI trigger threshold */
15061 pMac->roam.configParam.vccRssiThreshold =
15062 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
15063 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
15064 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 /* Check for user misconfig of UL MAC Loss trigger threshold */
15066 pMac->roam.configParam.vccUlMacLossThreshold =
15067 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
15068 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015069#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15070 {
15071 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015072 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 /* Indicate the neighbor roal algorithm about the connect indication */
15074 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
15075 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015076
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015077 /* Making sure we are roaming force fully to 5GHz AP only once and
15078 * only when we connected to 2.4GH AP only during initial association.
15079 */
15080 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
15081 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
15082 SIR_BAND_2_4_GHZ)
15083 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053015084 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015085 status = vos_timer_start(
15086 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
15087 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015088 if ( status != VOS_STATUS_SUCCESS )
15089 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015090 smsLog(pMac, LOGE,
15091 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
15092 status);
15093 //Send RSO start because in case 5G roaming
15094 //host have not enabled at initial connection
15095 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015096 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015097 else
15098 {
15099 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
15100 __func__);
15101 }
15102 }
15103 /*
15104 * Making ini value to false here only so we just roam to
15105 * only once for whole driver load to unload tenure
15106 * This feature is only applicable for first connection only
15107 */
15108 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
15109 {
15110 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
15111 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053015112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 }
15114#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015115}
15116
Jeff Johnson295189b2012-06-20 16:38:30 -070015117static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
15118{
15119 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015120
15121 if(!pSession)
15122 {
15123 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15124 return;
15125 }
15126
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 //Only to handle the case for Handover on infra link
15128 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15129 {
15130 return;
15131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
15133 csrRoamDeregStatisticsReq(pMac);
15134 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15135#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15136 /* Indicate the neighbor roal algorithm about the disconnect indication */
15137 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
15138#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070015139
15140 //Remove this code once SLM_Sessionization is supported
15141 //BMPS_WORKAROUND_NOT_NEEDED
15142 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070015143 csrIsInfraApStarted( pMac ) &&
15144 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070015145 {
15146 pMac->roam.configParam.doBMPSWorkaround = 0;
15147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015148}
15149
Jeff Johnson295189b2012-06-20 16:38:30 -070015150void csrRoamTlStatsTimerHandler(void *pv)
15151{
15152 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
15153 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15155
Jeff Johnsone7245742012-09-05 17:12:55 -070015156 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
15157
Jeff Johnson295189b2012-06-20 16:38:30 -070015158#if 0
15159 // TODO Persession .???
15160 //req TL for stats
15161 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
15162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015163 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 }
15165 else
15166 {
15167 //save in SME
15168 csrRoamSaveStatsFromTl(pMac, tlStats);
15169 }
15170#endif
15171 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15172 {
15173 if(pMac->roam.tlStatsReqInfo.periodicity)
15174 {
15175 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015176 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15177 pMac->roam.tlStatsReqInfo.periodicity);
15178 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015180 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 return;
15182 }
15183 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15184 }
15185 }
15186}
Jeff Johnson295189b2012-06-20 16:38:30 -070015187void csrRoamPeStatsTimerHandler(void *pv)
15188{
15189 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
15190 eHalStatus status;
15191 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
15192 VOS_STATUS vosStatus;
15193 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 pPeStatsReqListEntry->timerRunning = FALSE;
15195 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
15196 {
15197 // If we entered here, meaning the timer could not be successfully
15198 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
15199
15200 /* Destroy the timer */
15201 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
15202 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015204 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 }
15206
15207 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015208 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 pPeStatsReqListEntry = NULL;
15210 }
15211 else
15212 {
15213 if(!pPeStatsReqListEntry->rspPending)
15214 {
15215 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
15216 pPeStatsReqListEntry->staId);
15217 if(!HAL_STATUS_SUCCESS(status))
15218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015219 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 }
15221 else
15222 {
15223 pPeStatsReqListEntry->rspPending = TRUE;
15224 }
15225 }
15226
15227 //send down a req
15228 if(pPeStatsReqListEntry->periodicity &&
15229 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15230 {
15231 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15232 if(ePMC_FULL_POWER == powerState)
15233 {
15234 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15235 {
15236 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15237 }
15238 }
15239 else
15240 {
15241 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15242 {
15243 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15244 }
15245 }
15246 //start timer
15247 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15248 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15249 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015250 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 return;
15252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 pPeStatsReqListEntry->timerRunning = TRUE;
15254
15255 }
15256
15257 }
15258}
Jeff Johnson295189b2012-06-20 16:38:30 -070015259void csrRoamStatsClientTimerHandler(void *pv)
15260{
15261 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015262 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15263 {
15264#if 0
15265 // TODO Stats fix for multisession
15266 //start the timer
15267 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15268
15269 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015271 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 }
15273#endif
15274 }
15275#if 0
15276 //send up the stats report
15277 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15278 pStaEntry->staId, pStaEntry->pContext);
15279#endif
15280}
15281
15282
15283
Jeff Johnson295189b2012-06-20 16:38:30 -070015284eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15285{
15286 tAniGetPEStatsReq *pMsg;
15287 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015288 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15289 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015291 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015292 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 }
15294 // need to initiate a stats request to PE
15295 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15296 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15297 pMsg->staId = staId;
15298 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015300 if(!HAL_STATUS_SUCCESS(status))
15301 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015302 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015304 return status;
15305}
Jeff Johnson295189b2012-06-20 16:38:30 -070015306void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15307{
15308 tAniGetPEStatsRsp *pSmeStatsRsp;
15309 eHalStatus status = eHAL_STATUS_FAILURE;
15310 tListElem *pEntry = NULL;
15311 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15312 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15313 tANI_U32 tempMask = 0;
15314 tANI_U8 counter = 0;
15315 tANI_U8 *pStats = NULL;
15316 tANI_U32 length = 0;
15317 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015318 v_S7_t rssi = 0, snr = 0;
15319 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015320 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15322 if(pSmeStatsRsp->rc)
15323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015324 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015325 goto post_update;
15326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015327 tempMask = pSmeStatsRsp->statsMask;
15328 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015329 /* subtract all statistics from this length, and after processing the entire
15330 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15331 * in this 'stats' message.
15332 */
15333 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 //new stats info from PE, fill up the stats strucutres in PMAC
15335 while(tempMask)
15336 {
15337 if(tempMask & 1)
15338 {
15339 switch(counter)
15340 {
15341 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015342 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015343 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15344 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 pStats += sizeof(tCsrSummaryStatsInfo);
15346 length -= sizeof(tCsrSummaryStatsInfo);
15347 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015349 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015350 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15351 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15353 length -= sizeof(tCsrGlobalClassAStatsInfo);
15354 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015356 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015357 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15358 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15360 length -= sizeof(tCsrGlobalClassBStatsInfo);
15361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015363 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015364 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15365 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15367 length -= sizeof(tCsrGlobalClassCStatsInfo);
15368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015369 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015370 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15372 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015373 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15374 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 }
15376 else
15377 {
15378 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015379 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 VOS_ASSERT( 0 );
15381 }
15382 if(!HAL_STATUS_SUCCESS(status))
15383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015384 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 }
15386 pStats += sizeof(tCsrPerStaStatsInfo);
15387 length -= sizeof(tCsrPerStaStatsInfo);
15388 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015390 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 }
15393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015394 tempMask >>=1;
15395 counter++;
15396 }
15397 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15398 if (length != 0)
15399 {
15400 pRssi = (tANI_U32*)pStats;
15401 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015402 pStats += sizeof(tANI_U32);
15403 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 }
15405 else
15406 {
15407 /* If riva is not sending rssi, continue to use the hack */
15408 rssi = RSSI_HACK_BMPS;
15409 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015410
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015412
15413 if (length != 0)
15414 {
15415 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015416 pStats += sizeof(tANI_U32);
15417 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015418 }
15419 else
15420 {
15421 linkCapacity = 0;
15422 }
15423
15424 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015425
15426 if (length != 0)
15427 {
15428 pSnr = (tANI_U32*)pStats;
15429 snr = (v_S7_t)*pSnr;
15430 }
15431 else
15432 {
15433 snr = SNR_HACK_BMPS;
15434 }
15435
15436 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015437post_update:
15438 //make sure to update the pe stats req list
15439 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15440 if(pEntry)
15441 {
15442 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15443 pPeStaEntry->rspPending = FALSE;
15444
15445 }
15446 //check the one timer cases
15447 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15448 if(pEntry)
15449 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015450 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 if(pTempStaEntry->timerExpired)
15452 {
15453 //send up the stats report
15454 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15455 pTempStaEntry->staId, pTempStaEntry->pContext);
15456 //also remove from the client list
15457 csrRoamRemoveStatListEntry(pMac, pEntry);
15458 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 }
15460 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015461}
Jeff Johnson295189b2012-06-20 16:38:30 -070015462tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15463{
15464 tListElem *pEntry = NULL;
15465 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 if(!pEntry)
15468 {
15469 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015470 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 return NULL;
15472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015473 while( pEntry )
15474 {
15475 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 if(pTempStaEntry->statsMask == statsMask)
15477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015478 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015479 break;
15480 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015483 return pEntry;
15484}
15485
Jeff Johnson295189b2012-06-20 16:38:30 -070015486tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15487 tANI_BOOLEAN update)
15488{
15489 tListElem *pEntry;
15490 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015491 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015492 if(!pEntry)
15493 {
15494 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015495 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015496 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 return NULL;
15498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015499 while( pEntry )
15500 {
15501 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015502 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15503 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015505 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 if(update)
15507 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015508 pTempStaEntry->periodicity = pStaEntry->periodicity;
15509 pTempStaEntry->callback = pStaEntry->callback;
15510 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 }
15512 break;
15513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015516 return pEntry;
15517}
Jeff Johnson295189b2012-06-20 16:38:30 -070015518tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15519{
15520 tListElem *pEntry;
15521 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015523 if(!pEntry)
15524 {
15525 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015526 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015527 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015528 return NULL;
15529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 while( pEntry )
15531 {
15532 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015533 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15534 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015535 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015536 break;
15537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015538 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 return pEntry;
15541}
Jeff Johnson295189b2012-06-20 16:38:30 -070015542eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15543 csrRoamLinkQualityIndCallback callback,
15544 void *pContext)
15545{
15546 pMac->roam.linkQualityIndInfo.callback = callback;
15547 pMac->roam.linkQualityIndInfo.context = pContext;
15548 if( NULL == callback )
15549 {
15550 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15551 }
15552 else
15553 {
15554 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015555 /* do we need to invoke the callback to notify client of initial value ?? */
15556 }
15557 return eHAL_STATUS_SUCCESS;
15558}
Jeff Johnson295189b2012-06-20 16:38:30 -070015559void csrRoamVccTrigger(tpAniSirGlobal pMac)
15560{
15561 eCsrRoamLinkQualityInd newVccLinkQuality;
15562 tANI_U32 ul_mac_loss = 0;
15563 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15565 /*-------------------------------------------------------------------------
15566 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 Check for a change in link quality and notify client if necessary
15568 -------------------------------------------------------------------------*/
15569 ul_mac_loss_trigger_threshold =
15570 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015571 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015572 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015574 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015576 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15578 }
15579 else
15580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015581 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015584 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15585 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015586 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015588 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015589 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015591 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015592 newVccLinkQuality );
15593
15594 /* we now invoke the callback once to notify client of initial value */
15595 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15596 pMac->roam.linkQualityIndInfo.context );
15597 //event: EVENT_WLAN_VCC
15598 }
15599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015600 pMac->roam.vccLinkQuality = newVccLinkQuality;
15601
Jeff Johnson295189b2012-06-20 16:38:30 -070015602}
Jeff Johnson295189b2012-06-20 16:38:30 -070015603VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15604 v_U8_t rssiNotification,
15605 void * context)
15606{
15607 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15608 eCsrRoamLinkQualityInd newVccLinkQuality;
15609 // TODO : Session info unavailable
15610 tANI_U32 sessionId = 0;
15611 VOS_STATUS status = VOS_STATUS_SUCCESS;
15612 /*-------------------------------------------------------------------------
15613 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 Check for a change in link quality and notify client if necessary
15615 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015616 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 pMac->roam.configParam.vccRssiThreshold);
15618 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015620 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 return VOS_STATUS_SUCCESS;
15622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015623 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015625 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15627 }
15628 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015630 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15632 }
15633 else
15634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015635 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015636 //Set to this so the code below won't do anything
15637 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015638 VOS_ASSERT(0);
15639 }
15640
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015643 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015646 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 /* we now invoke the callback once to notify client of initial value */
15649 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15650 pMac->roam.linkQualityIndInfo.context );
15651 //event: EVENT_WLAN_VCC
15652 }
15653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015654 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 return status;
15656}
Jeff Johnson295189b2012-06-20 16:38:30 -070015657tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15658 tDblLinkList *pStaList,
15659 tCsrStatsClientReqInfo *pStaEntry)
15660{
15661 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015662 //if same entity requested for same set of stats with different periodicity &
15663 // callback update it
15664 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15665 {
15666
Kiet Lam64c1b492013-07-12 13:56:44 +053015667 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15668 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015669 {
15670 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015671 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015672 return NULL;
15673 }
15674
Jeff Johnson295189b2012-06-20 16:38:30 -070015675 pNewStaEntry->callback = pStaEntry->callback;
15676 pNewStaEntry->pContext = pStaEntry->pContext;
15677 pNewStaEntry->periodicity = pStaEntry->periodicity;
15678 pNewStaEntry->requesterId = pStaEntry->requesterId;
15679 pNewStaEntry->statsMask = pStaEntry->statsMask;
15680 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15681 pNewStaEntry->pMac = pStaEntry->pMac;
15682 pNewStaEntry->staId = pStaEntry->staId;
15683 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15684
15685 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15686 }
15687 return pNewStaEntry;
15688}
15689
Jeff Johnson295189b2012-06-20 16:38:30 -070015690tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15691 tDblLinkList *pStaList,
15692 tCsrPeStatsReqInfo *pStaEntry)
15693{
15694 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015695 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15696 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015697 {
15698 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015699 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 return NULL;
15701 }
15702
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15704 pNewStaEntry->numClient = pStaEntry->numClient;
15705 pNewStaEntry->periodicity = pStaEntry->periodicity;
15706 pNewStaEntry->statsMask = pStaEntry->statsMask;
15707 pNewStaEntry->pMac = pStaEntry->pMac;
15708 pNewStaEntry->staId = pStaEntry->staId;
15709 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15710 pNewStaEntry->rspPending = pStaEntry->rspPending;
15711
15712 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015713 return pNewStaEntry;
15714}
Jeff Johnson295189b2012-06-20 16:38:30 -070015715eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15716 tCsrRssiCallback callback,
15717 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15718{
15719 eHalStatus status = eHAL_STATUS_SUCCESS;
15720 vos_msg_t msg;
15721 tANI_U32 sessionId;
15722
15723 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015724 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015725 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15726 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015728 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015729 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015730 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15732
15733 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15734 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15735 pMsg->sessionId = sessionId;
15736 pMsg->staId = staId;
15737 pMsg->rssiCallback = callback;
15738 pMsg->pDevContext = pContext;
15739 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015740 msg.type = eWNI_SME_GET_RSSI_REQ;
15741 msg.bodyptr = pMsg;
15742 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015743 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15744 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015745 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015746 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 status = eHAL_STATUS_FAILURE;
15748 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015749 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 return status;
15751}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015752
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015753eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15754 tCsrSnrCallback callback,
15755 tANI_U8 staId, tCsrBssid bssId,
15756 void *pContext)
15757{
15758 eHalStatus status = eHAL_STATUS_SUCCESS;
15759 vos_msg_t msg;
15760 tANI_U32 sessionId;
15761
15762 tAniGetSnrReq *pMsg;
15763
15764 smsLog(pMac, LOG2, FL("called"));
15765
15766 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15767 if (NULL == pMsg )
15768 {
15769 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15770 return status;
15771 }
15772
15773 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15774
15775 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15776 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15777 pMsg->sessionId = sessionId;
15778 pMsg->staId = staId;
15779 pMsg->snrCallback = callback;
15780 pMsg->pDevContext = pContext;
15781 msg.type = eWNI_SME_GET_SNR_REQ;
15782 msg.bodyptr = pMsg;
15783 msg.reserved = 0;
15784
15785 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15786 {
15787 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15788 vos_mem_free((v_VOID_t *)pMsg);
15789 status = eHAL_STATUS_FAILURE;
15790 }
15791
15792 smsLog(pMac, LOG2, FL("returned"));
15793 return status;
15794}
15795
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015796#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015797eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15798 tCsrRssiCallback callback,
15799 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15800{
15801 eHalStatus status = eHAL_STATUS_SUCCESS;
15802 tAniGetRssiReq *pMsg;
15803
Kiet Lam64c1b492013-07-12 13:56:44 +053015804 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15805 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015806 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015807 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015808 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015809 }
15810 // need to initiate a stats request to PE
15811 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15812 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15813 pMsg->staId = staId;
15814 pMsg->rssiCallback = callback;
15815 pMsg->pDevContext = pContext;
15816 pMsg->pVosContext = pVosContext;
15817 status = palSendMBMessage(pMac->hHdd, pMsg );
15818 if(!HAL_STATUS_SUCCESS(status))
15819 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015820 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015821 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015822 status = eHAL_STATUS_FAILURE;
15823 }
15824 return status;
15825}
15826#endif
15827
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015828
15829
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015830#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015831eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15832 tCsrTsmStatsCallback callback,
15833 tANI_U8 staId,
15834 tCsrBssid bssId,
15835 void *pContext,
15836 void* pVosContext,
15837 tANI_U8 tid)
15838{
15839 eHalStatus status = eHAL_STATUS_SUCCESS;
15840 tAniGetTsmStatsReq *pMsg = NULL;
15841
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015842 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15843 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015844 {
15845 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015846 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015847 }
15848 // need to initiate a stats request to PE
15849 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15850 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15851 pMsg->staId = staId;
15852 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015853 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015854 pMsg->tsmStatsCallback = callback;
15855 pMsg->pDevContext = pContext;
15856 pMsg->pVosContext = pVosContext;
15857 status = palSendMBMessage(pMac->hHdd, pMsg );
15858 if(!HAL_STATUS_SUCCESS(status))
15859 {
15860 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15861 //pMsg is freed by palSendMBMessage
15862 status = eHAL_STATUS_FAILURE;
15863 }
15864 return status;
15865}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015866#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015867
15868
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015869/* ---------------------------------------------------------------------------
15870 \fn csrGetTLSTAState
15871 \helper function to get teh TL STA State whenever the function is called.
15872
15873 \param staId - The staID to be passed to the TL
15874 to get the relevant TL STA State
15875 \return the state as tANI_U16
15876 ---------------------------------------------------------------------------*/
15877tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15878{
15879 WLANTL_STAStateType tlSTAState;
15880 tlSTAState = WLANTL_STA_INIT;
15881
15882 //request TL for STA State
15883 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15884 {
15885 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15886 }
15887
15888 return tlSTAState;
15889}
15890
Jeff Johnson295189b2012-06-20 16:38:30 -070015891eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15892 tANI_U32 statsMask,
15893 tCsrStatsCallback callback,
15894 tANI_U32 periodicity, tANI_BOOLEAN cache,
15895 tANI_U8 staId, void *pContext)
15896{
15897 tCsrStatsClientReqInfo staEntry;
15898 tCsrStatsClientReqInfo *pStaEntry = NULL;
15899 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15900 tListElem *pEntry = NULL;
15901 tANI_BOOLEAN found = FALSE;
15902 eHalStatus status = eHAL_STATUS_SUCCESS;
15903 tANI_BOOLEAN insertInClientList = FALSE;
15904 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015905 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015906
15907 if( csrIsAllSessionDisconnected(pMac) )
15908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015909 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 return eHAL_STATUS_FAILURE;
15911 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015912
15913 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15914 {
15915 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15916 return eHAL_STATUS_FAILURE;
15917 }
15918
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 if((!statsMask) && (!callback))
15920 {
15921 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015922 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015923 return eHAL_STATUS_FAILURE;
15924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015925 //for the search list method for deregister
15926 staEntry.requesterId = requesterId;
15927 staEntry.statsMask = statsMask;
15928 //requester wants to deregister or just an error
15929 if((statsMask) && (!callback))
15930 {
15931 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15932 if(!pEntry)
15933 {
15934 //msg
15935 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015936 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 return eHAL_STATUS_FAILURE;
15938 }
15939 else
15940 {
15941 //clean up & return
15942 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015943 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015944 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015945 pStaEntry->pPeStaEntry->numClient--;
15946 //check if we need to delete the entry from peStatsReqList too
15947 if(!pStaEntry->pPeStaEntry->numClient)
15948 {
15949 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015951 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015952
Jeff Johnson295189b2012-06-20 16:38:30 -070015953 //check if we need to stop the tl stats timer too
15954 pMac->roam.tlStatsReqInfo.numClient--;
15955 if(!pMac->roam.tlStatsReqInfo.numClient)
15956 {
15957 if(pMac->roam.tlStatsReqInfo.timerRunning)
15958 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015959 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15960 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015962 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015963 return eHAL_STATUS_FAILURE;
15964 }
15965 }
15966 pMac->roam.tlStatsReqInfo.periodicity = 0;
15967 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15968 }
15969 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015970 // Destroy the vos timer...
15971 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15972 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015974 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015976 csrRoamRemoveStatListEntry(pMac, pEntry);
15977 pStaEntry = NULL;
15978 return eHAL_STATUS_SUCCESS;
15979 }
15980 }
15981
15982 if(cache && !periodicity)
15983 {
15984 //return the cached stats
15985 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15986 }
15987 else
15988 {
15989 //add the request in the client req list
15990 staEntry.callback = callback;
15991 staEntry.pContext = pContext;
15992 staEntry.periodicity = periodicity;
15993 staEntry.pPeStaEntry = NULL;
15994 staEntry.staId = staId;
15995 staEntry.pMac = pMac;
15996 staEntry.timerExpired = FALSE;
15997
15998
Jeff Johnson295189b2012-06-20 16:38:30 -070015999 //if periodic report requested with non cached result from PE/TL
16000 if(periodicity)
16001 {
16002
16003 //if looking for stats from PE
16004 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16005 {
16006
16007 //check if same request made already & waiting for rsp
16008 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
16009 periodicity, &found, staId);
16010 if(!pPeStaEntry)
16011 {
16012 //bail out, maxed out on number of req for PE
16013 return eHAL_STATUS_FAILURE;
16014 }
16015 else
16016 {
16017 staEntry.pPeStaEntry = pPeStaEntry;
16018 }
16019
16020 }
16021 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
16022 if(statsMask & (1 << eCsrGlobalClassDStats))
16023 {
16024 if(cache && pMac->roam.tlStatsReqInfo.numClient)
16025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016026 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016027 }
16028 else
16029 {
16030
16031 //update periodicity
16032 if(pMac->roam.tlStatsReqInfo.periodicity)
16033 {
16034 pMac->roam.tlStatsReqInfo.periodicity =
16035 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
16036 }
16037 else
16038 {
16039 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
16040 }
16041 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
16042 {
16043 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
16044 }
16045
16046 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16047 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016048 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016049 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016050 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016051 //req TL for class D stats
16052 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
16053 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016054 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016055 }
16056 else
16057 {
16058 //save in SME
16059 csrRoamSaveStatsFromTl(pMac, pTlStats);
16060 }
16061 vos_mem_free(pTlStats);
16062 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016063 }
16064 else
16065 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016066 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016067 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016068
Jeff Johnson295189b2012-06-20 16:38:30 -070016069 if(pMac->roam.tlStatsReqInfo.periodicity)
16070 {
16071 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016072 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16073 pMac->roam.tlStatsReqInfo.periodicity);
16074 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016075 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016076 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 return eHAL_STATUS_FAILURE;
16078 }
16079 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16080 }
16081 }
16082 }
16083 pMac->roam.tlStatsReqInfo.numClient++;
16084 }
16085
16086 insertInClientList = TRUE;
16087 }
16088 //if one time report requested with non cached result from PE/TL
16089 else if(!cache && !periodicity)
16090 {
16091 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16092 {
16093 //send down a req
16094 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16095 if(!HAL_STATUS_SUCCESS(status))
16096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016097 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 }
16099 //so that when the stats rsp comes back from PE we respond to upper layer
16100 //right away
16101 staEntry.timerExpired = TRUE;
16102 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 }
16104 if(statsMask & (1 << eCsrGlobalClassDStats))
16105 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016106 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016107 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016108 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016109 //req TL for class D stats
16110 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
16111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016112 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016113 }
16114 else
16115 {
16116 //save in SME
16117 csrRoamSaveStatsFromTl(pMac, pTlStats);
16118 }
16119 vos_mem_free(pTlStats);
16120 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016121 }
16122 else
16123 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016124 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016126
16127 }
16128 //if looking for stats from TL only
16129 if(!insertInClientList)
16130 {
16131 //return the stats
16132 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
16133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016135 if(insertInClientList)
16136 {
16137 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
16138 if(!pStaEntry)
16139 {
16140 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016141 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016142 return eHAL_STATUS_FAILURE;
16143 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016144 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016145 //Init & start timer if needed
16146 if(periodicity)
16147 {
16148 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
16149 csrRoamStatsClientTimerHandler, pStaEntry );
16150 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016152 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016153 return eHAL_STATUS_FAILURE;
16154 }
16155 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
16156 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016158 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016159 return eHAL_STATUS_FAILURE;
16160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016163 }
16164 return eHAL_STATUS_SUCCESS;
16165}
16166
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016167#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16168
16169static tSirRetStatus
16170csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
16171 tANI_U8* pBD,
16172 tANI_U8 type,
16173 tANI_U8 subType,
16174 tSirMacAddr peerAddr,
16175 tSirMacAddr selfMacAddr)
16176{
16177 tSirRetStatus statusCode = eSIR_SUCCESS;
16178 tpSirMacMgmtHdr pMacHdr;
16179
16180 /* Prepare MAC management header */
16181 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16182
16183 /* Prepare FC */
16184 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16185 pMacHdr->fc.type = type;
16186 pMacHdr->fc.subType = subType;
16187
16188 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016189 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
16190 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016191
16192 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
16193
16194 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016195 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
16196 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016197 return statusCode;
16198} /*** csrRoamScanOffloadPopulateMacHeader() ***/
16199
16200static tSirRetStatus
16201csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
16202 tANI_U8 nChannelNum,
16203 tANI_U32 dot11mode,
16204 tSirMacAddr selfMacAddr,
16205 tANI_U8 *pFrame,
16206 tANI_U16 *pusLen)
16207{
16208 tDot11fProbeRequest pr;
16209 tANI_U32 nStatus, nBytes, nPayload;
16210 tSirRetStatus nSirStatus;
16211 /*Bcast tx*/
16212 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
16213 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16214
16215
Kiet Lam64c1b492013-07-12 13:56:44 +053016216 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016217
16218 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
16219
16220 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
16221 {
16222 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
16223 }
16224
16225
16226 if (IS_DOT11_MODE_HT(dot11mode))
16227 {
16228 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16229 }
16230
16231
16232 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16233 if ( DOT11F_FAILED( nStatus ) )
16234 {
16235 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16236 "Failed to calculate the packed size f"
16237 "or a Probe Request (0x%08x).\n", nStatus );
16238
16239
16240 nPayload = sizeof( tDot11fProbeRequest );
16241 }
16242 else if ( DOT11F_WARNED( nStatus ) )
16243 {
16244 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16245 "There were warnings while calculating"
16246 "the packed size for a Probe Request ("
16247 "0x%08x).\n", nStatus );
16248 }
16249
16250 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16251
16252 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016253 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016254
16255
16256 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016257 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016258
16259 if ( eSIR_SUCCESS != nSirStatus )
16260 {
16261 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16262 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16263 nSirStatus );
16264 return nSirStatus;
16265 }
16266
16267
16268 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16269 sizeof( tSirMacMgmtHdr ),
16270 nPayload, &nPayload );
16271 if ( DOT11F_FAILED( nStatus ) )
16272 {
16273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16274 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16275 return eSIR_FAILURE;
16276 }
16277 else if ( DOT11F_WARNED( nStatus ) )
16278 {
16279 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016280 "There were warnings while packing a Probe Request (0x%08x).\n",
16281 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016282 }
16283
16284 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16285 return eSIR_SUCCESS;
16286}
16287
Mukul Sharmad68cda62015-03-20 21:25:41 +053016288/*
16289 * Below Table describe whether RSO command can be send down to fimrware or not.
16290 * Host check it on the basis of previous RSO command sent down to firmware.
16291||===========================================================================||
16292|| New cmd | LAST SENT COMMAND ---> ||
16293||====|======================================================================||
16294|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
16295|| --------------------------------------------------------------------------||
16296|| RSO_START | NO | YES | NO | NO ||
16297|| RSO_STOP | YES | YES | YES | YES ||
16298|| RSO_RESTART | YES | NO | NO | YES ||
16299|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
16300||===========================================================================||
16301*/
16302
16303#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
16304#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
16305#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
16306#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
16307
16308#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
16309#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
16310 RSO_STOP_BIT | RSO_START_BIT )
16311#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT )
16312#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
16313 RSO_START_BIT)
16314
16315tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
16316{
16317 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16318 tANI_U8 desiredMask = 0;
16319 switch(command)
16320 {
16321 case ROAM_SCAN_OFFLOAD_START:
16322 desiredMask = RSO_START_ALLOW_MASK;
16323 break;
16324 case ROAM_SCAN_OFFLOAD_STOP:
16325 desiredMask = RSO_STOP_ALLOW_MASK;
16326 break;
16327 case ROAM_SCAN_OFFLOAD_RESTART:
16328 desiredMask = RSO_RESTART_ALLOW_MASK;
16329 break;
16330 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
16331 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
16332 break;
16333 default:
16334 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16335 FL("Wrong RSO command %d, not allowed"), command);
16336 return 0;/*Cmd Not allowed*/
16337 }
16338 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
16339}
16340
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016341eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16342{
16343 vos_msg_t msg;
16344 tSirRoamOffloadScanReq *pRequestBuf;
16345 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16346 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016347 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016348 tANI_U8 *ChannelList = NULL;
16349 tANI_U32 sessionId;
16350 eHalStatus status = eHAL_STATUS_SUCCESS;
16351 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016352 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016353 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016354 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016355 tSirBssDescription *pBssDesc = NULL;
16356 tDot11fBeaconIEs *pIes = NULL;
16357 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016358 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016359
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016360 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16361
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016362 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016363 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016364 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016365 return eHAL_STATUS_FAILURE;
16366 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016367
16368 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16369 {
16370 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16371 return eHAL_STATUS_FAILURE;
16372 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016373
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016374 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16375 * It is important to ensure that the command is passed down to the FW only
16376 * if the Infra Station is in a connected state.A connected station could also be
16377 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16378 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16379 * irrespective of whichever state we are in.*/
16380 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16381 (command != ROAM_SCAN_OFFLOAD_STOP))
16382 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016383 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16384 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16385 macTraceGetNeighbourRoamState(
16386 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016387 return eHAL_STATUS_FAILURE;
16388 }
16389
Mukul Sharmad68cda62015-03-20 21:25:41 +053016390 if (!CsrIsRSOCommandAllowed(pMac, command))
16391 {
16392 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16393 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
16394 command, pNeighborRoamInfo->lastSentCmd);
16395 return eHAL_STATUS_FAILURE;
16396 }
16397
Abhishek Singh3e915632014-11-01 17:14:50 +053016398 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16399 * Also there are cases where pNeighborRoamInfo->currAPbssid
16400 * is set to 0 during disconnect and so we might return without stopping
16401 * the roam scan. So no need to find the session if command is
16402 * ROAM_SCAN_OFFLOAD_STOP.
16403 */
16404 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016405 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016406 status = csrRoamGetSessionIdFromBSSID(pMac,
16407 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16408 &sessionId);
16409
16410 if ( !HAL_STATUS_SUCCESS( status ) )
16411 {
16412 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16413 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16414 return eHAL_STATUS_FAILURE;
16415 }
16416 pSession = CSR_GET_SESSION( pMac, sessionId );
16417 if (NULL == pSession)
16418 {
16419 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016420 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016421 return eHAL_STATUS_FAILURE;
16422 }
16423 pBssDesc = pSession->pConnectBssDesc;
16424 if (pBssDesc == NULL)
16425 {
16426 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16427 "%s: pBssDesc not found for current session", __func__);
16428 return eHAL_STATUS_FAILURE;
16429 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016430 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016431 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16432 if (NULL == pRequestBuf)
16433 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016434 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16435 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16436 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016437 }
16438
Abhishek Singh3e915632014-11-01 17:14:50 +053016439 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16440 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16441 * host driver reloads, but Riva still up and running*/
16442 pRequestBuf->Command = command;
16443 if(command == ROAM_SCAN_OFFLOAD_STOP)
16444 {
16445 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053016446 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053016447 /*For a STOP Command, there is no need to
16448 * go through filling up all the below parameters
16449 * since they are not required for the STOP command*/
16450 goto send_roam_scan_offload_cmd;
16451 }
16452 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016453 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016454 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16455 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016456 sizeof(tCsrBssid));
16457 pRequestBuf->ConnectedNetwork.ssId.length =
16458 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16459 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16460 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16461 pRequestBuf->ConnectedNetwork.ssId.length);
16462 pRequestBuf->ConnectedNetwork.authentication =
16463 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16464 pRequestBuf->ConnectedNetwork.encryption =
16465 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16466 pRequestBuf->ConnectedNetwork.mcencryption =
16467 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016468 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16469 {
16470 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016471 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016472 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16473 }
16474 else
16475 {
16476 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16477 operationChannel = pSession->connectedProfile.operationChannel;
16478
16479 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16480 {
16481 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16482 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16483 vos_mem_free(pRequestBuf);
16484 return eHAL_STATUS_FAILURE;
16485 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016486 if(NULL == pIes)
16487 {
16488 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16489 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016490 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016491 return eHAL_STATUS_FAILURE;
16492 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016493 if (pIes->SuppRates.present)
16494 {
16495 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16496 /*Check for both basic rates and extended rates.*/
16497 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16498 {
16499 /*Check if the Rate is Mandatory or Not*/
16500 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16501 && (pIes->SuppRates.rates[i] & 0x80))
16502 {
16503 /*Retrieve the actual data rate*/
16504 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16505 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16506 if (minRate == 0)
16507 minRate = dataRate;
16508 else
16509 minRate = (minRate < dataRate) ? minRate:dataRate;
16510 }
16511 }
16512
16513 if (pIes->ExtSuppRates.present)
16514 {
16515 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16516 {
16517 /*Check if the Rate is Mandatory or Not*/
16518 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16519 && (pIes->ExtSuppRates.rates[i] & 0x80))
16520 {
16521 /*Retrieve the actual data rate*/
16522 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16523 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16524 if (minRate == 0)
16525 minRate = dataRate;
16526 else
16527 minRate = (minRate < dataRate) ? minRate:dataRate;
16528 }
16529 }
16530 }
16531 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16532 }
16533 else
16534 {
16535 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16536 "%s: Supp Rates not present in pIes", __func__);
16537 vos_mem_free(pRequestBuf);
16538 return eHAL_STATUS_FAILURE;
16539 }
16540 if (NULL != pIes)
16541 {
16542 vos_mem_free(pIes);
16543 pIes = NULL;
16544 }
16545 switch (minRate)
16546 {
16547 case 1:
16548 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16549 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16550 break;
16551 case 2:
16552 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16553 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16554 break;
16555 case 5:
16556 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16557 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16558 break;
16559 case 6:
16560 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16561 {
16562 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16563 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16564 }
16565 else
16566 {
16567 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16568 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16569 }
16570 break;
16571 case 11:
16572 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16573 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16574 break;
16575 case 12:
16576 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16577 {
16578 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16579 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16580 }
16581 else
16582 {
16583 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16584 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16585 }
16586 break;
16587 case 24:
16588 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16589 {
16590 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16591 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16592 }
16593 else
16594 {
16595 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16596 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16597 }
16598 break;
16599 default:
16600 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16601 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16602 break;
16603 }
16604 }
16605 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16606 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16607 operationChannel, minRate,
16608 pRequestBuf->RxSensitivityThreshold,
16609 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016610 pRequestBuf->RoamRssiDiff =
16611 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016612 pRequestBuf->StartScanReason = reason;
16613 pRequestBuf->NeighborScanTimerPeriod =
16614 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16615 pRequestBuf->NeighborRoamScanRefreshPeriod =
16616 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16617 pRequestBuf->NeighborScanChannelMinTime =
16618 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16619 pRequestBuf->NeighborScanChannelMaxTime =
16620 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16621 pRequestBuf->EmptyRefreshScanPeriod =
16622 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016623 /* MAWC feature */
16624 pRequestBuf->MAWCEnabled =
16625 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016626#ifdef FEATURE_WLAN_ESE
16627 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016628#endif
16629 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016630#ifdef FEATURE_WLAN_ESE
16631 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016632 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16633 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016634 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16635#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016636 currChannelListInfo->numOfChannels == 0)
16637 {
16638
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016639 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16640 * Give Preference to INI Channels.*/
16641 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16642 {
16643 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16644 /*The INI channels need to be filtered with respect to the current
16645 * band that is supported.*/
16646 eBand = pMac->roam.configParam.bandCapability;
16647 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016648 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016649 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16650 "Invalid band, No operation carried out (Band %d)", eBand);
16651 vos_mem_free(pRequestBuf);
16652 return eHAL_STATUS_FAILURE;
16653 }
16654 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16655 {
16656 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16657 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16658 (eCSR_BAND_ALL == eBand))
16659 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016660 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
16661 ((pMac->roam.configParam.allowDFSChannelRoam) ||
16662 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
16663 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016664 {
16665 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16666 }
16667 }
16668 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016669 }
16670 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16671 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016672 }
16673 else
16674 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016675 ChannelList = pMac->scan.occupiedChannels.channelList;
16676 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16677 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016678 /*Allow DFS channels only if the DFS channel roam flag is enabled */
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016679 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016680 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016681 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016682 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016683 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016684 }
16685 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016686 }
16687 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16688 /* If the profile changes as to what it was earlier, inform the FW through
16689 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16690 * for the earlier profile and try to learn them afresh.*/
16691 if (reason == REASON_FLUSH_CHANNEL_LIST)
16692 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16693 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016694 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16695 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16696 else
16697 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016698 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016699 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016700 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016701#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016702 else
16703 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016704 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016705 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016706 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016707 if (currChannelListInfo->numOfChannels != 0)
16708 {
16709 ChannelList = currChannelListInfo->ChannelList;
16710 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016711 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016712 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
16713 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
16714 {
16715 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
16716 *ChannelList;
16717 }
16718 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016719 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016720 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16721 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16722 }
16723 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016724#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016725 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
16726 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016727 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016728 if (j < sizeof(ChannelCacheStr))
16729 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016730 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16731 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016732 }
16733 else
16734 {
16735 break;
16736 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016737 }
16738 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16739 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16740 pRequestBuf->ChannelCacheType,
16741 pRequestBuf->ConnectedNetwork.ChannelCount,
16742 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016743 num_channels = 0;
16744 ChannelList = NULL;
16745
16746 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016747 host_channels = sizeof(pMac->roam.validChannelList);
16748 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016749 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016750 ChannelList = pMac->roam.validChannelList;
16751 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016752 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016753 else
16754 {
16755 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16756 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016757 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016758 return eHAL_STATUS_FAILURE;
16759 }
16760 for(i=0; i<pMac->roam.numValidChannels; i++)
16761 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053016762 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
16763 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
Srinivas Girigowda56076852013-08-20 14:00:50 -070016764 {
16765 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16766 }
16767 ChannelList++;
16768 }
16769 pRequestBuf->ValidChannelCount = num_channels;
16770
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016771 pRequestBuf->MDID.mdiePresent =
16772 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16773 pRequestBuf->MDID.mobilityDomain =
16774 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016775 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16776
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016777 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016778 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16779 * where RFS is the RF Switching time. It is twice RFS to consider the
16780 * time to go off channel and return to the home channel. */
16781 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16782 {
16783 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16784 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16785 " Hence enforcing home away time to disable (0)",
16786 __func__, pRequestBuf->HomeAwayTime,
16787 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16788 pRequestBuf->HomeAwayTime = 0;
16789 }
16790 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016791
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016792 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16793 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16794 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16795 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16796 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16797
16798 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16799 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016800send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016801 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016802 msg.reserved = 0;
16803 msg.bodyptr = pRequestBuf;
16804 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16805 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016806 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16807 vos_mem_free(pRequestBuf);
16808 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016809 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016810 else
16811 {
16812 if (ROAM_SCAN_OFFLOAD_START == command)
16813 bRoamScanOffloadStarted = VOS_TRUE;
16814 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16815 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053016816
16817 /*update the last sent cmd*/
16818 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016819 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016820
16821 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16822 return status;
16823}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016824
16825eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16826{
16827 switch(reason)
16828 {
16829 case 0:
16830 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16831 break;
16832 case REASON_OS_REQUESTED_ROAMING_NOW:
16833 csrNeighborRoamProceedWithHandoffReq(pMac);
16834 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016835 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16836 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16837 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016838 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016839 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 -070016840 }
16841 return eHAL_STATUS_SUCCESS;
16842}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016843#endif
16844
Jeff Johnson295189b2012-06-20 16:38:30 -070016845tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16846 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16847{
16848 tANI_BOOLEAN found = FALSE;
16849 eHalStatus status = eHAL_STATUS_SUCCESS;
16850 tCsrPeStatsReqInfo staEntry;
16851 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16852 tListElem *pStaEntry = NULL;
16853 VOS_STATUS vosStatus;
16854 tPmcPowerState powerState;
16855 *pFound = FALSE;
16856
16857 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16858 if(pStaEntry)
16859 {
16860 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16861 if(pTempStaEntry->periodicity)
16862 {
16863 pTempStaEntry->periodicity =
16864 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16865 }
16866 else
16867 {
16868 pTempStaEntry->periodicity = periodicity;
16869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 pTempStaEntry->numClient++;
16871 found = TRUE;
16872 }
16873 else
16874 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016875 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 staEntry.numClient = 1;
16877 staEntry.periodicity = periodicity;
16878 staEntry.pMac = pMac;
16879 staEntry.rspPending = FALSE;
16880 staEntry.staId = staId;
16881 staEntry.statsMask = statsMask;
16882 staEntry.timerRunning = FALSE;
16883 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16884 if(!pTempStaEntry)
16885 {
16886 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016887 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016888 return NULL;
16889 }
16890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016891 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16892 if(ePMC_FULL_POWER == powerState)
16893 {
16894 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16895 {
16896 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16897 }
16898 }
16899 else
16900 {
16901 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16902 {
16903 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16904 }
16905 }
16906 if(!pTempStaEntry->timerRunning)
16907 {
16908 //send down a req in case of one time req, for periodic ones wait for timer to expire
16909 if(!pTempStaEntry->rspPending &&
16910 !pTempStaEntry->periodicity)
16911 {
16912 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16913 if(!HAL_STATUS_SUCCESS(status))
16914 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016915 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016916 }
16917 else
16918 {
16919 pTempStaEntry->rspPending = TRUE;
16920 }
16921 }
16922 if(pTempStaEntry->periodicity)
16923 {
16924 if(!found)
16925 {
16926
16927 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16928 csrRoamPeStatsTimerHandler, pTempStaEntry );
16929 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16930 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016931 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016932 return NULL;
16933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016934 }
16935 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016936 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016937 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16938 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016940 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 return NULL;
16942 }
16943 pTempStaEntry->timerRunning = TRUE;
16944 }
16945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 *pFound = found;
16947 return pTempStaEntry;
16948}
16949
Jeff Johnson295189b2012-06-20 16:38:30 -070016950/*
16951 pStaEntry is no longer invalid upon the return of this function.
16952*/
16953static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16954{
16955 if(pEntry)
16956 {
16957 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16958 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016959 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016961 }
16962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016963
16964void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16965{
16966 tListElem *pEntry;
16967 tCsrPeStatsReqInfo *pTempStaEntry;
16968 VOS_STATUS vosStatus;
16969 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016970 if(!pEntry)
16971 {
16972 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016973 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016974 return;
16975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016976 while( pEntry )
16977 {
16978 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016979 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16980 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016981 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 if(pTempStaEntry->timerRunning)
16983 {
16984 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16985 /* If we are not able to stop the timer here, just remove
16986 * the entry from the linked list. Destroy the timer object
16987 * and free the memory in the timer CB
16988 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016989 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016990 {
16991 /* the timer is successfully stopped */
16992 pTempStaEntry->timerRunning = FALSE;
16993
16994 /* Destroy the timer */
16995 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16996 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016998 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016999 }
17000 }
17001 else
17002 {
17003 // the timer could not be stopped. Hence destroy and free the
17004 // memory for the PE stat entry in the timer CB.
17005 pTempStaEntry->timerStopFailed = TRUE;
17006 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017008
17009 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
17010 {
17011 // Only free the memory if we could stop the timer successfully
17012 if(!pTempStaEntry->timerStopFailed)
17013 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017014 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070017015 pTempStaEntry = NULL;
17016 }
17017 break;
17018 }
17019
17020 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
17021 }
17022 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017023 return;
17024}
17025
17026
Jeff Johnsone7245742012-09-05 17:12:55 -070017027void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017028{
17029
Jeff Johnsone7245742012-09-05 17:12:55 -070017030 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
17031 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
17032 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
17033 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
17034 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
17035 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
17036 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070017037 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070017038 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
17039 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
17040 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
17041 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
17042 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
17043 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070017044 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070017045 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
17046 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070017047
17048}
17049
Jeff Johnson295189b2012-06-20 16:38:30 -070017050void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
17051 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
17052{
17053 tANI_U8 stats[500];
17054 tANI_U8 *pStats = NULL;
17055 tANI_U32 tempMask = 0;
17056 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017057 if(!callback)
17058 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017059 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017060 return;
17061 }
17062 if(!statsMask)
17063 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017064 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017065 return;
17066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017067 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017068 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070017069 while(tempMask)
17070 {
17071 if(tempMask & 1)
17072 {
17073 //new stats info from PE, fill up the stats strucutres in PMAC
17074 switch(counter)
17075 {
17076 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017077 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017078 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
17079 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017080 pStats += sizeof(tCsrSummaryStatsInfo);
17081 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017082 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017083 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017084 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
17085 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017086 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017087 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017088 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017089 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017090 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
17091 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017092 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017093 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017094 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017095 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017096 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
17097 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017098 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017099 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017100 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017101 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017102 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
17103 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017104 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017105 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017106 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017107 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017108 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
17109 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017110 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017111 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017112 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017113 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070017114 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017115 }
17116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017117 tempMask >>=1;
17118 counter++;
17119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017120 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070017121}
17122
Jeff Johnson295189b2012-06-20 16:38:30 -070017123eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
17124{
17125 tListElem *pEntry = NULL;
17126 tListElem *pPrevEntry = NULL;
17127 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
17128 eHalStatus status = eHAL_STATUS_SUCCESS;
17129 VOS_STATUS vosStatus;
17130 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017131 if(!pEntry)
17132 {
17133 //list empty
17134 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017135 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070017136 return status;
17137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017138 while( pEntry )
17139 {
17140 if(pPrevEntry)
17141 {
17142 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17143 //send up the stats report
17144 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17145 pTempStaEntry->staId, pTempStaEntry->pContext);
17146 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017148 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070017149 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
17150 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017151 pTempStaEntry->pPeStaEntry->numClient--;
17152 //check if we need to delete the entry from peStatsReqList too
17153 if(!pTempStaEntry->pPeStaEntry->numClient)
17154 {
17155 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
17156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017158 //check if we need to stop the tl stats timer too
17159 pMac->roam.tlStatsReqInfo.numClient--;
17160 if(!pMac->roam.tlStatsReqInfo.numClient)
17161 {
17162 if(pMac->roam.tlStatsReqInfo.timerRunning)
17163 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017164 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17165 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017166 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017167 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017168 //we will continue
17169 }
17170 }
17171 pMac->roam.tlStatsReqInfo.periodicity = 0;
17172 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017174 if (pTempStaEntry->periodicity)
17175 {
17176 //While creating StaEntry in csrGetStatistics,
17177 //Initializing and starting timer only when periodicity is set.
17178 //So Stop and Destroy timer only when periodicity is set.
17179
Jeff Johnsone7245742012-09-05 17:12:55 -070017180 vos_timer_stop( &pTempStaEntry->timer );
17181 // Destroy the vos timer...
17182 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
17183 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017185 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017187 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017188
Jeff Johnson295189b2012-06-20 16:38:30 -070017189
17190 pPrevEntry = pEntry;
17191 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
17192 }
17193 //the last one
17194 if(pPrevEntry)
17195 {
17196 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17197 //send up the stats report
17198 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17199 pTempStaEntry->staId, pTempStaEntry->pContext);
17200 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17201 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017202 return status;
17203
17204}
17205
Jeff Johnson295189b2012-06-20 16:38:30 -070017206eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
17207 tRequestFullPowerReason *pReason,
17208 tANI_BOOLEAN *pfNeedPower )
17209{
17210 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17211 tRequestFullPowerReason reason = eSME_REASON_OTHER;
17212 tPmcState pmcState;
17213 eHalStatus status = eHAL_STATUS_SUCCESS;
17214 // TODO : Session info unavailable
17215 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 if( pfNeedPower )
17217 {
17218 *pfNeedPower = eANI_BOOLEAN_FALSE;
17219 }
17220 //We only handle CSR commands
17221 if( !(eSmeCsrCommandMask & pCommand->command) )
17222 {
17223 return eHAL_STATUS_SUCCESS;
17224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017225 //Check PMC state first
17226 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017227 switch( pmcState )
17228 {
17229 case REQUEST_IMPS:
17230 case IMPS:
17231 if( eSmeCommandScan == pCommand->command )
17232 {
17233 switch( pCommand->u.scanCmd.reason )
17234 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017235#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17236 case eCsrScanGetLfrResult:
17237#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017238 case eCsrScanGetResult:
17239 case eCsrScanBGScanAbort:
17240 case eCsrScanBGScanEnable:
17241 case eCsrScanGetScanChnInfo:
17242 //Internal process, no need for full power
17243 fNeedFullPower = eANI_BOOLEAN_FALSE;
17244 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017245 default:
17246 //Other scans are real scan, ask for power
17247 fNeedFullPower = eANI_BOOLEAN_TRUE;
17248 break;
17249 } //switch
17250 }
17251 else
17252 {
17253 //ask for power for roam and status change
17254 fNeedFullPower = eANI_BOOLEAN_TRUE;
17255 }
17256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017257 case REQUEST_BMPS:
17258 case BMPS:
17259 case REQUEST_START_UAPSD:
17260 case UAPSD:
17261 //We treat WOWL same as BMPS
17262 case REQUEST_ENTER_WOWL:
17263 case WOWL:
17264 if( eSmeCommandRoam == pCommand->command )
17265 {
17266 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
17267 tCsrScanResult *pScanResult;
17268 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070017269 switch ( pCommand->u.roamCmd.roamReason )
17270 {
17271 case eCsrForcedDisassoc:
17272 case eCsrForcedDisassocMICFailure:
17273 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17274 fNeedFullPower = eANI_BOOLEAN_TRUE;
17275 break;
17276 case eCsrSmeIssuedDisassocForHandoff:
17277 case eCsrForcedDeauth:
17278 case eCsrHddIssuedReassocToSameAP:
17279 case eCsrSmeIssuedReassocToSameAP:
17280 fNeedFullPower = eANI_BOOLEAN_TRUE;
17281 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017282 case eCsrCapsChange:
17283 fNeedFullPower = eANI_BOOLEAN_TRUE;
17284 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017285 default:
17286 //Check whether the profile is already connected. If so, no need for full power
17287 //Note: IBSS is ignored for now because we don't support powersave in IBSS
17288 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
17289 {
17290 //Only need to check the first one
17291 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
17292 if( pEntry )
17293 {
17294 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17295#if 0
17296 // TODO : Session Specific info pConnectBssDesc
17297 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17298 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17299 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17300 {
17301 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17302 // with Authenticating first. To force this, stop the current association (Disassociate) and
17303 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17304 // a new Association.
17305 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17306 {
17307 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17308 {
17309 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17310 //No need for full power
17311 //Set the flag so the code later can avoid to do the above
17312 //check again.
17313 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17314 break;
17315 }
17316 }
17317 }
17318#endif
17319 }
17320 }
17321 //If we are here, full power is needed
17322 fNeedFullPower = eANI_BOOLEAN_TRUE;
17323 break;
17324 }
17325 }
17326 else if( eSmeCommandWmStatusChange == pCommand->command )
17327 {
17328 //need full power for all
17329 fNeedFullPower = eANI_BOOLEAN_TRUE;
17330 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17331 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017332#ifdef FEATURE_WLAN_TDLS
17333 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17334 {
17335 //TDLS link is getting established. need full power
17336 fNeedFullPower = eANI_BOOLEAN_TRUE;
17337 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17338 }
17339#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017340 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017341 case REQUEST_STOP_UAPSD:
17342 case REQUEST_EXIT_WOWL:
17343 if( eSmeCommandRoam == pCommand->command )
17344 {
17345 fNeedFullPower = eANI_BOOLEAN_TRUE;
17346 switch ( pCommand->u.roamCmd.roamReason )
17347 {
17348 case eCsrForcedDisassoc:
17349 case eCsrForcedDisassocMICFailure:
17350 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17351 break;
17352 default:
17353 break;
17354 }
17355 }
17356 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 case STOPPED:
17358 case REQUEST_STANDBY:
17359 case STANDBY:
17360 case LOW_POWER:
17361 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017362 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17363 " stopped/standby state %s (%d)" ),
17364 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017365 status = eHAL_STATUS_FAILURE;
17366 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017367 case FULL_POWER:
17368 case REQUEST_FULL_POWER:
17369 default:
17370 //No need to ask for full power. This has to be FULL_POWER state
17371 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017372 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017373 if( pReason )
17374 {
17375 *pReason = reason;
17376 }
17377 if( pfNeedPower )
17378 {
17379 *pfNeedPower = fNeedFullPower;
17380 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017381 return ( status );
17382}
17383
Jeff Johnson295189b2012-06-20 16:38:30 -070017384static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17385{
17386 eHalStatus status = eHAL_STATUS_SUCCESS;
17387 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17388 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017389 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017390 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17391 {
17392 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017394 return ( status );
17395}
17396
Jeff Johnson295189b2012-06-20 16:38:30 -070017397tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17398{
17399 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017400 if( pCmd )
17401 {
17402 pMac->roam.sPendingCommands++;
17403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017404 return ( pCmd );
17405}
17406
Jeff Johnson295189b2012-06-20 16:38:30 -070017407void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17408{
17409 if (pMac->roam.sPendingCommands > 0)
17410 {
17411 //All command allocated through csrGetCommandBuffer need to
17412 //decrement the pending count when releasing.
17413 pMac->roam.sPendingCommands--;
17414 smeReleaseCommand( pMac, pCommand );
17415 }
17416 else
17417 {
17418 smsLog(pMac, LOGE, FL( "no pending commands"));
17419 VOS_ASSERT(0);
17420 }
17421}
17422
Jeff Johnson295189b2012-06-20 16:38:30 -070017423//Return SUCCESS is the command is queued, failed
17424eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17425{
17426 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053017427
17428 if (!SME_IS_START(pMac))
17429 {
17430 smsLog( pMac, LOGE, FL("Sme in stop state"));
17431 return eHAL_STATUS_FAILURE;
17432 }
17433
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17435 {
17436 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17437 pCommand->u.scanCmd.reason);
17438 return eHAL_STATUS_CSR_WRONG_STATE;
17439 }
17440
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017441 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17442 {
17443 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17444 &pCommand->Link, LL_ACCESS_LOCK);
17445 // process the command queue...
17446 smeProcessPendingQueue(pMac);
17447 status = eHAL_STATUS_SUCCESS;
17448 goto end;
17449 }
17450
Jeff Johnson295189b2012-06-20 16:38:30 -070017451 //We can call request full power first before putting the command into pending Q
17452 //because we are holding SME lock at this point.
17453 status = csrRequestFullPower( pMac, pCommand );
17454 if( HAL_STATUS_SUCCESS( status ) )
17455 {
17456 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017457 //make sure roamCmdPendingList is not empty first
17458 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17459 if( fNoCmdPending )
17460 {
17461 smePushCommand( pMac, pCommand, fHighPriority );
17462 }
17463 else
17464 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017465 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017466 //no list lock is needed since SME lock is held
17467 if( !fHighPriority )
17468 {
17469 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17470 }
17471 else {
17472 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17473 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017475 }
17476 else if( eHAL_STATUS_PMC_PENDING == status )
17477 {
17478 //no list lock is needed since SME lock is held
17479 if( !fHighPriority )
17480 {
17481 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17482 }
17483 else {
17484 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17485 }
17486 //Let caller know the command is queue
17487 status = eHAL_STATUS_SUCCESS;
17488 }
17489 else
17490 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017491 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017492 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017493 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017494 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017495end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017496 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017497}
Jeff Johnson295189b2012-06-20 16:38:30 -070017498eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17499{
17500 eHalStatus status = eHAL_STATUS_SUCCESS;
17501 tSirUpdateAPWPSIEsReq *pMsg;
17502 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17503
17504 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17505 if (NULL == pSession)
17506 {
17507 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17508 return eHAL_STATUS_FAILURE;
17509 }
17510
Jeff Johnson295189b2012-06-20 16:38:30 -070017511 do
17512 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017513 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17514 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17515 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017516 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17517
17518 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017519 VOS_ASSERT(pBuf);
17520
Jeff Johnson295189b2012-06-20 16:38:30 -070017521 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017522 // transactionId
17523 *pBuf = 0;
17524 *( pBuf + 1 ) = 0;
17525 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017526 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017527 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17528 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017529 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017530 //sessionId
17531 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017532 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017533 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017534 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017535 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017536 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017537 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017538 return ( status );
17539}
Jeff Johnson295189b2012-06-20 16:38:30 -070017540eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17541{
17542 eHalStatus status = eHAL_STATUS_SUCCESS;
17543 tSirUpdateAPWPARSNIEsReq *pMsg;
17544 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017545 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17546 if (NULL == pSession)
17547 {
17548 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17549 return eHAL_STATUS_FAILURE;
17550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017551 do
17552 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017553 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17554 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17555 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017556 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017557 pBuf = (tANI_U8 *)&pMsg->transactionId;
17558 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017559 // transactionId
17560 *pBuf = 0;
17561 *( pBuf + 1 ) = 0;
17562 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017563 VOS_ASSERT(pBuf);
17564
Jeff Johnson295189b2012-06-20 16:38:30 -070017565 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017566 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17567 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017568 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017569 // sessionId
17570 *pBuf++ = (tANI_U8)sessionId;
17571
17572 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017573 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017574 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017575 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017576 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017577 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017578 return ( status );
17579}
Jeff Johnson295189b2012-06-20 16:38:30 -070017580
17581#ifdef WLAN_FEATURE_VOWIFI_11R
17582//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17583eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17584{
17585 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17586 tpSirFTPreAuthReq pftPreAuthReq;
17587 tANI_U16 auth_req_len = 0;
17588 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017589 auth_req_len = sizeof(tSirFTPreAuthReq);
17590 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017591 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017592 {
17593 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17594 return eHAL_STATUS_RESOURCES;
17595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017596 // Save the SME Session ID here. We need it while processing the preauth response
17597 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017598 vos_mem_zero(pftPreAuthReq, auth_req_len);
17599
17600 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17601 sizeof(pBssDescription->length) + pBssDescription->length);
17602
17603 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17604
17605 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17606
Kiet Lam64c1b492013-07-12 13:56:44 +053017607 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17608 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17609 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17610 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017611
Jeff Johnson295189b2012-06-20 16:38:30 -070017612#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017613 if (csrRoamIs11rAssoc(pMac) &&
17614 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017615 {
17616 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017617 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17618 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017619 }
17620 else
17621#endif
17622 {
17623 pftPreAuthReq->ft_ies_length = 0;
17624 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017625 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17626 sizeof(pBssDescription->length) + pBssDescription->length);
17627 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017628 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17629}
Jeff Johnson295189b2012-06-20 16:38:30 -070017630/*--------------------------------------------------------------------------
17631 * This will receive and process the FT Pre Auth Rsp from the current
17632 * associated ap.
17633 *
17634 * This will invoke the hdd call back. This is so that hdd can now
17635 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17636 ------------------------------------------------------------------------*/
17637void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17638{
17639 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17640 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017641#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017642 tCsrRoamInfo roamInfo;
17643#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017644 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017645
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017646#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017647 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017648 if (status != eHAL_STATUS_SUCCESS) {
17649 /*
17650 * Bail out if pre-auth was not even processed.
17651 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017652 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17653 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017654 return;
17655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017657 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17658 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17659 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017660 // Implies a success
17661 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017662 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17663 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017664 /* No need to notify qos module if this is a non 11r & ESE roam*/
17665 if (csrRoamIs11rAssoc(pMac)
17666#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17667 || csrRoamIsESEAssoc(pMac)
17668#endif
17669 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017670 {
17671 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17672 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053017673 if (pMac->roam.configParam.roamDelayStatsEnabled)
17674 {
17675 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017677 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17678 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017679 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17680 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053017681 if (pMac->roam.configParam.roamDelayStatsEnabled)
17682 {
17683 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17684 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017685 if (eHAL_STATUS_SUCCESS != status)
17686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017687 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017688 return;
17689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017690 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017691 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17692 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017693 if (csrRoamIs11rAssoc(pMac))
17694 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17695 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17696
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017697#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17698 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017699 {
17700 /* read TSF */
17701 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17702
17703 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017704 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017705 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17706 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017707#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017708#ifdef FEATURE_WLAN_LFR
17709 // If Legacy Fast Roaming is enabled, signal the supplicant
17710 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017711 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017712 {
17713 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017714 vos_mem_copy((void *)&roamInfo.bssid,
17715 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017716 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17717 }
17718
17719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017720
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017721 // If its an Open Auth, FT IEs are not provided by supplicant
17722 // Hence populate them here
17723 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17724 pMac->ft.ftSmeContext.addMDIE = FALSE;
17725 if( csrRoamIs11rAssoc(pMac) &&
17726 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17727 {
17728 tANI_U16 ft_ies_length;
17729 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17730
17731 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17732 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17733 {
17734 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17735 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17736 }
17737
17738 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17739 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17740 {
17741 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17742 }
17743 else
17744 {
17745 // Copy the RIC IEs to reassoc IEs
17746 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17747 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17748 pFTPreAuthRsp->ric_ies_length);
17749 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17750 pMac->ft.ftSmeContext.addMDIE = TRUE;
17751 }
17752 }
17753
Jeff Johnson295189b2012-06-20 16:38:30 -070017754 // Done with it, init it.
17755 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17756}
17757#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017758
Jeff Johnson295189b2012-06-20 16:38:30 -070017759#ifdef FEATURE_WLAN_BTAMP_UT_RF
17760void csrRoamJoinRetryTimerHandler(void *pv)
17761{
17762 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17763 tpAniSirGlobal pMac = pInfo->pMac;
17764 tANI_U32 sessionId = pInfo->sessionId;
17765 tCsrRoamSession *pSession;
17766
17767 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017769 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017770 pSession = CSR_GET_SESSION( pMac, sessionId );
17771 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17772 {
17773 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017775 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017776 }
17777 }
17778 }
17779}
Jeff Johnson295189b2012-06-20 16:38:30 -070017780eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17781{
17782 eHalStatus status = eHAL_STATUS_FAILURE;
17783 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17784
17785 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17786 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017787 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017788 pSession->maxRetryCount--;
17789 pSession->joinRetryTimerInfo.pMac = pMac;
17790 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017791 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17792 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017794 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017795 }
17796 }
17797 else
17798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017799 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017800 pSession->maxRetryCount);
17801 }
17802
17803 return (status);
17804}
Jeff Johnson295189b2012-06-20 16:38:30 -070017805eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17806{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017807 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017808 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17809 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017810 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017811 }
17812
17813 return eHAL_STATUS_SUCCESS;
17814}
17815#endif
17816
17817
17818/*
17819 pBuf points to the beginning of the message
17820 LIM packs disassoc rsp as below,
17821 messageType - 2 bytes
17822 messageLength - 2 bytes
17823 sessionId - 1 byte
17824 transactionId - 2 bytes (tANI_U16)
17825 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17826 peerMacAddr - 6 bytes
17827 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17828*/
17829static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17830{
17831 if(pBuf && pRsp)
17832 {
17833 pBuf += 4; //skip type and length
17834 pRsp->sessionId = *pBuf++;
17835 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17836 pBuf += 2;
17837 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17838 pBuf += 4;
17839 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17840 }
17841}
17842
Jeff Johnsond13512a2012-07-17 11:42:19 -070017843eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17844{
17845 static uNvTables nvTables;
17846 eHalStatus status = eHAL_STATUS_SUCCESS;
17847 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17848
17849 /* read the country code from NV and use it */
17850 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17851 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017852 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17853 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017854 return status;
17855 }
17856 else
17857 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017858 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017859 status = eHAL_STATUS_FAILURE;
17860 return status;
17861 }
17862}
17863
17864eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17865{
Kiet Lam64c1b492013-07-12 13:56:44 +053017866 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017867 return eHAL_STATUS_SUCCESS;
17868}
schang86c22c42013-03-13 18:41:24 -070017869
17870eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17871{
17872 tSirSetTxPowerReq *pMsg = NULL;
17873 eHalStatus status = eHAL_STATUS_SUCCESS;
17874 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17875
17876 if (!pSession)
17877 {
17878 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17879 return eHAL_STATUS_FAILURE;
17880 }
17881
Kiet Lam64c1b492013-07-12 13:56:44 +053017882 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17883 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17884 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17885 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17886 pMsg->length = sizeof(tSirSetTxPowerReq);
17887 pMsg->mwPower = mW;
17888 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17889 sizeof(tSirMacAddr));
17890 status = palSendMBMessage(pMac->hHdd, pMsg);
17891 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017892 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017893 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17894 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017895 }
17896 return status;
17897}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017898
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017899eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17900{
17901 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17902 eHalStatus status = eHAL_STATUS_SUCCESS;
17903 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17904
17905 if (!pSession)
17906 {
17907 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17908 return eHAL_STATUS_FAILURE;
17909 }
17910 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17911 {
17912 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017913
17914 if( NULL == pMsg )
17915 {
17916 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17917 return eHAL_STATUS_FAILURE;
17918 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017919 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17920 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17921 pMsg->length = sizeof(tANI_U8);
17922 pMsg->seesionId = sessionId;
17923 status = palSendMBMessage(pMac->hHdd, pMsg);
17924 if (!HAL_STATUS_SUCCESS(status))
17925 {
17926 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17927 //pMsg is freed by palSendMBMessage
17928 }
17929 }
17930 else
17931 {
17932 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17933 status = eHAL_STATUS_FAILURE;
17934 }
17935 return status;
17936}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017937/* Returns whether a session is in VOS_STA_MODE...or not */
17938tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17939{
17940 tCsrRoamSession *pSession = NULL;
17941 pSession = CSR_GET_SESSION ( pMac, sessionId );
17942 if(!pSession)
17943 {
17944 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17945 return eANI_BOOLEAN_FALSE;
17946 }
17947 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17948 {
17949 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17950 return eANI_BOOLEAN_FALSE;
17951 }
17952 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17953 {
17954 return eANI_BOOLEAN_FALSE;
17955 }
17956 /* There is a possibility that the above check may fail,because
17957 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17958 * when it is connected.So,we may sneak through the above check even
17959 * if we are not a STA mode INFRA station. So, if we sneak through
17960 * the above condition, we can use the following check if we are
17961 * really in STA Mode.*/
17962
17963 if ( NULL != pSession->pCurRoamProfile )
17964 {
17965 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17966 {
17967 return eANI_BOOLEAN_TRUE;
17968 } else {
17969 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17970 return eANI_BOOLEAN_FALSE;
17971 }
17972 }
17973
17974 return eANI_BOOLEAN_FALSE;
17975}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017976
17977#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17978eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17979 tCsrHandoffRequest *pHandoffInfo)
17980{
17981 eHalStatus status = eHAL_STATUS_SUCCESS;
17982 vos_msg_t msg;
17983
17984 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017985 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17986 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017987 {
17988 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017989 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017990 }
17991 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17992 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17993 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17994 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017995 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017996 pHandoffInfo->bssid,
17997 6);
17998 msg.type = eWNI_SME_HANDOFF_REQ;
17999 msg.bodyptr = pMsg;
18000 msg.reserved = 0;
18001 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
18002 {
18003 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053018004 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018005 status = eHAL_STATUS_FAILURE;
18006 }
18007 return status;
18008}
18009#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018010
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018011
18012#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018013/* ---------------------------------------------------------------------------
18014 \fn csrSetCCKMIe
18015 \brief This function stores the CCKM IE passed by the supplicant in a place holder
18016 data structure and this IE will be packed inside reassociation request
18017 \param pMac - pMac global structure
18018 \param sessionId - Current session id
18019 \param pCckmIe - pointer to CCKM IE data
18020 \param ccKmIeLen - length of the CCKM IE
18021 \- return Success or failure
18022 -------------------------------------------------------------------------*/
18023VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
18024 const tANI_U8 *pCckmIe,
18025 const tANI_U8 ccKmIeLen)
18026{
18027 eHalStatus status = eHAL_STATUS_SUCCESS;
18028 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18029
18030 if (!pSession)
18031 {
18032 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18033 return eHAL_STATUS_FAILURE;
18034 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053018035 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018036 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
18037 return status;
18038}
18039
18040/* ---------------------------------------------------------------------------
18041 \fn csrRoamReadTSF
18042 \brief This function reads the TSF; and also add the time elapsed since last beacon or
18043 probe response reception from the hand off AP to arrive at the latest TSF value.
18044 \param pMac - pMac global structure
18045 \param pTimestamp - output TSF timestamp
18046 \- return Success or failure
18047 -------------------------------------------------------------------------*/
18048VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
18049{
18050 eHalStatus status = eHAL_STATUS_SUCCESS;
18051 tCsrNeighborRoamBSSInfo handoffNode;
18052 tANI_U32 timer_diff = 0;
18053 tANI_U32 timeStamp[2];
18054 tpSirBssDescription pBssDescription = NULL;
18055
18056 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
18057 pBssDescription = handoffNode.pBssDescription;
18058
18059 // Get the time diff in milli seconds
18060 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
18061 // Convert msec to micro sec timer
18062 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
18063
18064 timeStamp[0] = pBssDescription->timeStamp[0];
18065 timeStamp[1] = pBssDescription->timeStamp[1];
18066
18067 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
18068
Kiet Lamf2f201e2013-11-16 21:24:16 +053018069 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018070 sizeof (tANI_U32) * 2);
18071 return status;
18072}
18073
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018074#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018075
Agarwal Ashish738843c2014-09-25 12:27:56 +053018076/* ---------------------------------------------------------------------------
18077 \fn csrDisableDfsChannel
18078 \brief This function will call csrApplyChannelPowerCountryInfo to
18079 \ to trim the list on basis of NO_DFS flag.
18080 \param pMac - pMac global structure
18081 \- return void
18082 -------------------------------------------------------------------------*/
18083void csrDisableDfsChannel(tpAniSirGlobal pMac)
18084{
18085 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
18086 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
18087}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053018088
18089/* ---------------------------------------------------------------------------
18090 \fn csrGetStaticUapsdMask
18091 \brief This function will get the static uapsd settings for an existing
18092 \ Infra session.
18093 \param pMac - pMac global structure
18094 \- return void
18095 -------------------------------------------------------------------------*/
18096void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
18097{
18098 tANI_S8 sessionId;
18099 tCsrRoamSession *pSession = NULL;
18100
18101 *staticUapsdMask = 0;
18102 sessionId = csrGetInfraSessionId(pMac);
18103 if(sessionId == -1)
18104 smsLog(pMac, LOGE, FL("Valid session not present."));
18105 else
18106 pSession = CSR_GET_SESSION(pMac, sessionId);
18107
18108 if(!pSession || !pSession->pCurRoamProfile)
18109 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
18110 " pSession:%p"), pSession);
18111 else
18112 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
18113}
18114