blob: 15787620d6e9f7f6e43986a957c4317aad449a4a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053061#include "sme_Trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "logDump.h"
63#include "smeQosInternal.h"
64#include "wlan_qct_tl.h"
65#include "smeInside.h"
66#include "vos_diag_core_event.h"
67#include "vos_diag_core_log.h"
68#include "csrApi.h"
69#include "pmc.h"
70#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053071#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070072#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
73#include "csrNeighborRoam.h"
74#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080075#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
76#include "csrEse.h"
77#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053078#include "vos_utils.h"
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053079#ifdef WLAN_FEATURE_LFR_MBB
80#include "csr_roam_mbb.h"
81#endif
82
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084#define CSR_NUM_IBSS_START_CHANNELS_50 4
85#define CSR_NUM_IBSS_START_CHANNELS_24 3
86#define CSR_DEF_IBSS_START_CHANNEL_50 36
87#define CSR_DEF_IBSS_START_CHANNEL_24 1
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053088
Jeff Johnson295189b2012-06-20 16:38:30 -070089/*---------------------------------------------------------------------------
90 OBIWAN recommends [8 10]% : pick 9%
91---------------------------------------------------------------------------*/
92#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070093/*---------------------------------------------------------------------------
94 OBIWAN recommends -85dBm
95---------------------------------------------------------------------------*/
96#define CSR_VCC_RSSI_THRESHOLD 80
97#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
98#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
99#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
100#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700101//We use constatnt 4 here
102//This macro returns true when higher AC parameter is bigger than lower AC for a difference
103//The bigger the number, the less chance of TX
104//It must put lower AC as the first parameter.
105#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//Flag to send/do not send disassoc frame over the air
107#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700109#define MAX_CB_VALUE_IN_INI (2)
110
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700111#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
112static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
113#endif
114
Agrawal Ashishe4288772016-01-13 14:10:10 +0530115#define MAX_PWR_FCC_CHAN_12 8
116#define MAX_PWR_FCC_CHAN_13 2
117
Jeff Johnson295189b2012-06-20 16:38:30 -0700118/*--------------------------------------------------------------------------
119 Static Type declarations
120 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800121static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800122
Jeff Johnson295189b2012-06-20 16:38:30 -0700123/*--------------------------------------------------------------------------
124 Type declarations
125 ------------------------------------------------------------------------*/
126#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700127int diagAuthTypeFromCSRType(eCsrAuthType authType)
128{
129 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 switch(authType)
131 {
132 case eCSR_AUTH_TYPE_SHARED_KEY:
133 n = AUTH_SHARED;
134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 case eCSR_AUTH_TYPE_WPA:
136 n = AUTH_WPA_EAP;
137 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 case eCSR_AUTH_TYPE_WPA_PSK:
139 n = AUTH_WPA_PSK;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530142#ifdef WLAN_FEATURE_11W
143 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 n = AUTH_WPA2_EAP;
146 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700147 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700148#ifdef WLAN_FEATURE_11W
149 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
150#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 n = AUTH_WPA2_PSK;
152 break;
153#ifdef FEATURE_WLAN_WAPI
154 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
155 n = AUTH_WAPI_CERT;
156 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
158 n = AUTH_WAPI_PSK;
159 break;
160#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 default:
162 break;
163 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 return (n);
165}
Jeff Johnson295189b2012-06-20 16:38:30 -0700166int diagEncTypeFromCSRType(eCsrEncryptionType encType)
167{
168 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 switch(encType)
170 {
171 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
172 case eCSR_ENCRYPT_TYPE_WEP40:
173 n = ENC_MODE_WEP40;
174 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
176 case eCSR_ENCRYPT_TYPE_WEP104:
177 n = ENC_MODE_WEP104;
178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 case eCSR_ENCRYPT_TYPE_TKIP:
180 n = ENC_MODE_TKIP;
181 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700182 case eCSR_ENCRYPT_TYPE_AES:
183 n = ENC_MODE_AES;
184 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700185#ifdef FEATURE_WLAN_WAPI
186 case eCSR_ENCRYPT_TYPE_WPI:
187 n = ENC_MODE_SMS4;
188 break;
189#endif /* FEATURE_WLAN_WAPI */
190 default:
191 break;
192 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 return (n);
194}
Jeff Johnson295189b2012-06-20 16:38:30 -0700195#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700196static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
197static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700198static void initConfigParam(tpAniSirGlobal pMac);
199static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
200 eCsrRoamCompleteResult Result, void *Context );
201static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
202 tCsrRoamProfile *pProfile,
203 tANI_BOOLEAN *pfSameIbss );
204static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
205static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700206 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
207static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700208eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
209static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
210eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
211eHalStatus csrRoamClose(tpAniSirGlobal pMac);
212void csrRoamMICErrorTimerHandler(void *pv);
213void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
214tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
215
216static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
217static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
218static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700219eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
220static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700221static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700222static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700223eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
224 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
225 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
226 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
227 tANI_U8 *pKeyRsc );
228static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
229 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
230 tCsrRoamProfile *pProfile );
231void csrRoamStatisticsTimerHandler(void *pv);
232void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
234 v_U8_t rssiNotification,
235 void * context);
236static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
237void csrRoamVccTrigger(tpAniSirGlobal pMac);
238eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
239/*
240 pStaEntry is no longer invalid upon the return of this function.
241*/
242static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700243static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700244static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700245tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
246 tDblLinkList *pStaList,
247 tCsrStatsClientReqInfo *pStaEntry);
248void csrRoamStatsClientTimerHandler(void *pv);
249tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
250 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
251void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
252 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700253void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254void csrRoamTlStatsTimerHandler(void *pv);
255void csrRoamPeStatsTimerHandler(void *pv);
256tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
257void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
258tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
259eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
260static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
261static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
262static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
263static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
264 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
265//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
266static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
267void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
268#ifdef FEATURE_WLAN_BTAMP_UT_RF
269void csrRoamJoinRetryTimerHandler(void *pv);
270#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530271void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700272extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700273extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700275void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
277//Initialize global variables
278static void csrRoamInitGlobals(tpAniSirGlobal pMac)
279{
280 if(pMac)
281 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800282 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
283 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 }
285 return;
286}
287
Jeff Johnson295189b2012-06-20 16:38:30 -0700288static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
289{
290 if(pMac)
291 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800292 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 }
294 return;
295}
Jeff Johnson295189b2012-06-20 16:38:30 -0700296eHalStatus csrOpen(tpAniSirGlobal pMac)
297{
298 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530299#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 static uNvTables nvTables;
301 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 tANI_U32 i;
305
306 do
307 {
308 /* Initialize CSR Roam Globals */
309 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
311 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
312
313 initConfigParam(pMac);
314 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
315 break;
316 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
317 break;
318 pMac->roam.nextRoamId = 1; //Must not be 0
319 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
320 break;
321 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
322 break;
323 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
324 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530325
326#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
328 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
329 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530330 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
331 WNI_CFG_COUNTRY_CODE_LEN);
332 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 }
334 else
335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800336 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 //hardcoded for now
338 pMac->scan.countryCodeDefault[0] = 'U';
339 pMac->scan.countryCodeDefault[1] = 'S';
340 pMac->scan.countryCodeDefault[2] = 'I';
341 //status = eHAL_STATUS_SUCCESS;
342 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700343 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530344
345 if (!('0' == pMac->scan.countryCodeDefault[0] &&
346 '0' == pMac->scan.countryCodeDefault[1]))
347 {
348 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
349 &regId, COUNTRY_NV);
350 }
351 else
352 {
353 regId = REGDOMAIN_WORLD;
354 }
Abhishek Singha306a442013-11-07 18:39:01 +0530355 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 pMac->scan.domainIdDefault = regId;
357 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530358 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
359 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530361#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530363
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 return (status);
365}
366
Mihir Shetee1093ba2014-01-21 20:13:32 +0530367/* --------------------------------------------------------------------------
368 \fn csrInitChannels
369 \brief This function must be called to initialize CSR channel lists
370 \return eHalStatus
371 ----------------------------------------------------------------------------*/
372eHalStatus csrInitChannels(tpAniSirGlobal pMac)
373{
374 eHalStatus status = eHAL_STATUS_SUCCESS;
375 static uNvTables nvTables;
376 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530377 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530378
379 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
380 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
381 {
382 vos_mem_copy(pMac->scan.countryCodeDefault,
383 nvTables.defaultCountryTable.countryCode,
384 WNI_CFG_COUNTRY_CODE_LEN);
385 }
386 else
387 {
388 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
389 //hardcoded for now
390 pMac->scan.countryCodeDefault[0] = 'U';
391 pMac->scan.countryCodeDefault[1] = 'S';
392 pMac->scan.countryCodeDefault[2] = 'I';
393 }
394 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
395
Mihir Shetee1093ba2014-01-21 20:13:32 +0530396 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
397 pMac->scan.domainIdDefault = regId;
398 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
399 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
400 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530401 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
402 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530403 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
404 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530405 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530406 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530407
408 return status;
409}
410
Mihir Shete04206452014-11-20 17:50:58 +0530411#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530412eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530413{
414 eHalStatus status = eHAL_STATUS_SUCCESS;
415 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530416 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530417
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530418 /* In case of driver load ; driver need to get channel
419 * list with default Countrycode.
420 * In case of SSR; driver need to get channel list
421 * with old country code. 0 is for init and
422 * 1 is for reinit
423 */
424 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530425 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530426 case INIT:
427 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
428 WNI_CFG_COUNTRY_CODE_LEN);
429 if (!('0' == cc[0] &&
430 '0' == cc[1]))
431 {
432 csrGetRegulatoryDomainForCountry(pMac, cc,
433 &regId, COUNTRY_NV);
434 }
435 else
436 {
437 return status;
438 }
439 pMac->scan.domainIdDefault = regId;
440 break;
441 case REINIT:
442 vos_getCurrentCountryCode(&cc[0]);
443 status = csrGetRegulatoryDomainForCountry(pMac,
444 cc, &regId, COUNTRY_QUERY);
445 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530446 }
447 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530448 pMac->scan.domainIdCurrent = regId;
449 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530450 WNI_CFG_COUNTRY_CODE_LEN);
451 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530452
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530453 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
454 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
455 pMac->scan.countryCodeCurrent[1]);
456
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530457 /* reset info based on new cc, and we are done */
458 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
459 csrScanFilterResults(pMac);
460
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530461 return status;
462}
Mihir Shete04206452014-11-20 17:50:58 +0530463#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530464
Jeff Johnson295189b2012-06-20 16:38:30 -0700465eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
466{
467 eHalStatus status = eHAL_STATUS_SUCCESS;
468 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
469 v_REGDOMAIN_t regId;
470 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 if(NULL == apCntryCode)
472 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530473 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 return eHAL_STATUS_FAILURE;
475 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530476 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 /* To get correct Regulatory domain from NV table
478 * 2 character Country code should be used
479 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700480 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
481/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700483
484 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800486 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700487 return eHAL_STATUS_FAILURE;
488 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700489*/
Kiet Lam6c583332013-10-14 05:37:09 +0530490 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
491 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 if (status != eHAL_STATUS_SUCCESS)
493 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700494 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 return status;
496 }
Abhishek Singha306a442013-11-07 18:39:01 +0530497 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 if (status != eHAL_STATUS_SUCCESS)
499 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700500 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 return status;
502 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 pMac->scan.domainIdDefault = regId;
504 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530506 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530509 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
510
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 /* If 2 bytes country code, 3rd byte must be filled with space */
512 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
513 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530514 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530516 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
517 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 return status;
520}
Jeff Johnson295189b2012-06-20 16:38:30 -0700521eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
522{
523 eHalStatus status = eHAL_STATUS_SUCCESS;
524 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
525 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530526 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
527 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
529 {
530 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
531 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
532 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
533 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
534 }
535 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
536
537 return status;
538}
Jeff Johnson295189b2012-06-20 16:38:30 -0700539eHalStatus csrClose(tpAniSirGlobal pMac)
540{
541 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800542
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 csrRoamClose(pMac);
544 csrScanClose(pMac);
545 csrLLClose(&pMac->roam.statsClientReqList);
546 csrLLClose(&pMac->roam.peStatsReqList);
547 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 /* DeInit Globals */
549 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 return (status);
551}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530552
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800553eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530554{
555 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800556 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530557 tANI_U32 numChan = 0;
558 tANI_U32 bufLen ;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530559 tANI_U8 i, j;
560 tANI_U8 num_channel = 0;
561 tANI_U8 channel_state;
562 tANI_U8 cfgnumChannels = 0;
563 tANI_U8 *cfgChannelList = NULL;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530564 eHalStatus status;
565 tSmeCmd *command;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530566
Atul Mittalb849d5a2014-07-29 12:08:39 +0530567 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530568 numChan = sizeof(pMac->roam.validChannelList);
569
570 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
571 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
572 {
573 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
574 return eHAL_STATUS_FAILED_ALLOC;
575 }
576
577 bufLen = sizeof(tSirUpdateChanList) +
578 (sizeof(tSirUpdateChanParam) * (numChan - 1));
579
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530580 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
581 if (!pChanList)
582 {
583 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
584 "Failed to allocate memory for tSirUpdateChanList");
585 return eHAL_STATUS_FAILED_ALLOC;
586 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530587 vos_mem_zero(pChanList, bufLen);
588
589 smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"),
590 pMac->scan.fEnableDFSChnlScan);
591
592 for (i = 0; i < numChan; i++)
593 {
594 channel_state =
595 vos_nv_getChannelEnabledState(pMac->roam.validChannelList[i]);
596
597 if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
598 && (channel_state == NV_CHANNEL_DFS))
599 {
600 continue;
601 }
602 pChanList->chanParam[num_channel].chanId =
603 pMac->roam.validChannelList[i];
604 pChanList->chanParam[num_channel].pwr =
605 cfgGetRegulatoryMaxTransmitPower(pMac,
606 pScan->defaultPowerTable[i].chanId);
Agrawal Ashishe4288772016-01-13 14:10:10 +0530607 if (pMac->scan.fcc_constraint)
608 {
609 if (pChanList->chanParam[num_channel].chanId == 12)
610 {
611 pChanList->chanParam[num_channel].pwr = MAX_PWR_FCC_CHAN_12;
612 smsLog(pMac, LOG1,
613 "fcc_constraint is set, txpower for channel 12 is 8db ");
614 }
615 if (pChanList->chanParam[num_channel].chanId == 13)
616 {
617 pChanList->chanParam[num_channel].pwr = MAX_PWR_FCC_CHAN_13;
618 smsLog(pMac, LOG1,
619 "fcc_constraint is set, txpower for channel 13 is 2db ");
620 }
621 }
622
Sushant Kaushikece4b562015-04-09 18:27:33 +0530623 if (!pChanList->chanParam[num_channel].pwr)
624 {
625 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
626 "setting to default %d"),
627 pChanList->chanParam[num_channel].chanId,
628 TX_POWER_DEFAULT);
629 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
630 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530631 if (channel_state == NV_CHANNEL_DFS)
632 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
633 else
634 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
635
636 /* When DFS mode is 2, mark static channels as active */
637 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
638 {
639 cfgnumChannels =
640 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
641 cfgChannelList =
642 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
643
644 if (cfgChannelList)
645 {
646 for(j=0; j< cfgnumChannels; j++)
647 {
648 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
649 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
650 {
651 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
653 "%s Marked DFS ch %d as active\n", __func__,
654 cfgChannelList[j]);
655 }
656 }
657 }
658 else
659 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
660 "%s cfgChannelList is NULL \n", __func__);
661 }
662
663 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
664 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
665 pChanList->chanParam[num_channel].chanId,
666 pChanList->chanParam[num_channel].dfsSet,
667 pChanList->chanParam[num_channel].pwr);
668 num_channel++;
669 }
670 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530671
Sachin Ahuja2d15ff62015-06-30 12:46:44 +0530672 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
673 "%s : regID : %d \n", __func__,
674 pChanList->regId);
675
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530676 pChanList->numChan = num_channel;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530677
678 status = sme_AcquireGlobalLock(&pMac->sme);
679 if (HAL_STATUS_SUCCESS(status)) {
680 command = csrGetCommandBuffer(pMac);
681 if (command) {
682 command->command = eSmeCommandUpdateChannelList;
683 command->u.chan_list = pChanList;
684
685 status = csrQueueSmeCommand(pMac, command, eANI_BOOLEAN_TRUE);
686 if (!HAL_STATUS_SUCCESS(status)) {
687 smsLog(pMac, LOGE, FL("fail to send msg status = %d"), status);
688 csrReleaseCommand(pMac, command);
689 }
690 } else {
691 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
692 status = eHAL_STATUS_RESOURCES;
693 }
694 sme_ReleaseGlobalLock(&pMac->sme);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530695 }
696
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530697 return status;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530698}
699
Jeff Johnson295189b2012-06-20 16:38:30 -0700700eHalStatus csrStart(tpAniSirGlobal pMac)
701{
702 eHalStatus status = eHAL_STATUS_SUCCESS;
703 tANI_U32 i;
704
705 do
706 {
707 //save the global vos context
708 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
709 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
710 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
711
712 status = csrRoamStart(pMac);
713 if(!HAL_STATUS_SUCCESS(status)) break;
714 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
715 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
716 if(!HAL_STATUS_SUCCESS(status)) break;
717 pMac->roam.sPendingCommands = 0;
718 csrScanEnable(pMac);
719#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
720 status = csrNeighborRoamInit(pMac);
721#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
722 pMac->roam.tlStatsReqInfo.numClient = 0;
723 pMac->roam.tlStatsReqInfo.periodicity = 0;
724 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
725 //init the link quality indication also
726 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
727 if(!HAL_STATUS_SUCCESS(status))
728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800729 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 break;
731 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530732
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734#if defined(ANI_LOGDUMP)
735 csrDumpInit(pMac);
736#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return (status);
738}
739
Kiet Lama72a2322013-11-15 11:18:11 +0530740eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700741{
742 tANI_U32 sessionId;
743 tANI_U32 i;
744
745 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
746 {
mukul sharmabab477d2015-06-11 17:14:55 +0530747 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 csrScanDisable(pMac);
750 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
751 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
753
754#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
755 csrNeighborRoamClose(pMac);
756#endif
757 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 // deregister from PMC since we register during csrStart()
759 // (ignore status since there is nothing we can do if it fails)
760 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 //Reset the domain back to the deault
762 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700763
764 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
765 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530766 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
768 }
769
Kiet Lama72a2322013-11-15 11:18:11 +0530770#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
771 /* When HAL resets all the context information
772 * in HAL is lost, so we might need to send the
773 * scan offload request again when it comes
774 * out of reset for scan offload to be functional
775 */
776 if (HAL_STOP_TYPE_SYS_RESET == stopType)
777 {
778 bRoamScanOffloadStarted = VOS_FALSE;
779 }
780#endif
781
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 return (eHAL_STATUS_SUCCESS);
783}
784
Jeff Johnson295189b2012-06-20 16:38:30 -0700785eHalStatus csrReady(tpAniSirGlobal pMac)
786{
787 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 csrScanGetSupportedChannels( pMac );
789 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
790 //use it to init the background scan list
791 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 //Store the AC weights in TL for later use
793 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 status = csrInitChannelList( pMac );
795 if ( ! HAL_STATUS_SUCCESS( status ) )
796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800797 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 status );
799 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 return (status);
801}
Jeff Johnson295189b2012-06-20 16:38:30 -0700802void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
803{
804 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
806 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
807}
Jeff Johnson295189b2012-06-20 16:38:30 -0700808void csrSetGlobalCfgs( tpAniSirGlobal pMac )
809{
Jeff Johnsone7245742012-09-05 17:12:55 -0700810
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
812 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
813 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
814 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
815 NULL, eANI_BOOLEAN_FALSE);
816 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700817 /* 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
818 * Once session is established we will use the session related params stored in PE session for CB mode
819 */
820 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
822
823 //Update the operating mode to configured value during initialization,
824 //So that client can advertise full capabilities in Probe request frame.
825 csrSetDefaultDot11Mode( pMac );
826}
827
Jeff Johnson295189b2012-06-20 16:38:30 -0700828eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
829{
830 eHalStatus status = eHAL_STATUS_SUCCESS;
831 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +0530832 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 do
834 {
835 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
836 {
837 pSession = CSR_GET_SESSION( pMac, i );
838 pSession->roamingTimerInfo.pMac = pMac;
839 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
840 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
842 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530843 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
844 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530846 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800848 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 break;
850 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530851 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
852 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
853 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800855 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 return eHAL_STATUS_FAILURE;
857 }
858 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 return (status);
860}
861
Jeff Johnson295189b2012-06-20 16:38:30 -0700862eHalStatus csrRoamClose(tpAniSirGlobal pMac)
863{
864 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
866 {
mukul sharmabab477d2015-06-11 17:14:55 +0530867 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530869 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
870 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
871 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
872 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 return (eHAL_STATUS_SUCCESS);
874}
875
Jeff Johnson295189b2012-06-20 16:38:30 -0700876eHalStatus csrRoamStart(tpAniSirGlobal pMac)
877{
878 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 return (eHAL_STATUS_SUCCESS);
880}
881
Jeff Johnson295189b2012-06-20 16:38:30 -0700882void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
883{
884 csrRoamStopRoamingTimer(pMac, sessionId);
885 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
886 csrRoamDeregStatisticsReq(pMac);
887}
Jeff Johnson295189b2012-06-20 16:38:30 -0700888eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
889{
890 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800891 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 {
893 status = eHAL_STATUS_SUCCESS;
894 *pState = pMac->roam.roamSession[sessionId].connectState;
895 }
896 return (status);
897}
898
Jeff Johnson295189b2012-06-20 16:38:30 -0700899eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
900{
901 eHalStatus status = eHAL_STATUS_FAILURE;
902 tANI_U32 size = 0;
903 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700904
905 if(!pSession)
906 {
907 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
908 return eHAL_STATUS_FAILURE;
909 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
911 if(pProfile)
912 {
913 if(pSession->pConnectBssDesc)
914 {
915 do
916 {
917 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
918 if(size)
919 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530920 pProfile->pBssDesc = vos_mem_malloc(size);
921 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530923 vos_mem_copy(pProfile->pBssDesc,
924 pSession->pConnectBssDesc, size);
925 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 }
927 else
928 break;
929 }
930 else
931 {
932 pProfile->pBssDesc = NULL;
933 }
934 pProfile->AuthType = pSession->connectedProfile.AuthType;
935 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
936 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
937 pProfile->BSSType = pSession->connectedProfile.BSSType;
938 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
939 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530940 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
941 sizeof(tCsrBssid));
942 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
943 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700944#ifdef WLAN_FEATURE_VOWIFI_11R
945 if (pSession->connectedProfile.MDID.mdiePresent)
946 {
947 pProfile->MDID.mdiePresent = 1;
948 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
949 }
950 else
951 {
952 pProfile->MDID.mdiePresent = 0;
953 pProfile->MDID.mobilityDomain = 0;
954 }
955#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800956#ifdef FEATURE_WLAN_ESE
957 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
958 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800960 vos_mem_copy (pProfile->eseCckmInfo.krk,
961 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530962 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800963 pProfile->eseCckmInfo.reassoc_req_num=
964 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
965 pProfile->eseCckmInfo.krk_plumbed =
966 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 }
968#endif
969 }while(0);
970 }
971 }
972
973 return (status);
974}
975
Jeff Johnson295189b2012-06-20 16:38:30 -0700976eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
977{
978 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700979
980 if((csrIsConnStateConnected(pMac, sessionId)) ||
981 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 {
983 if(pProfile)
984 {
985 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
986 }
987 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 return (status);
989}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700990
Jeff Johnson295189b2012-06-20 16:38:30 -0700991eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
992{
993 eHalStatus status = eHAL_STATUS_SUCCESS;
994
Kiet Lam64c1b492013-07-12 13:56:44 +0530995 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530997 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530999 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001000 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301001 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001002 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301003 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
1004
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
1006 return (status);
1007}
1008
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301009eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -07001010{
1011 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 if( pConnectedInfo->pbFrames )
1013 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301014 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 pConnectedInfo->pbFrames = NULL;
1016 }
1017 pConnectedInfo->nBeaconLength = 0;
1018 pConnectedInfo->nAssocReqLength = 0;
1019 pConnectedInfo->nAssocRspLength = 0;
1020 pConnectedInfo->staId = 0;
1021#ifdef WLAN_FEATURE_VOWIFI_11R
1022 pConnectedInfo->nRICRspLength = 0;
1023#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001024#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 pConnectedInfo->nTspecIeLength = 0;
1026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 return ( status );
1028}
1029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030
1031
Jeff Johnsone7245742012-09-05 17:12:55 -07001032
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001033void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1034{
1035 csrReinitPreauthCmd(pMac, pCommand);
1036 csrReleaseCommand( pMac, pCommand );
1037}
1038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1040{
1041 csrReinitRoamCmd(pMac, pCommand);
1042 csrReleaseCommand( pMac, pCommand );
1043}
1044
Jeff Johnson295189b2012-06-20 16:38:30 -07001045void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1046{
1047 csrReinitScanCmd(pMac, pCommand);
1048 csrReleaseCommand( pMac, pCommand );
1049}
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1052{
1053 csrReinitWmStatusChangeCmd(pMac, pCommand);
1054 csrReleaseCommand( pMac, pCommand );
1055}
1056
Jeff Johnson295189b2012-06-20 16:38:30 -07001057void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1058{
Kiet Lam64c1b492013-07-12 13:56:44 +05301059 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001060}
1061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1063{
Kiet Lam64c1b492013-07-12 13:56:44 +05301064 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065}
1066
Jeff Johnson295189b2012-06-20 16:38:30 -07001067void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1068{
1069 csrReinitSetKeyCmd(pMac, pCommand);
1070 csrReleaseCommand( pMac, pCommand );
1071}
Jeff Johnson295189b2012-06-20 16:38:30 -07001072void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1073{
1074 csrReinitRemoveKeyCmd(pMac, pCommand);
1075 csrReleaseCommand( pMac, pCommand );
1076}
Abhishek Singh7b2d0812016-04-28 11:44:29 +05301077
1078/**
1079 * csr_is_disconnect_full_power_cmd() - Check if command is for
1080 * disconnect or for fullpower
1081 * @command: command to check
1082 *
1083 * Return: true if disconnect or full power command else false
1084 */
1085bool csr_is_disconnect_full_power_cmd(tSmeCmd *command)
1086{
1087 switch (command->command) {
1088 case eSmeCommandRoam:
1089 if (CSR_IS_DISCONNECT_COMMAND(command))
1090 return true;
1091 break;
1092 case eSmeCommandWmStatusChange:
1093 case eSmeCommandExitImps:
1094 case eSmeCommandExitBmps:
1095 case eSmeCommandExitUapsd:
1096 case eSmeCommandExitWowl:
1097 return true;
1098 default:
1099 return false;
1100 }
1101 return false;
1102}
1103
Jeff Johnson295189b2012-06-20 16:38:30 -07001104void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1105{
1106
1107 if( eSmeCsrCommandMask & pCommand->command )
1108 {
1109 switch (pCommand->command)
1110 {
1111 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001112 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001113 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1114 __func__, pCommand->u.scanCmd.reason,
1115 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 if (NULL != pCommand->u.scanCmd.callback)
1117 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001118 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1120 }
1121 csrReleaseCommandScan( pMac, pCommand );
1122 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 case eSmeCommandRoam:
1124 csrReleaseCommandRoam( pMac, pCommand );
1125 break;
1126
1127 case eSmeCommandWmStatusChange:
1128 csrReleaseCommandWmStatusChange( pMac, pCommand );
1129 break;
1130
1131 case eSmeCommandSetKey:
1132 csrReleaseCommandSetKey( pMac, pCommand );
1133 break;
1134
1135 case eSmeCommandRemoveKey:
1136 csrReleaseCommandRemoveKey( pMac, pCommand );
1137 break;
1138
1139 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001140 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 csrReleaseCommand( pMac, pCommand );
1142 break;
1143 }
1144 }
1145}
1146
Jeff Johnson295189b2012-06-20 16:38:30 -07001147void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1148{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301149 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1150 macTraceGetcsrRoamSubState(NewSubstate),
1151 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001152
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1154 {
1155 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 pMac->roam.curSubState[sessionId] = NewSubstate;
1158}
1159
Jeff Johnson295189b2012-06-20 16:38:30 -07001160eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1161{
1162 eCsrRoamState PreviousState;
1163
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301164 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1165 macTraceGetcsrRoamState(NewRoamState),
1166 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001167
1168 PreviousState = pMac->roam.curState[sessionId];
1169
1170 if ( NewRoamState != pMac->roam.curState[sessionId] )
1171 {
1172 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1173 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1174 {
1175 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1176 }
1177
1178 pMac->roam.curState[sessionId] = NewRoamState;
1179 }
1180 return( PreviousState );
1181}
1182
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001183void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001184{
1185 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 if(catOffset)
1187 {
1188 pMac->roam.configParam.bCatRssiOffset = catOffset;
1189 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1190 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001191 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 -07001192 }
1193 }
1194}
1195
Jeff Johnson295189b2012-06-20 16:38:30 -07001196static void initConfigParam(tpAniSirGlobal pMac)
1197{
1198 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301200 pMac->roam.configParam.channelBondingMode24GHz =
1201 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1202 pMac->roam.configParam.channelBondingMode5GHz =
1203 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1205 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1206 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1207 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1208 pMac->roam.configParam.HeartbeatThresh24 = 40;
1209 pMac->roam.configParam.HeartbeatThresh50 = 40;
1210 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1211 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1212 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001213 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 pMac->roam.configParam.RTSThreshold = 2346;
1215 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1216 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1217 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1218 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1219 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1220 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1221 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1222 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1223 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1224 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1225 {
1226 pMac->roam.configParam.BssPreferValue[i] = i;
1227 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001228 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1230 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1231 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1233 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301234 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1236 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1237 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1238 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301239 pMac->roam.configParam.max_chntime_btc_esco =
1240 CSR_ACTIVE_MAX_CHANNEL_TIME_ESCO_BTC;
1241 pMac->roam.configParam.min_chntime_btc_esco =
1242 CSR_ACTIVE_MIN_CHANNEL_TIME_ESCO_BTC;
1243 pMac->roam.configParam.min_chntime_btc_sco =
1244 CSR_ACTIVE_MIN_CHANNEL_TIME_SCO_BTC;
1245 pMac->roam.configParam.max_chntime_btc_sco=
1246 CSR_ACTIVE_MAX_CHANNEL_TIME_SCO_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001247 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001248#ifdef WLAN_AP_STA_CONCURRENCY
1249 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1250 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1251 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1252 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1253 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001254 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1255 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001256#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1258 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1259 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1260 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001261#ifdef WLAN_FEATURE_VOWIFI_11R
1262 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001264#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1265 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1266 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1267 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1268 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1269 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1270 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1271 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1272 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1273 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1274 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1275 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001276 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301277 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001278#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001279#ifdef WLAN_FEATURE_11AC
1280 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001282
1283 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1284 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001285
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001286 //Remove this code once SLM_Sessionization is supported
1287 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001288 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001289
Jeff Johnsone7245742012-09-05 17:12:55 -07001290}
Jeff Johnson295189b2012-06-20 16:38:30 -07001291eCsrBand csrGetCurrentBand(tHalHandle hHal)
1292{
1293 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1294 return pMac->roam.configParam.bandCapability;
1295}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001296
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001297
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001298#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001299/*
1300 This function flushes the roam scan cache
1301*/
1302eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1303{
1304 eHalStatus status = eHAL_STATUS_SUCCESS;
1305 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1306
1307 /* Free up the memory first (if required) */
1308 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1309 {
1310 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1311 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1312 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1313 }
1314 return status;
1315}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001316#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001317
1318
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001319#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001320/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001321 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001322*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001323eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001324{
1325 eHalStatus status = eHAL_STATUS_SUCCESS;
1326 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1327
1328 /* Free up the memory first (if required) */
1329 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1330 {
1331 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1332 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001333 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001334 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001335 return status;
1336}
1337
1338
1339
1340/*
1341 This function flushes the roam scan cache and creates fresh cache
1342 based on the input channel list
1343*/
1344eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1345 const tANI_U8 *pChannelList,
1346 const tANI_U8 numChannels)
1347{
1348 eHalStatus status = eHAL_STATUS_SUCCESS;
1349 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1350
Srinivas Girigowdade697412013-02-14 16:31:48 -08001351 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1352
1353 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1354 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1355
1356 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1357 {
1358 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1359 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1360 return eHAL_STATUS_RESOURCES;
1361 }
1362
1363 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301364 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1365 pChannelList,
1366 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001367 return status;
1368}
1369
1370/* This function modifies the bgscan channel list set via config ini or
1371 runtime, whenever the band changes.
1372 if the band is auto, then no operation is performed on the channel list
1373 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1374 if the band is 5G, then make sure channel list contains only 5G valid channels
1375*/
1376eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1377 eCsrBand eBand)
1378{
1379 eHalStatus status = eHAL_STATUS_SUCCESS;
1380 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1381 tANI_U8 outNumChannels = 0;
1382 tANI_U8 inNumChannels = 0;
1383 tANI_U8 *inPtr = NULL;
1384 tANI_U8 i = 0;
1385 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1386
1387 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1388
1389 {
1390 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1391 "No update required for channel list "
1392 "either cfg.ini channel list is not set up or "
1393 "auto band (Band %d)", eBand);
1394 return status;
1395 }
1396
1397 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1398 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1399 if (eCSR_BAND_24 == eBand)
1400 {
1401 for (i = 0; i < inNumChannels; i++)
1402 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001403 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001404 {
1405 ChannelList[outNumChannels++] = inPtr[i];
1406 }
1407 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001408 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001409 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001410 }
1411 else if (eCSR_BAND_5G == eBand)
1412 {
1413 for (i = 0; i < inNumChannels; i++)
1414 {
1415 /* Add 5G Non-DFS channel */
1416 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001417 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001418 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1419 {
1420 ChannelList[outNumChannels++] = inPtr[i];
1421 }
1422 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001423 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001424 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001425 }
1426 else if (eCSR_BAND_ALL == eBand)
1427 {
1428 for (i = 0; i < inNumChannels; i++)
1429 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001430 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001431 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1432 {
1433 ChannelList[outNumChannels++] = inPtr[i];
1434 }
1435 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001436 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001437 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001438 }
1439 else
1440 {
1441 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1442 "Invalid band, No operation carried out (Band %d)", eBand);
1443 status = eHAL_STATUS_INVALID_PARAMETER;
1444 }
1445
1446 return status;
1447}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001448#endif
1449
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001450#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001451/* This function modifies the roam scan channel list as per AP neighbor
1452 report; AP neighbor report may be empty or may include only other AP
1453 channels; in any case, we merge the channel list with the learned occupied
1454 channels list.
1455 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1456 if the band is 5G, then make sure channel list contains only 5G valid channels
1457*/
1458eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1459 tANI_U8 *pChannelList,
1460 tANI_U8 numChannels,
1461 const eCsrBand eBand)
1462{
1463 eHalStatus status = eHAL_STATUS_SUCCESS;
1464 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1465 tANI_U8 outNumChannels = 0;
1466 tANI_U8 inNumChannels = numChannels;
1467 tANI_U8 *inPtr = pChannelList;
1468 tANI_U8 i = 0;
1469 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1470 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1471 tANI_U8 mergedOutputNumOfChannels = 0;
1472 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1473
1474 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1475 * report Channels. This increases the chances of the DUT to get a candidate AP while
1476 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1477 if (pMac->scan.occupiedChannels.numChannels)
1478 {
1479 csrNeighborRoamMergeChannelLists(pMac,
1480 &pMac->scan.occupiedChannels.channelList[0],
1481 pMac->scan.occupiedChannels.numChannels,
1482 inPtr,
1483 inNumChannels,
1484 &mergedOutputNumOfChannels);
1485 inNumChannels = mergedOutputNumOfChannels;
1486 }
1487
1488 if (eCSR_BAND_24 == eBand)
1489 {
1490 for (i = 0; i < inNumChannels; i++)
1491 {
1492 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1493 {
1494 ChannelList[outNumChannels++] = inPtr[i];
1495 }
1496 }
1497 }
1498 else if (eCSR_BAND_5G == eBand)
1499 {
1500 for (i = 0; i < inNumChannels; i++)
1501 {
1502 /* Add 5G Non-DFS channel */
1503 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1504 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1505 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1506 {
1507 ChannelList[outNumChannels++] = inPtr[i];
1508 }
1509 }
1510 }
1511 else if (eCSR_BAND_ALL == eBand)
1512 {
1513 for (i = 0; i < inNumChannels; i++)
1514 {
1515 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1516 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1517 {
1518 ChannelList[outNumChannels++] = inPtr[i];
1519 }
1520 }
1521 }
1522 else
1523 {
1524 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1525 "Invalid band, No operation carried out (Band %d)", eBand);
1526 return eHAL_STATUS_INVALID_PARAMETER;
1527 }
1528
1529 /* if roaming within band is enabled, then select only the
1530 in band channels .
1531 This is required only if the band capability is set to ALL,
1532 E.g., if band capability is only 2.4G then all the channels in the
1533 list are already filtered for 2.4G channels, hence ignore this check*/
1534
1535 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1536 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301537 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001538 pMac,
1539 ChannelList,
1540 outNumChannels,
1541 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301542 &outNumChannels,
1543 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301544 vos_mem_copy(ChannelList,
1545 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001546 }
1547
1548 /* Prepare final roam scan channel list */
1549 if(outNumChannels)
1550 {
1551 /* Clear the channel list first */
1552 if (NULL != currChannelListInfo->ChannelList)
1553 {
1554 vos_mem_free(currChannelListInfo->ChannelList);
1555 currChannelListInfo->ChannelList = NULL;
1556 currChannelListInfo->numOfChannels = 0;
1557 }
1558
1559 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1560 if (NULL == currChannelListInfo->ChannelList)
1561 {
1562 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1563 "Failed to allocate memory for roam scan channel list");
1564 currChannelListInfo->numOfChannels = 0;
1565 return VOS_STATUS_E_RESOURCES;
1566 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301567 vos_mem_copy(currChannelListInfo->ChannelList,
1568 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001569 }
1570 return status;
1571}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001572#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1575{
1576 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1577 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1579 (eBand == eCSR_BAND_24))
1580 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001581 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001583 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001584 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pMac->roam.configParam.uCfgDot11Mode, eBand);
1586 return eHAL_STATUS_INVALID_PARAMETER;
1587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1589 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1590 (eBand == eCSR_BAND_5G))
1591 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001592 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001594 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001595 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 pMac->roam.configParam.uCfgDot11Mode, eBand);
1597 return eHAL_STATUS_INVALID_PARAMETER;
1598 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001599 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001600 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001601 pMac->roam.configParam.eBand = eBand;
1602 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001604#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001605 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1606 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001607#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 status = csrInitGetChannels( pMac );
1609 if (eHAL_STATUS_SUCCESS == status)
1610 csrInitChannelList( hHal );
1611 return status;
1612}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001613
1614
Jeff Johnsone7245742012-09-05 17:12:55 -07001615/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1616 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1617 * Ideally we should have kept the ini value and enum value same and representing the same
1618 * cb values as in 11n standard i.e.
1619 * Set to 1 (SCA) if the secondary channel is above the primary channel
1620 * Set to 3 (SCB) if the secondary channel is below the primary channel
1621 * Set to 0 (SCN) if no secondary channel is present
1622 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1623 * 0 - secondary none
1624 * 1 - secondary LOW
1625 * 2 - secondary HIGH
1626 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1627 * The enum values are as follows:
1628 * PHY_SINGLE_CHANNEL_CENTERED = 0
1629 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1630 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1631 */
1632ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1633{
1634
1635 ePhyChanBondState phyCbState;
1636 switch (cbIniValue) {
1637 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301638 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1640 break;
1641 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301642 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001643 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1644 break;
1645 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301646 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1648 break;
1649#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301650 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1651 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001652 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301653 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001654 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1655 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301656 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1657 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1658 break;
1659 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001660 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1661 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301662 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001663 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301664 break;
1665 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001666 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1667 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301668 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001669 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301670 break;
1671#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001672 default:
1673 // If an invalid value is passed, disable CHANNEL BONDING
1674 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1675 break;
1676 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301677
Jeff Johnsone7245742012-09-05 17:12:55 -07001678 return phyCbState;
1679}
1680
1681v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1682{
1683
1684 v_U32_t cbIniValue;
1685 switch (phyCbState) {
1686 // secondary none
1687 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301688 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001689 break;
1690 // secondary LOW
1691 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301692 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001693 break;
1694 // secondary HIGH
1695 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301696 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001697 break;
1698#ifdef WLAN_FEATURE_11AC
1699 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301700 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001701 break;
1702 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301703 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001704 break;
1705 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301706 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001707 break;
1708 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301709 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001710 break;
1711 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301712 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001713 break;
1714 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301715 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001716 break;
1717 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301718 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001719 break;
1720#endif
1721 default:
1722 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301723 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001724 break;
1725 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301726
Jeff Johnsone7245742012-09-05 17:12:55 -07001727 return cbIniValue;
1728}
Jeff Johnson295189b2012-06-20 16:38:30 -07001729
1730eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1731{
1732 eHalStatus status = eHAL_STATUS_SUCCESS;
1733
1734 if(pParam)
1735 {
1736 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1737 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1738 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1739 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1740 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1741 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1742
1743 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001744 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1745
Jeff Johnsone7245742012-09-05 17:12:55 -07001746 /* channelBondingMode5GHz plays a dual role right now
1747 * 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
1748 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1749 */
1750 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001752 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001753 }
1754 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1755 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001757 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001758 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301759#ifdef WLAN_FEATURE_AP_HT40_24G
1760 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1761#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001762 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1764 pMac->roam.configParam.phyMode = pParam->phyMode;
1765 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1766 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1767 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1768 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1769 pMac->roam.configParam.TxRate = pParam->TxRate;
1770 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1771 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1772 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1773 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1774 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001775 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 //if HDD passed down non zero values then only update,
1777 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301778 if (pParam->nInitialDwellTime)
1779 {
1780 pMac->roam.configParam.nInitialDwellTime =
1781 pParam->nInitialDwellTime;
1782 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001783 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 {
1785 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301786 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1787 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001789 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 {
1791 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301792 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1793 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001795 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 {
1797 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301798 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1799 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001801 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 {
1803 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301804 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1805 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301807 if (pParam->nOBSSScanWidthTriggerInterval)
1808 {
1809 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1810 pParam->nOBSSScanWidthTriggerInterval;
1811 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1812 pParam->nOBSSScanWidthTriggerInterval);
1813 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301814 if (pParam->max_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001815 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301816 pMac->roam.configParam.max_chntime_btc_esco =
1817 pParam->max_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001818 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301819 if (pParam->min_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001820 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301821 pMac->roam.configParam.min_chntime_btc_esco =
1822 pParam->min_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001823 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301824 if (pParam->min_chntime_btc_sco)
1825 pMac->roam.configParam.min_chntime_btc_sco =
1826 pParam->min_chntime_btc_sco;
1827 if (pParam->max_chntime_btc_sco)
1828 pMac->roam.configParam.max_chntime_btc_sco =
1829 pParam->max_chntime_btc_sco;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001830#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001831 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001832 {
1833 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1834 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001835 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001836 {
1837 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1838 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001839 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001840 {
1841 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1842 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001843 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001844 {
1845 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1846 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001847 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001848 {
1849 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1850 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001851 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001852 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001853 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1854 }
1855 if (pParam->nNumP2PChanCombinedConc)
1856 {
1857 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001858 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001861 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 {
1863 //Change the unit from second to microsecond
1864 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1866 {
1867 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1868 }
1869 else
1870 {
1871 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1872 }
1873 }
1874 else
1875 {
1876 pMac->roam.configParam.impsSleepTime = 0;
1877 }
1878 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1880 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 //if HDD passed down non zero values for age params, then only update,
1882 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001883 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 {
1885 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 if(pParam->scanAgeTimeNCNPS)
1888 {
1889 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 if(pParam->scanAgeTimeNCPS)
1892 {
1893 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 if(pParam->scanAgeTimeCNPS)
1896 {
1897 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1898 }
1899 if(pParam->scanAgeTimeCPS)
1900 {
1901 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1902 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301903 if (pParam->initialScanSkipDFSCh)
1904 {
1905 pMac->roam.configParam.initialScanSkipDFSCh =
1906 pParam->initialScanSkipDFSCh;
1907 }
1908
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001909 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1911 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1912 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1913 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1914 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1916 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1918 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1919 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1920 //Assign this before calling CsrInit11dInfo
1921 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 if( csrIs11dSupported( pMac ) )
1923 {
1924 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1925 }
1926 else
1927 {
1928 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1929 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001930
1931 /* Initialize the power + channel information if 11h is enabled.
1932 If 11d is enabled this information has already been initialized */
1933 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1934 {
1935 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1936 }
1937
1938
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301939#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301940 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1941 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001942 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001943#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001944#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001946 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001947 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001948 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001949 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001950 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001951 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001952 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001953 pMac->roam.configParam.nProbes = pParam->nProbes;
1954 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001956#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301957 pMac->roam.configParam.isRoamOffloadScanEnabled =
1958 pParam->isRoamOffloadScanEnabled;
1959 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1960 pParam->bFastRoamInConIniFeatureEnabled;
1961 pMac->roam.configParam.isPERRoamEnabled =
1962 pParam->isPERRoamEnabled;
1963 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
1964 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
1965 pMac->roam.configParam.waitPeriodForNextPERScan =
1966 pParam->waitPeriodForNextPERScan;
1967 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
1968 pMac->roam.configParam.isPERRoamCCAEnabled =
1969 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05301970 pMac->roam.configParam.PERRoamFullScanThreshold =
1971 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05301972 pMac->roam.configParam.PERroamTriggerPercent =
1973 pParam->PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05301974 pMac->roam.configParam.PERMinRssiThresholdForRoam =
1975 pParam->PERMinRssiThresholdForRoam;
1976 pMac->PERroamTimeout = pParam->waitPeriodForNextPERScan;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001977#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301978
1979#ifdef WLAN_FEATURE_LFR_MBB
1980 pMac->roam.configParam.enable_lfr_mbb = pParam->enable_lfr_mbb;
1981#endif
1982
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001983#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001984 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001985 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001986#endif
1987
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001988#ifdef FEATURE_WLAN_ESE
1989 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001991#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301992 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1993 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001994 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1995 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1996 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1997 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1998 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1999 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
2000 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
2001 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302002 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 {
2004 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002005 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 -07002006 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2007 {
2008 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 }
2011#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
2013 pMac->scan.fValidateList = pParam->fValidateList;
2014 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2015 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302016 pMac->scan.disable_scan_during_sco = pParam->disable_scan_during_sco;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08002017 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002019 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05302020 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07002021 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2022 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2023 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2024 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2025 * single session
2026 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002027 //Remove this code once SLM_Sessionization is supported
2028 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002029 pMac->roam.configParam.doBMPSWorkaround = 0;
2030
Jeff Johnsone7245742012-09-05 17:12:55 -07002031#ifdef WLAN_FEATURE_11AC
2032 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002033 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002034 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002035 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302036 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2037 if ( pParam->enableTxBF )
2038 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2039 else
2040 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002041#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002042 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002043
2044 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002045 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302046 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302047 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302048 pMac->roam.configParam.disableP2PMacSpoofing =
2049 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302050 pMac->roam.configParam.enableFatalEvent =
2051 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002052 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2053 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302054 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302055 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302056#ifdef WLAN_FEATURE_AP_HT40_24G
2057 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2058#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302059 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302060 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2061 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302062
2063 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2064 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2065 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2066 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2067 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2068
2069 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2070 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2071 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2072 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2073
2074 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2075 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2076 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2077 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 }
2079
2080 return status;
2081}
2082
Jeff Johnson295189b2012-06-20 16:38:30 -07002083eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2084{
2085 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 if(pParam)
2087 {
2088 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2089 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2090 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2091 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2092 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2093 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002094 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302095#ifdef WLAN_FEATURE_AP_HT40_24G
2096 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2097#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002098 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2100 pParam->phyMode = pMac->roam.configParam.phyMode;
2101 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2102 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2103 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2104 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2105 pParam->TxRate = pMac->roam.configParam.TxRate;
2106 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2107 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2108 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2109 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2110 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2112 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2113 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2114 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05302115 pParam->max_chntime_btc_esco =
2116 pMac->roam.configParam.max_chntime_btc_esco;
2117 pParam->min_chntime_btc_esco =
2118 pMac->roam.configParam.min_chntime_btc_esco;
2119 pParam->min_chntime_btc_sco =
2120 pMac->roam.configParam.min_chntime_btc_sco;
2121 pParam->max_chntime_btc_sco =
2122 pMac->roam.configParam.max_chntime_btc_sco;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002123 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002124#ifdef WLAN_AP_STA_CONCURRENCY
2125 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2126 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2127 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2128 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2129 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002130 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2131 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002132#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 //Change the unit from microsecond to second
2134 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2135 pParam->eBand = pMac->roam.configParam.eBand;
2136 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2137 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2138 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2139 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2140 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2141 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2142 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2143 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2144 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2145 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2146 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2147 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2148 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2150 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2151 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2152 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2154 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2155 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2156 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302157 pParam->disable_scan_during_sco = pMac->scan.disable_scan_during_sco;
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002159 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002160 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002161 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002162 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302163 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002164#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302165 vos_mem_copy(&pParam->neighborRoamConfig,
2166 &pMac->roam.configParam.neighborRoamConfig,
2167 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002168#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002169#ifdef WLAN_FEATURE_11AC
2170 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002171 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002172 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002173 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302174 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2175 if ( pParam->enableTxBF )
2176 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2177 else
2178 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002179#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002180#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302181 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2182 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002183#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002184#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002185 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2186 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2187 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2188 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2189 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002190 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002191 pParam->nProbes = pMac->roam.configParam.nProbes;
2192 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002193#endif
2194#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2195 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2196 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302197 pParam->isPERRoamEnabled =
2198 pMac->roam.configParam.isPERRoamEnabled;
2199 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2200 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2201 pParam->waitPeriodForNextPERScan =
2202 pMac->roam.configParam.waitPeriodForNextPERScan;
2203 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2204 pParam->isPERRoamCCAEnabled =
2205 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302206 pParam->PERRoamFullScanThreshold =
2207 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302208 pParam->PERroamTriggerPercent =
2209 pMac->roam.configParam.PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302210 pParam->PERMinRssiThresholdForRoam =
2211 pMac->roam.configParam.PERMinRssiThresholdForRoam;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002212#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302213
2214#ifdef WLAN_FEATURE_LFR_MBB
2215 pParam->enable_lfr_mbb = pMac->roam.configParam.enable_lfr_mbb;
2216#endif
2217
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002218#ifdef FEATURE_WLAN_LFR
2219 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2220#endif
2221
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002222#ifdef FEATURE_WLAN_ESE
2223 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002224#endif
2225#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302226 vos_mem_copy(&pParam->neighborRoamConfig,
2227 &pMac->roam.configParam.neighborRoamConfig,
2228 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002229 {
2230 int i;
2231 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2232 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2233 {
2234 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2235 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002236 }
2237#endif
2238
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002239 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002240
krunal soni5afa96c2013-09-06 22:19:02 -07002241 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002242 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302243 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302244 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302245 pParam->disableP2PMacSpoofing =
2246 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302247 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002248
krunal sonie9002db2013-11-25 14:24:17 -08002249 pParam->isCoalesingInIBSSAllowed =
2250 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302251 pParam->allowDFSChannelRoam =
2252 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302253 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302255#ifdef WLAN_FEATURE_AP_HT40_24G
2256 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2257#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302258 pParam->max_chan_for_dwell_time_cfg =
2259 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
Abhishek Singh48cd3402016-03-30 15:20:19 +05302261 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2262 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2263 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2264 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2265 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2266
2267 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2268 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2269 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2270 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2271
2272 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2273 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2274 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2275 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
2276
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 status = eHAL_STATUS_SUCCESS;
2278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 return (status);
2280}
2281
Jeff Johnson295189b2012-06-20 16:38:30 -07002282eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2283{
2284 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2285 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2286 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2287 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 do
2289 {
2290 if(eCSR_BAND_24 == eBand)
2291 {
2292 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2293 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2294 }
2295 if(eCSR_BAND_5G == eBand)
2296 {
2297 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2298 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2299 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2300 )
2301 {
2302 break;
2303 }
2304 }
2305 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2306 {
2307 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2308 }
2309 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2310 {
2311 newPhyMode = eCSR_DOT11_MODE_AUTO;
2312 }
2313 else
2314 {
2315 //Check for dual band and higher capability first
2316 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2317 {
2318 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2319 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2320 }
2321 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2322 {
2323 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2324 if(eCSR_BAND_24 == eBand) break;
2325 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2326 eBand = eCSR_BAND_5G;
2327 }
2328 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2329 {
2330 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2331 if(eCSR_BAND_5G == eBand) break;
2332 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2333 eBand = eCSR_BAND_24;
2334 }
2335 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2336 {
2337 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2338 if(eCSR_BAND_5G == eBand) break;
2339 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2340 eBand = eCSR_BAND_24;
2341 }
2342 else if(eCSR_DOT11_MODE_11n & phyMode)
2343 {
2344 newPhyMode = eCSR_DOT11_MODE_11n;
2345 }
2346 else if(eCSR_DOT11_MODE_abg & phyMode)
2347 {
2348 newPhyMode = eCSR_DOT11_MODE_abg;
2349 }
2350 else if(eCSR_DOT11_MODE_11a & phyMode)
2351 {
2352 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2353 {
2354 if(eCSR_BAND_ALL == eBand)
2355 {
2356 newPhyMode = eCSR_DOT11_MODE_abg;
2357 }
2358 else
2359 {
2360 //bad setting
2361 break;
2362 }
2363 }
2364 else
2365 {
2366 newPhyMode = eCSR_DOT11_MODE_11a;
2367 eBand = eCSR_BAND_5G;
2368 }
2369 }
2370 else if(eCSR_DOT11_MODE_11g & phyMode)
2371 {
2372 newPhyMode = eCSR_DOT11_MODE_11g;
2373 eBand = eCSR_BAND_24;
2374 }
2375 else if(eCSR_DOT11_MODE_11b & phyMode)
2376 {
2377 newPhyMode = eCSR_DOT11_MODE_11b;
2378 eBand = eCSR_BAND_24;
2379 }
2380 else
2381 {
2382 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002383 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 newPhyMode = eCSR_DOT11_MODE_AUTO;
2385 }
2386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 //Done validating
2388 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 //Now we need to check whether a restart is needed.
2390 if(eBand != pMac->roam.configParam.eBand)
2391 {
2392 fRestartNeeded = eANI_BOOLEAN_TRUE;
2393 break;
2394 }
2395 if(newPhyMode != pMac->roam.configParam.phyMode)
2396 {
2397 fRestartNeeded = eANI_BOOLEAN_TRUE;
2398 break;
2399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 if(HAL_STATUS_SUCCESS(status))
2402 {
2403 pMac->roam.configParam.eBand = eBand;
2404 pMac->roam.configParam.phyMode = newPhyMode;
2405 if(pfRestartNeeded)
2406 {
2407 *pfRestartNeeded = fRestartNeeded;
2408 }
2409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 return (status);
2411}
2412
Jeff Johnson295189b2012-06-20 16:38:30 -07002413void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2414{
2415 tANI_U8 Index;
2416 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 // for dual band NICs, don't need to trim the channel list....
2418 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2419 {
2420 // 2.4 GHz band operation requires the channel list to be trimmed to
2421 // the 2.4 GHz channels only...
2422 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2423 {
2424 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2425 Index++ )
2426 {
2427 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2428 {
2429 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2430 cChannels++;
2431 }
2432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2434 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2435 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2436 // only if we need to.
2437 //
2438 // The amount of memory to clear is the number of channesl that we trimmed
2439 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2440
2441 if ( pChannelList->numChannels > cChannels )
2442 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302443 vos_mem_set(&pChannelList->channelList[ cChannels ],
2444 sizeof( pChannelList->channelList[ 0 ] ) *
2445 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447
2448 pChannelList->numChannels = cChannels;
2449 }
2450 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2451 {
2452 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2453 {
2454 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2455 {
2456 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2457 cChannels++;
2458 }
2459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2461 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2462 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2463 // only if we need to.
2464 //
2465 // The amount of memory to clear is the number of channesl that we trimmed
2466 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2467 if ( pChannelList->numChannels > cChannels )
2468 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302469 vos_mem_set(&pChannelList->channelList[ cChannels ],
2470 sizeof( pChannelList->channelList[ 0 ] ) *
2471 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 }
2473
2474 pChannelList->numChannels = cChannels;
2475 }
2476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002477}
Jeff Johnson295189b2012-06-20 16:38:30 -07002478#define INFRA_AP_DEFAULT_CHANNEL 6
2479eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2480{
2481 tANI_U8 index= 0;
2482 eHalStatus status = eHAL_STATUS_FAILURE;
2483 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2484 {
2485 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2486 status = eHAL_STATUS_SUCCESS;
2487 break;
2488 }
2489 }
2490 return status;
2491}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002492
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002493
Jeff Johnson295189b2012-06-20 16:38:30 -07002494eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2495{
2496 eHalStatus status = eHAL_STATUS_SUCCESS;
2497 tANI_U8 num20MHzChannelsFound = 0;
2498 VOS_STATUS vosStatus;
2499 tANI_U8 Index = 0;
2500 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002501
Jeff Johnson295189b2012-06-20 16:38:30 -07002502
2503 //TODO: this interface changed to include the 40MHz channel list
2504 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2505 // Read the scan channel list (including the power limit) from EEPROM
2506 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2507 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2508 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002510 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 status = eHAL_STATUS_FAILURE;
2512 }
2513 else
2514 {
2515 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2516 {
2517 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2518 }
2519 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2520 // Move the channel list to the global data
2521 // structure -- this will be used as the scan list
2522 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2523 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 }
2526 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2527 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2528 {
2529 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2530 }
2531 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2532 {
2533 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2534 }
2535 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 return (status);
2538}
Jeff Johnson295189b2012-06-20 16:38:30 -07002539eHalStatus csrInitChannelList( tHalHandle hHal )
2540{
2541 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2542 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2544 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002545 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2546 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002548 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302549 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 return (status);
2551}
Jeff Johnson295189b2012-06-20 16:38:30 -07002552eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2553 tCsrUpdateConfigParam *pUpdateConfigParam)
2554{
2555 eHalStatus status = eHAL_STATUS_FAILURE;
2556 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2558 status = CsrInit11dInfo(pMac, ps11dinfo);
2559 return status;
2560}
2561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2563{
2564 eHalStatus status = eHAL_STATUS_FAILURE;
2565 tANI_U8 index;
2566 tANI_U32 count=0;
2567 tSirMacChanInfo *pChanInfo;
2568 tSirMacChanInfo *pChanInfoStart;
2569 tANI_BOOLEAN applyConfig = TRUE;
2570
Mihir Shetebc866f62014-02-13 16:08:53 +05302571 pMac->scan.currentCountryRSSI = -128;
2572
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 if(!ps11dinfo)
2574 {
2575 return (status);
2576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2578 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302579 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2580 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2581 ps11dinfo->Channels.channelList,
2582 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 }
2584 else
2585 {
2586 //No change
2587 return (eHAL_STATUS_SUCCESS);
2588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302590
2591 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2592 WNI_CFG_COUNTRY_CODE_LEN);
2593
2594
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 //Tush: at csropen get this initialized with default, during csr reset if this
2596 // already set with some value no need initilaize with default again
2597 if(0 == pMac->scan.countryCodeCurrent[0])
2598 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302599 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2600 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302603 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2604 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302606 vos_mem_set(pChanInfo,
2607 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2608 0);
2609
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002611 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2612 {
2613 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2614 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2615 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2616 pChanInfo++;
2617 count++;
2618 }
2619 if(count)
2620 {
2621 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2622 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302623 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002624 }
2625 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2626 if( HAL_STATUS_SUCCESS(status) )
2627 {
2628 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2629 {
2630 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2631 {
2632 applyConfig = FALSE;
2633 }
2634 }
2635
2636 if(TRUE == applyConfig)
2637 {
2638 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002639 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002640 }
2641
2642 }
2643 return (status);
2644}
2645/* Initialize the Channel + Power List in the local cache and in the CFG */
2646eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2647{
2648 tANI_U8 index;
2649 tANI_U32 count=0;
2650 tSirMacChanInfo *pChanInfo;
2651 tSirMacChanInfo *pChanInfoStart;
2652
2653 if(!ps11dinfo || !pMac)
2654 {
2655 return eHAL_STATUS_FAILURE;
2656 }
2657
Kiet Lam64c1b492013-07-12 13:56:44 +05302658 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2659 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002660 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302661 vos_mem_set(pChanInfo,
2662 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2663 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002664 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002665
2666 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2667 {
2668 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2669 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2670 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2671 pChanInfo++;
2672 count++;
2673 }
2674 if(count)
2675 {
2676 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2677 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302678 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 }
2680
Jeff Johnsone7245742012-09-05 17:12:55 -07002681 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682}
2683
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302684/**
2685 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2686 * list
2687 *
2688 * @pMac: pointer to global mac
2689 * @sessionId: session id for the cmd
2690 * @pList: pending list from which cmd needs to be removed
2691 * @pCommand: cmd to be removed, can be NULL
2692 * @eRoamReason: cmd with reason to be removed
2693 *
2694 * Remove duplicate command from the pending list.
2695 *
2696 * Return: void
2697 */
2698void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2699 tANI_U32 sessionId, tDblLinkList *pList,
2700 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002701{
2702 tListElem *pEntry, *pNextEntry;
2703 tSmeCmd *pDupCommand;
2704 tDblLinkList localList;
2705
2706 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302707 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302709 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 return;
2711 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302712 csrLLLock(pList);
2713 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2714 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302716 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2717 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2718 /*
2719 * Remove the previous command if..
2720 * - the new roam command is for the same RoamReason...
2721 * - the new roam command is a NewProfileList.
2722 * - the new roam command is a Forced Dissoc
2723 * - the new roam command is from an 802.11 OID
2724 * (OID_SSID or OID_BSSID).
2725 */
2726 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2727 ((pCommand->command == pDupCommand->command) &&
2728 /*
2729 * This peermac check is requried for Softap/GO scenarios
2730 * For STA scenario below OR check will suffice as pCommand
2731 * will always be NULL for STA scenarios
2732 */
2733 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2734 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2735 ((pCommand->u.roamCmd.roamReason ==
2736 pDupCommand->u.roamCmd.roamReason) ||
2737 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2738 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2739 /* OR if pCommand is NULL */
2740 ((sessionId == pDupCommand->sessionId) &&
2741 (eSmeCommandRoam == pDupCommand->command) &&
2742 ((eCsrForcedDisassoc == eRoamReason) ||
2743 (eCsrHddIssued == eRoamReason))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302745 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2746 pDupCommand->u.roamCmd.roamReason);
2747 /* Remove the 'stale' roam command from the pending list */
2748 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 }
2751 pEntry = pNextEntry;
2752 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302753 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002754
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302755 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 {
2757 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302758 /* Tell caller that the command is cancelled */
2759 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2760 pDupCommand->u.roamCmd.roamId,
2761 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 csrReleaseCommandRoam(pMac, pDupCommand);
2763 }
2764 csrLLClose(&localList);
2765}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302766
2767/**
2768 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2769 * from pending lists.
2770 *
2771 * @pMac: pointer to global mac
2772 * @sessionId: session id for the cmd
2773 * @pCommand: cmd to be removed, can be null
2774 * @eRoamReason: cmd with reason to be removed
2775 *
2776 * Remove duplicate command from the sme and roam pending list.
2777 *
2778 * Return: void
2779 */
2780void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2781 tANI_U32 sessionId, tSmeCmd *pCommand,
2782 eCsrRoamReason eRoamReason)
2783{
2784 /* Always lock active list before locking pending lists */
2785 csrLLLock(&pMac->sme.smeCmdActiveList);
2786 csr_roam_remove_duplicate_cmd_from_list(pMac,
2787 sessionId, &pMac->sme.smeCmdPendingList,
2788 pCommand, eRoamReason);
2789 csr_roam_remove_duplicate_cmd_from_list(pMac,
2790 sessionId, &pMac->roam.roamCmdPendingList,
2791 pCommand, eRoamReason);
2792 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2793}
2794
Jeff Johnson295189b2012-06-20 16:38:30 -07002795eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2796 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2797{
2798 eHalStatus status = eHAL_STATUS_SUCCESS;
2799#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2800 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2801#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302802 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2804 {
2805 pSession = CSR_GET_SESSION( pMac, sessionId );
2806 }
2807 else
2808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002809 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 VOS_ASSERT(0);
2811 return eHAL_STATUS_FAILURE;
2812 }
krunal soni587bf012014-02-04 12:35:11 -08002813
2814 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2815 {
2816 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2817 return eHAL_STATUS_FAILURE;
2818 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002819
krunal soni587bf012014-02-04 12:35:11 -08002820 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2821
krunal soni7f7d2c92014-02-06 15:08:43 -08002822 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002824 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002826 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2827 /*
2828 * Decrement bRefAssocStartCnt for FT reassoc failure.
2829 * Reason: For FT reassoc failures, we first call
2830 * csrRoamCallCallback before notifying a failed roam
2831 * completion through csrRoamComplete. The latter in
2832 * turn calls csrRoamProcessResults which tries to
2833 * once again call csrRoamCallCallback if bRefAssocStartCnt
2834 * is non-zero. Since this is redundant for FT reassoc
2835 * failure, decrement bRefAssocStartCnt.
2836 */
2837 pSession->bRefAssocStartCnt--;
2838 }
2839
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 if(NULL != pSession->callback)
2841 {
2842 if( pRoamInfo )
2843 {
2844 pRoamInfo->sessionId = (tANI_U8)sessionId;
2845 }
2846
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302847 /* avoid holding the global lock when making the roaming callback, original change came
2848 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2849 is possible on other OS ports where the callback may need to take locks to protect
2850 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2852 that may actually depend on the lock being held */
2853 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2854 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2855 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2856 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302857 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2858 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002859#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302860 vos_mem_set(&connectionStatus,
2861 sizeof(vos_event_wlan_status_payload_type), 0);
2862
krunal soni7f7d2c92014-02-06 15:08:43 -08002863 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 {
2865 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2866 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2867 if(NULL != pRoamInfo->pBssDesc)
2868 {
2869 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2870 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2873 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2874 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302875 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302876 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2877 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302878
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302880 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2883 {
2884 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2885 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302886 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 if(eCSR_ROAM_RESULT_FORCED == u2)
2889 {
2890 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2891 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302892 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2895 {
2896 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2897 connectionStatus.reason = eCSR_REASON_DISASSOC;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302898 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2901 {
2902 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2903 connectionStatus.reason = eCSR_REASON_DEAUTH;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302904 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002906#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2907
2908 return (status);
2909}
Jeff Johnson295189b2012-06-20 16:38:30 -07002910// Returns whether handoff is currently in progress or not
2911tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2912{
2913#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2914 return csrNeighborRoamIsHandoffInProgress(pMac);
2915#else
2916 return eANI_BOOLEAN_FALSE;
2917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002918}
Jeff Johnson295189b2012-06-20 16:38:30 -07002919eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2920 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2921{
2922 eHalStatus status = eHAL_STATUS_SUCCESS;
2923 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2924 tANI_U16 reasonCode;
2925 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002926
2927 if(!pSession)
2928 {
2929 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2930 return eHAL_STATUS_FAILURE;
2931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002932
2933 //Restore AC weight in case we change it
2934 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2935 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002936 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 -07002937 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2938 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2939 }
2940
2941 if ( fMICFailure )
2942 {
2943 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2944 }
2945 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2946 {
2947 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002948 }
2949 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 {
2951 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002953#ifdef WLAN_FEATURE_VOWIFI_11R
2954 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2955 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2956 {
2957 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302958 vos_mem_copy(&bssId,
2959 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2960 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002961 }
2962 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002963#endif
2964 if(pSession->pConnectBssDesc)
2965 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302966 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002968
Jeff Johnson295189b2012-06-20 16:38:30 -07002969
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302970 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2971 " subState = %s reason=%d"),
2972 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2973 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002974
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2976
2977 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2978
2979 if(HAL_STATUS_SUCCESS(status))
2980 {
2981 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002982#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2983 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2984 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2985 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002986 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2988 }
2989#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002990 }
2991 else
2992 {
2993 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2994 }
2995
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 return (status);
2997}
Jeff Johnson295189b2012-06-20 16:38:30 -07002998
Jeff Johnson295189b2012-06-20 16:38:30 -07002999/* ---------------------------------------------------------------------------
3000 \fn csrRoamIssueDisassociateStaCmd
3001 \brief csr function that HDD calls to disassociate a associated station
3002 \param sessionId - session Id for Soft AP
3003 \param pPeerMacAddr - MAC of associated station to delete
3004 \param reason - reason code, be one of the tSirMacReasonCodes
3005 \return eHalStatus
3006 ---------------------------------------------------------------------------*/
3007eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303008 tANI_U32 sessionId,
3009#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3010 const tANI_U8 *pPeerMacAddr,
3011#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303013#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 tANI_U32 reason)
3015{
3016 eHalStatus status = eHAL_STATUS_SUCCESS;
3017 tSmeCmd *pCommand;
3018
3019 do
3020 {
3021 pCommand = csrGetCommandBuffer( pMac );
3022 if ( !pCommand )
3023 {
3024 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3025 status = eHAL_STATUS_RESOURCES;
3026 break;
3027 }
3028 pCommand->command = eSmeCommandRoam;
3029 pCommand->sessionId = (tANI_U8)sessionId;
3030 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
3031 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
3032 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
3033 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3034 if( !HAL_STATUS_SUCCESS( status ) )
3035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003036 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 csrReleaseCommandRoam( pMac, pCommand );
3038 }
3039 }while(0);
3040
3041 return status;
3042}
3043
3044
Jeff Johnson295189b2012-06-20 16:38:30 -07003045/* ---------------------------------------------------------------------------
3046 \fn csrRoamIssueDeauthSta
3047 \brief csr function that HDD calls to delete a associated station
3048 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303049 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 \return eHalStatus
3051 ---------------------------------------------------------------------------*/
3052eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303053 tANI_U32 sessionId,
3054 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003055{
3056 eHalStatus status = eHAL_STATUS_SUCCESS;
3057 tSmeCmd *pCommand;
3058
3059 do
3060 {
3061 pCommand = csrGetCommandBuffer( pMac );
3062 if ( !pCommand )
3063 {
3064 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3065 status = eHAL_STATUS_RESOURCES;
3066 break;
3067 }
3068 pCommand->command = eSmeCommandRoam;
3069 pCommand->sessionId = (tANI_U8)sessionId;
3070 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303071 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3072 sizeof(tSirMacAddr));
3073 pCommand->u.roamCmd.reason =
3074 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3076 if( !HAL_STATUS_SUCCESS( status ) )
3077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003078 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 csrReleaseCommandRoam( pMac, pCommand );
3080 }
3081 }while(0);
3082
3083 return status;
3084}
Jeff Johnson295189b2012-06-20 16:38:30 -07003085eHalStatus
3086csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3087 tANI_BOOLEAN bEnable )
3088{
3089 eHalStatus status = eHAL_STATUS_FAILURE;
3090 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3091 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 if (!pSession)
3093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003094 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 return (status);
3096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 if (pSession->pConnectBssDesc)
3098 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303099 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 }
3101 else
3102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003103 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 return (status);
3105 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003106 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3107 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3109 return (status);
3110}
Jeff Johnson295189b2012-06-20 16:38:30 -07003111eHalStatus
3112csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3113 VOS_MODULE_ID modId, void *pUsrContext,
3114 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3115{
3116 eHalStatus status = eHAL_STATUS_SUCCESS;
3117 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3118 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 if (!pSession)
3120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003121 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 return (status);
3123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 if(pSession->pConnectBssDesc)
3125 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303126 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 }
3128 else
3129 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003130 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 return (status);
3132 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003133 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3134 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3136 return (status);
3137}
Jeff Johnson295189b2012-06-20 16:38:30 -07003138eHalStatus
3139csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3140 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3141{
3142 eHalStatus status = eHAL_STATUS_SUCCESS;
3143 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3144 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3145
3146 if (!pSession)
3147 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003148 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 return (status);
3150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 if(pSession->pConnectBssDesc)
3152 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303153 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 }
3155 else
3156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003157 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 return (status);
3159 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003160 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3161 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003162
3163 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3164
3165 return (status);
3166}
Jeff Johnson295189b2012-06-20 16:38:30 -07003167eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3168{
3169 eHalStatus status = eHAL_STATUS_SUCCESS;
3170 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3171 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003172
3173 if (!pSession)
3174 {
3175 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3176 return eHAL_STATUS_FAILURE;
3177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003178
3179 if(pSession->pConnectBssDesc)
3180 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303181 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003183 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3184 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3186
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303187 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303188 if(HAL_STATUS_SUCCESS(status))
3189 {
3190 csrRoamLinkDown(pMac, sessionId);
3191 }
3192 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003193 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303194 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3195 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003196 }
3197
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 return (status);
3199}
3200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3202{
3203 eHalStatus status = eHAL_STATUS_SUCCESS;
3204 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3205 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003206
3207 if(!pSession)
3208 {
3209 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3210 return eHAL_STATUS_FAILURE;
3211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003212
3213 // If no BSS description was found in this connection (happens with start IBSS), then
3214 // nix the BSS description that we keep around for the connected BSS) and get out...
3215 if(NULL == pBssDesc)
3216 {
3217 csrFreeConnectBssDesc(pMac, sessionId);
3218 }
3219 else
3220 {
3221 size = pBssDesc->length + sizeof( pBssDesc->length );
3222 if(NULL != pSession->pConnectBssDesc)
3223 {
3224 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3225 {
3226 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3227 csrFreeConnectBssDesc(pMac, sessionId);
3228 }
3229 }
3230 if(NULL == pSession->pConnectBssDesc)
3231 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303232 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303234 if (NULL == pSession->pConnectBssDesc)
3235 status = eHAL_STATUS_FAILURE;
3236 else
3237 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 return (status);
3240}
3241
Jeff Johnson295189b2012-06-20 16:38:30 -07003242eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3243 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3244 tDot11fBeaconIEs *pIes)
3245{
3246 eHalStatus status = eHAL_STATUS_SUCCESS;
3247 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303249 if (pIes == NULL)
3250 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003251
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 do
3253 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303254 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3255 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 //get qos
3257 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3258 //get SSID
3259 if(pIes->SSID.present)
3260 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303261 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3263 }
3264 else
3265 pBssConfig->SSID.length = 0;
3266 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003268 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 //Return failed if profile doesn't have an SSID either.
3270 if(pProfile->SSIDs.numOfSSIDs == 0)
3271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003272 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 status = eHAL_STATUS_FAILURE;
3274 break;
3275 }
3276 }
3277 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3278 {
3279 pBssConfig->eBand = eCSR_BAND_5G;
3280 }
3281 else
3282 {
3283 pBssConfig->eBand = eCSR_BAND_24;
3284 }
3285 //phymode
3286 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3287 {
3288 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3289 }
3290 else
3291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003292 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 //force it
3294 if(eCSR_BAND_24 == pBssConfig->eBand)
3295 {
3296 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3297 }
3298 else
3299 {
3300 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3301 }
3302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 //Qos
3304 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3305 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3306 {
3307 //Joining BSS is not 11n capable and WMM is disabled on client.
3308 //Disable QoS and WMM
3309 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3310 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303311
3312 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303313 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303314 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3315 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3316 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3317 {
3318 //Joining BSS is 11n capable and WMM is disabled on AP.
3319 //Assume all HT AP's are QOS AP's and enable WMM
3320 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3321 }
3322
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 //auth type
3324 switch( pProfile->negotiatedAuthType )
3325 {
3326 default:
3327 case eCSR_AUTH_TYPE_WPA:
3328 case eCSR_AUTH_TYPE_WPA_PSK:
3329 case eCSR_AUTH_TYPE_WPA_NONE:
3330 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3331 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3332 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 case eCSR_AUTH_TYPE_SHARED_KEY:
3334 pBssConfig->authType = eSIR_SHARED_KEY;
3335 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 case eCSR_AUTH_TYPE_AUTOSWITCH:
3337 pBssConfig->authType = eSIR_AUTO_SWITCH;
3338 break;
3339 }
3340 //short slot time
3341 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3342 {
3343 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3344 }
3345 else
3346 {
3347 pBssConfig->uShortSlotTime = 0;
3348 }
3349 if(pBssConfig->BssCap.ibss)
3350 {
3351 //We don't support 11h on IBSS
3352 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3353 }
3354 else
3355 {
3356 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3357 }
3358 //power constraint
3359 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3360 //heartbeat
3361 if ( CSR_IS_11A_BSS( pBssDesc ) )
3362 {
3363 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3364 }
3365 else
3366 {
3367 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3368 }
3369 //Join timeout
3370 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003371 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 if ( pBssDesc->beaconInterval )
3373 {
3374 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003375 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 }
3377 else
3378 {
3379 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3380 }
3381 //validate CB
3382 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303383 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3384 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 return (status);
3387}
3388
Jeff Johnson295189b2012-06-20 16:38:30 -07003389static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3390 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3391{
3392 eHalStatus status = eHAL_STATUS_SUCCESS;
3393 tANI_U8 operationChannel = 0;
3394 tANI_U8 qAPisEnabled = FALSE;
3395 //SSID
3396 pBssConfig->SSID.length = 0;
3397 if(pProfile->SSIDs.numOfSSIDs)
3398 {
3399 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303400 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3401 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 }
3403 else
3404 {
3405 //SSID must present
3406 return eHAL_STATUS_FAILURE;
3407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 //Settomg up the capabilities
3409 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3410 {
3411 pBssConfig->BssCap.ibss = 1;
3412 }
3413 else
3414 {
3415 pBssConfig->BssCap.ess = 1;
3416 }
3417 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3418 {
3419 pBssConfig->BssCap.privacy = 1;
3420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 pBssConfig->eBand = pMac->roam.configParam.eBand;
3422 //phymode
3423 if(pProfile->ChannelInfo.ChannelList)
3424 {
3425 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3428 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 //QOS
3430 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 if ( pBssConfig->BssCap.ess == 1 )
3432 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 /*For Softap case enable WMM*/
3434 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3435 qAPisEnabled = TRUE;
3436 }
3437 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3439 qAPisEnabled = TRUE;
3440 } else {
3441 qAPisEnabled = FALSE;
3442 }
3443 } else {
3444 qAPisEnabled = TRUE;
3445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3447 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3448 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3449 )
3450 {
3451 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3452 } else {
3453 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3454 }
3455
3456 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003457 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 {
3459 default:
3460 case eCSR_AUTH_TYPE_WPA:
3461 case eCSR_AUTH_TYPE_WPA_PSK:
3462 case eCSR_AUTH_TYPE_WPA_NONE:
3463 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3464 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3465 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 case eCSR_AUTH_TYPE_SHARED_KEY:
3467 pBssConfig->authType = eSIR_SHARED_KEY;
3468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 case eCSR_AUTH_TYPE_AUTOSWITCH:
3470 pBssConfig->authType = eSIR_AUTO_SWITCH;
3471 break;
3472 }
3473 //short slot time
3474 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3475 {
3476 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3477 }
3478 else
3479 {
3480 pBssConfig->uShortSlotTime = 0;
3481 }
3482 //power constraint. We don't support 11h on IBSS
3483 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3484 pBssConfig->uPowerLimit = 0;
3485 //heartbeat
3486 if ( eCSR_BAND_5G == pBssConfig->eBand )
3487 {
3488 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3489 }
3490 else
3491 {
3492 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3493 }
3494 //Join timeout
3495 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003496
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 return (status);
3498}
Jeff Johnson295189b2012-06-20 16:38:30 -07003499static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3500{
3501 eHalStatus status = eHAL_STATUS_FAILURE;
3502 tDot11fBeaconIEs *pIes = NULL;
3503
3504 do
3505 {
3506 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3507 {
3508 //err msg
3509 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003510 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 break;
3512 }
3513 //check if the AP is QAP & it supports APSD
3514 if( CSR_IS_QOS_BSS(pIes) )
3515 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303516 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 }
3518 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303519
3520 if (NULL != pIes)
3521 {
3522 vos_mem_free(pIes);
3523 }
3524
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 return status;
3526}
3527
Jeff Johnson295189b2012-06-20 16:38:30 -07003528void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3529{
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3531 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3532 // See !!Note: below in this function...
3533 tANI_U32 PrivacyEnabled = 0;
3534 tANI_U32 RsnEnabled = 0;
3535 tANI_U32 WepDefaultKeyId = 0;
3536 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3537 tANI_U32 Key0Length = 0;
3538 tANI_U32 Key1Length = 0;
3539 tANI_U32 Key2Length = 0;
3540 tANI_U32 Key3Length = 0;
3541
3542 // Reserve for the biggest key
3543 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3544 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3545 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3546 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3547
3548 switch ( pProfile->negotiatedUCEncryptionType )
3549 {
3550 case eCSR_ENCRYPT_TYPE_NONE:
3551
3552 // for NO encryption, turn off Privacy and Rsn.
3553 PrivacyEnabled = 0;
3554 RsnEnabled = 0;
3555
3556 // WEP key length and Wep Default Key ID don't matter in this case....
3557
3558 // clear out the WEP keys that may be hanging around.
3559 Key0Length = 0;
3560 Key1Length = 0;
3561 Key2Length = 0;
3562 Key3Length = 0;
3563
3564 break;
3565
3566 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303567 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003568
3569 // Privacy is ON. NO RSN for Wep40 static key.
3570 PrivacyEnabled = 1;
3571 RsnEnabled = 0;
3572
3573 // Set the Wep default key ID.
3574 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 // Wep key size if 5 bytes (40 bits).
3576 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3577
3578 // set encryption keys in the CFG database or clear those that are not present in this profile.
3579 if ( pProfile->Keys.KeyLength[0] )
3580 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303581 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3582 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3584 }
3585 else
3586 {
3587 Key0Length = 0;
3588 }
3589
3590 if ( pProfile->Keys.KeyLength[1] )
3591 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303592 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3593 WNI_CFG_WEP_KEY_LENGTH_5);
3594 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 }
3596 else
3597 {
3598 Key1Length = 0;
3599 }
3600
3601 if ( pProfile->Keys.KeyLength[2] )
3602 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303603 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3604 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3606 }
3607 else
3608 {
3609 Key2Length = 0;
3610 }
3611
3612 if ( pProfile->Keys.KeyLength[3] )
3613 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303614 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3615 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3617 }
3618 else
3619 {
3620 Key3Length = 0;
3621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 break;
3623
3624 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303625 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003626
3627 // Privacy is ON. NO RSN for Wep40 static key.
3628 PrivacyEnabled = 1;
3629 RsnEnabled = 0;
3630
3631 // Set the Wep default key ID.
3632 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3633
3634 // Wep key size if 13 bytes (104 bits).
3635 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3636
3637 // set encryption keys in the CFG database or clear those that are not present in this profile.
3638 if ( pProfile->Keys.KeyLength[0] )
3639 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303640 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3641 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3643 }
3644 else
3645 {
3646 Key0Length = 0;
3647 }
3648
3649 if ( pProfile->Keys.KeyLength[1] )
3650 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303651 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3652 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3654 }
3655 else
3656 {
3657 Key1Length = 0;
3658 }
3659
3660 if ( pProfile->Keys.KeyLength[2] )
3661 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303662 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3663 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3665 }
3666 else
3667 {
3668 Key2Length = 0;
3669 }
3670
3671 if ( pProfile->Keys.KeyLength[3] )
3672 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303673 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3674 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3676 }
3677 else
3678 {
3679 Key3Length = 0;
3680 }
3681
3682 break;
3683
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 case eCSR_ENCRYPT_TYPE_TKIP:
3685 case eCSR_ENCRYPT_TYPE_AES:
3686#ifdef FEATURE_WLAN_WAPI
3687 case eCSR_ENCRYPT_TYPE_WPI:
3688#endif /* FEATURE_WLAN_WAPI */
3689 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3690 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3691 PrivacyEnabled = (0 != fPrivacy);
3692
3693 // turn on RSN enabled for WPA associations
3694 RsnEnabled = 1;
3695
3696 // WEP key length and Wep Default Key ID don't matter in this case....
3697
3698 // clear out the static WEP keys that may be hanging around.
3699 Key0Length = 0;
3700 Key1Length = 0;
3701 Key2Length = 0;
3702 Key3Length = 0;
3703
3704 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 default:
3706 PrivacyEnabled = 0;
3707 RsnEnabled = 0;
3708 break;
3709 }
3710
3711 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3712 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3713 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3714 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3715 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3716 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3717 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3718 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3719}
3720
Jeff Johnson295189b2012-06-20 16:38:30 -07003721static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3722{
3723 tANI_U32 len = 0;
3724 if(pSSID->length <= WNI_CFG_SSID_LEN)
3725 {
3726 len = pSSID->length;
3727 }
3728 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3729}
3730
Jeff Johnson295189b2012-06-20 16:38:30 -07003731eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3732{
3733 eHalStatus status = eHAL_STATUS_SUCCESS;
3734 tANI_U32 QoSEnabled;
3735 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 // set the CFG enable/disable variables based on the qosType being configured...
3737 switch( qosType )
3738 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3740 QoSEnabled = FALSE;
3741 WmeEnabled = TRUE;
3742 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3744 QoSEnabled = FALSE;
3745 WmeEnabled = TRUE;
3746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3748 QoSEnabled = FALSE;
3749 WmeEnabled = TRUE;
3750 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3752 QoSEnabled = TRUE;
3753 WmeEnabled = FALSE;
3754 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 case eCSR_MEDIUM_ACCESS_11e_HCF:
3756 QoSEnabled = TRUE;
3757 WmeEnabled = FALSE;
3758 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 default:
3760 case eCSR_MEDIUM_ACCESS_DCF:
3761 QoSEnabled = FALSE;
3762 WmeEnabled = FALSE;
3763 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
3765 //save the WMM setting for later use
3766 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303767 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 return (status);
3769}
Jeff Johnson295189b2012-06-20 16:38:30 -07003770static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303771 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003772{
3773 eHalStatus status = eHAL_STATUS_FAILURE;
3774 int i;
3775 eCsrCfgDot11Mode cfgDot11Mode;
3776 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303777 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303778 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3779 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003781
3782 if( NULL != pIes )
3783 {
3784 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 // Originally, we thought that for 11a networks, the 11a rates are always
3786 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3787 // appear in the Operational Rate set. Consequently, in either case, we
3788 // would blindly put the rates we support into our Operational Rate set
3789 // (including the basic rates, which we have already verified are
3790 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 // However, it turns out that this is not always the case. Some AP's
3792 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3793 // too. Now, we're a little more careful:
3794 pDstRate = pOpRateSet->rate;
3795 if(pIes->SuppRates.present)
3796 {
3797 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3798 {
3799 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3800 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003801 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3802 {
3803 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3804 *pDstRate++ = pIes->SuppRates.rates[ i ];
3805 pOpRateSet->numRates++;
3806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 }
3808 }
3809 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303810 /* If there are Extended Rates in the beacon, we will reflect those
3811 * extended rates that we support in out Extended Operational Rate
3812 * set*/
3813 pDstRate = pExRateSet->rate;
3814 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303816 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303818 if (csrRatesIsDot11RateSupported(pMac,
3819 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303821 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3822 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303824 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3825 &rateBitmap);
3826 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3827 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 }
3829 }
3830 }
3831 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303832 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 }//Parsing BSSDesc
3834 else
3835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003836 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 }
3838 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3839 return status;
3840}
3841
3842static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3843 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3844{
3845 int i;
3846 tANI_U8 *pDstRate;
3847 eCsrCfgDot11Mode cfgDot11Mode;
3848 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3849 tANI_U32 OperationalRatesLength = 0;
3850 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3851 tANI_U32 ExtendedOperationalRatesLength = 0;
3852 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3853 tANI_U32 ProprietaryOperationalRatesLength = 0;
3854 tANI_U32 PropRatesEnable = 0;
3855 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3856 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 if( NULL != pIes )
3859 {
3860 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 // Originally, we thought that for 11a networks, the 11a rates are always
3862 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3863 // appear in the Operational Rate set. Consequently, in either case, we
3864 // would blindly put the rates we support into our Operational Rate set
3865 // (including the basic rates, which we have already verified are
3866 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 // However, it turns out that this is not always the case. Some AP's
3868 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3869 // too. Now, we're a little more careful:
3870 pDstRate = OperationalRates;
3871 if(pIes->SuppRates.present)
3872 {
3873 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3874 {
3875 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3876 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3877 {
3878 *pDstRate++ = pIes->SuppRates.rates[ i ];
3879 OperationalRatesLength++;
3880 }
3881 }
3882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3884 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3885 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3886 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3887 {
3888 // If there are Extended Rates in the beacon, we will reflect those
3889 // extended rates that we support in out Extended Operational Rate
3890 // set:
3891 pDstRate = ExtendedOperationalRates;
3892 if(pIes->ExtSuppRates.present)
3893 {
3894 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3895 {
3896 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3897 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3898 {
3899 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3900 ExtendedOperationalRatesLength++;
3901 }
3902 }
3903 }
3904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 // Enable proprietary MAC features if peer node is Airgo node and STA
3906 // user wants to use them
3907 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3908 {
3909 PropRatesEnable = 1;
3910 }
3911 else
3912 {
3913 PropRatesEnable = 0;
3914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 // For ANI network companions, we need to populate the proprietary rate
3916 // set with any proprietary rates we found in the beacon, only if user
3917 // allows them...
3918 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3919 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3920 {
3921 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3922 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3923 {
3924 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3925 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303926 vos_mem_copy(ProprietaryOperationalRates,
3927 pIes->Airgo.PropSuppRates.rates,
3928 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 }
3930 else {
3931 // No proprietary modes...
3932 ProprietaryOperationalRatesLength = 0;
3933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 /* Get MCS Rate */
3935 pDstRate = MCSRateIdxSet;
3936 if ( pIes->HTCaps.present )
3937 {
3938 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3939 {
3940 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3941 {
3942 MCSRateLength++;
3943 *pDstRate++ = i;
3944 }
3945 }
3946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 // Set the operational rate set CFG variables...
3948 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3949 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3950 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3951 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3952 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3953 ProprietaryOperationalRates,
3954 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3955 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3956 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3957 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3958 }//Parsing BSSDesc
3959 else
3960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003961 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 }
3963}
3964
Jeff Johnson295189b2012-06-20 16:38:30 -07003965static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3966 tCsrRoamProfile *pProfile )
3967{
3968 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3969 { 8,
3970 { SIR_MAC_RATE_6,
3971 SIR_MAC_RATE_9,
3972 SIR_MAC_RATE_12,
3973 SIR_MAC_RATE_18,
3974 SIR_MAC_RATE_24,
3975 SIR_MAC_RATE_36,
3976 SIR_MAC_RATE_48,
3977 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3979 { 4,
3980 { SIR_MAC_RATE_1,
3981 SIR_MAC_RATE_2,
3982 SIR_MAC_RATE_5_5,
3983 SIR_MAC_RATE_11 } } };
3984
3985
3986 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3987 { SIR_MAC_RATE_72,
3988 SIR_MAC_RATE_96,
3989 SIR_MAC_RATE_108 } };
3990 eCsrCfgDot11Mode cfgDot11Mode;
3991 eCsrBand eBand;
3992 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3993 tANI_U32 OperationalRatesLength = 0;
3994 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3995 tANI_U32 ExtendedOperationalRatesLength = 0;
3996 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3997 tANI_U32 ProprietaryOperationalRatesLength = 0;
3998 tANI_U32 PropRatesEnable = 0;
3999 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 if(pProfile->ChannelInfo.ChannelList)
4001 {
4002 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4006 // networks, the 11b rates appear in the Operational Rate set. In either case,
4007 // we can blindly put the rates we support into our Operational Rate set
4008 // (including the basic rates, which we have already verified are supported
4009 // earlier in the roaming decision).
4010 if ( eCSR_BAND_5G == eBand )
4011 {
4012 // 11a rates into the Operational Rate Set.
4013 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4014 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304015 vos_mem_copy(OperationalRates,
4016 DefaultSupportedRates11a.supportedRateSet.rate,
4017 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004018
4019 // Nothing in the Extended rate set.
4020 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 // populate proprietary rates if user allows them
4022 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4023 {
4024 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4025 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304026 vos_mem_copy(ProprietaryOperationalRates,
4027 DefaultSupportedPropRates.propRate,
4028 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 }
4030 else
4031 {
4032 // No proprietary modes
4033 ProprietaryOperationalRatesLength = 0;
4034 }
4035 }
4036 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4037 {
4038 // 11b rates into the Operational Rate Set.
4039 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4040 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304041 vos_mem_copy(OperationalRates,
4042 DefaultSupportedRates11b.supportedRateSet.rate,
4043 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 // Nothing in the Extended rate set.
4045 ExtendedOperationalRatesLength = 0;
4046 // No proprietary modes
4047 ProprietaryOperationalRatesLength = 0;
4048 }
4049 else
4050 {
4051 // 11G
4052
4053 // 11b rates into the Operational Rate Set.
4054 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4055 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304056 vos_mem_copy(OperationalRates,
4057 DefaultSupportedRates11b.supportedRateSet.rate,
4058 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004059
4060 // 11a rates go in the Extended rate set.
4061 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4062 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304063 vos_mem_copy(ExtendedOperationalRates,
4064 DefaultSupportedRates11a.supportedRateSet.rate,
4065 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004066
4067 // populate proprietary rates if user allows them
4068 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4069 {
4070 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4071 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304072 vos_mem_copy(ProprietaryOperationalRates,
4073 DefaultSupportedPropRates.propRate,
4074 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 }
4076 else
4077 {
4078 // No proprietary modes
4079 ProprietaryOperationalRatesLength = 0;
4080 }
4081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4083 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4084 {
4085 PropRatesEnable = 1;
4086 }
4087 else
4088 {
4089 PropRatesEnable = 0;
4090 }
4091
4092 // Set the operational rate set CFG variables...
4093 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4094 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4095 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4096 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4097 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4098 ProprietaryOperationalRates,
4099 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4100 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101}
Jeff Johnson295189b2012-06-20 16:38:30 -07004102void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4103{
4104 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4107 tANI_U32 sessionId;
4108 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 if(NULL == pEntry)
4110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004111 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 return;
4113 }
4114 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4115 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304116 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4117 " current state : %d sub state : %d "),
4118 result, pMac->roam.curState[sessionId],
4119 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4121 {
4122 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4123 }
4124}
4125
Jeff Johnson295189b2012-06-20 16:38:30 -07004126//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4127tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4128{
4129 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4130 {
4131 return (WNI_CFG_PHY_MODE_11B);
4132 }
4133 else
4134 {
4135 if(eCSR_BAND_24 == band)
4136 return (WNI_CFG_PHY_MODE_11G);
4137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 return (WNI_CFG_PHY_MODE_11A);
4139}
Jeff Johnson295189b2012-06-20 16:38:30 -07004140
Jeff Johnsone7245742012-09-05 17:12:55 -07004141
4142#ifdef WLAN_FEATURE_11AC
4143ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4144{
4145 switch ( aniCBMode )
4146 {
4147 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4148 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4149 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4150 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4151 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4152 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4153 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4154 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4155 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004156 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004157 return PHY_SINGLE_CHANNEL_CENTERED;
4158 }
4159}
4160#endif
4161
Jeff Johnson295189b2012-06-20 16:38:30 -07004162//pIes may be NULL
4163eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4164 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304165 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004166{
4167 eHalStatus status = eHAL_STATUS_SUCCESS;
4168 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4169 tANI_U8 channel = 0;
4170 //Make sure we have the domain info for the BSS we try to connect to.
4171 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304172 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304174 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 {
4176 //Make sure the 11d info from this BSSDesc can be applied
4177 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304178 if (VOS_TRUE == resetCountry)
4179 {
4180 csrApplyCountryInformation(pMac, FALSE);
4181 }
4182 else
4183 {
4184 csrApplyCountryInformation(pMac, TRUE);
4185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 }
Kiran4a17ebe2013-01-31 10:43:43 -08004187 if ((csrIs11dSupported (pMac)) && pIes)
4188 {
4189 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004190 {
Kiran4a17ebe2013-01-31 10:43:43 -08004191 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004192 }
4193 else
4194 {
4195 //Let's also update the below to make sure we don't update CC while
4196 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304197 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004198 pBssDesc->bssId, sizeof(tSirMacAddr));
4199 }
Kiran4a17ebe2013-01-31 10:43:43 -08004200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 //Qos
4203 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4204 //SSID
4205 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4206 //fragment threshold
4207 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4208 //RTS threshold
4209 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4210
4211 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 //Auth type
4213 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4214 //encryption type
4215 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4216 //short slot time
4217 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 //11d
4219 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4220 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4221 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 /*//11h
4223 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4224 */
4225 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4226 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004227
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004228 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 {
4230 channel = pProfile->operationChannel;
4231 }
4232 else
4233 {
4234 if(pBssDesc)
4235 {
4236 channel = pBssDesc->channelId;
4237 }
4238 }
4239 if(0 != channel)
4240 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304241 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4242 !pMac->roam.configParam.channelBondingMode24GHz &&
4243 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4244 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304246 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4247 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4248 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 }
4250 else
4251 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004252 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 }
4254 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004255#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004256 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4257 // in function csrConvertCBIniValueToPhyCBState()
4258 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4259 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004260 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004261 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004262 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004263 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304264 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004265 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004266 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004267 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004268 }
4269 else
4270#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4272 //Rate
4273 //Fixed Rate
4274 if(pBssDesc)
4275 {
4276 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4277 }
4278 else
4279 {
4280 csrSetCfgRateSetFromProfile(pMac, pProfile);
4281 }
4282 //Make this the last CFG to set. The callback will trigger a join_req
4283 //Join time out
4284 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4285
4286 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 return (status);
4288}
4289
Jeff Johnson295189b2012-06-20 16:38:30 -07004290eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4291 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4292{
4293 eHalStatus status;
4294 tBssConfigParam *pBssConfig;
4295 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004296
4297 if(!pSession)
4298 {
4299 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4300 return eHAL_STATUS_FAILURE;
4301 }
4302
Kiet Lam64c1b492013-07-12 13:56:44 +05304303 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4304 if ( NULL == pBssConfig )
4305 status = eHAL_STATUS_FAILURE;
4306 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304308 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4310 if(HAL_STATUS_SUCCESS(status))
4311 {
4312 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004313 /* This will allow to pass cbMode during join req */
4314 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 //For IBSS, we need to prepare some more information
4316 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 )
4319 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004320 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 }
4322 // If we are in an IBSS, then stop the IBSS...
4323 ////Not worry about WDS connection for now
4324 if ( csrIsConnStateIbss( pMac, sessionId ) )
4325 {
4326 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4327 }
4328 else
4329 {
4330 // if we are in an Infrastructure association....
4331 if ( csrIsConnStateInfra( pMac, sessionId ) )
4332 {
4333 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4334 // across SSIDs (roaming to a new SSID)... //
4335 //Not worry about WDS connection for now
4336 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304337 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 {
4339 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304340 status = csrRoamIssueDisassociate( pMac, sessionId,
4341 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304343 else
4344 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4346 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304347 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304349 // Set parameters for this Bss.
4350 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4351 pBssDesc, pBssConfig,
4352 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304356 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 {
4358 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4359 // Nothing to stop.
4360 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304362 )
4363 {
4364 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4365 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4366 // Set parameters for this Bss.
4367 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4368 pBssDesc, pBssConfig,
4369 pIes, is11rRoamingFlag);
4370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 }
4372 }
4373 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304374 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 return (status);
4377}
4378
Jeff Johnson295189b2012-06-20 16:38:30 -07004379eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4380 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4381{
4382 eCsrJoinState eRoamState = eCsrContinueRoaming;
4383 eHalStatus status;
4384 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4385 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4386 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004387
4388 if(!pSession)
4389 {
4390 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4391 return (eCsrStopRoaming);
4392 }
4393
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 if( CSR_IS_WDS_STA( pProfile ) )
4395 {
4396 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4397 if( !HAL_STATUS_SUCCESS( status ) )
4398 {
4399 eRoamState = eCsrStopRoaming;
4400 }
4401 }
4402 else
4403 {
4404 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4405 {
4406 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4407 return (eCsrStopRoaming);
4408 }
4409 if ( csrIsInfraBssDesc( pBssDesc ) )
4410 {
4411 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4412 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4413 // have changed and handle the changes (without disturbing the current association).
4414
4415 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4416 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4417 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4418 )
4419 {
4420 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4421 // with Authenticating first. To force this, stop the current association (Disassociate) and
4422 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4423 // a new Association.
4424 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4425 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004426 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4428 {
4429 eRoamState = eCsrReassocToSelfNoCapChange;
4430 }
4431 else
4432 {
4433 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304435 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4437 if(HAL_STATUS_SUCCESS(status))
4438 {
4439 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004440 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304442 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4443 pBssDesc, &bssConfig,
4444 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 if(!HAL_STATUS_SUCCESS(status))
4446 {
4447 eRoamState = eCsrStopRoaming;
4448 }
4449 }
4450 else
4451 {
4452 eRoamState = eCsrStopRoaming;
4453 }
4454 }//same profile
4455 }
4456 else
4457 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304458 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4460 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304461 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4462 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304466 }
4467 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 {
4469 // 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 -07004470 // stop the existing network before attempting to join the new network...
4471 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4472 {
4473 eRoamState = eCsrStopRoaming;
4474 }
4475 }
4476 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304477 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 {
4479 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4480 {
4481 eRoamState = eCsrStopRoaming;
4482 }
4483 }
4484 if( pIesLocal && !pScanResult->pvIes )
4485 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304486 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 }
4488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 return( eRoamState );
4490}
4491
Jeff Johnson295189b2012-06-20 16:38:30 -07004492eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4493 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4494{
4495 eHalStatus status = eHAL_STATUS_SUCCESS;
4496 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304497 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 roamInfo.pBssDesc = pBssDesc;
4499 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4500 return (status);
4501}
Jeff Johnson295189b2012-06-20 16:38:30 -07004502//In case no matching BSS is found, use whatever default we can find
4503static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4504{
4505 //Need to get all negotiated types in place first
4506 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004507 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 {
4509 default:
4510 case eCSR_AUTH_TYPE_WPA:
4511 case eCSR_AUTH_TYPE_WPA_PSK:
4512 case eCSR_AUTH_TYPE_WPA_NONE:
4513 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4514 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4515 break;
4516
4517 case eCSR_AUTH_TYPE_SHARED_KEY:
4518 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4519 break;
4520
4521 case eCSR_AUTH_TYPE_AUTOSWITCH:
4522 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4523 break;
4524 }
4525 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4526 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4527 //In this case, the multicast encryption needs to follow the uncast ones.
4528 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4529 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4530}
4531
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004532
4533static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4534{
4535 switch(pCommand->u.roamCmd.roamReason)
4536 {
4537 case eCsrLostLink1:
4538 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4539 break;
4540 case eCsrLostLink2:
4541 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4542 break;
4543 case eCsrLostLink3:
4544 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4545 break;
4546 default:
4547 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4548 pCommand->u.roamCmd.roamReason);
4549 break;
4550 }
4551}
4552
Jeff Johnson295189b2012-06-20 16:38:30 -07004553static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4554{
4555 eHalStatus status;
4556 tCsrScanResult *pScanResult = NULL;
4557 eCsrJoinState eRoamState = eCsrStopRoaming;
4558 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4559 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4560 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4561#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4562 v_U8_t acm_mask = 0;
4563#endif
4564 tANI_U32 sessionId = pCommand->sessionId;
4565 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4566 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4567 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004568
4569 if(!pSession)
4570 {
4571 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4572 return (eCsrStopRoaming);
4573 }
4574
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 do
4576 {
4577 // Check for Cardbus eject condition, before trying to Roam to any BSS
4578 //***if( !balIsCardPresent(pAdapter) ) break;
4579
Kiet Lam64c1b492013-07-12 13:56:44 +05304580 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304581 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 if(NULL != pBSSList)
4583 {
4584 // When handling AP's capability change, continue to associate to
4585 // same BSS and make sure pRoamBssEntry is not Null.
4586 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4587 {
4588 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4589 {
4590 //Try the first BSS
4591 pCommand->u.roamCmd.pLastRoamBss = NULL;
4592 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4593 }
4594 else
4595 {
4596 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4597 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4598 {
4599 //Done with all the BSSs
4600 //In this case, will tell HDD the completion
4601 break;
4602 }
4603 else
4604 {
4605 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304606 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4608 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4609 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4610 pRoamInfo = &roamInfo;
4611 }
4612 }
4613 while(pCommand->u.roamCmd.pRoamBssEntry)
4614 {
4615 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 /*If concurrency enabled take the concurrent connected channel first. */
4617 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304618 if (vos_concurrent_open_sessions_running() &&
4619 !csrIsValidMcConcurrentSession(pMac, sessionId,
4620 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 {
4622 concurrentChannel =
4623 csrGetConcurrentOperationChannel(pMac);
4624 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004625 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 if ((concurrentChannel) &&
4627 (concurrentChannel ==
4628 pScanResult->Result.BssDescriptor.channelId))
4629 {
4630 //make this 0 because we do not want the
4631 //below check to pass as we don't want to
4632 //connect on other channel
4633 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4634 FL("Concurrent channel match =%d"),
4635 concurrentChannel);
4636 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 }
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639
4640 if (!concurrentChannel)
4641 {
4642
4643 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4644 sessionId, &pScanResult->Result.BssDescriptor,
4645 pCommand->u.roamCmd.roamId)))
4646 {
4647 //Ok to roam this
4648 break;
4649 }
4650 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004651 else
4652 {
4653 eRoamState = eCsrStopRoamingDueToConcurrency;
4654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4656 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4657 {
4658 //Done with all the BSSs
4659 fDone = eANI_BOOLEAN_TRUE;
4660 break;
4661 }
4662 }
4663 if(fDone)
4664 {
4665 break;
4666 }
4667 }
4668 }
4669 //We have something to roam, tell HDD when it is infra.
4670 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4671 //For WDS, the indication is eCSR_ROAM_WDS_IND
4672 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4673 {
4674 if(pRoamInfo)
4675 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004676 if(pSession->bRefAssocStartCnt)
4677 {
4678 pSession->bRefAssocStartCnt--;
4679 //Complete the last association attemp because a new one is about to be tried
4680 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4681 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004683 }
4684 }
4685 /* If the roaming has stopped, not to continue the roaming command*/
4686 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4687 {
4688 //No need to complete roaming here as it already completes
4689 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4690 pCommand->u.roamCmd.roamReason);
4691 eRoamState = eCsrStopRoaming;
4692 csrSetAbortRoamingCommand(pMac, pCommand);
4693 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304695 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 if(pScanResult)
4697 {
4698 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004701 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 fDone = eANI_BOOLEAN_TRUE;
4703 eRoamState = eCsrStopRoaming;
4704 break;
4705 }
4706 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4707 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4708 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4709 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4710 CSR_IS_QOS_BSS(pIesLocal) &&
4711 CSR_IS_UAPSD_BSS(pIesLocal) )
4712 {
4713#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4715 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004716#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 }
4718 else
4719 {
4720 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4721 }
4722 if( pIesLocal && !pScanResult->Result.pvIes)
4723 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304724 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 }
4726 }
4727 else
4728 {
4729 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4730 }
4731 roamInfo.pProfile = pProfile;
4732 pSession->bRefAssocStartCnt++;
4733 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4734 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4737 {
4738 // If this is a start IBSS profile, then we need to start the IBSS.
4739 if ( CSR_IS_START_IBSS(pProfile) )
4740 {
4741 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 // Attempt to start this IBSS...
4743 csrRoamAssignDefaultParam( pMac, pCommand );
4744 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4745 if(HAL_STATUS_SUCCESS(status))
4746 {
4747 if ( fSameIbss )
4748 {
4749 eRoamState = eCsrStartIbssSameIbss;
4750 }
4751 else
4752 {
4753 eRoamState = eCsrContinueRoaming;
4754 }
4755 }
4756 else
4757 {
4758 //it somehow fail need to stop
4759 eRoamState = eCsrStopRoaming;
4760 }
4761 break;
4762 }
4763 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 )
4766 {
4767 // Attempt to start this WDS...
4768 csrRoamAssignDefaultParam( pMac, pCommand );
4769 /* For AP WDS, we dont have any BSSDescription */
4770 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4771 if(HAL_STATUS_SUCCESS(status))
4772 {
4773 eRoamState = eCsrContinueRoaming;
4774 }
4775 else
4776 {
4777 //it somehow fail need to stop
4778 eRoamState = eCsrStopRoaming;
4779 }
4780 }
4781 else
4782 {
4783 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004784 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 eRoamState = eCsrStopRoaming;
4786 break;
4787 }
4788 }
4789 else //We have BSS
4790 {
4791 //Need to assign these value because they are used in csrIsSameProfile
4792 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004793 /* The OSEN IE doesn't provide the cipher suite.
4794 * Therefore set to constant value of AES */
4795 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4796 {
4797 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4798 eCSR_ENCRYPT_TYPE_AES;
4799 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4800 eCSR_ENCRYPT_TYPE_AES;
4801 }
4802 else
4803 {
4804 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4805 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4806 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4807 pScanResult->mcEncryptionType;
4808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4810 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4811 {
4812 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4813 {
4814 eRoamState = eCsrStartIbssSameIbss;
4815 break;
4816 }
4817 }
4818 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4819 {
4820 //trying to connect to the one already connected
4821 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4822 eRoamState = eCsrReassocToSelfNoCapChange;
4823 break;
4824 }
4825 // Attempt to Join this Bss...
4826 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4827 break;
4828 }
4829
4830 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4832 {
4833 //Need to indicate association_completion if association_start has been done
4834 if(pSession->bRefAssocStartCnt > 0)
4835 {
4836 pSession->bRefAssocStartCnt--;
4837 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004838 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4840 eCSR_ROAM_ASSOCIATION_COMPLETION,
4841 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4842 }
4843 }
4844
4845 return( eRoamState );
4846}
4847
Jeff Johnson295189b2012-06-20 16:38:30 -07004848static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4849{
4850 eHalStatus status = eHAL_STATUS_SUCCESS;
4851 eCsrJoinState RoamState;
4852 tANI_U32 sessionId = pCommand->sessionId;
4853
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 //***if( hddIsRadioStateOn( pAdapter ) )
4855 {
4856 // Attept to join a Bss...
4857 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004858
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004860 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 {
4862 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 // and if connected in Infrastructure mode...
4864 if ( csrIsConnStateInfra(pMac, sessionId) )
4865 {
4866 //... then we need to issue a disassociation
4867 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4868 if(!HAL_STATUS_SUCCESS(status))
4869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004870 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 //roam command is completed by caller in the failed case
4872 fComplete = eANI_BOOLEAN_TRUE;
4873 }
4874 }
4875 else if( csrIsConnStateIbss(pMac, sessionId) )
4876 {
4877 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4878 if(!HAL_STATUS_SUCCESS(status))
4879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004880 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 //roam command is completed by caller in the failed case
4882 fComplete = eANI_BOOLEAN_TRUE;
4883 }
4884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4886 {
4887 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4888 if(!HAL_STATUS_SUCCESS(status))
4889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004890 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 //roam command is completed by caller in the failed case
4892 fComplete = eANI_BOOLEAN_TRUE;
4893 }
4894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 else
4896 {
4897 fComplete = eANI_BOOLEAN_TRUE;
4898 }
4899 if(fComplete)
4900 {
4901 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004902 if(eCsrStopRoamingDueToConcurrency == RoamState)
4903 {
4904 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4905 }
4906 else
4907 {
4908 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 }
4911 }
4912 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4913 {
4914 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4915 }
4916 else if ( eCsrStartIbssSameIbss == RoamState )
4917 {
4918 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4919 }
4920 }//hddIsRadioStateOn
4921
4922 return status;
4923}
Jeff Johnson295189b2012-06-20 16:38:30 -07004924eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4925{
4926 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05304927 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 tCsrScanResult *pScanResult = NULL;
4929 tSirBssDescription *pBssDesc = NULL;
4930 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 sessionId = pCommand->sessionId;
4932 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004933
4934 if(!pSession)
4935 {
4936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4937 return eHAL_STATUS_FAILURE;
4938 }
4939
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4941 {
4942 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004943 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4945 return eHAL_STATUS_FAILURE;
4946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 if (pCommand->u.roamCmd.pRoamBssEntry)
4948 {
4949 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4950 pBssDesc = &pScanResult->Result.BssDescriptor;
4951 }
4952 else
4953 {
4954 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004955 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4957 return eHAL_STATUS_FAILURE;
4958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4960 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4961 return status;
4962}
4963
Jeff Johnson295189b2012-06-20 16:38:30 -07004964eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4965{
4966 eHalStatus status = eHAL_STATUS_SUCCESS;
4967 tCsrRoamInfo roamInfo;
4968 tANI_U32 sessionId = pCommand->sessionId;
4969 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004970
4971 if(!pSession)
4972 {
4973 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4974 return eHAL_STATUS_FAILURE;
4975 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304976 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
4977 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 switch ( pCommand->u.roamCmd.roamReason )
4979 {
4980 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004982 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 case eCsrSmeIssuedDisassocForHandoff:
4985 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4986#if 0 // TODO : Confirm this change
4987 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4988#else
4989 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4990#endif
4991
4992 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004995 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004999 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 case eCsrHddIssuedReassocToSameAP:
5002 case eCsrSmeIssuedReassocToSameAP:
5003 {
5004 tDot11fBeaconIEs *pIes = NULL;
5005
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 if( pSession->pConnectBssDesc )
5007 {
5008 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5009 if(!HAL_STATUS_SUCCESS(status) )
5010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005011 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 }
5013 else
5014 {
5015 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5016 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5017 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5019 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5020 pSession->bRefAssocStartCnt++;
5021 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5022 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5023
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005024 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005025 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5026 &pCommand->u.roamCmd.roamProfile );
5027 if(!HAL_STATUS_SUCCESS(status))
5028 {
5029 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005030 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005031 }
5032
Kiet Lam64c1b492013-07-12 13:56:44 +05305033 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 pIes = NULL;
5035 }
5036 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305037 else
5038 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 break;
5040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005042 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5044 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5045 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005047 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5049 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005050
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 case eCsrStopBss:
5052 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5053 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5054 break;
5055
5056 case eCsrForcedDisassocSta:
5057 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5058 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5059 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5060 pCommand->u.roamCmd.reason);
5061 break;
5062
5063 case eCsrForcedDeauthSta:
5064 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5065 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5066 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5067 pCommand->u.roamCmd.reason);
5068 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005069
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005070 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005071 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005072 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5073 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005074 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305076#ifdef WLAN_FEATURE_LFR_MBB
5077 case ecsr_mbb_perform_preauth_reassoc:
5078 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5079 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5080 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305081 if (eHAL_STATUS_SUCCESS != status)
5082 {
5083 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5084 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5085 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5086 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305087 break;
5088#endif
5089
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 default:
5091 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5092
5093 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5094 {
5095 //Remember the roaming profile
5096 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305097 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5098 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305100 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5102 }
5103 }
5104
5105 //At this point, original uapsd_mask is saved in pCurRoamProfile
5106 //uapsd_mask in the pCommand may change from this point on.
5107
5108 // Attempt to roam with the new scan results (if we need to..)
5109 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005110 if(!HAL_STATUS_SUCCESS(status))
5111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005112 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 break;
5115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 return (status);
5117}
5118
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005119void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5120{
5121 pCommand->u.roamCmd.pLastRoamBss = NULL;
5122 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5123 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305124 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005125}
5126
Jeff Johnson295189b2012-06-20 16:38:30 -07005127void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5128{
5129 if(pCommand->u.roamCmd.fReleaseBssList)
5130 {
5131 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5132 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5133 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5134 }
5135 if(pCommand->u.roamCmd.fReleaseProfile)
5136 {
5137 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5138 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5139 }
5140 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5141 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305142 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005143}
5144
Jeff Johnson295189b2012-06-20 16:38:30 -07005145void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5146{
Kiet Lam64c1b492013-07-12 13:56:44 +05305147 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005148}
Jeff Johnson295189b2012-06-20 16:38:30 -07005149void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5150{
5151 tListElem *pEntry;
5152 tSmeCmd *pCommand;
5153 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005154 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5156 if ( pEntry )
5157 {
5158 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 // If the head of the queue is Active and it is a ROAM command, remove
5160 // and put this on the Free queue.
5161 if ( eSmeCommandRoam == pCommand->command )
5162 {
5163 //we need to process the result first before removing it from active list because state changes
5164 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5165 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5166 if( fReleaseCommand )
5167 {
5168 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5169 {
5170 csrReleaseCommandRoam( pMac, pCommand );
5171 }
5172 else
5173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005174 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005175 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 }
5177 }
5178 else
5179 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005180 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005181 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 }
5183 }
5184 else
5185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005186 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 }
5188 }
5189 else
5190 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005191 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 if( fReleaseCommand )
5194 {
5195 smeProcessPendingQueue( pMac );
5196 }
5197}
5198
Jeff Johnson295189b2012-06-20 16:38:30 -07005199void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5200{
5201 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005202 if(!pSession)
5203 {
5204 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5205 return;
5206 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305207 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5208 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 pSession->NumPmkidCandidate = 0;
5210}
Jeff Johnson295189b2012-06-20 16:38:30 -07005211#ifdef FEATURE_WLAN_WAPI
5212void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5213{
5214 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005215 if(!pSession)
5216 {
5217 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5218 return;
5219 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305220 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5221 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 pSession->NumBkidCandidate = 0;
5223}
5224#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005225extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5226
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305227eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5228 tANI_U32 sessionId, eCsrAuthType authType,
5229 tSirBssDescription *pSirBssDesc,
5230 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005231{
5232 eHalStatus status = eHAL_STATUS_SUCCESS;
5233 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5234 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005235
5236 if(!pSession)
5237 {
5238 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5239 return eHAL_STATUS_FAILURE;
5240 }
5241
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 if((eCSR_AUTH_TYPE_WPA == authType) ||
5243 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5244 (eCSR_AUTH_TYPE_RSN == authType) ||
5245 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5246#if defined WLAN_FEATURE_VOWIFI_11R
5247 ||
5248 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5249 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5250#endif /* FEATURE_WLAN_WAPI */
5251#ifdef FEATURE_WLAN_WAPI
5252 ||
5253 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5254 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5255#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005256#ifdef WLAN_FEATURE_11W
5257 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305258 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5259 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005260#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 )
5262 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005265 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 }
5267 if( pIesLocal )
5268 {
5269 tANI_U32 nIeLen;
5270 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 if((eCSR_AUTH_TYPE_RSN == authType) ||
5272#if defined WLAN_FEATURE_VOWIFI_11R
5273 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5274 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5275#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005276#if defined WLAN_FEATURE_11W
5277 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305278 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5281 {
5282 if(pIesLocal->RSN.present)
5283 {
5284 //Calculate the actual length
5285 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5286 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5287 + 2 //akm_suite_count
5288 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5289 + 2; //reserved
5290 if( pIesLocal->RSN.pmkid_count )
5291 {
5292 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5293 }
5294 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305295 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5296 if (NULL == pSession->pWpaRsnRspIE)
5297 status = eHAL_STATUS_FAILURE;
5298 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305300 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5302 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5303 //copy upto akm_suites
5304 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305305 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5306 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005307 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305308 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5309 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005310 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305311 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5312 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005313 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 if( pIesLocal->RSN.pwise_cipher_suite_count )
5315 {
5316 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305317 vos_mem_copy(pIeBuf,
5318 pIesLocal->RSN.pwise_cipher_suites,
5319 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5321 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305322 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 pIeBuf += 2;
5324 if( pIesLocal->RSN.akm_suite_count )
5325 {
5326 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305327 vos_mem_copy(pIeBuf,
5328 pIesLocal->RSN.akm_suites,
5329 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5331 }
5332 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305333 vos_mem_copy(pIeBuf,
5334 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5335 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5337 }
5338 }
5339 }
5340 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5341 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5342 {
5343 if(pIesLocal->WPA.present)
5344 {
5345 //Calculate the actual length
5346 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5347 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5348 + 2 //auth_suite_count
5349 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5350 // The WPA capabilities follows the Auth Suite (two octects)--
5351 // this field is optional, and we always "send" zero, so just
5352 // remove it. This is consistent with our assumptions in the
5353 // frames compiler; c.f. bug 15234:
5354 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305355
5356 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5357 if ( NULL == pSession->pWpaRsnRspIE )
5358 status = eHAL_STATUS_FAILURE;
5359 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 {
5361 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5362 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5363 pIeBuf = pSession->pWpaRsnRspIE + 2;
5364 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305365 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305367 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5368 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305370 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5371 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5373 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5374 }
5375 }
5376 }
5377#ifdef FEATURE_WLAN_WAPI
5378 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5379 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5380 {
5381 if(pIesLocal->WAPI.present)
5382 {
5383 //Calculate the actual length
5384 nIeLen = 4 //version + akm_suite_count
5385 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5386 + 2 //pwise_cipher_suite_count
5387 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5388 + 6; //gp_cipher_suite + preauth + reserved
5389 if( pIesLocal->WAPI.bkid_count )
5390 {
5391 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5392 }
5393
5394 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305395 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5396 if ( NULL == pSession->pWapiRspIE )
5397 status = eHAL_STATUS_FAILURE;
5398 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 {
5400 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5401 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5402 pIeBuf = pSession->pWapiRspIE + 2;
5403 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305404 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 pIeBuf += 4;
5406 if( pIesLocal->WAPI.akm_suite_count )
5407 {
5408 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305409 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5410 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305412 }
5413 vos_mem_copy(pIeBuf,
5414 &pIesLocal->WAPI.unicast_cipher_suite_count,
5415 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5418 {
5419 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305420 vos_mem_copy( pIeBuf,
5421 pIesLocal->WAPI.unicast_cipher_suites,
5422 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5424 }
lukez3c809222013-05-03 10:23:02 -07005425 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305426 vos_mem_copy(pIeBuf,
5427 pIesLocal->WAPI.multicast_cipher_suite,
5428 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005429 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305430 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305431 vos_mem_copy(pIeBuf,
5432 pIesLocal->WAPI.multicast_cipher_suite + 4,
5433 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005434 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305435 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305437 //bkid_count
5438 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5439 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305441 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5442 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5444 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305445 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 }
5448 }
5449#endif /* FEATURE_WLAN_WAPI */
5450 if( !pIes )
5451 {
5452 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305453 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 }
5455 }
5456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 return (status);
5458}
5459
Jeff Johnson295189b2012-06-20 16:38:30 -07005460static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5461{
5462 v_U8_t bACWeights[WLANTL_MAX_AC];
5463 v_U8_t paramBk, paramBe, paramVi, paramVo;
5464 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5466 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5467 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5468 //This doesn't address the case where the lower AC needs a real higher weight
5469 if( pIEs->WMMParams.present )
5470 {
5471 //no change to the lowest ones
5472 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5473 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5474 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5475 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5476 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5477 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5478 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5479 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5480 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5481 {
5482 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5483 fWeightChange = VOS_TRUE;
5484 }
5485 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5486 {
5487 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5488 fWeightChange = VOS_TRUE;
5489 }
5490 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5491 {
5492 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5493 fWeightChange = VOS_TRUE;
5494 }
5495 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5496 {
5497 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5498 fWeightChange = VOS_TRUE;
5499 }
5500 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5501 {
5502 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5503 fWeightChange = VOS_TRUE;
5504 }
5505 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5506 {
5507 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5508 fWeightChange = VOS_TRUE;
5509 }
5510 if(fWeightChange)
5511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005512 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 bACWeights[2], bACWeights[3]);
5514 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5515 }
5516 }
5517}
Jeff Johnson295189b2012-06-20 16:38:30 -07005518#ifdef WLAN_FEATURE_VOWIFI_11R
5519//Returns whether the current association is a 11r assoc or not
5520tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5521{
5522#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5523 return csrNeighborRoamIs11rAssoc(pMac);
5524#else
5525 return eANI_BOOLEAN_FALSE;
5526#endif
5527}
5528#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005529#ifdef FEATURE_WLAN_ESE
5530//Returns whether the current association is a ESE assoc or not
5531tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005532{
5533#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005534 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005535#else
5536 return eANI_BOOLEAN_FALSE;
5537#endif
5538}
5539#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005540#ifdef FEATURE_WLAN_LFR
5541//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305542tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005543{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305544 tCsrRoamSession *pSession = NULL;
5545
5546 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5547 {
5548 pSession = CSR_GET_SESSION( pMac, sessionId );
5549 if (NULL != pSession->pCurRoamProfile)
5550 {
5551 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5552 {
5553 return eANI_BOOLEAN_FALSE;
5554 }
5555 }
5556 }
5557
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005558#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5559 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5560 {
5561 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5562 }
5563 else
5564#endif
5565 {
5566 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005567 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005568 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005569}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005570
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005571#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005572/* ---------------------------------------------------------------------------
5573
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005574 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005575
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005576 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005577
5578 \param pMac - The handle returned by macOpen.
5579
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005580 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005581
5582---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005583tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005584{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005585 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005586}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005587#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005588
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005589#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5590//Returns whether "FW based BG scan" is currently enabled...or not
5591tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5592{
5593 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5594}
5595#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005596#endif
5597
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005598#if defined(FEATURE_WLAN_ESE)
5599tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005600{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005601 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005602}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005603#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005604
Jeff Johnson295189b2012-06-20 16:38:30 -07005605//Return true means the command can be release, else not
5606static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5607 eCsrRoamCompleteResult Result, void *Context )
5608{
5609 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5610 tSirBssDescription *pSirBssDesc = NULL;
5611 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5612 tCsrScanResult *pScanResult = NULL;
5613 tCsrRoamInfo roamInfo;
5614 sme_QosAssocInfo assocInfo;
5615 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5616 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5617 tDot11fBeaconIEs *pIes = NULL;
5618 tANI_U32 sessionId = pCommand->sessionId;
5619 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5620 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5621 eRoamCmdStatus roamStatus;
5622 eCsrRoamResult roamResult;
5623 eHalStatus status;
5624 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005626
Jeff Johnson32d95a32012-09-10 13:15:23 -07005627 if(!pSession)
5628 {
5629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5630 return eANI_BOOLEAN_FALSE;
5631 }
5632
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005633 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 switch( Result )
5635 {
5636 case eCsrJoinSuccess:
5637 // reset the IDLE timer
5638 // !!
5639 // !! fall through to the next CASE statement here is intentional !!
5640 // !!
5641 case eCsrReassocSuccess:
5642 if(eCsrReassocSuccess == Result)
5643 {
5644 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5645 }
5646 else
5647 {
5648 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5649 }
5650 // Success Join Response from LIM. Tell NDIS we are connected and save the
5651 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005652 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305653 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 //always free the memory here
5655 if(pSession->pWpaRsnRspIE)
5656 {
5657 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305658 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 pSession->pWpaRsnRspIE = NULL;
5660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005661#ifdef FEATURE_WLAN_WAPI
5662 if(pSession->pWapiRspIE)
5663 {
5664 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305665 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 pSession->pWapiRspIE = NULL;
5667 }
5668#endif /* FEATURE_WLAN_WAPI */
5669#ifdef FEATURE_WLAN_BTAMP_UT_RF
5670 //Reset counter so no join retry is needed.
5671 pSession->maxRetryCount = 0;
5672 csrRoamStopJoinRetryTimer(pMac, sessionId);
5673#endif
5674 /* This creates problem since we have not saved the connected profile.
5675 So moving this after saving the profile
5676 */
5677 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305678
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305679 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305680 * by last failed secured connection.
5681 * It should be set only for secured connection.
5682 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305683 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5685 {
5686 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5687 }
5688 else
5689 {
5690 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 //Use the last connected bssdesc for reassoc-ing to the same AP.
5693 //NOTE: What to do when reassoc to a different AP???
5694 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5695 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5696 {
5697 pSirBssDesc = pSession->pConnectBssDesc;
5698 if(pSirBssDesc)
5699 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305700 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5701 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 }
5703 }
5704 else
5705 {
5706
5707 if(pCommand->u.roamCmd.pRoamBssEntry)
5708 {
5709 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5710 if(pScanResult != NULL)
5711 {
5712 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5713 //this can be NULL
5714 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305715 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5716 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 }
5718 }
5719 }
5720 if( pSirBssDesc )
5721 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5724 //Save WPA/RSN IE
5725 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005726#ifdef FEATURE_WLAN_ESE
5727 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005728#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305729#ifdef WLAN_FEATURE_VOWIFI_11R
5730 if (pSirBssDesc->mdiePresent)
5731 {
5732 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5733#ifdef FEATURE_WLAN_ESE
5734 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5735 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5736#endif
5737 )
5738 {
5739 // is11Rconnection;
5740 roamInfo.is11rAssoc = VOS_TRUE;
5741 }
5742 else
5743 {
5744 // is11Rconnection;
5745 roamInfo.is11rAssoc = VOS_FALSE;
5746 }
5747 }
5748#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5750 // substate change.
5751 // Moving even save profile above so that below mentioned conditon is also met.
5752 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5753 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5755 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5756 // will be dropped for the security context may not be set properly.
5757 //
5758 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5759 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5760 //
5761 // this reordering was done on titan_prod_usb branch and is being replicated here.
5762 //
5763
5764 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5765 !pProfile->bWPSAssociation)
5766 {
5767 // Issue the set Context request to LIM to establish the Unicast STA context
5768 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5769 pProfile->negotiatedUCEncryptionType,
5770 pSirBssDesc, &(pSirBssDesc->bssId),
5771 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005773 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5775 }
5776 // Issue the set Context request to LIM to establish the Broadcast STA context
5777 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5778 pSirBssDesc, &BroadcastMac,
5779 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5780 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305781 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 {
5783 //Need to wait for supplicant authtication
5784 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 //Set the subestate to WaitForKey in case authentiation is needed
5786 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5787
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 if(pProfile->bWPSAssociation)
5789 {
5790 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5791 }
5792 else
5793 {
5794 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5795 }
5796
5797 //Save sessionId in case of timeout
5798 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5799 //This time should be long enough for the rest of the process plus setting key
5800 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5801 {
5802 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005803 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5805 }
5806 }
5807
5808 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5809 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 if(Context)
5811 {
5812 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5813 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5815 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5816#ifdef WLAN_FEATURE_VOWIFI_11R
5817 len += pJoinRsp->parsedRicRspLen;
5818#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005819#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 len += pJoinRsp->tspecIeLen;
5821#endif
5822 if(len)
5823 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305824 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5825 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305827 vos_mem_copy(pSession->connectedInfo.pbFrames,
5828 pJoinRsp->frames, len);
5829 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5830 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5831 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005832#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305833 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005835#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305836 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005837#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305838 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5839 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5840 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5841 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 }
5843 }
5844 if(pCommand->u.roamCmd.fReassoc)
5845 {
5846 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5847 }
5848 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5849 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5850 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5851 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305852 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 }
5854 else
5855 {
5856 if(pCommand->u.roamCmd.fReassoc)
5857 {
5858 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5859 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5860 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5861 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5862 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5863 }
5864 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305865 /* Update the staId from the previous connected profile info
5866 as the reassociation is triggred at SME/HDD */
5867 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5868 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5869 {
5870 roamInfo.staId = pSession->connectedInfo.staId;
5871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005872#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5873 // Indicate SME-QOS with reassoc success event, only after
5874 // copying the frames
5875 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5876#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 roamInfo.pBssDesc = pSirBssDesc;
5878 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5879 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5880#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5881 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5882#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5883 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5885 //It may be better to let QoS do this????
5886 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005888 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5890 pmcStartUapsd( pMac, NULL, NULL );
5891 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305892 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5894 if( pSession->bRefAssocStartCnt > 0 )
5895 {
5896 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005897 //Remove this code once SLM_Sessionization is supported
5898 //BMPS_WORKAROUND_NOT_NEEDED
5899 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005900 {
5901 pMac->roam.configParam.doBMPSWorkaround = 1;
5902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5904 }
5905
5906 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 // reset the PMKID candidate list
5908 csrResetPMKIDCandidateList( pMac, sessionId );
5909 //Update TL's AC weight base on the current EDCA parameters
5910 //These parameters may change in the course of the connection, that sictuation
5911 //is not taken care here. This change is mainly to address a WIFI WMM test where
5912 //BE has a equal or higher TX priority than VI.
5913 //We only do this for infra link
5914 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5915 {
5916 csrCheckAndUpdateACWeight(pMac, pIes);
5917 }
5918#ifdef FEATURE_WLAN_WAPI
5919 // reset the BKID candidate list
5920 csrResetBKIDCandidateList( pMac, sessionId );
5921#endif /* FEATURE_WLAN_WAPI */
5922 }
5923 else
5924 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005925 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 csrScanCancelIdleScan(pMac);
5928 //Not to signal link up because keys are yet to be set.
5929 //The linkup function will overwrite the sub-state that we need to keep at this point.
5930 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5931 {
5932 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5935 //enough to let security and DHCP handshake succeed before entry into BMPS
5936 if (pmcShouldBmpsTimerRun(pMac))
5937 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305938 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05305939 * until keys are set before going into BMPS.
5940 */
5941 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5942 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305943 pMac->pmc.full_power_till_set_key = true;
5944 smsLog(pMac, LOG1,
5945 FL("Set full_power_till_set_key to make sure we wait until keys are set before going to BMPS"));
Abhishek Singh65d939e2014-04-25 13:33:07 +05305946 }
5947
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5949 != eHAL_STATUS_SUCCESS)
5950 {
5951 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5952 }
5953 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 break;
5956
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 case eCsrStartBssSuccess:
5958 // on the StartBss Response, LIM is returning the Bss Description that we
5959 // are beaconing. Add this Bss Description to our scan results and
5960 // chain the Profile to this Bss Description. On a Start BSS, there was no
5961 // detected Bss description (no partner) so we issued the Start Bss to
5962 // start the Ibss without any Bss description. Lim was kind enough to return
5963 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005964 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305967 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 if( CSR_IS_IBSS( pProfile ) )
5969 {
5970 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 else if (CSR_IS_INFRA_AP(pProfile))
5973 {
5974 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 else
5977 {
5978 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5979 }
5980 if( !CSR_IS_WDS_STA( pProfile ) )
5981 {
5982 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5985 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305986 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 roamInfo.pBssDesc = pSirBssDesc;
5988 //We need to associate_complete it first, becasue Associate_start already indicated.
5989 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5990 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5991 break;
5992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005995 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 }
5997 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5998 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5999 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6000 if(pSirBssDesc)
6001 {
6002 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306003 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6004 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 }
6006 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306007 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006008#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6009 {
6010 vos_log_ibss_pkt_type *pIbssLog;
6011 tANI_U32 bi;
6012
6013 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6014 if(pIbssLog)
6015 {
6016 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6017 {
6018 //We start the IBSS (didn't find any matched IBSS out there)
6019 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6020 }
6021 else
6022 {
6023 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6024 }
6025 if(pSirBssDesc)
6026 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306027 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6029 }
6030 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6031 {
6032 //***U8 is not enough for beacon interval
6033 pIbssLog->beaconInterval = (v_U8_t)bi;
6034 }
6035 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6036 }
6037 }
6038#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6039 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6040 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6042 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6044 csrRoamIssueSetContextReq( pMac, sessionId,
6045 pProfile->negotiatedMCEncryptionType,
6046 pSirBssDesc, &BroadcastMac,
6047 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6048 }
6049 }
6050 else
6051 {
6052 //Keep the state to eCSR_ROAMING_STATE_JOINING
6053 //Need to send join_req.
6054 if(pCommand->u.roamCmd.pRoamBssEntry)
6055 {
6056 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6057 {
6058 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6059 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6060 // Set the roaming substate to 'join attempt'...
6061 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006062 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 }
6064 }
6065 else
6066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006067 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 VOS_ASSERT( 0 );
6069 }
6070 }
6071 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6072 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6073 //trigger the connection start indication in Vista
6074 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6075 {
6076 roamStatus = eCSR_ROAM_IBSS_IND;
6077 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6078 if( CSR_IS_WDS( pProfile ) )
6079 {
6080 roamStatus = eCSR_ROAM_WDS_IND;
6081 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 if( CSR_IS_INFRA_AP( pProfile ) )
6084 {
6085 roamStatus = eCSR_ROAM_INFRA_IND;
6086 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006088
6089 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6090 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6091 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306092 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6094 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006095 //We start the IBSS (didn't find any matched IBSS out there)
6096 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306098 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6099 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006100 //Remove this code once SLM_Sessionization is supported
6101 //BMPS_WORKAROUND_NOT_NEEDED
6102 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006103 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006104 {
6105 pMac->roam.configParam.doBMPSWorkaround = 1;
6106 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006107
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6109 }
6110
6111 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006112
6113 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 {
6115 //need to send stop BSS because we fail to send join_req
6116 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6117 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6118 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 case eCsrStartBssFailure:
6122#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6123 {
6124 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6126 if(pIbssLog)
6127 {
6128 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6129 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6130 }
6131 }
6132#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 roamStatus = eCSR_ROAM_IBSS_IND;
6134 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6135 if( CSR_IS_WDS( pProfile ) )
6136 {
6137 roamStatus = eCSR_ROAM_WDS_IND;
6138 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 if( CSR_IS_INFRA_AP( pProfile ) )
6141 {
6142 roamStatus = eCSR_ROAM_INFRA_IND;
6143 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 if(Context)
6146 {
6147 pSirBssDesc = (tSirBssDescription *)Context;
6148 }
6149 else
6150 {
6151 pSirBssDesc = NULL;
6152 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306153 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 roamInfo.pBssDesc = pSirBssDesc;
6155 //We need to associate_complete it first, becasue Associate_start already indicated.
6156 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6157 csrSetDefaultDot11Mode( pMac );
6158 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 case eCsrSilentlyStopRoaming:
6160 // We are here because we try to start the same IBSS
6161 //No message to PE
6162 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006163 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6165 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306166 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6168 if( roamInfo.pBssDesc )
6169 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306170 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6171 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 }
6173 //Since there is no change in the current state, simply pass back no result otherwise
6174 //HDD may be mistakenly mark to disconnected state.
6175 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6176 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 case eCsrSilentlyStopRoamingSaveState:
6179 //We are here because we try to connect to the same AP
6180 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006181 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306182 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006183
6184 //to aviod resetting the substate to NONE
6185 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6186 //No need to change substate to wai_for_key because there is no state change
6187 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6188 if( roamInfo.pBssDesc )
6189 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306190 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6191 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6194 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6195 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6196 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6197 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6198 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6199 roamInfo.staId = pSession->connectedInfo.staId;
6200 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 pSession->bRefAssocStartCnt--;
6203 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6204 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6205 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6206 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 case eCsrReassocFailure:
6208#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6209 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6210#endif
6211 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006212 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 csrFreeConnectBssDesc(pMac, sessionId);
6214 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6215 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306216 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6218 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6219 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6220 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6221 eCSR_ROAM_WDS_IND,
6222 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6223 //Need to issue stop_bss
6224 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 case eCsrJoinFailure:
6226 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006227 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 default:
6229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006230 smsLog(pMac, LOGW, FL("receives no association indication"));
6231 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006232 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6234 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6235 {
6236 //do not free for the other profiles as we need to send down stop BSS later
6237 csrFreeConnectBssDesc(pMac, sessionId);
6238 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6239 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6240 csrSetDefaultDot11Mode( pMac );
6241 }
6242
6243 switch( pCommand->u.roamCmd.roamReason )
6244 {
6245 // If this transition is because of an 802.11 OID, then we transition
6246 // back to INIT state so we sit waiting for more OIDs to be issued and
6247 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006248 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 case eCsrSmeIssuedAssocToSimilarAP:
6250 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006251 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306253 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6255 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6256 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306257 vos_mem_copy(&roamInfo.bssid,
6258 &pSession->joinFailStatusCode.bssId,
6259 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006260
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 /* Defeaturize this later if needed */
6262#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6263 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6264 if (csrRoamIsHandoffInProgress(pMac))
6265 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 /* Should indicate neighbor roam algorithm about the connect failure here */
6267 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 if(pSession->bRefAssocStartCnt > 0)
6271 {
6272 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006273 if(eCsrJoinFailureDueToConcurrency == Result)
6274 {
6275 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6276 eCSR_ROAM_ASSOCIATION_COMPLETION,
6277 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6278 }
6279 else
6280 {
6281 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 eCSR_ROAM_ASSOCIATION_COMPLETION,
6283 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006286 else
6287 {
6288 /* bRefAssocStartCnt is not incremented when
6289 * eRoamState == eCsrStopRoamingDueToConcurrency
6290 * in csrRoamJoinNextBss API. so handle this in
6291 * else case by sending assoc failure
6292 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006293 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006294 pCommand->u.scanCmd.roamId,
6295 eCSR_ROAM_ASSOCIATION_FAILURE,
6296 eCSR_ROAM_RESULT_FAILURE);
6297 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006298 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006299#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306300 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6302#endif
6303 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6304 csrScanStartIdleScan(pMac);
6305#ifdef FEATURE_WLAN_BTAMP_UT_RF
6306 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6307 //BT activity and not able to recevie WLAN traffic. Retry the join
6308 if( CSR_IS_WDS_STA(pProfile) )
6309 {
6310 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6311 }
6312#endif
6313 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 case eCsrHddIssuedReassocToSameAP:
6315 case eCsrSmeIssuedReassocToSameAP:
6316 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6317
6318 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6319#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6320 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6321#endif
6322 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6323 csrScanStartIdleScan(pMac);
6324 break;
6325 case eCsrForcedDisassoc:
6326 case eCsrForcedDeauth:
6327 case eCsrSmeIssuedIbssJoinFailure:
6328 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6329
6330 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6331 {
6332 // Notify HDD that IBSS join failed
6333 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6334 }
6335 else
6336 {
6337 csrRoamCallCallback(pMac, sessionId, NULL,
6338 pCommand->u.roamCmd.roamId,
6339 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6340 }
6341#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6342 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6343#endif
6344 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006345 /*
6346 *DelSta not done FW still in conneced state so dont
6347 *issue IMPS req
6348 */
6349 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6350 {
6351 smsLog(pMac, LOGW, FL("FW still in connected state "));
6352 break;
6353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 csrScanStartIdleScan(pMac);
6355 break;
6356 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306357 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 csrRoamCallCallback(pMac, sessionId, NULL,
6359 pCommand->u.roamCmd.roamId,
6360 eCSR_ROAM_IBSS_LEAVE,
6361 eCSR_ROAM_RESULT_IBSS_STOP);
6362 break;
6363 case eCsrForcedDisassocMICFailure:
6364 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6365
6366 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6367#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6368 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6369#endif
6370 csrScanStartIdleScan(pMac);
6371 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 case eCsrStopBss:
6373 csrRoamCallCallback(pMac, sessionId, NULL,
6374 pCommand->u.roamCmd.roamId,
6375 eCSR_ROAM_INFRA_IND,
6376 eCSR_ROAM_RESULT_INFRA_STOPPED);
6377 break;
6378 case eCsrForcedDisassocSta:
6379 case eCsrForcedDeauthSta:
6380 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6381 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6382 {
6383 pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306384 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306386 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6387 {
6388 roamInfo.u.pConnectedProfile =
6389 &pSession->connectedProfile;
6390 vos_mem_copy(roamInfo.peerMac,
6391 pCommand->u.roamCmd.peerMac,
6392 sizeof(tSirMacAddr));
6393 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6394 roamInfo.statusCode = eSIR_SME_SUCCESS;
6395 status = csrRoamCallCallback(pMac, sessionId,
6396 &roamInfo, pCommand->u.roamCmd.roamId,
6397 eCSR_ROAM_LOSTLINK,
6398 eCSR_ROAM_RESULT_FORCED);
6399 }
6400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 }
6402 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 case eCsrLostLink1:
6404 // if lost link roam1 failed, then issue lost link Scan2 ...
6405 csrScanRequestLostLink2(pMac, sessionId);
6406 break;
6407 case eCsrLostLink2:
6408 // if lost link roam2 failed, then issue lost link scan3 ...
6409 csrScanRequestLostLink3(pMac, sessionId);
6410 break;
6411 case eCsrLostLink3:
6412 default:
6413 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6414
6415 //We are done with one round of lostlink roaming here
6416 csrScanHandleFailedLostlink3(pMac, sessionId);
6417 break;
6418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 break;
6420 }
6421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 return ( fReleaseCommand );
6423}
6424
Jeff Johnson295189b2012-06-20 16:38:30 -07006425eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6426{
6427 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 return (status);
6429}
6430
Jeff Johnson295189b2012-06-20 16:38:30 -07006431eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6432{
6433 eHalStatus status = eHAL_STATUS_SUCCESS;
6434 tANI_U32 size = 0;
6435
6436 do
6437 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306438 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6440 {
6441 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306442 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6443 if ( NULL == pDstProfile->BSSIDs.bssid )
6444 status = eHAL_STATUS_FAILURE;
6445 else
6446 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 if(!HAL_STATUS_SUCCESS(status))
6448 {
6449 break;
6450 }
6451 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306452 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6453 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 }
6455 if(pSrcProfile->SSIDs.numOfSSIDs)
6456 {
6457 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306458 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6459 if ( NULL == pDstProfile->SSIDs.SSIDList )
6460 status = eHAL_STATUS_FAILURE;
6461 else
6462 status = eHAL_STATUS_SUCCESS;
6463 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 {
6465 break;
6466 }
6467 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306468 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6469 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 }
6471 if(pSrcProfile->nWPAReqIELength)
6472 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306473 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6474 if ( NULL == pDstProfile->pWPAReqIE )
6475 status = eHAL_STATUS_FAILURE;
6476 else
6477 status = eHAL_STATUS_SUCCESS;
6478
6479 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 {
6481 break;
6482 }
6483 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306484 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6485 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 }
6487 if(pSrcProfile->nRSNReqIELength)
6488 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306489 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6490 if ( NULL == pDstProfile->pRSNReqIE )
6491 status = eHAL_STATUS_FAILURE;
6492 else
6493 status = eHAL_STATUS_SUCCESS;
6494
6495 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 {
6497 break;
6498 }
6499 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306500 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6501 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 }
6503#ifdef FEATURE_WLAN_WAPI
6504 if(pSrcProfile->nWAPIReqIELength)
6505 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306506 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6507 if ( NULL == pDstProfile->pWAPIReqIE )
6508 status = eHAL_STATUS_FAILURE;
6509 else
6510 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 if(!HAL_STATUS_SUCCESS(status))
6512 {
6513 break;
6514 }
6515 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306516 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6517 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
6519#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 if(pSrcProfile->nAddIEScanLength)
6521 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306522 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6523 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306525 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306526 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306527 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6528 }
6529 else
6530 {
6531 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6532 FL(" AddIEScanLength is not valid %u"),
6533 pSrcProfile->nAddIEScanLength);
6534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 if(pSrcProfile->nAddIEAssocLength)
6537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306538 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6539 if ( NULL == pDstProfile->pAddIEAssoc )
6540 status = eHAL_STATUS_FAILURE;
6541 else
6542 status = eHAL_STATUS_SUCCESS;
6543
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 if(!HAL_STATUS_SUCCESS(status))
6545 {
6546 break;
6547 }
6548 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306549 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6550 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 if(pSrcProfile->ChannelInfo.ChannelList)
6553 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306554 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6555 pSrcProfile->ChannelInfo.numOfChannels);
6556 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6557 status = eHAL_STATUS_FAILURE;
6558 else
6559 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 if(!HAL_STATUS_SUCCESS(status))
6561 {
6562 break;
6563 }
6564 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306565 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6566 pSrcProfile->ChannelInfo.ChannelList,
6567 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 pDstProfile->AuthType = pSrcProfile->AuthType;
6570 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6571 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6572 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6573 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6574 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006575#ifdef WLAN_FEATURE_11W
6576 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6577 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6578 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6579#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 pDstProfile->BSSType = pSrcProfile->BSSType;
6581 pDstProfile->phyMode = pSrcProfile->phyMode;
6582 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6583
6584#ifdef FEATURE_WLAN_WAPI
6585 if(csrIsProfileWapi(pSrcProfile))
6586 {
6587 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6588 {
6589 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6590 }
6591 }
6592#endif /* FEATURE_WLAN_WAPI */
6593 pDstProfile->CBMode = pSrcProfile->CBMode;
6594 /*Save the WPS info*/
6595 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006596 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 pDstProfile->privacy = pSrcProfile->privacy;
6600 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6601 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6602 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6603 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6604 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6605 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6606 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6607 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6608 pDstProfile->wps_state = pSrcProfile->wps_state;
6609 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306610 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6611 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006612#ifdef WLAN_FEATURE_VOWIFI_11R
6613 if (pSrcProfile->MDID.mdiePresent)
6614 {
6615 pDstProfile->MDID.mdiePresent = 1;
6616 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6617 }
6618#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 }while(0);
6620
6621 if(!HAL_STATUS_SUCCESS(status))
6622 {
6623 csrReleaseProfile(pMac, pDstProfile);
6624 pDstProfile = NULL;
6625 }
6626
6627 return (status);
6628}
Jeff Johnson295189b2012-06-20 16:38:30 -07006629eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6630{
6631 eHalStatus status = eHAL_STATUS_SUCCESS;
6632 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6633 do
6634 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306635 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 if(pSrcProfile->bssid)
6637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306638 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6639 if ( NULL == pDstProfile->BSSIDs.bssid )
6640 status = eHAL_STATUS_FAILURE;
6641 else
6642 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 if(!HAL_STATUS_SUCCESS(status))
6644 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306645 smsLog( pMac, LOGE,
6646 FL("failed to allocate memory for BSSID"
6647 "%02x:%02x:%02x:%02x:%02x:%02x"),
6648 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6649 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 break;
6651 }
6652 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306653 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6654 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 }
6656 if(pSrcProfile->SSID.ssId)
6657 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306658 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6659 if ( NULL == pDstProfile->SSIDs.SSIDList )
6660 status = eHAL_STATUS_FAILURE;
6661 else
6662 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 if(!HAL_STATUS_SUCCESS(status))
6664 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306665 smsLog( pMac, LOGE,
6666 FL("failed to allocate memory for SSIDList"
6667 "%02x:%02x:%02x:%02x:%02x:%02x"),
6668 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6669 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 break;
6671 }
6672 pDstProfile->SSIDs.numOfSSIDs = 1;
6673 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6674 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306675 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6676 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006678 if(pSrcProfile->nAddIEAssocLength)
6679 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306680 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6681 if ( NULL == pDstProfile->pAddIEAssoc)
6682 status = eHAL_STATUS_FAILURE;
6683 else
6684 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006685 if(!HAL_STATUS_SUCCESS(status))
6686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006687 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006688 break;
6689 }
6690 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306691 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6692 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006693 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306694 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6695 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6696 status = eHAL_STATUS_FAILURE;
6697 else
6698 status = eHAL_STATUS_SUCCESS;
6699
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 if(!HAL_STATUS_SUCCESS(status))
6701 {
6702 break;
6703 }
6704 pDstProfile->ChannelInfo.numOfChannels = 1;
6705 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 pDstProfile->AuthType.numEntries = 1;
6707 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6708 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6709 pDstProfile->EncryptionType.numEntries = 1;
6710 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6711 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6712 pDstProfile->mcEncryptionType.numEntries = 1;
6713 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6714 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6715 pDstProfile->BSSType = pSrcProfile->BSSType;
6716 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306717 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6718 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306719#ifdef WLAN_FEATURE_11W
6720 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6721 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6722 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6723#endif
6724
Jeff Johnson295189b2012-06-20 16:38:30 -07006725#ifdef WLAN_FEATURE_VOWIFI_11R
6726 if (pSrcProfile->MDID.mdiePresent)
6727 {
6728 pDstProfile->MDID.mdiePresent = 1;
6729 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6730 }
6731#endif
6732
6733 }while(0);
6734
6735 if(!HAL_STATUS_SUCCESS(status))
6736 {
6737 csrReleaseProfile(pMac, pDstProfile);
6738 pDstProfile = NULL;
6739 }
6740
6741 return (status);
6742}
6743
Jeff Johnson295189b2012-06-20 16:38:30 -07006744eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6745 tScanResultHandle hBSSList,
6746 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6747 tANI_BOOLEAN fClearScan)
6748{
6749 eHalStatus status = eHAL_STATUS_SUCCESS;
6750 tSmeCmd *pCommand;
6751
6752 pCommand = csrGetCommandBuffer(pMac);
6753 if(NULL == pCommand)
6754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006755 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 status = eHAL_STATUS_RESOURCES;
6757 }
6758 else
6759 {
6760 if( fClearScan )
6761 {
6762 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306763 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 }
6765 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6766 if(NULL == pProfile)
6767 {
6768 //We can roam now
6769 //Since pProfile is NULL, we need to build our own profile, set everything to default
6770 //We can only support open and no encryption
6771 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6772 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6773 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6774 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6775 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6776 }
6777 else
6778 {
6779 //make a copy of the profile
6780 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6781 if(HAL_STATUS_SUCCESS(status))
6782 {
6783 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6784 }
6785 }
6786 pCommand->command = eSmeCommandRoam;
6787 pCommand->sessionId = (tANI_U8)sessionId;
6788 pCommand->u.roamCmd.hBSSList = hBSSList;
6789 pCommand->u.roamCmd.roamId = roamId;
6790 pCommand->u.roamCmd.roamReason = reason;
6791 //We need to free the BssList when the command is done
6792 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6793 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6795 FL("CSR PERSONA=%d"),
6796 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006797 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6798 if( !HAL_STATUS_SUCCESS( status ) )
6799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006800 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 csrReleaseCommandRoam( pMac, pCommand );
6802 }
6803 }
6804
6805 return (status);
6806}
Jeff Johnson295189b2012-06-20 16:38:30 -07006807eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6808 tCsrRoamModifyProfileFields *pMmodProfileFields,
6809 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6810{
6811 eHalStatus status = eHAL_STATUS_SUCCESS;
6812 tSmeCmd *pCommand;
6813
6814 pCommand = csrGetCommandBuffer(pMac);
6815 if(NULL == pCommand)
6816 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006817 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 status = eHAL_STATUS_RESOURCES;
6819 }
6820 else
6821 {
6822 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306823 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 if(pProfile)
6825 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 //This is likely trying to reassoc to different profile
6827 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6828 //make a copy of the profile
6829 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6830 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 }
6832 else
6833 {
6834 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6835 //how to update WPA/WPA2 info in roamProfile??
6836 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 if(HAL_STATUS_SUCCESS(status))
6839 {
6840 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6841 }
6842 pCommand->command = eSmeCommandRoam;
6843 pCommand->sessionId = (tANI_U8)sessionId;
6844 pCommand->u.roamCmd.roamId = roamId;
6845 pCommand->u.roamCmd.roamReason = reason;
6846 //We need to free the BssList when the command is done
6847 //For reassoc there is no BSS list, so the boolean set to false
6848 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6849 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6850 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6852 if( !HAL_STATUS_SUCCESS( status ) )
6853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006854 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6856 csrReleaseCommandRoam( pMac, pCommand );
6857 }
6858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 return (status);
6860}
6861
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006862eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6863 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306864// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006865{
6866 eHalStatus status = eHAL_STATUS_SUCCESS;
6867 tSmeCmd *pCommand;
6868
6869 pCommand = csrGetCommandBuffer(pMac);
6870 if(NULL == pCommand)
6871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006872 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006873 status = eHAL_STATUS_RESOURCES;
6874 }
6875 else
6876 {
6877 if(pBssDescription)
6878 {
6879 //copy over the parameters we need later
6880 pCommand->command = eSmeCommandRoam;
6881 pCommand->sessionId = (tANI_U8)sessionId;
6882 pCommand->u.roamCmd.roamReason = reason;
6883 //this is the important parameter
6884 //in this case we are using this field for the "next" BSS
6885 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6886 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6887 if( !HAL_STATUS_SUCCESS( status ) )
6888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006889 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006890 csrReleaseCommandPreauth( pMac, pCommand );
6891 }
6892 }
6893 else
6894 {
6895 //Return failure
6896 status = eHAL_STATUS_RESOURCES;
6897 }
6898 }
6899 return (status);
6900}
6901
6902eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6903{
6904 tListElem *pEntry;
6905 tSmeCmd *pCommand;
6906 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6907 if ( pEntry )
6908 {
6909 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6910 if ( (eSmeCommandRoam == pCommand->command) &&
6911 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6912 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006913 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006914 pCommand->command, pCommand->u.roamCmd.roamReason);
6915 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6916 csrReleaseCommandPreauth( pMac, pCommand );
6917 }
6918 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006919 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006920 pCommand->command, pCommand->u.roamCmd.roamReason);
6921 }
6922 }
6923 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006924 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006925 }
6926 smeProcessPendingQueue( pMac );
6927 return eHAL_STATUS_SUCCESS;
6928}
6929
Jeff Johnson295189b2012-06-20 16:38:30 -07006930eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6931 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6932{
6933 eHalStatus status = eHAL_STATUS_FAILURE;
6934 tScanResultHandle hBSSList;
6935 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6937 if(HAL_STATUS_SUCCESS(status))
6938 {
6939 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6940 if(pRoamId)
6941 {
6942 *pRoamId = roamId;
6943 }
6944 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6945 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6946 if(!HAL_STATUS_SUCCESS(status))
6947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006948 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 csrScanResultPurge(pMac, hBSSList);
6950 }
6951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 return (status);
6953}
6954
Jeff Johnson295189b2012-06-20 16:38:30 -07006955eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6956 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6957{
6958 eHalStatus status = eHAL_STATUS_SUCCESS;
6959 tScanResultHandle hBSSList;
6960 tCsrScanResultFilter *pScanFilter;
6961 tANI_U32 roamId = 0;
6962 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6963 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 if (NULL == pProfile)
6965 {
6966 smsLog(pMac, LOGP, FL("No profile specified"));
6967 return eHAL_STATUS_FAILURE;
6968 }
Abhishek Singh230371c2015-11-23 11:29:57 +05306969 if(!pSession)
6970 {
6971 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6972 return eHAL_STATUS_FAILURE;
6973 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306974 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6975 "encryType = %d"),
6976 lim_BssTypetoString(pProfile->BSSType),
6977 pProfile->BSSType,
6978 pProfile->AuthType.authType[0],
6979 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 if( CSR_IS_WDS( pProfile ) &&
6981 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006983 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006984 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 return status;
6986 }
Abhishek Singh230371c2015-11-23 11:29:57 +05306987 /* Reset abortConnection for the fresh connection */
6988 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 csrRoamCancelRoaming(pMac, sessionId);
6990 csrScanRemoveFreshScanCommand(pMac, sessionId);
6991 csrScanCancelIdleScan(pMac);
6992 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306993 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306994
6995 if (!vos_concurrent_open_sessions_running() &&
6996 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306998 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 csrScanDisable(pMac);
7000 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307001
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7003 //Check whether ssid changes
7004 if(csrIsConnStateConnected(pMac, sessionId))
7005 {
7006 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7007 {
7008 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7009 }
7010 }
7011#ifdef FEATURE_WLAN_BTAMP_UT_RF
7012 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7013#endif
Abhishek Singh7b52ed52016-02-11 17:45:54 +05307014 /*
7015 * If roamSession.connectState is disconnecting that mean
7016 * disconnect/stop adapter was received with scan for ssid
7017 * in progress and dropped. This state will ensure that
7018 * connect will not be issued from scan for ssid completion.
7019 * Thus if this fresh connect also issue scan for ssid the connect
7020 * command will be dropped assuming disconnect is in progress.
7021 * Thus reset connectState here
7022 */
7023 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
7024 pMac->roam.roamSession[sessionId].connectState)
7025 pMac->roam.roamSession[sessionId].connectState =
7026 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007029 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7031 if(pRoamId)
7032 {
7033 roamId = *pRoamId;
7034 }
7035 if(!HAL_STATUS_SUCCESS(status))
7036 {
7037 fCallCallback = eANI_BOOLEAN_TRUE;
7038 }
7039 }
7040 else
7041 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307042 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7043 if ( NULL == pScanFilter )
7044 status = eHAL_STATUS_FAILURE;
7045 else
7046 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 if(HAL_STATUS_SUCCESS(status))
7048 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307049 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 //Try to connect to any BSS
7051 if(NULL == pProfile)
7052 {
7053 //No encryption
7054 pScanFilter->EncryptionType.numEntries = 1;
7055 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7056 }//we don't have a profile
7057 else
7058 {
7059 //Here is the profile we need to connect to
7060 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7061 }//We have a profile
7062 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7063 if(pRoamId)
7064 {
7065 *pRoamId = roamId;
7066 }
7067
7068 if(HAL_STATUS_SUCCESS(status))
7069 {
7070 /*Save the WPS info*/
7071 if(NULL != pProfile)
7072 {
7073 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007074 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 }
7076 else
7077 {
7078 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007079 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 do
7082 {
7083 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 )
7086 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007087 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7089 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7090 if(!HAL_STATUS_SUCCESS(status))
7091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007092 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 fCallCallback = eANI_BOOLEAN_TRUE;
7094 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007095 else
7096 {
7097 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 break;
7100 }
7101 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007102 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 if(HAL_STATUS_SUCCESS(status))
7104 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7106 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7107 if(!HAL_STATUS_SUCCESS(status))
7108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007109 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 csrScanResultPurge(pMac, hBSSList);
7111 fCallCallback = eANI_BOOLEAN_TRUE;
7112 }
7113 }//Have scan result
7114 else if(NULL != pProfile)
7115 {
7116 //Check whether it is for start ibss
7117 if(CSR_IS_START_IBSS(pProfile))
7118 {
7119 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7120 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7121 if(!HAL_STATUS_SUCCESS(status))
7122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007123 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 fCallCallback = eANI_BOOLEAN_TRUE;
7125 }
7126 }
7127 else
7128 {
7129 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007130 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 if(!HAL_STATUS_SUCCESS(status))
7132 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007133 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 fCallCallback = eANI_BOOLEAN_TRUE;
7135 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007136 else
7137 {
7138 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 }
7141 }
7142 else
7143 {
7144 fCallCallback = eANI_BOOLEAN_TRUE;
7145 }
7146 } while (0);
7147 if(NULL != pProfile)
7148 {
7149 //we need to free memory for filter if profile exists
7150 csrFreeScanFilter(pMac, pScanFilter);
7151 }
7152 }//Got the scan filter from profile
7153
Kiet Lam64c1b492013-07-12 13:56:44 +05307154 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 }//allocated memory for pScanFilter
7156 }//No Bsslist coming in
7157 //tell the caller if we fail to trigger a join request
7158 if( fCallCallback )
7159 {
7160 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7161 }
7162
7163 return (status);
7164}
Jeff Johnson295189b2012-06-20 16:38:30 -07007165eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7166 tCsrRoamModifyProfileFields modProfileFields,
7167 tANI_U32 *pRoamId)
7168{
7169 eHalStatus status = eHAL_STATUS_SUCCESS;
7170 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7171 tANI_U32 roamId = 0;
7172 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 if (NULL == pProfile)
7174 {
7175 smsLog(pMac, LOGP, FL("No profile specified"));
7176 return eHAL_STATUS_FAILURE;
7177 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307178 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7179 "encryType = %d"),
7180 lim_BssTypetoString(pProfile->BSSType),
7181 pProfile->BSSType,
7182 pProfile->AuthType.authType[0],
7183 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 csrRoamCancelRoaming(pMac, sessionId);
7185 csrScanRemoveFreshScanCommand(pMac, sessionId);
7186 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307187 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 if(csrIsConnStateConnected(pMac, sessionId))
7190 {
7191 if(pProfile)
7192 {
7193 if(pProfile->SSIDs.numOfSSIDs &&
7194 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7195 {
7196 fCallCallback = eANI_BOOLEAN_FALSE;
7197 }
7198 else
7199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007200 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 }
7202 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307203 else if (!vos_mem_compare(&modProfileFields,
7204 &pSession->connectedProfile.modifyProfileFields,
7205 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 {
7207 fCallCallback = eANI_BOOLEAN_FALSE;
7208 }
7209 else
7210 {
7211 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007212 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 }
7214 }
7215 else
7216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007217 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 if(!fCallCallback)
7220 {
7221 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7222 if(pRoamId)
7223 {
7224 *pRoamId = roamId;
7225 }
7226
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7228 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 }
7230 else
7231 {
7232 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7233 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 return status;
7236}
Jeff Johnson295189b2012-06-20 16:38:30 -07007237eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7238{
7239 eHalStatus status = eHAL_STATUS_FAILURE;
7240 tScanResultHandle hBSSList = NULL;
7241 tCsrScanResultFilter *pScanFilter = NULL;
7242 tANI_U32 roamId;
7243 tCsrRoamProfile *pProfile = NULL;
7244 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007245
7246 if(!pSession)
7247 {
7248 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7249 return eHAL_STATUS_FAILURE;
7250 }
7251
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 do
7253 {
7254 if(pSession->pCurRoamProfile)
7255 {
7256 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307257 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307259 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7260 if ( NULL == pProfile )
7261 status = eHAL_STATUS_FAILURE;
7262 else
7263 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 if(!HAL_STATUS_SUCCESS(status))
7265 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307266 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307268 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307270 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7271 if ( NULL == pScanFilter )
7272 status = eHAL_STATUS_FAILURE;
7273 else
7274 status = eHAL_STATUS_SUCCESS;
7275
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 if(!HAL_STATUS_SUCCESS(status))
7277 {
7278 break;
7279 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307280 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7282 if(!HAL_STATUS_SUCCESS(status))
7283 {
7284 break;
7285 }
7286 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7287 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7288 if(HAL_STATUS_SUCCESS(status))
7289 {
7290 //we want to put the last connected BSS to the very beginning, if possible
7291 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7292 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7293 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7294 if(!HAL_STATUS_SUCCESS(status))
7295 {
7296 csrScanResultPurge(pMac, hBSSList);
7297 break;
7298 }
7299 }
7300 else
7301 {
7302 //Do a scan on this profile
7303 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007304 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 if(!HAL_STATUS_SUCCESS(status))
7306 {
7307 break;
7308 }
7309 }
7310 }//We have a profile
7311 else
7312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007313 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 break;
7315 }
7316 }while(0);
7317 if(pScanFilter)
7318 {
7319 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307320 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 }
7322 if(NULL != pProfile)
7323 {
7324 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307325 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 return (status);
7328}
Jeff Johnson295189b2012-06-20 16:38:30 -07007329eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7330{
7331 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 if(csrIsConnStateConnected(pMac, sessionId))
7333 {
7334 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7335 if(HAL_STATUS_SUCCESS(status))
7336 {
7337 status = csrRoamJoinLastProfile(pMac, sessionId);
7338 }
7339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 return (status);
7341}
7342
Jeff Johnson295189b2012-06-20 16:38:30 -07007343eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7344{
7345 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007346 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 csrRoamCancelRoaming(pMac, sessionId);
7348 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7349 if(csrIsConnStateDisconnected(pMac, sessionId))
7350 {
7351 status = csrRoamJoinLastProfile(pMac, sessionId);
7352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 return (status);
7354}
7355
Jeff Johnson295189b2012-06-20 16:38:30 -07007356eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7357{
7358 eHalStatus status = eHAL_STATUS_SUCCESS;
7359 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7360 eCsrRoamSubState NewSubstate;
7361 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307362
7363 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7364 {
7365 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7366 " eCSR_ROAM_SUBSTATE_NONE"));
7367 csrRoamStopWaitForKeyTimer( pMac );
7368 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 // change state to 'Roaming'...
7371 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7372
7373 if ( csrIsConnStateIbss( pMac, sessionId ) )
7374 {
7375 // If we are in an IBSS, then stop the IBSS...
7376 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7377 fComplete = (!HAL_STATUS_SUCCESS(status));
7378 }
7379 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007381 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 -07007382 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7383 //Restore AC weight in case we change it
7384 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7385 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7386 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7387 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7388 {
7389 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7390 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307391 else
7392 {
7393 // If we are in neighbor preauth done state then on receiving
7394 // disassoc or deauth we dont roam instead we just disassoc
7395 // from current ap and then go to disconnected state
7396 // This happens for ESE and 11r FT connections ONLY.
7397#ifdef WLAN_FEATURE_VOWIFI_11R
7398 if (csrRoamIs11rAssoc(pMac) &&
7399 (csrNeighborRoamStatePreauthDone(pMac)))
7400 {
7401 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7402 }
7403#endif
7404#ifdef FEATURE_WLAN_ESE
7405 if (csrRoamIsESEAssoc(pMac) &&
7406 (csrNeighborRoamStatePreauthDone(pMac)))
7407 {
7408 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7409 }
7410#endif
7411#ifdef FEATURE_WLAN_LFR
7412 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7413 (csrNeighborRoamStatePreauthDone(pMac)))
7414 {
7415 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7416 }
7417#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307418#ifdef WLAN_FEATURE_LFR_MBB
7419 csr_stop_preauth_reassoc_mbb_timer(pMac);
7420#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307421 }
7422
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 if( fDisassoc )
7424 {
7425 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307426 if (pMac->roam.configParam.roamDelayStatsEnabled)
7427 {
7428 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 }
7431 else
7432 {
7433 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7434 }
7435 fComplete = (!HAL_STATUS_SUCCESS(status));
7436 }
7437 else if ( csrIsConnStateWds( pMac, sessionId ) )
7438 {
7439 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7440 {
7441 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7442 fComplete = (!HAL_STATUS_SUCCESS(status));
7443 }
7444 //This has to be WDS station
7445 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7446 {
7447
7448 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7449 if( fDisassoc )
7450 {
7451 status = csrRoamIssueDisassociate( pMac, sessionId,
7452 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7453 fComplete = (!HAL_STATUS_SUCCESS(status));
7454 }
7455 }
7456 } else {
7457 // we got a dis-assoc request while not connected to any peer
7458 // just complete the command
7459 fComplete = eANI_BOOLEAN_TRUE;
7460 status = eHAL_STATUS_FAILURE;
7461 }
7462 if(fComplete)
7463 {
7464 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7465 }
7466
7467 if(HAL_STATUS_SUCCESS(status))
7468 {
7469 if ( csrIsConnStateInfra( pMac, sessionId ) )
7470 {
7471 //Set the state to disconnect here
7472 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307473#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7474 //we don't need to run this timer any more
7475 if (VOS_TIMER_STATE_RUNNING ==
7476 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7477 {
7478 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7479 if (status != eHAL_STATUS_SUCCESS)
7480 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7481 }
7482#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 }
7484 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007485 else
7486 {
7487 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 return (status);
7490}
7491
Jeff Johnson295189b2012-06-20 16:38:30 -07007492/* This is been removed from latest code base */
7493/*
7494static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7495{
7496 eHalStatus status;
7497 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7499 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 return ( status );
7501}
7502*/
7503
Jeff Johnson295189b2012-06-20 16:38:30 -07007504eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7505{
7506 eHalStatus status = eHAL_STATUS_SUCCESS;
7507 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 do
7510 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 pCommand = csrGetCommandBuffer( pMac );
7512 if ( !pCommand )
7513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007514 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 status = eHAL_STATUS_RESOURCES;
7516 break;
7517 }
7518 //Change the substate in case it is wait-for-key
7519 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7520 {
7521 csrRoamStopWaitForKeyTimer( pMac );
7522 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7523 }
7524 pCommand->command = eSmeCommandRoam;
7525 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307526 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7527 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007528 switch ( reason )
7529 {
7530 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7531 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7532 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 case eCSR_DISCONNECT_REASON_DEAUTH:
7534 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7535 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7538 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7540 case eCSR_DISCONNECT_REASON_DISASSOC:
7541 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7542 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7544 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7545 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7547 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7548 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 default:
7550 break;
7551 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307552 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 if( !HAL_STATUS_SUCCESS( status ) )
7554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007555 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 csrReleaseCommandRoam( pMac, pCommand );
7557 }
7558 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 return( status );
7560}
7561
Jeff Johnson295189b2012-06-20 16:38:30 -07007562eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7563{
7564 eHalStatus status = eHAL_STATUS_SUCCESS;
7565 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 pCommand = csrGetCommandBuffer( pMac );
7567 if ( NULL != pCommand )
7568 {
7569 //Change the substate in case it is wait-for-key
7570 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7571 {
7572 csrRoamStopWaitForKeyTimer( pMac );
7573 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7574 }
7575 pCommand->command = eSmeCommandRoam;
7576 pCommand->sessionId = (tANI_U8)sessionId;
7577 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7578 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7579 if( !HAL_STATUS_SUCCESS( status ) )
7580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007581 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 csrReleaseCommandRoam( pMac, pCommand );
7583 }
7584 }
7585 else
7586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007587 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 status = eHAL_STATUS_RESOURCES;
7589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 return ( status );
7591}
7592
Jeff Johnson295189b2012-06-20 16:38:30 -07007593eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7594{
7595 eHalStatus status = eHAL_STATUS_SUCCESS;
7596 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007597
7598 if(!pSession)
7599 {
7600 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7601 return eHAL_STATUS_FAILURE;
7602 }
7603
Jeff Johnson295189b2012-06-20 16:38:30 -07007604#ifdef FEATURE_WLAN_BTAMP_UT_RF
7605 //Stop te retry
7606 pSession->maxRetryCount = 0;
7607 csrRoamStopJoinRetryTimer(pMac, sessionId);
7608#endif
7609 //Not to call cancel roaming here
7610 //Only issue disconnect when necessary
7611 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7612 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7613 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7614
7615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007616 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7618 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307619 else
7620 {
Abhishek Singh7b52ed52016-02-11 17:45:54 +05307621 pMac->roam.roamSession[sessionId].connectState =
7622 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307623 csrScanAbortScanForSSID(pMac, sessionId);
7624 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307625 smsLog(pMac, LOGE,
7626 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 return (status);
7629}
7630
Jeff Johnson295189b2012-06-20 16:38:30 -07007631eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7632{
7633 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007634
7635 if(!pSession)
7636 {
7637 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7638 return eHAL_STATUS_FAILURE;
7639 }
7640
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7643
7644 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7645}
7646
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307647void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7648{
7649 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7650 if(!pSession)
7651 {
7652 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7653 return;
7654 }
7655 pSession->abortConnection = TRUE;
7656 return;
7657}
7658
Jeff Johnson295189b2012-06-20 16:38:30 -07007659eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7660 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7661{
7662 eHalStatus status = eHAL_STATUS_SUCCESS;
7663 tDot11fBeaconIEs *pIesTemp = pIes;
7664 tANI_U8 index;
7665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7666 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007667
7668 if(!pSession)
7669 {
7670 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7671 return eHAL_STATUS_FAILURE;
7672 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007673 if(pConnectProfile->pAddIEAssoc)
7674 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307675 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007676 pConnectProfile->pAddIEAssoc = NULL;
7677 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307678 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7680 pConnectProfile->AuthInfo = pProfile->AuthType;
7681 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7682 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7683 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7684 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7685 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7686 pConnectProfile->BSSType = pProfile->BSSType;
7687 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7688 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007689 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307690 if (!pConnectProfile->beaconInterval)
7691 {
7692 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7693 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307694 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007695 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7696 if(pProfile->nAddIEAssocLength)
7697 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307698 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7699 if ( NULL == pConnectProfile->pAddIEAssoc )
7700 status = eHAL_STATUS_FAILURE;
7701 else
7702 status = eHAL_STATUS_SUCCESS;
7703 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007704 {
7705 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7706 return eHAL_STATUS_FAILURE;
7707 }
7708 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307709 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7710 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007711 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307712
7713#ifdef WLAN_FEATURE_11W
7714 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7715 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7716 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7717#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007718
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 //Save bssid
7720 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7721#ifdef WLAN_FEATURE_VOWIFI_11R
7722 if (pSirBssDesc->mdiePresent)
7723 {
7724 pConnectProfile->MDID.mdiePresent = 1;
7725 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7726 }
7727#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007728 if( NULL == pIesTemp )
7729 {
7730 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7731 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007732#ifdef FEATURE_WLAN_ESE
7733 if ((csrIsProfileESE(pProfile) ||
7734 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307735 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7736 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7737 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7738 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7739#ifdef WLAN_FEATURE_11W
7740 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307741 || (pProfile->negotiatedAuthType ==
7742 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307743#endif
7744 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007745 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007746 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007747 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 }
7749#endif
7750 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 if(HAL_STATUS_SUCCESS(status))
7752 {
7753 if(pIesTemp->SSID.present)
7754 {
7755 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307756 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7757 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 }
7759
7760 //Save the bss desc
7761 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307762
7763 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307765 //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 -07007766 pConnectProfile->qap = TRUE;
7767 }
7768 else
7769 {
7770 pConnectProfile->qap = FALSE;
7771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 if ( NULL == pIes )
7773 {
7774 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307775 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007776 }
7777 }
7778 //Save Qos connection
7779 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7780
7781 if(!HAL_STATUS_SUCCESS(status))
7782 {
7783 csrFreeConnectBssDesc(pMac, sessionId);
7784 }
7785 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7786 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307787 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7788 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7789 pConnectProfile->SSID.ssId,
7790 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 {
7792 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7793 break;
7794 }
7795 pConnectProfile->handoffPermitted = FALSE;
7796 }
7797
7798 return (status);
7799}
7800
Jeff Johnson295189b2012-06-20 16:38:30 -07007801static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7802{
7803 tListElem *pEntry = NULL;
7804 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307805 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 //The head of the active list is the request we sent
7807 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7808 if(pEntry)
7809 {
7810 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7811 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307812 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007813 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7814 {
7815 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7816 {
7817#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7818 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7819#endif
7820 }
7821 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307822 if(!pSession)
7823 {
7824 smsLog(pMac, LOGE, FL(" session %d not found "),
7825 pSmeJoinRsp->sessionId);
7826 return;
7827 }
7828 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 }
7830 else
7831 {
7832 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007833 if(!pSession)
7834 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307835 smsLog(pMac, LOGE, FL(" session %d not found "),
7836 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007837 return;
7838 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307839 if (pSession->abortConnection)
7840 {
7841 smsLog(pMac, LOG1, FL("Disconnection in progess"
7842 "abort Join request"));
7843 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7844 pSession->abortConnection = FALSE;
7845 return;
7846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 //The head of the active list is the request we sent
7848 //Try to get back the same profile and roam again
7849 if(pCommand)
7850 {
7851 roamId = pCommand->u.roamCmd.roamId;
7852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7854 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007855 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007856#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7857 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7858 if (csrRoamIsHandoffInProgress(pMac))
7859 {
7860 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7861 /* Should indicate neighbor roam algorithm about the connect failure here */
7862 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7863 }
7864#endif
7865 if (pCommand)
7866 {
7867 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7868 {
7869 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7870 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7871 csrRoamReissueRoamCommand(pMac);
7872 }
7873 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7874 {
7875 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7876 }
7877 else
7878 {
7879 csrRoam(pMac, pCommand);
7880 }
7881 }
7882 else
7883 {
7884 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7885 }
7886 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7887}
7888
Jeff Johnson295189b2012-06-20 16:38:30 -07007889eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7890 tDot11fBeaconIEs *pIes,
7891 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7892{
7893 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007894 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7895 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007896
7897 // Set the roaming substate to 'join attempt'...
7898 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007900 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 return (status);
7902}
7903
Jeff Johnson295189b2012-06-20 16:38:30 -07007904static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7905 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7906{
7907 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 // Set the roaming substate to 'join attempt'...
7909 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7910
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307911 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7912 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307913 if (pMac->roam.configParam.roamDelayStatsEnabled)
7914 {
7915 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7916 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007919 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007920}
7921
Jeff Johnson295189b2012-06-20 16:38:30 -07007922void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7923{
7924 tListElem *pEntry;
7925 tSmeCmd *pCommand;
7926 tCsrRoamInfo roamInfo;
7927 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307928 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007929
7930 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7931 if(pEntry)
7932 {
7933 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7934 if ( eSmeCommandRoam == pCommand->command )
7935 {
7936 sessionId = pCommand->sessionId;
7937 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007938
7939 if(!pSession)
7940 {
7941 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7942 return;
7943 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307944 /* While switching between two AP, csr will reissue roam command again
7945 to the nextbss if it was interrupted by the dissconnect req for the
7946 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7947 so reset the bRefAssocStartCnt.
7948 */
7949 if(pSession->bRefAssocStartCnt > 0)
7950 {
7951 pSession->bRefAssocStartCnt--;
7952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 if( pCommand->u.roamCmd.fStopWds )
7954 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307955 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7957 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7958 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7961 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7962 eCSR_ROAM_WDS_IND,
7963 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7965 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7966 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7967 eCSR_ROAM_INFRA_IND,
7968 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7969 }
7970
Jeff Johnson295189b2012-06-20 16:38:30 -07007971
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007974 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7976 }
7977 }
7978 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007980 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007981 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7982 }
7983 }
7984 else
7985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007986 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 }
7988 }
7989 else
7990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007991 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 }
7993}
7994
Jeff Johnson295189b2012-06-20 16:38:30 -07007995tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7996{
7997 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7998 tListElem *pEntry;
7999 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008000 //alwasy lock active list before locking pending list
8001 csrLLLock( &pMac->sme.smeCmdActiveList );
8002 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8003 if(pEntry)
8004 {
8005 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8006 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8007 {
8008 fRet = eANI_BOOLEAN_TRUE;
8009 }
8010 }
8011 if(eANI_BOOLEAN_FALSE == fRet)
8012 {
8013 csrLLLock(&pMac->sme.smeCmdPendingList);
8014 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8015 while(pEntry)
8016 {
8017 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8018 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8019 {
8020 fRet = eANI_BOOLEAN_TRUE;
8021 break;
8022 }
8023 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8024 }
8025 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8026 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308027 if (eANI_BOOLEAN_FALSE == fRet)
8028 {
8029 csrLLLock(&pMac->roam.roamCmdPendingList);
8030 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8031 while (pEntry)
8032 {
8033 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8034 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8035 {
8036 fRet = eANI_BOOLEAN_TRUE;
8037 break;
8038 }
8039 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8040 }
8041 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 return (fRet);
8045}
8046
Jeff Johnson295189b2012-06-20 16:38:30 -07008047tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8048{
8049 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8050 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8052 {
8053 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8054 {
8055 break;
8056 }
8057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 return ( fRet );
8059}
8060
Jeff Johnson295189b2012-06-20 16:38:30 -07008061tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8062{
8063 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 //alwasy lock active list before locking pending list
8065 csrLLLock( &pMac->sme.smeCmdActiveList );
8066 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8067 if(eANI_BOOLEAN_FALSE == fRet)
8068 {
8069 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8070 }
8071 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 return (fRet);
8073}
8074
Jeff Johnson295189b2012-06-20 16:38:30 -07008075tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8076{
8077 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8078 tListElem *pEntry;
8079 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 //alwasy lock active list before locking pending list
8081 csrLLLock( &pMac->sme.smeCmdActiveList );
8082 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8083 if( pEntry )
8084 {
8085 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8086 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8087 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8088 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8089 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8090 {
8091 fRet = eANI_BOOLEAN_TRUE;
8092 }
8093 }
8094 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 return (fRet);
8096}
Jeff Johnson295189b2012-06-20 16:38:30 -07008097eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8098{
8099 eHalStatus status = eHAL_STATUS_SUCCESS;
8100 tSmeCmd *pCommand = NULL;
8101 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8102 tANI_BOOLEAN fRemoveCmd = FALSE;
8103 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 // Delete the old assoc command. All is setup for reassoc to be serialized
8105 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8106 if ( pEntry )
8107 {
8108 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8109 if ( !pCommand )
8110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008111 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 return eHAL_STATUS_RESOURCES;
8113 }
8114 if ( eSmeCommandRoam == pCommand->command )
8115 {
8116 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8117 {
8118 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8119 }
8120 else
8121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008122 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 }
8124 if (fRemoveCmd == FALSE)
8125 {
8126 // Implies we did not get the serialized assoc command we
8127 // were expecting
8128 pCommand = NULL;
8129 }
8130 }
8131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 if(NULL == pCommand)
8133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008134 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 return eHAL_STATUS_RESOURCES;
8136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 do
8138 {
8139 //Change the substate in case it is wait-for-key
8140 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8141 {
8142 csrRoamStopWaitForKeyTimer( pMac );
8143 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8144 }
8145 pCommand->command = eSmeCommandRoam;
8146 pCommand->sessionId = (tANI_U8)sessionId;
8147 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8149 if( !HAL_STATUS_SUCCESS( status ) )
8150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008151 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 csrReleaseCommandRoam( pMac, pCommand );
8153 }
8154 } while( 0 );
8155
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 return( status );
8157}
8158static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8159{
8160 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8161 tCsrScanResult *pScanResult = NULL;
8162 tSirBssDescription *pBssDesc = NULL;
8163 tSmeCmd *pCommand = NULL;
8164 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308165 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 if(NULL == pEntry)
8167 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308168 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 return;
8170 }
8171 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8172 sessionId = pCommand->sessionId;
8173 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008174
8175 if(!pSession)
8176 {
8177 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8178 return;
8179 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308180 smsLog(pMac, LOG1, FL("CFG return value is %d "
8181 " current state is : %d substate is : %d "),
8182 result, pMac->roam.curState[sessionId],
8183 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8185 {
8186 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008187 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8189 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008190 /* If the roaming has stopped, not to continue the roaming command*/
8191 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8192 {
8193 //No need to complete roaming here as it already completes
8194 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8195 pCommand->u.roamCmd.roamReason);
8196 csrSetAbortRoamingCommand( pMac, pCommand );
8197 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 else
8200 {
8201 if ( CCM_IS_RESULT_SUCCESS(result) )
8202 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308203 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 // Successfully set the configuration parameters for the new Bss. Attempt to
8205 // join the roaming Bss.
8206 if(pCommand->u.roamCmd.pRoamBssEntry)
8207 {
8208 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308209 if (!pScanResult)
8210 {
8211 smsLog(pMac, LOGE,
8212 FL("Failed to get base address for pScanResult"));
8213 return;
8214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 pBssDesc = &pScanResult->Result.BssDescriptor;
8216 }
8217 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8218 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 )
8221 {
8222 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8223 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8224 pBssDesc, pCommand->u.roamCmd.roamId )))
8225 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308226 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 //We need to complete the command
8228 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8229 }
8230 }
8231 else
8232 {
8233 if (!pCommand->u.roamCmd.pRoamBssEntry)
8234 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308235 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 //We need to complete the command
8237 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8238 return;
8239 }
8240 // If we are roaming TO an Infrastructure BSS...
8241 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308242 if( !pScanResult->Result.pvIes )
8243 {
8244 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8245 return;
8246 }
8247
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 if ( csrIsInfraBssDesc( pBssDesc ) )
8249 {
8250 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308251 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8253 {
8254 // ..and currently in an Infrastructure connection....
8255 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8256 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308257 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 // ...and the SSIDs are equal, then we Reassoc.
8259 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8260 pIesLocal ) )
8261 // ..and currently in an infrastructure connection
8262 {
8263 // then issue a Reassoc.
8264 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8265 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8266 &pCommand->u.roamCmd.roamProfile );
8267 }
8268 else
8269 {
8270
8271 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8272 // previously associated AP.
8273 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8274 pIesLocal,
8275 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8276 {
8277 //try something else
8278 csrRoam( pMac, pCommand );
8279 }
8280 }
8281 }
8282 else
8283 {
8284 eHalStatus status = eHAL_STATUS_SUCCESS;
8285
8286 /* We need to come with other way to figure out that this is because of HO in BMP
8287 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008288 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 * use join request */
8290#ifdef WLAN_FEATURE_VOWIFI_11R
8291 if (csrRoamIsHandoffInProgress(pMac) &&
8292 csrRoamIs11rAssoc(pMac))
8293 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308294 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8296 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8297 }
8298 else
8299#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008300#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008302 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308304 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 // Now serialize the reassoc command.
8306 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8307 }
8308 else
8309#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008310#ifdef FEATURE_WLAN_LFR
8311 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308312 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008313 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308314 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008315 // Now serialize the reassoc command.
8316 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8317 }
8318 else
8319#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008320 // else we are not connected and attempting to Join. Issue the
8321 // Join request.
8322 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308323 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8325 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8326 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8327 }
8328 if(!HAL_STATUS_SUCCESS(status))
8329 {
8330 //try something else
8331 csrRoam( pMac, pCommand );
8332 }
8333 }
8334 if( !pScanResult->Result.pvIes )
8335 {
8336 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308337 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 }
8339 }
8340 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8341 else
8342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008343 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 }
8345 }//else
8346 }//if ( WNI_CFG_SUCCESS == result )
8347 else
8348 {
8349 // In the event the configuration failed, for infra let the roam processor
8350 //attempt to join something else...
8351 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8352 {
8353 csrRoam(pMac, pCommand);
8354 }
8355 else
8356 {
8357 //We need to complete the command
8358 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8359 {
8360 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8361 }
8362 else
8363 {
8364 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8365 }
8366 }
8367 }
8368 }//we have active entry
8369}
8370
Jeff Johnson295189b2012-06-20 16:38:30 -07008371static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8372{
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008375 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8377 // join the new one...
8378 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8380 }
8381 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008382 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 /***profHandleLostLinkAfterReset(pAdapter);
8384 // In the event the authenticate fails, let the roam processor attempt to join something else...
8385 roamRoam( pAdapter );***/
8386 }
8387}
8388
Jeff Johnson295189b2012-06-20 16:38:30 -07008389static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8390{
8391 eCsrRoamCompleteResult result;
8392 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8393 tCsrRoamInfo roamInfo;
8394 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308395 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308396 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308397 tANI_U8 nilMac[6] = {0};
8398
8399 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008401 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 /* Defeaturize this part later if needed */
8404#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8405 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8406 * we need the response contents while processing the result in csrRoamProcessResults() */
8407 if (csrRoamIsHandoffInProgress(pMac))
8408 {
8409 /* Need to dig more on indicating events to SME QoS module */
8410 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8411 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308412#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8413 /* Add previous BSSID to blacklist ; this will be in blacklised for
8414 * some period and score of this AP will be reduced if black listed
8415 * to avoid ping pong */
8416 if (pMac->PERroamCandidatesCnt)
8417 {
8418 current_timestamp = jiffies_to_msecs(jiffies);
8419 for (candidateApCnt = 0; candidateApCnt <
8420 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8421 {
8422 /* Find one blank entry */
8423 if (sirCompareMacAddr(nilMac,
8424 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8425 {
8426 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8427 bssAddr,
8428 pNeighborRoamInfo->prevConnProfile.bssid,
8429 sizeof(tSirMacAddr));
8430 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8431 current_timestamp;
8432 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8433 MAC_ADDR_ARRAY(
8434 pNeighborRoamInfo->prevConnProfile.bssid),
8435 candidateApCnt);
8436 break;
8437 }
8438 /* if already in the list */
8439 if (sirCompareMacAddr(pMac->previousRoamApInfo
8440 [candidateApCnt].bssAddr,
8441 pNeighborRoamInfo->prevConnProfile.bssid) &&
8442 ((current_timestamp -
8443 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8444 pMac->PERroamTimeout))
8445 {
8446 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8447 bssAddr,
8448 pNeighborRoamInfo->prevConnProfile.bssid,
8449 sizeof(tSirMacAddr));
8450 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8451 current_timestamp;
8452 break;
8453 } else
8454 {
8455 /* find oldest BSSID entry in the blacklist */
8456 if (max_time <
8457 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8458 {
8459 max_time =
8460 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8461 oldestIndex = candidateApCnt;
8462 }
8463 }
8464 }
8465 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8466 {
8467 smsLog(pMac, LOGW,
8468 "%s: Clearing out oldest roam results bssid="
8469 MAC_ADDRESS_STR,
8470 __func__,
8471 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8472 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8473 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8474 pNeighborRoamInfo->prevConnProfile.bssid,
8475 sizeof(tSirMacAddr));
8476 }
8477 }
8478#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 }
8480 else
8481#endif
8482 {
8483 csrRoamComplete( pMac, result, NULL );
8484 }
8485 }
8486 /* Should we handle this similar to handling the join failure? Is it ok
8487 * to call csrRoamComplete() with state as CsrJoinFailure */
8488 else
8489 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008490 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308492 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8493 WLAN_LOG_INDICATOR_HOST_DRIVER,
8494 WLAN_LOG_REASON_ROAM_FAIL,
8495 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008496#ifdef WLAN_FEATURE_VOWIFI_11R
8497 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308498 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8499 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 {
8501 // Inform HDD to turn off FT flag in HDD
8502 if (pNeighborRoamInfo)
8503 {
8504 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8505 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8506 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008507 /*
8508 * Since the above callback sends a disconnect
8509 * to HDD, we should clean-up our state
8510 * machine as well to be in sync with the upper
8511 * layers. There is no need to send a disassoc
8512 * since: 1) we will never reassoc to the current
8513 * AP in LFR, and 2) there is no need to issue a
8514 * disassoc to the AP with which we were trying
8515 * to reassoc.
8516 */
8517 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8518 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 }
8520 }
8521#endif
8522 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8523 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8524 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8525 //The disassoc rsp message will remove the command from active list
8526 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8527 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8528 {
8529 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8530 }
8531 }
8532}
8533
Jeff Johnson295189b2012-06-20 16:38:30 -07008534static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8535{
Jeff Johnson295189b2012-06-20 16:38:30 -07008536#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8537 {
8538 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8540 if(pIbssLog)
8541 {
8542 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8543 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8544 {
8545 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8546 }
8547 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8548 }
8549 }
8550#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8552 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8553 {
8554 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8555 }
8556 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8557 {
8558 csrRoamReissueRoamCommand(pMac);
8559 }
8560}
8561
Jeff Johnson295189b2012-06-20 16:38:30 -07008562void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8563{
8564 tSirResultCodes statusCode;
8565#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8566 tScanResultHandle hBSSList;
8567 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8568 eHalStatus status;
8569 tCsrRoamInfo roamInfo;
8570 tCsrScanResultFilter *pScanFilter = NULL;
8571 tANI_U32 roamId = 0;
8572 tCsrRoamProfile *pCurRoamProfile = NULL;
8573 tListElem *pEntry = NULL;
8574 tSmeCmd *pCommand = NULL;
8575#endif
8576 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308577 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008578
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 tSirSmeDisassocRsp SmeDisassocRsp;
8580
8581 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8582 sessionId = SmeDisassocRsp.sessionId;
8583 statusCode = SmeDisassocRsp.statusCode;
8584
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008585 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008586
8587 if ( csrIsConnStateInfra( pMac, sessionId ) )
8588 {
8589 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008592
8593 if(!pSession)
8594 {
8595 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8596 return;
8597 }
8598
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8600 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308601 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8603 }
8604 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8605 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8606 {
8607 if ( eSIR_SME_SUCCESS == statusCode )
8608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008609 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8611 }
8612 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8615 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308616 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8617 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008618#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008619 /*
8620 * First ensure if the roam profile is in the scan cache.
8621 * If not, post a reassoc failure and disconnect.
8622 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308623 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8624 if ( NULL == pScanFilter )
8625 status = eHAL_STATUS_FAILURE;
8626 else
8627 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008628 if(HAL_STATUS_SUCCESS(status))
8629 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308630 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008631 status = csrRoamPrepareFilterFromProfile(pMac,
8632 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8633 if(!HAL_STATUS_SUCCESS(status))
8634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008635 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008636 __func__, status);
8637 goto POST_ROAM_FAILURE;
8638 }
8639 else
8640 {
8641 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8642 if (!HAL_STATUS_SUCCESS(status))
8643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008644 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008645 __func__, status);
8646 goto POST_ROAM_FAILURE;
8647 }
8648 }
8649 }
8650 else
8651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008652 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008653 __func__, status);
8654 goto POST_ROAM_FAILURE;
8655 }
8656
8657 /*
8658 * After ensuring that the roam profile is in the scan result list,
8659 * dequeue the command from the active list.
8660 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8662 if ( pEntry )
8663 {
8664 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008665 /* If the head of the queue is Active and it is a ROAM command, remove
8666 * and put this on the Free queue.
8667 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 if ( eSmeCommandRoam == pCommand->command )
8669 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008670
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008671 /*
8672 * we need to process the result first before removing it from active list
8673 * because state changes still happening insides roamQProcessRoamResults so
8674 * no other roam command should be issued.
8675 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8677 if(pCommand->u.roamCmd.fReleaseProfile)
8678 {
8679 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8680 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008683 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 else
8685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008686 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008687 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 }
8689 }
8690 else
8691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008692 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 }
8694 }
8695 else
8696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008697 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008699
8700 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008701 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8702
Kiet Lam64c1b492013-07-12 13:56:44 +05308703 vos_mem_copy(roamInfo.bssid,
8704 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8705 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008706
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008707 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8708 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008709
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008710 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308711 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8712 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308714 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008715 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8716 //make sure to put it at the head of the cmd queue
8717 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8718 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8719 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8720
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 if(!HAL_STATUS_SUCCESS(status))
8722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008723 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008724 __func__, status);
8725 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 }
8727
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008728 /* Notify sub-modules like QoS etc. that handoff happening */
8729 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308730 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008731 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308732 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308734 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008735 return;
8736 }
8737
8738POST_ROAM_FAILURE:
8739 if (pScanFilter)
8740 {
8741 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308742 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008743 }
8744 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308745 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008746
8747 /* Inform the upper layers that the reassoc failed */
8748 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8749 csrRoamCallCallback(pMac, sessionId,
8750 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8751
8752 /*
8753 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8754 * Upon success, we would re-enter this routine after receiving the disassoc
8755 * response and will fall into the reassoc fail sub-state. And, eventually
8756 * call csrRoamComplete which would remove the roam command from SME active
8757 * queue.
8758 */
8759 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8760 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008762 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008763 __func__, status);
8764 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008766#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008767
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8769 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8770 {
8771 // Disassoc due to Reassoc failure falls into this codepath....
8772 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8773 }
8774 else
8775 {
8776 if ( eSIR_SME_SUCCESS == statusCode )
8777 {
8778 // Successfully disassociated from the 'old' Bss...
8779 //
8780 // We get Disassociate response in three conditions.
8781 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8782 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8783 // Infrastructure network.
8784 // - Third is where we are doing an Infra to Infra roam between networks with different
8785 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8786
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008787 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 }
8789 else
8790 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008791 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008792 }
8793 //We are not done yet. Get the data and continue roaming
8794 csrRoamReissueRoamCommand(pMac);
8795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008796}
8797
Jeff Johnson295189b2012-06-20 16:38:30 -07008798static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8799{
8800 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008802 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8804 {
8805 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8806 }
8807 else
8808 {
8809 if ( eSIR_SME_SUCCESS == statusCode )
8810 {
8811 // Successfully deauth from the 'old' Bss...
8812 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008813 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 }
8815 else
8816 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008817 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 }
8819 //We are not done yet. Get the data and continue roaming
8820 csrRoamReissueRoamCommand(pMac);
8821 }
8822}
8823
Jeff Johnson295189b2012-06-20 16:38:30 -07008824static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8825{
8826 eCsrRoamCompleteResult result;
8827
8828 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008830 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 result = eCsrStartBssSuccess;
8832 }
8833 else
8834 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008835 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 //Let csrRoamComplete decide what to do
8837 result = eCsrStartBssFailure;
8838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008840}
8841
Jeff Johnson295189b2012-06-20 16:38:30 -07008842/*
8843 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8844 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8845 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8846 For the messages where sender allocates memory for specific structures, then it can be
8847 cast accordingly.
8848*/
8849void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8850{
8851 tSirSmeRsp *pSmeRsp;
8852 tSmeIbssPeerInd *pIbssPeerInd;
8853 tCsrRoamInfo roamInfo;
8854 // TODO Session Id need to be acquired in this function
8855 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308857 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8858 pSmeRsp->messageType, pSmeRsp->messageType,
8859 macTraceGetcsrRoamSubState(
8860 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 pSmeRsp->messageType = (pSmeRsp->messageType);
8862 pSmeRsp->length = (pSmeRsp->length);
8863 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 switch (pSmeRsp->messageType)
8865 {
8866
8867 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8868 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8869 {
8870 //We sent a JOIN_REQ
8871 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8872 }
8873 break;
8874
8875 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8876 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8877 {
8878 //We sent a AUTH_REQ
8879 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8880 }
8881 break;
8882
8883 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8884 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8885 {
8886 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8887 }
8888 break;
8889
8890 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8891 {
8892 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8893 }
8894 break;
8895
8896 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8897 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8898 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8899 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8900 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8901 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8902//HO
8903 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8904 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308905 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8906 macTraceGetcsrRoamSubState(
8907 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308909 if (pMac->roam.configParam.roamDelayStatsEnabled)
8910 {
8911 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 }
8914 break;
8915
8916 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8917 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8918 {
8919 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8920 }
8921 break;
8922
8923 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8924 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8925 {
8926 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8927 }
8928 break;
8929
8930 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8931 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8932 {
8933 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8937 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8938 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008939 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308940 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8941 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8943 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308944 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8945 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008946 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8947 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8948 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8949 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05308950 case eWNI_SME_LOST_LINK_PARAMS_IND:
8951 {
8952 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
8953 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8954 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8955 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8956 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
8957 pRoamInfo = &roamInfo;
8958 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
8959 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
8960 break;
8961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308963 smsLog(pMac, LOG1,
8964 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8965 pSmeRsp->messageType, pSmeRsp->messageType,
8966 macTraceGetcsrRoamSubState(
8967 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008968
8969 //If we are connected, check the link status change
8970 if(!csrIsConnStateDisconnected(pMac, sessionId))
8971 {
8972 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8973 }
8974 break;
8975 }
8976}
8977
Jeff Johnson295189b2012-06-20 16:38:30 -07008978void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8979{
8980 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 switch (pSirMsg->messageType)
8982 {
8983 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008984 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 csrRoamStatsRspProcessor( pMac, pSirMsg );
8986 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8988 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308989 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8991 tCsrRoamInfo roamInfo;
8992 tCsrRoamInfo *pRoamInfo = NULL;
8993 tANI_U32 sessionId;
8994 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008995 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308996 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8999 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9000 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009001
9002 if(!pSession)
9003 {
9004 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9005 return;
9006 }
9007
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9009 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9011 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9012 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9014 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309015 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9016 sizeof(tSirMacAddr));
9017 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9018 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309020#ifdef WLAN_FEATURE_AP_HT40_24G
9021 pRoamInfo->HT40MHzIntoEnabledSta =
9022 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9023 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9024 pRoamInfo->HT40MHzIntoEnabledSta);
9025#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309026 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9028 {
9029 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9030 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9031 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9032 }
9033 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9034 {
9035 vos_sleep( 100 );
9036 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9037 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9038 }
9039
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 }
9041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 default:
9043 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9044 break;
9045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009046}
9047
Jeff Johnson295189b2012-06-20 16:38:30 -07009048eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9049 tSirBssDescription *pBssDescription,
9050 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9051 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9052 tANI_U8 keyId, tANI_U16 keyLength,
9053 tANI_U8 *pKey, tANI_U8 paeRole )
9054{
9055 eHalStatus status = eHAL_STATUS_SUCCESS;
9056 tAniEdType edType;
9057
9058 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9059 {
9060 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9061 }
9062
9063 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9064
9065 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9066 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9067 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9068 addKey )
9069 {
9070 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 setKey.encType = EncryptType;
9072 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309073 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 setKey.paeRole = paeRole; //0 for supplicant
9075 setKey.keyId = keyId; // Kye index
9076 setKey.keyLength = keyLength;
9077 if( keyLength )
9078 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309079 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 }
9081 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 return (status);
9084}
9085
Jeff Johnson295189b2012-06-20 16:38:30 -07009086static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9087 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9088{
9089 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9090 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009091#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009093#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009094
9095 do
9096 {
9097 pCommand = csrGetCommandBuffer(pMac);
9098 if(NULL == pCommand)
9099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009100 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 status = eHAL_STATUS_RESOURCES;
9102 break;
9103 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309104 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009105 pCommand->command = eSmeCommandSetKey;
9106 pCommand->sessionId = (tANI_U8)sessionId;
9107 // validate the key length, Adjust if too long...
9108 // for static WEP the keys are not set thru' SetContextReq
9109 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9110 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9111 {
9112 //KeyLength maybe 0 for static WEP
9113 if( pSetKey->keyLength )
9114 {
9115 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009117 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 break;
9119 }
9120
9121 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309122 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9123 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 }
9125 }
9126 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9127 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9128 {
9129 //KeyLength maybe 0 for static WEP
9130 if( pSetKey->keyLength )
9131 {
9132 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009134 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 break;
9136 }
9137
9138 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309139 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9140 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 }
9142 }
9143 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9144 {
9145 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009147 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 break;
9149 }
9150 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309151 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9152 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 }
9154 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9155 {
9156 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009158 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 break;
9160 }
9161 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309162 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9163 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 }
9165#ifdef FEATURE_WLAN_WAPI
9166 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9167 {
9168 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009170 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 break;
9172 }
9173 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309174 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9175 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009176 }
9177#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9180 {
9181 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009183 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 break;
9185 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009186 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309187 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009188 pSession->eseCckmInfo.reassoc_req_num=1;
9189 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 status = eHAL_STATUS_SUCCESS;
9191 break;
9192 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009193#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009194
Jeff Johnson295189b2012-06-20 16:38:30 -07009195#ifdef WLAN_FEATURE_11W
9196 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009197 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009199 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009201 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 break;
9203 }
9204 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309205 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 }
9207#endif
9208 status = eHAL_STATUS_SUCCESS;
9209 pCommand->u.setKeyCmd.roamId = roamId;
9210 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9211 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309212 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9213 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9215 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309216 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 //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
9218
9219 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9220 if( !HAL_STATUS_SUCCESS( status ) )
9221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009222 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 }
9224 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009226 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009227 if ( ( NULL != pCommand ) &&
9228 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009229#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009231#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009232 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 {
9234 csrReleaseCommandSetKey( pMac, pCommand );
9235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 return( status );
9237}
9238
Jeff Johnson295189b2012-06-20 16:38:30 -07009239eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9240 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9241{
9242 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9243 tSmeCmd *pCommand = NULL;
9244 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 do
9246 {
9247 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009249 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009250 status = eHAL_STATUS_CSR_WRONG_STATE;
9251 break;
9252 }
9253 pCommand = csrGetCommandBuffer(pMac);
9254 if(NULL == pCommand)
9255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009256 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 status = eHAL_STATUS_RESOURCES;
9258 break;
9259 }
9260 pCommand->command = eSmeCommandRemoveKey;
9261 pCommand->sessionId = (tANI_U8)sessionId;
9262 pCommand->u.removeKeyCmd.roamId = roamId;
9263 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309264 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9265 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9267 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9268 {
9269 //in this case, put it to the end of the Q incase there is a set key pending.
9270 fImediate = eANI_BOOLEAN_FALSE;
9271 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009272 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009273 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009274 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9276 if( !HAL_STATUS_SUCCESS( status ) )
9277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009278 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009279 break;
9280 }
9281 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9283 {
9284 csrReleaseCommandRemoveKey( pMac, pCommand );
9285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 return (status );
9287}
9288
Jeff Johnson295189b2012-06-20 16:38:30 -07009289eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9290{
9291 eHalStatus status;
9292 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9293 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9294 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9295 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009296#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9297 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9298 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309299 if(!pSession)
9300 {
9301 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9302 return eHAL_STATUS_FAILURE;
9303 }
lukez3c809222013-05-03 10:23:02 -07009304 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309306 vos_mem_set(&setKeyEvent,
9307 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009308 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9309 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309310 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9312 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9313 }
9314 else
9315 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309316 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9318 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9319 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309320 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009321 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 {
9323 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 //It has to be static WEP here
9325 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9326 {
9327 setKeyEvent.keyId = (v_U8_t)defKeyId;
9328 }
9329 }
9330 else
9331 {
9332 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9333 }
9334 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9335 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9336 }
9337#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 if( csrIsSetKeyAllowed(pMac, sessionId) )
9339 {
9340 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9341 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9342 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9343 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9344 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9345 pCommand->u.setKeyCmd.keyRsc);
9346 }
9347 else
9348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009349 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 //Set this status so the error handling take care of the case.
9351 status = eHAL_STATUS_CSR_WRONG_STATE;
9352 }
9353 if( !HAL_STATUS_SUCCESS(status) )
9354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009355 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009356 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009357#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009358 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 {
9360 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9361 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309362 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 }
9364 else
9365 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309366 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 }
9368 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9369 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9370 }
9371#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009373 return ( status );
9374}
9375
Jeff Johnson295189b2012-06-20 16:38:30 -07009376eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9377{
9378 eHalStatus status;
9379 tpSirSmeRemoveKeyReq pMsg = NULL;
9380 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9381 tANI_U8 *p;
9382 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009383#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9384 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9385 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309386 if(!pSession)
9387 {
9388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9389 return eHAL_STATUS_FAILURE;
9390 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309391 vos_mem_set(&removeKeyEvent,
9392 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9394 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9395 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309396 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009397 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9398 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9399 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9400#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009401 if( csrIsSetKeyAllowed(pMac, sessionId) )
9402 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309403 pMsg = vos_mem_malloc(wMsgLen);
9404 if ( NULL == pMsg )
9405 status = eHAL_STATUS_FAILURE;
9406 else
9407 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 }
9409 else
9410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009411 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 //Set the error status so error handling kicks in below
9413 status = eHAL_STATUS_CSR_WRONG_STATE;
9414 }
9415 if( HAL_STATUS_SUCCESS( status ) )
9416 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309417 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9419 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 pMsg->sessionId = (tANI_U8)sessionId;
9421 pMsg->transactionId = 0;
9422 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9423 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9424 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309425 vos_mem_copy(p,
9426 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9427 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 p += sizeof(tSirMacAddr);
9429 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309430 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 p += sizeof(tSirMacAddr);
9432 // edType
9433 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9434 p++;
9435 // weptype
9436 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9437 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9438 {
9439 *p = (tANI_U8)eSIR_WEP_STATIC;
9440 }
9441 else
9442 {
9443 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9444 }
9445 p++;
9446 //keyid
9447 *p = pCommand->u.removeKeyCmd.keyId;
9448 p++;
9449 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 status = palSendMBMessage(pMac->hHdd, pMsg);
9451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 if( !HAL_STATUS_SUCCESS( status ) )
9453 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009454 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009455#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9456 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009457 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9459#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 return ( status );
9463}
9464
Jeff Johnson295189b2012-06-20 16:38:30 -07009465eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9466{
9467 eHalStatus status;
9468
9469 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9470 {
9471 status = eHAL_STATUS_CSR_WRONG_STATE;
9472 }
9473 else
9474 {
9475 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 return ( status );
9478}
9479
Jeff Johnson295189b2012-06-20 16:38:30 -07009480/*
9481 Prepare a filter base on a profile for parsing the scan results.
9482 Upon successful return, caller MUST call csrFreeScanFilter on
9483 pScanFilter when it is done with the filter.
9484*/
9485eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9486 tCsrScanResultFilter *pScanFilter)
9487{
9488 eHalStatus status = eHAL_STATUS_SUCCESS;
9489 tANI_U32 size = 0;
9490 tANI_U8 index = 0;
9491
9492 do
9493 {
9494 if(pProfile->BSSIDs.numOfBSSIDs)
9495 {
9496 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309497 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9498 if ( NULL == pScanFilter->BSSIDs.bssid )
9499 status = eHAL_STATUS_FAILURE;
9500 else
9501 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 if(!HAL_STATUS_SUCCESS(status))
9503 {
9504 break;
9505 }
9506 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309507 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009508 }
9509 if(pProfile->SSIDs.numOfSSIDs)
9510 {
9511 if( !CSR_IS_WDS_STA( pProfile ) )
9512 {
9513 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9514 }
9515 else
9516 {
9517 //For WDS station
9518 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9519 pScanFilter->SSIDs.numOfSSIDs = 1;
9520 }
9521 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309522 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9523 if ( NULL == pScanFilter->SSIDs.SSIDList )
9524 status = eHAL_STATUS_FAILURE;
9525 else
9526 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 if(!HAL_STATUS_SUCCESS(status))
9528 {
9529 break;
9530 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309531 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9532 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 }
9534 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9535 {
9536 pScanFilter->ChannelInfo.numOfChannels = 0;
9537 pScanFilter->ChannelInfo.ChannelList = NULL;
9538 }
9539 else if(pProfile->ChannelInfo.numOfChannels)
9540 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309541 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9542 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9543 pProfile->ChannelInfo.numOfChannels);
9544 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9545 status = eHAL_STATUS_FAILURE;
9546 else
9547 status = eHAL_STATUS_SUCCESS;
9548
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 pScanFilter->ChannelInfo.numOfChannels = 0;
9550 if(HAL_STATUS_SUCCESS(status))
9551 {
9552 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9553 {
9554 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9555 {
9556 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9557 = pProfile->ChannelInfo.ChannelList[index];
9558 pScanFilter->ChannelInfo.numOfChannels++;
9559 }
9560 else
9561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009562 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 }
9565 }
9566 else
9567 {
9568 break;
9569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 }
9571 else
9572 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309573 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 status = eHAL_STATUS_FAILURE;
9575 break;
9576 }
9577 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9578 pScanFilter->authType = pProfile->AuthType;
9579 pScanFilter->EncryptionType = pProfile->EncryptionType;
9580 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9581 pScanFilter->BSSType = pProfile->BSSType;
9582 pScanFilter->phyMode = pProfile->phyMode;
9583#ifdef FEATURE_WLAN_WAPI
9584 //check if user asked for WAPI with 11n or auto mode, in that case modify
9585 //the phymode to 11g
9586 if(csrIsProfileWapi(pProfile))
9587 {
9588 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9589 {
9590 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9591 }
9592 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9593 {
9594 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9595 }
9596 if(!pScanFilter->phyMode)
9597 {
9598 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9599 }
9600 }
9601#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 /*Save the WPS info*/
9603 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009604 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 if( pProfile->countryCode[0] )
9606 {
9607 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309608 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9609 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 }
9611#ifdef WLAN_FEATURE_VOWIFI_11R
9612 if (pProfile->MDID.mdiePresent)
9613 {
9614 pScanFilter->MDID.mdiePresent = 1;
9615 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9616 }
9617#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309618 vos_mem_copy(pScanFilter->bssid_hint,
9619 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309620
9621#ifdef WLAN_FEATURE_11W
9622 // Management Frame Protection
9623 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9624 pScanFilter->MFPRequired = pProfile->MFPRequired;
9625 pScanFilter->MFPCapable = pProfile->MFPCapable;
9626#endif
9627
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 }while(0);
9629
9630 if(!HAL_STATUS_SUCCESS(status))
9631 {
9632 csrFreeScanFilter(pMac, pScanFilter);
9633 }
9634
9635 return(status);
9636}
9637
Jeff Johnson295189b2012-06-20 16:38:30 -07009638tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9639 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9640{
9641 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9642 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 do
9644 {
9645 // Validate the type is ok...
9646 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9647 pCommand = csrGetCommandBuffer( pMac );
9648 if ( !pCommand )
9649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009650 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 break;
9652 }
9653 //Change the substate in case it is waiting for key
9654 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9655 {
9656 csrRoamStopWaitForKeyTimer( pMac );
9657 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9658 }
9659 pCommand->command = eSmeCommandWmStatusChange;
9660 pCommand->sessionId = (tANI_U8)sessionId;
9661 pCommand->u.wmStatusChangeCmd.Type = Type;
9662 if ( eCsrDisassociated == Type )
9663 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309664 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9665 pSmeRsp,
9666 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }
9668 else
9669 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309670 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9671 pSmeRsp,
9672 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 }
9674 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9675 {
9676 fCommandQueued = eANI_BOOLEAN_TRUE;
9677 }
9678 else
9679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009680 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 csrReleaseCommandWmStatusChange( pMac, pCommand );
9682 }
9683
Jeff Johnson295189b2012-06-20 16:38:30 -07009684 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9685 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 return( fCommandQueued );
9688}
9689
Jeff Johnson295189b2012-06-20 16:38:30 -07009690static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9691{
9692 v_S7_t rssi = 0;
9693 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9694 if(pGetRssiReq)
9695 {
9696 if(NULL != pGetRssiReq->pVosContext)
9697 {
9698 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9699 }
9700 else
9701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009702 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 return;
9704 }
9705
9706 if(NULL != pGetRssiReq->rssiCallback)
9707 {
9708 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9709 }
9710 else
9711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009712 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 return;
9714 }
9715 }
9716 else
9717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009718 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009719 }
9720 return;
9721}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309722
9723static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9724{
9725 tANI_S8 snr = 0;
9726 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9727
9728 if (pGetSnrReq)
9729 {
9730 if (VOS_STATUS_SUCCESS !=
9731 WDA_GetSnr(pGetSnrReq->staId, &snr))
9732 {
9733 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9734 return;
9735 }
9736
9737 if (pGetSnrReq->snrCallback)
9738 {
9739 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9740 pGetSnrReq->pDevContext);
9741 }
9742 else
9743 {
9744 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9745 return;
9746 }
9747 }
9748 else
9749 {
9750 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9751 }
9752 return;
9753}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009754#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009755void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9756{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009757 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9758
Jeff Johnson36d483b2013-04-08 11:08:53 -07009759 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009760 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009761 /* Get roam Rssi request is backed up and passed back to the response,
9762 Extract the request message to fetch callback */
9763 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9764 v_S7_t rssi = pRoamRssiRsp->rssi;
9765
9766 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009767 {
9768 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9769 reqBkp->rssiCallback = NULL;
9770 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009771 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009772 }
9773 else
9774 {
9775 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9776 if (NULL != reqBkp)
9777 {
9778 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009779 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009780 }
9781 }
9782 }
9783 else
9784 {
9785 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9786 }
9787 return;
9788}
9789#endif
9790
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009791
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009792#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009793void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9794{
9795 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9796
9797 if (NULL != pTsmStatsRsp)
9798 {
9799 /* Get roam Rssi request is backed up and passed back to the response,
9800 Extract the request message to fetch callback */
9801 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9802
9803 if (NULL != reqBkp)
9804 {
9805 if (NULL != reqBkp->tsmStatsCallback)
9806 {
9807 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9808 pTsmStatsRsp->staId, reqBkp->pDevContext);
9809 reqBkp->tsmStatsCallback = NULL;
9810 }
9811 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009812 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009813 }
9814 else
9815 {
9816 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9817 if (NULL != reqBkp)
9818 {
9819 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009820 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009821 }
9822 }
9823 }
9824 else
9825 {
9826 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9827 }
9828 return;
9829}
9830
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009831void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009832{
9833 tANI_U32 roamTS2 = 0;
9834 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009835 tpPESession pSessionEntry = NULL;
9836 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009837
9838 if (NULL == pSession)
9839 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009840 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009841 return;
9842 }
9843
9844 roamTS2 = vos_timer_get_system_time();
9845 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009846 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9847 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009848 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009849
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009850 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9851 if (NULL == pSessionEntry)
9852 {
9853 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9854 return;
9855 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009856 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009857 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009858 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009859}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009860#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009861
Jeff Johnsone7245742012-09-05 17:12:55 -07009862static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9863{
9864 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9865 if(pTlRssiInd)
9866 {
9867 if(NULL != pTlRssiInd->tlCallback)
9868 {
9869 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009870 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009871 }
9872 else
9873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009874 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009875 }
9876 }
9877 else
9878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009879 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009880 }
9881 return;
9882}
Jeff Johnson295189b2012-06-20 16:38:30 -07009883
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309884eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9885{
9886 tpSirResetAPCapsChange pMsg;
9887 tANI_U16 len;
9888 eHalStatus status = eHAL_STATUS_SUCCESS;
9889
9890 /* Create the message and send to lim */
9891 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309892 pMsg = vos_mem_malloc(len);
9893 if ( NULL == pMsg )
9894 status = eHAL_STATUS_FAILURE;
9895 else
9896 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309897 if (HAL_STATUS_SUCCESS(status))
9898 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309899 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309900 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9901 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309902 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009903 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9904 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309905 status = palSendMBMessage(pMac->hHdd, pMsg);
9906 }
9907 else
9908 {
9909 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9910 }
9911 return status;
9912}
9913
Jeff Johnson295189b2012-06-20 16:38:30 -07009914void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9915{
9916 tSirSmeAssocInd *pAssocInd;
9917 tSirSmeDisassocInd *pDisassocInd;
9918 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +05309919 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9921 tSirSmeNewBssInfo *pNewBss;
9922 tSmeIbssPeerInd *pIbssPeerInd;
9923 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9924 tSirSmeApNewCaps *pApNewCaps;
9925 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9926 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9927 tCsrRoamInfo *pRoamInfo = NULL;
9928 tCsrRoamInfo roamInfo;
9929 eHalStatus status;
9930 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9931 tCsrRoamSession *pSession = NULL;
9932 tpSirSmeSwitchChannelInd pSwitchChnInd;
9933 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309934 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009935
9936
9937 if (NULL == pSirMsg)
9938 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9939 return;
9940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 switch( pSirMsg->messageType )
9942 {
9943 case eWNI_SME_ASSOC_IND:
9944 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309945 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05309946 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9948 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9949 if( HAL_STATUS_SUCCESS( status ) )
9950 {
9951 pSession = CSR_GET_SESSION(pMac, sessionId);
9952
Jeff Johnson32d95a32012-09-10 13:15:23 -07009953 if(!pSession)
9954 {
9955 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9956 return;
9957 }
9958
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 pRoamInfo = &roamInfo;
9960
9961 // Required for indicating the frames to upper layer
9962 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9963 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9964
9965 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9966 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9967 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9968 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9969
9970 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9971 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9972 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9973
9974 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9975 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309976 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9977 sizeof(tSirMacAddr));
9978 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9979 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309981 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309982#ifdef WLAN_FEATURE_AP_HT40_24G
9983 pRoamInfo->HT40MHzIntoEnabledSta =
9984 pAssocInd->HT40MHzIntoEnabledSta;
9985 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9986 pRoamInfo->HT40MHzIntoEnabledSta);
9987#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9991 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05309992#ifdef SAP_AUTH_OFFLOAD
9993 if (pMac->sap_auth_offload)
9994 {
9995 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
9996 pRoamInfo->fAuthRequired = FALSE;
9997 }
9998 else
9999 {
10000#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10002 {
10003 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10004 pSession->pConnectBssDesc,
10005 &(pRoamInfo->peerMac),
10006 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10007 pRoamInfo->fAuthRequired = FALSE;
10008 }
10009 else
10010 {
10011 pRoamInfo->fAuthRequired = TRUE;
10012 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010013#ifdef SAP_AUTH_OFFLOAD
10014 }
10015#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10017 if (!HAL_STATUS_SUCCESS(status))
10018 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 /* Send Association completion message to PE */
10021 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10022
10023 /* send a message to CSR itself just to avoid the EAPOL frames going
10024 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10026 {
10027 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10030 {
10031 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10032 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10033 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 }
10036 }
10037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010040 // Check if AP dis-associated us because of MIC failure. If so,
10041 // then we need to take action immediately and not wait till the
10042 // the WmStatusChange requests is pushed and processed
10043 tSmeCmd *pCommand;
10044
10045 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10046 status = csrRoamGetSessionIdFromBSSID( pMac,
10047 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10048 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010050 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10051 " for session %d "), sessionId);
10052 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10053 MAC_ADDRESS_STR " "
10054 " reason = %d status = %d "),
10055 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10056 pDisassocInd->reasonCode,
10057 pDisassocInd->statusCode);
10058 // If we are in neighbor preauth done state then on receiving
10059 // disassoc or deauth we dont roam instead we just disassoc
10060 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010061 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010062#ifdef WLAN_FEATURE_VOWIFI_11R
10063 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10064 {
10065 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010067#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010068#ifdef FEATURE_WLAN_ESE
10069 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010070 {
10071 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010073#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010074#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010075 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10076 {
10077 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10078 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010079#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010080#ifdef WLAN_FEATURE_LFR_MBB
10081 csr_stop_preauth_reassoc_mbb_timer(pMac);
10082#endif
10083
Agarwal Ashish4f616132013-12-30 23:32:50 +053010084 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010085
Agarwal Ashish4f616132013-12-30 23:32:50 +053010086 if (!pSession)
10087 {
10088 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10089 return;
10090 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010091
Agarwal Ashish4f616132013-12-30 23:32:50 +053010092 if ( csrIsConnStateInfra( pMac, sessionId ) )
10093 {
10094 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010096#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010097 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010098#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010099 csrRoamLinkDown(pMac, sessionId);
10100 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10101 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10102 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010103 /*
10104 * STA/P2P client got disassociated so remove any pending deauth
10105 * commands in sme pending list
10106 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010107 pCommand = csrGetCommandBuffer(pMac);
10108 if (NULL == pCommand)
10109 {
10110 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10111 status = eHAL_STATUS_RESOURCES;
10112 return;
10113 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010114 pCommand->command = eSmeCommandRoam;
10115 pCommand->sessionId = (tANI_U8)sessionId;
10116 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10117 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10118 pDisassocInd->peerMacAddr,
10119 sizeof(tSirMacAddr));
10120 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10121 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010122
Agarwal Ashish4f616132013-12-30 23:32:50 +053010123 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010125 else
10126 {
10127 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10128 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10129 }
Kiet Lam82004c62013-11-11 13:24:28 +053010130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010133 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10135 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10136 if( HAL_STATUS_SUCCESS( status ) )
10137 {
10138 // If we are in neighbor preauth done state then on receiving
10139 // disassoc or deauth we dont roam instead we just disassoc
10140 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010141 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010142#ifdef WLAN_FEATURE_VOWIFI_11R
10143 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10144 {
10145 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10146 }
10147#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010148#ifdef FEATURE_WLAN_ESE
10149 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 {
10151 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10152 }
10153#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010154#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010155 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010156 {
10157 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10158 }
10159#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010160#ifdef WLAN_FEATURE_LFR_MBB
10161 csr_stop_preauth_reassoc_mbb_timer(pMac);
10162#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 pSession = CSR_GET_SESSION( pMac, sessionId );
10164
Jeff Johnson32d95a32012-09-10 13:15:23 -070010165 if(!pSession)
10166 {
10167 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10168 return;
10169 }
10170
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 if ( csrIsConnStateInfra( pMac, sessionId ) )
10172 {
10173 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010175#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10176 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10177#endif
10178 csrRoamLinkDown(pMac, sessionId);
10179 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 }
10181 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010182
10183 case eWNI_SME_DISCONNECT_DONE_IND:
10184 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10185 smsLog( pMac, LOG1,
10186 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10187 pDisConDoneInd->reasonCode);
10188 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10189 {
10190 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10191 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10192 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10193 sizeof(tSirMacAddr));
10194 status = csrRoamCallCallback(pMac,
10195 pDisConDoneInd->sessionId,
10196 &roamInfo, 0,
10197 eCSR_ROAM_LOSTLINK,
10198 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010199 pSession = CSR_GET_SESSION(pMac,
10200 pDisConDoneInd->sessionId);
10201 if (pSession &&
10202 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10203 csrRoamStateChange(pMac,
10204 eCSR_ROAMING_STATE_IDLE,
10205 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010206 }
10207 else
10208 {
10209 smsLog(pMac, LOGE, FL("Inactive session %d"),
10210 pDisConDoneInd->sessionId);
10211 }
10212 break;
10213
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 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 -080010215 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10217 //Update with the new channel id.
10218 //The channel id is hidden in the statusCode.
10219 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10220 if( HAL_STATUS_SUCCESS( status ) )
10221 {
10222 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010223 if(!pSession)
10224 {
10225 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10226 return;
10227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10229 if(pSession->pConnectBssDesc)
10230 {
10231 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10232 }
10233 }
10234 break;
10235
10236 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010237 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 {
10239 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10240 sessionId = pDeauthRsp->sessionId;
10241 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10242 {
10243 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10245 {
10246 pRoamInfo = &roamInfo;
10247 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010248 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10249 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10251 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10252 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10253 }
10254 }
10255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 break;
10257
10258 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010259 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010260 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 {
10262 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10263 sessionId = pDisassocRsp->sessionId;
10264 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10265 {
10266 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10268 {
10269 pRoamInfo = &roamInfo;
10270 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010271 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10272 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10274 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10275 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10276 }
10277 }
10278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010280 case eWNI_SME_LOST_LINK_PARAMS_IND:
10281 {
10282 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10283 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10284 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10285 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10286 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10287 pRoamInfo = &roamInfo;
10288 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10289 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10290 break;
10291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 case eWNI_SME_MIC_FAILURE_IND:
10293 {
10294 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10295 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10296 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010297
10298 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10299 if( HAL_STATUS_SUCCESS( status ) )
10300 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010301 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010302 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10303 pRoamInfo = &roamInfo;
10304 if(pMicInd->info.multicast)
10305 {
10306 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10307 }
10308 else
10309 {
10310 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10311 }
10312 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10313 }
10314
Jeff Johnson295189b2012-06-20 16:38:30 -070010315#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10316 {
lukez3c809222013-05-03 10:23:02 -070010317 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010319 if(!pSession)
10320 {
10321 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10322 return;
10323 }
lukez3c809222013-05-03 10:23:02 -070010324
Kiet Lam64c1b492013-07-12 13:56:44 +053010325 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10327 secEvent.encryptionModeMulticast =
10328 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10329 secEvent.encryptionModeUnicast =
10330 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10331 secEvent.authMode =
10332 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010333 vos_mem_copy(secEvent.bssid,
10334 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10336 }
10337#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 }
10339 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010340 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10341 {
10342 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10343 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010344 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010345
10346 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10347 if( HAL_STATUS_SUCCESS( status ) )
10348 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010349 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10351 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10352 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10353 }
10354 }
10355 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010356
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10358 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10359 switch( pStatusChangeMsg->statusChangeCode )
10360 {
10361 case eSIR_SME_IBSS_ACTIVE:
10362 sessionId = csrFindIbssSession( pMac );
10363 if( CSR_SESSION_ID_INVALID != sessionId )
10364 {
10365 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010366 if(!pSession)
10367 {
10368 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10369 return;
10370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010371 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10372 if(pSession->pConnectBssDesc)
10373 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010374 vos_mem_copy(&roamInfo.bssid,
10375 pSession->pConnectBssDesc->bssId,
10376 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10378 pRoamInfo = &roamInfo;
10379 }
10380 else
10381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010382 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 }
10384 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10385 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10386 }
10387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010388 case eSIR_SME_IBSS_INACTIVE:
10389 sessionId = csrFindIbssSession( pMac );
10390 if( CSR_SESSION_ID_INVALID != sessionId )
10391 {
10392 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010393 if(!pSession)
10394 {
10395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10396 return;
10397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10399 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10400 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10401 }
10402 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10404 sessionId = csrFindIbssSession( pMac );
10405 if( CSR_SESSION_ID_INVALID != sessionId )
10406 {
10407 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010408 if(!pSession)
10409 {
10410 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10411 return;
10412 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 // update the connection state information
10414 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010415#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10416 {
10417 vos_log_ibss_pkt_type *pIbssLog;
10418 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10420 if(pIbssLog)
10421 {
10422 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10423 if(pNewBss)
10424 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010425 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010426 if(pNewBss->ssId.length)
10427 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010428 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
10429 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 }
10431 pIbssLog->operatingChannel = pNewBss->channelNumber;
10432 }
10433 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10434 {
10435 //***U8 is not enough for beacon interval
10436 pIbssLog->beaconInterval = (v_U8_t)bi;
10437 }
10438 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10439 }
10440 }
10441#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010443
10444 if ((eCSR_ENCRYPT_TYPE_NONE ==
10445 pSession->connectedProfile.EncryptionType ))
10446 {
10447 csrRoamIssueSetContextReq( pMac, sessionId,
10448 pSession->connectedProfile.EncryptionType,
10449 pSession->pConnectBssDesc,
10450 &Broadcastaddr,
10451 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10454 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010455 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10456 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 pRoamInfo = &roamInfo;
10458 //This BSSID is th ereal BSSID, let's save it
10459 if(pSession->pConnectBssDesc)
10460 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010461 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10462 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010465 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 // detection by LIM that the capabilities of the associated AP have changed.
10468 case eSIR_SME_AP_CAPS_CHANGED:
10469 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010470 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10472 if( HAL_STATUS_SUCCESS( status ) )
10473 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010474 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10475 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010476 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010477 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10478 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10479 )
10480 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010481 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10482 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010483 }
10484 else
10485 {
10486 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010487 FL("Skipping csrScanForCapabilityChange as "
10488 "CSR is in state %s and sub-state %s"),
10489 macTraceGetcsrRoamState(
10490 pMac->roam.curState[sessionId]),
10491 macTraceGetcsrRoamSubState(
10492 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010493 /* We ignore the caps change event if CSR is not in full connected state.
10494 * Send one event to PE to reset limSentCapsChangeNtf
10495 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10496 * otherwise lim cannot send any CAPS change events to SME */
10497 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 }
10500 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010501
Jeff Johnson295189b2012-06-20 16:38:30 -070010502 default:
10503 roamStatus = eCSR_ROAM_FAILED;
10504 result = eCSR_ROAM_RESULT_NONE;
10505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010506 } // end switch on statusChangeCode
10507 if(eCSR_ROAM_RESULT_NONE != result)
10508 {
10509 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10510 }
10511 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010512 case eWNI_SME_IBSS_NEW_PEER_IND:
10513 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010514#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10515 {
10516 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10518 if(pIbssLog)
10519 {
10520 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010521 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10523 }
10524 }
10525#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 sessionId = csrFindIbssSession( pMac );
10527 if( CSR_SESSION_ID_INVALID != sessionId )
10528 {
10529 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010530
10531 if(!pSession)
10532 {
10533 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10534 return;
10535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10537 if(pSession->pConnectBssDesc)
10538 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010539 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10540 sizeof(tCsrBssid));
10541 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10542 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10544 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010545 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10546 - sizeof(tSmeIbssPeerInd)));
10547 if ( NULL == roamInfo.pbFrames )
10548 status = eHAL_STATUS_FAILURE;
10549 else
10550 status = eHAL_STATUS_SUCCESS;
10551 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 {
10553 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010554 vos_mem_copy(roamInfo.pbFrames,
10555 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10556 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 }
10558 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10559 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10560 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010561 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10562 if ( NULL == roamInfo.pBssDesc )
10563 status = eHAL_STATUS_FAILURE;
10564 else
10565 status = eHAL_STATUS_SUCCESS;
10566 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010568 vos_mem_copy(roamInfo.pBssDesc,
10569 pSession->pConnectBssDesc,
10570 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 }
10572 if(HAL_STATUS_SUCCESS(status))
10573 {
10574 pRoamInfo = &roamInfo;
10575 }
10576 else
10577 {
10578 if(roamInfo.pbFrames)
10579 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010580 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 }
10582 if(roamInfo.pBssDesc)
10583 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010584 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 }
10586 }
10587 }
10588 else
10589 {
10590 pRoamInfo = &roamInfo;
10591 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010592 if ((eCSR_ENCRYPT_TYPE_NONE ==
10593 pSession->connectedProfile.EncryptionType ))
10594 {
10595 csrRoamIssueSetContextReq( pMac, sessionId,
10596 pSession->connectedProfile.EncryptionType,
10597 pSession->pConnectBssDesc,
10598 &(pIbssPeerInd->peerAddr),
10599 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10600 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 }
10602 else
10603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010604 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 }
10606 //send up the sec type for the new peer
10607 if (pRoamInfo)
10608 {
10609 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10610 }
10611 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10612 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10613 if(pRoamInfo)
10614 {
10615 if(roamInfo.pbFrames)
10616 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010617 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 }
10619 if(roamInfo.pBssDesc)
10620 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010621 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010622 }
10623 }
10624 }
10625 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10627 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10628 sessionId = csrFindIbssSession( pMac );
10629 if( CSR_SESSION_ID_INVALID != sessionId )
10630 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010631#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10632 {
10633 vos_log_ibss_pkt_type *pIbssLog;
10634
10635 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10636 if(pIbssLog)
10637 {
10638 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10639 if(pIbssPeerInd)
10640 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010641 vos_mem_copy(pIbssLog->peerMacAddr,
10642 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010643 }
10644 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10645 }
10646 }
10647#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010648 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10650 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10651 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010652 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10653 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10655 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10656 }
10657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 case eWNI_SME_SETCONTEXT_RSP:
10659 {
10660 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10661 tListElem *pEntry;
10662 tSmeCmd *pCommand;
10663
10664 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10665 if ( pEntry )
10666 {
10667 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10668 if ( eSmeCommandSetKey == pCommand->command )
10669 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010670 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010671 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010672
10673 if(!pSession)
10674 {
10675 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10676 return;
10677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010678
10679#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10680 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10681 {
10682 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010683 vos_mem_set(&setKeyEvent,
10684 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010685 if( pRsp->peerMacAddr[0] & 0x01 )
10686 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010687 setKeyEvent.eventId =
10688 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 }
10690 else
10691 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010692 setKeyEvent.eventId =
10693 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010694 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010695 if( pRsp->peerMacAddr[0] & 0x01 )
10696 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010697 pMac->pmc.full_power_till_set_key = false;
10698 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010699 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010700 setKeyEvent.encryptionModeMulticast =
10701 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10702 setKeyEvent.encryptionModeUnicast =
10703 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010704 vos_mem_copy(setKeyEvent.bssid,
10705 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 setKeyEvent.authMode =
10707 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010708 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 {
10710 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10711 }
10712 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10713 }
10714#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10715 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10716 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010717 csrRoamStopWaitForKeyTimer( pMac );
10718
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 //We are done with authentication, whethere succeed or not
10720 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 //We do it here because this linkup function is not called after association
10722 //when a key needs to be set.
10723 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10724 {
10725 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10726 }
10727 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010728 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010729 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010730 vos_mem_copy(&roamInfo.peerMac,
10731 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010732 //Make sure we install the GTK before indicating to HDD as authenticated
10733 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010734 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10735 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010736 {
Yathish9f22e662012-12-10 14:21:35 -080010737#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10738 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10739 {
10740 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010741 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010742 if (NULL == pMsg)
10743 {
10744 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10745 return;
10746 }
10747
Yathish9f22e662012-12-10 14:21:35 -080010748 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010749 pMsg->length = pal_cpu_to_be16(sizeof(
10750 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010751 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010752 vos_mem_copy(pMsg->bssid,
10753 pSession->connectedProfile.bssid,
10754 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010755 status = palSendMBMessage(pMac->hHdd, pMsg );
10756 }
10757#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010758 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010759 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010760 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010761 && (pSession->connectState ==
10762 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10763 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010764 && (VOS_P2P_GO_MODE !=
10765 pSession->pCurRoamProfile->csrPersona
10766 && VOS_STA_SAP_MODE !=
10767 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010768 {
10769 tpSirSmeHT40OBSSScanInd pMsg;
10770 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010771 if (NULL == pMsg)
10772 {
10773 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10774 return;
10775 }
10776
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010777 pMsg->messageType =
10778 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10779 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010780 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10781 vos_mem_copy(pMsg->peerMacAddr,
10782 pSession->connectedProfile.bssid,
10783 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010784 status = palSendMBMessage(pMac->hHdd,
10785 pMsg );
10786 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010787 else
10788 {
10789 smsLog( pMac, LOG1,FL("OBSS SCAN"
10790 "Indication not sent to FW"
10791 "channel %d OBSS_SCAN: %d"),
10792 pSession->connectedProfile.
10793 operationChannel,
10794 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10795 smsLog( pMac, LOG1,FL("connectState %d"
10796 "pCurRoamProfile %p"),
10797 pSession->connectState,
10798 pSession->pCurRoamProfile);
10799 }
10800
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010801 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010802 }
10803 else
10804 {
10805 result = eCSR_ROAM_RESULT_NONE;
10806 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010807 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 }
10809 else
10810 {
10811 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010812 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10813 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10814 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010816 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10818 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10820 // can go ahead and initiate the TSPEC if any are pending
10821 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010822#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 //Send Adjacent AP repot to new AP.
10824 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10825 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010826 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010828#ifdef FEATURE_WLAN_ESE_UPLOAD
10829 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010830#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010831 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010832#endif
10833 pSession->isPrevApInfoValid = FALSE;
10834 }
10835#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10837 {
10838 csrReleaseCommandSetKey( pMac, pCommand );
10839 }
10840 }
10841 else
10842 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010843 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 }
10845 }
10846 else
10847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010848 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 smeProcessPendingQueue( pMac );
10851 }
10852 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 case eWNI_SME_REMOVEKEY_RSP:
10854 {
10855 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10856 tListElem *pEntry;
10857 tSmeCmd *pCommand;
10858
10859 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10860 if ( pEntry )
10861 {
10862 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10863 if ( eSmeCommandRemoveKey == pCommand->command )
10864 {
10865 sessionId = pCommand->sessionId;
10866 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010867
10868 if(!pSession)
10869 {
10870 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10871 return;
10872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010873#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10874 {
10875 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010876 vos_mem_set(&removeKeyEvent,
10877 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10879 removeKeyEvent.encryptionModeMulticast =
10880 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10881 removeKeyEvent.encryptionModeUnicast =
10882 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010883 vos_mem_copy( removeKeyEvent.bssid,
10884 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010885 removeKeyEvent.authMode =
10886 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010887 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010888 {
10889 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10890 }
10891 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10892 }
10893#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010894 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010896 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10897 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 result = eCSR_ROAM_RESULT_NONE;
10899 pRoamInfo = &roamInfo;
10900 }
10901 else
10902 {
10903 result = eCSR_ROAM_RESULT_FAILURE;
10904 }
10905 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10906 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10907 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10908 {
10909 csrReleaseCommandRemoveKey( pMac, pCommand );
10910 }
10911 }
10912 else
10913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010914 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010915 }
10916 }
10917 else
10918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010919 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 smeProcessPendingQueue( pMac );
10922 }
10923 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010925 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010926 csrRoamStatsRspProcessor( pMac, pSirMsg );
10927 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010928#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010929 case eWNI_SME_GET_ROAM_RSSI_RSP:
10930 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10931 csrRoamRssiRspProcessor( pMac, pSirMsg );
10932 break;
10933#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010934#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010935 case eWNI_SME_GET_TSM_STATS_RSP:
10936 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10937 csrTsmStatsRspProcessor( pMac, pSirMsg );
10938 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010939#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010941 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 csrUpdateRssi( pMac, pSirMsg );
10943 break;
10944
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010945 case eWNI_SME_GET_SNR_REQ:
10946 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10947 csrUpdateSnr(pMac, pSirMsg);
10948 break;
10949
Jeff Johnson295189b2012-06-20 16:38:30 -070010950#ifdef WLAN_FEATURE_VOWIFI_11R
10951 case eWNI_SME_FT_PRE_AUTH_RSP:
10952 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10953 break;
10954#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010955#ifdef WLAN_FEATURE_LFR_MBB
10956 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
10957 csr_roam_preauth_rsp_mbb_processor(pMac,
10958 (tpSirFTPreAuthRsp)pSirMsg);
10959 break;
10960#endif
10961
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10963 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010964 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 -070010965 sessionId = pSmeMaxAssocInd->sessionId;
10966 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010967 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10968 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10970 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10971 break;
10972
10973 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010974 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010975 btampEstablishLogLinkHdlr( pSirMsg );
10976 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010977 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010978 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010979 csrRoamRssiIndHdlr( pMac, pSirMsg );
10980 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010981#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10982 case eWNI_SME_CANDIDATE_FOUND_IND:
10983 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10984 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10985 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010986 case eWNI_SME_HANDOFF_REQ:
10987 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10988 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10989 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010991
10992 default:
10993 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010994 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010995}
10996
Jeff Johnson295189b2012-06-20 16:38:30 -070010997void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10998 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10999{
11000 if(pSession)
11001 {
11002 if(pSession->bRefAssocStartCnt)
11003 {
11004 pSession->bRefAssocStartCnt--;
11005 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11006 //Need to call association_completion because there is an assoc_start pending.
11007 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11008 eCSR_ROAM_ASSOCIATION_COMPLETION,
11009 eCSR_ROAM_RESULT_FAILURE);
11010 }
11011 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11012 }
11013 else
11014 {
11015 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11016 }
11017}
11018
11019
11020eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11021{
11022 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11024 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11025 {
11026 status = csrScanRequestLostLink1( pMac, sessionId );
11027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011028 return(status);
11029}
11030
Jeff Johnson295189b2012-06-20 16:38:30 -070011031//return a boolean to indicate whether roaming completed or continue.
11032tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11033 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11034{
11035 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11036 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11037 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11038 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011039 if(!pSession)
11040 {
11041 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11042 return eANI_BOOLEAN_FALSE;
11043 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011044 //Check whether time is up
11045 if(pSession->fCancelRoaming || fForce ||
11046 ((curTime - pSession->roamingStartTime) > roamTime) ||
11047 eCsrReassocRoaming == pSession->roamingReason ||
11048 eCsrDynamicRoaming == pSession->roamingReason)
11049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011050 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011051 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11052 {
11053 //roaming is cancelled, tell HDD to indicate disconnect
11054 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11055 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11056 //to be eSIR_BEACON_MISSED
11057 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11058 {
11059 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11060 }
11061 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11062 {
11063 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11064 }
11065 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11066 {
11067 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11068 }
11069 else
11070 {
11071 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11072 }
11073 }
11074 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11075 pSession->roamingReason = eCsrNotRoaming;
11076 }
11077 else
11078 {
11079 pSession->roamResult = roamResult;
11080 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11081 {
11082 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11083 pSession->roamingReason = eCsrNotRoaming;
11084 }
11085 else
11086 {
11087 fCompleted = eANI_BOOLEAN_FALSE;
11088 }
11089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011090 return(fCompleted);
11091}
11092
Jeff Johnson295189b2012-06-20 16:38:30 -070011093void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11094{
11095 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011096
11097 if(!pSession)
11098 {
11099 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11100 return;
11101 }
11102
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 if(CSR_IS_ROAMING(pSession))
11104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011105 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011106 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11107 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11108 {
11109 //No need to do anything in here because the handler takes care of it
11110 }
11111 else
11112 {
11113 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11114 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11115 //Roaming is stopped after here
11116 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11117 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011118 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 csrRoamStopRoamingTimer(pMac, sessionId);
11120 }
11121 }
11122}
11123
Jeff Johnson295189b2012-06-20 16:38:30 -070011124void csrRoamRoamingTimerHandler(void *pv)
11125{
11126 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11127 tpAniSirGlobal pMac = pInfo->pMac;
11128 tANI_U32 sessionId = pInfo->sessionId;
11129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011130
11131 if(!pSession)
11132 {
11133 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11134 return;
11135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011136
11137 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11138 {
11139 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11140 {
11141 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11142 pSession->roamingReason = eCsrNotRoaming;
11143 }
11144 }
11145}
11146
Jeff Johnson295189b2012-06-20 16:38:30 -070011147eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11148{
11149 eHalStatus status;
11150 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011151
11152 if(!pSession)
11153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011154 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011155 return eHAL_STATUS_FAILURE;
11156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011157
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011158 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011159 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011160 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011161
11162 return (status);
11163}
11164
Jeff Johnson295189b2012-06-20 16:38:30 -070011165eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11166{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011167 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011168}
11169
Jeff Johnson295189b2012-06-20 16:38:30 -070011170void csrRoamWaitForKeyTimeOutHandler(void *pv)
11171{
11172 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11173 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011175 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011176
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011177 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011178 macTraceGetNeighbourRoamState(
11179 pMac->roam.neighborRoamInfo.neighborRoamState),
11180 macTraceGetcsrRoamSubState(
11181 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011182
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011183 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011185 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11186 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011187#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011188 if (csrNeighborRoamIsHandoffInProgress(pMac))
11189 {
11190 /*
11191 * Enable heartbeat timer when hand-off is in progress
11192 * and Key Wait timer expired.
11193 */
11194 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11195 " (nHBCount=%d)",
11196 pMac->roam.configParam.HeartbeatThresh24);
11197 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11198 pMac->roam.configParam.HeartbeatThresh24,
11199 NULL, eANI_BOOLEAN_FALSE);
11200 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011201#endif
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011202 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011203
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011204 //Change the substate so command queue is unblocked.
11205 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11206 {
11207 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
11208 pInfo->sessionId);
11209 }
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011210
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011211 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011212 {
11213 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11214 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011215 status = sme_AcquireGlobalLock(&pMac->sme);
11216 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011217 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011218 csrRoamDisconnect(pMac, pInfo->sessionId,
11219 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11220 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011221 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011222 }
11223 else
11224 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011225 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11226 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011227 }
11228 }
11229 else
11230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011231 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 }
11234
11235}
11236
Jeff Johnson295189b2012-06-20 16:38:30 -070011237eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11238{
11239 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011240#ifdef FEATURE_WLAN_LFR
11241 if (csrNeighborRoamIsHandoffInProgress(pMac))
11242 {
11243 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011244 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11245 macTraceGetNeighbourRoamState(
11246 pMac->roam.neighborRoamInfo.neighborRoamState),
11247 macTraceGetcsrRoamSubState(
11248 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11249 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011250 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11251 }
11252#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011253 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011254 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011255
11256 return (status);
11257}
11258
Jeff Johnson295189b2012-06-20 16:38:30 -070011259eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11260{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011261 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11262 macTraceGetNeighbourRoamState(
11263 pMac->roam.neighborRoamInfo.neighborRoamState),
11264 macTraceGetcsrRoamSubState(
11265 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011266#ifdef FEATURE_WLAN_LFR
11267 if (csrNeighborRoamIsHandoffInProgress(pMac))
11268 {
11269 /*
11270 * Enable heartbeat timer when hand-off is in progress
11271 * and Key Wait timer got stopped for some reason
11272 */
11273 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011274 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011275 pMac->roam.configParam.HeartbeatThresh24);
11276 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11277 pMac->roam.configParam.HeartbeatThresh24,
11278 NULL, eANI_BOOLEAN_FALSE);
11279 }
11280#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011281 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011282}
11283
Jeff Johnson295189b2012-06-20 16:38:30 -070011284void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11285 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11286{
11287 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11288 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011289 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11290 /* To silence the KW tool Null chaeck is added */
11291 if(!pSession)
11292 {
11293 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11294 return;
11295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011296
11297 if(pCommand)
11298 {
11299 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11303 {
11304 //if success, force roaming completion
11305 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11306 }
11307 else
11308 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011309 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011310 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11312 }
11313}
11314
Jeff Johnson295189b2012-06-20 16:38:30 -070011315eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11316{
11317 eHalStatus status = eHAL_STATUS_SUCCESS;
11318 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11319 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11320 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
11321 tCsrRoamInfo *pRoamInfo = NULL;
11322 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011323 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011325 /* To silence the KW tool Null chaeck is added */
11326 if(!pSession)
11327 {
11328 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11329 return eHAL_STATUS_FAILURE;
11330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011332 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
11334 if ( eWNI_SME_DISASSOC_IND == type )
11335 {
11336 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11337 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11338 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011339 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 }
11341 else if ( eWNI_SME_DEAUTH_IND == type )
11342 {
11343 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11344 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11345 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011346 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 }
11348 else
11349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011350 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011352 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 }
11354
11355 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070011357 {
11358 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
11359 }
11360
11361 if ( eWNI_SME_DISASSOC_IND == type )
11362 {
11363 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11364 }
11365 else if ( eWNI_SME_DEAUTH_IND == type )
11366 {
11367 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011369 if(!HAL_STATUS_SUCCESS(status))
11370 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011371 //If fail to send confirmation to PE, not to trigger roaming
11372 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 }
11374
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011375 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053011376 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11378 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 if( eWNI_SME_DISASSOC_IND == type)
11380 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011381 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053011382 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11383 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011384 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
11385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 else if( eWNI_SME_DEAUTH_IND == type )
11387 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011388 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053011389 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11390 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011391 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
11392 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011393 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011394
11395 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11396 that we are roaming. But if we cannot possibly roam, or if we are unable to
11397 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 if(fToRoam)
11399 {
11400 //Only remove the connected BSS in infrastructure mode
11401 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11402 //Not to do anying for lostlink with WDS
11403 if( pMac->roam.configParam.nRoamingTime )
11404 {
11405 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
11406 ( eWNI_SME_DEAUTH_IND == type ) ?
11407 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
11408 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011409 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 //For IBSS, we need to give some more info to HDD
11411 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
11412 {
11413 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
11414 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11415 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11416 }
11417 else
11418 {
11419 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
11420 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011421 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
11423 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
11424 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11425 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
11426 }
11427 else
11428 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011429 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 fToRoam = eANI_BOOLEAN_FALSE;
11431 }
11432 }
11433 else
11434 {
11435 //We are told not to roam, indicate lostlink
11436 fToRoam = eANI_BOOLEAN_FALSE;
11437 }
11438 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 if(!fToRoam)
11440 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011441 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070011442 Still enable idle scan for polling in case concurrent sessions are running */
11443 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11444 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011445 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 }
11447 }
11448
11449 return (status);
11450}
11451
Jeff Johnson295189b2012-06-20 16:38:30 -070011452eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11453{
11454 eHalStatus status = eHAL_STATUS_SUCCESS;
11455 tListElem *pEntry = NULL;
11456 tSmeCmd *pCommand = NULL;
11457 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011458
11459 if(!pSession)
11460 {
11461 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11462 return eHAL_STATUS_FAILURE;
11463 }
11464
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 //Only remove the connected BSS in infrastructure mode
11467 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11468 if(pMac->roam.configParam.nRoamingTime)
11469 {
11470 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11471 {
11472 //before starting the lost link logic release the roam command for handoff
11473 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11474 if(pEntry)
11475 {
11476 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11477 }
11478 if(pCommand)
11479 {
11480 if (( eSmeCommandRoam == pCommand->command ) &&
11481 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11482 {
11483 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11484 {
11485 csrReleaseCommandRoam( pMac, pCommand );
11486 }
11487 }
11488 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011489 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 }
11491 }
11492 else
11493 {
11494 //We are told not to roam, indicate lostlink
11495 status = eHAL_STATUS_FAILURE;
11496 }
11497
11498 return (status);
11499}
Jeff Johnson295189b2012-06-20 16:38:30 -070011500void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11501{
11502 tListElem *pEntry;
11503 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11505 if ( pEntry )
11506 {
11507 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11508 if ( eSmeCommandWmStatusChange == pCommand->command )
11509 {
11510 // Nothing to process in a Lost Link completion.... It just kicks off a
11511 // roaming sequence.
11512 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11513 {
11514 csrReleaseCommandWmStatusChange( pMac, pCommand );
11515 }
11516 else
11517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011518 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 }
11520
11521 }
11522 else
11523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011524 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 }
11526 }
11527 else
11528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011529 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011531 smeProcessPendingQueue( pMac );
11532}
11533
Jeff Johnson295189b2012-06-20 16:38:30 -070011534void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11535{
11536 eHalStatus status = eHAL_STATUS_FAILURE;
11537 tSirSmeRsp *pSirSmeMsg;
11538 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011539
11540 if(!pSession)
11541 {
11542 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11543 return;
11544 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011545 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11546 pCommand->sessionId,
11547 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011548 switch ( pCommand->u.wmStatusChangeCmd.Type )
11549 {
11550 case eCsrDisassociated:
11551 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11552 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 case eCsrDeauthenticated:
11555 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11556 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11557 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011559 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 break;
11561 }
11562 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11563 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11564 {
11565 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11566 {
11567 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011568 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 }
11570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11572 // command here since there is nothing else to do.
11573 csrRoamWmStatusChangeComplete( pMac );
11574}
11575
Jeff Johnson295189b2012-06-20 16:38:30 -070011576//This function returns band and mode information.
11577//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11578//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011579static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11580 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011581{
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11583 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11584 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011586
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 //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 -070011588 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11589 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11590 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11591 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 {
11593 switch( pMac->roam.configParam.uCfgDot11Mode )
11594 {
11595 case eCSR_CFG_DOT11_MODE_11A:
11596 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11597 eBand = eCSR_BAND_5G;
11598 break;
11599 case eCSR_CFG_DOT11_MODE_11B:
11600 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11601 eBand = eCSR_BAND_24;
11602 break;
11603 case eCSR_CFG_DOT11_MODE_11G:
11604 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11605 eBand = eCSR_BAND_24;
11606 break;
11607 case eCSR_CFG_DOT11_MODE_11N:
11608 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011609 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11610 break;
11611#ifdef WLAN_FEATURE_11AC
11612 case eCSR_CFG_DOT11_MODE_11AC:
11613 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11614 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011615 /* If the operating channel is in 2.4 GHz band, check for
11616 * INI item to disable VHT operation in 2.4 GHz band
11617 */
11618 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11619 !pMac->roam.configParam.enableVhtFor24GHz)
11620 {
11621 /* Disable 11AC operation */
11622 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11623 }
11624 else
11625 {
11626 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11627 }
11628 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011629 }
11630 else
11631 {
11632 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11633 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11634 }
11635 break;
11636 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11637 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11638 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011639 /* If the operating channel is in 2.4 GHz band, check for
11640 * INI item to disable VHT operation in 2.4 GHz band
11641 */
11642 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11643 !pMac->roam.configParam.enableVhtFor24GHz)
11644 {
11645 /* Disable 11AC operation */
11646 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11647 }
11648 else
11649 {
11650 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11651 }
11652 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011653 }
11654 else
11655 {
11656 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11657 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11658 }
11659 break;
11660#endif
11661 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011662#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011663 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11664 {
11665 /* If the operating channel is in 2.4 GHz band, check for
11666 * INI item to disable VHT operation in 2.4 GHz band
11667 */
11668 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11669 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011670 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011671 /* Disable 11AC operation */
11672 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011673 }
11674 else
11675 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011676 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11677 }
11678 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11679 }
11680 else
11681 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011682 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11683 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011684 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011685#else
11686 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11687 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11688#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011689 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 default:
11691 // Global dot11 Mode setting is 11a/b/g.
11692 // use the channel number to determine the Mode setting.
11693 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11694 {
11695 eBand = pMac->roam.configParam.eBand;
11696 if(eCSR_BAND_24 == eBand)
11697 {
11698 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11699 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11700 }
11701 else
11702 {
11703 //prefer 5GHz
11704 eBand = eCSR_BAND_5G;
11705 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11706 }
11707 }
11708 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11709 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011710 // WiFi tests require IBSS networks to start in 11b mode
11711 // without any change to the default parameter settings
11712 // on the adapter. We use ACU to start an IBSS through
11713 // creation of a startIBSS profile. This startIBSS profile
11714 // has Auto MACProtocol and the adapter property setting
11715 // for dot11Mode is also AUTO. So in this case, let's
11716 // start the IBSS network in 11b mode instead of 11g mode.
11717 // So this is for Auto=profile->MacProtocol && Auto=Global.
11718 // dot11Mode && profile->channel is < 14, then start the IBSS
11719 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011721 // Note: we used to have this start as an 11g IBSS for best
11722 // performance... now to specify that the user will have to
11723 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11725 eBand = eCSR_BAND_24;
11726 }
11727 else
11728 {
11729 // else, it's a 5.0GHz channel. Set mode to 11a.
11730 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11731 eBand = eCSR_BAND_5G;
11732 }
11733 break;
11734 }//switch
11735 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11736 else
11737 {
11738 //dot11 mode is set, lets pick the band
11739 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11740 {
11741 // channel is Auto also.
11742 eBand = pMac->roam.configParam.eBand;
11743 if(eCSR_BAND_ALL == eBand)
11744 {
11745 //prefer 5GHz
11746 eBand = eCSR_BAND_5G;
11747 }
11748 }
11749 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11750 {
11751 eBand = eCSR_BAND_24;
11752 }
11753 else
11754 {
11755 eBand = eCSR_BAND_5G;
11756 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 if(pBand)
11759 {
11760 *pBand = eBand;
11761 }
11762
11763 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011764 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11766 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011767
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011768 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053011769 if (
11770#ifdef SAP_AUTH_OFFLOAD
11771 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11772#endif
11773 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11774 ((pProfile->privacy == 1) &&
11775 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011776 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011777#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011778 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011779#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011780 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11781 {
11782 //We cannot do 11n here
11783 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11784 {
11785 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11786 }
11787 else
11788 {
11789 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11790 }
11791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 return( cfgDot11Mode );
11793}
11794
Jeff Johnson295189b2012-06-20 16:38:30 -070011795eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11796{
11797 eHalStatus status;
11798 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011799
11800 if(!pSession)
11801 {
11802 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11803 return eHAL_STATUS_FAILURE;
11804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011805
11806#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11807 {
11808 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11810 if(pIbssLog)
11811 {
11812 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11813 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11814 }
11815 }
11816#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 // Set the roaming substate to 'stop Bss request'...
11818 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11819
11820 // attempt to stop the Bss (reason code is ignored...)
11821 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011822 if(!HAL_STATUS_SUCCESS(status))
11823 {
11824 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11825 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 return (status);
11827}
11828
Jeff Johnson295189b2012-06-20 16:38:30 -070011829//pNumChan is a caller allocated space with the sizeof pChannels
11830eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11831{
11832
11833 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11834 (tANI_U8 *)pChannels,
11835 pNumChan));
11836}
11837
Kiran4a17ebe2013-01-31 10:43:43 -080011838tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11839{
11840 tANI_U32 cfgLength = 0;
11841 tANI_U16 cfgId = 0;
11842 tPowerdBm maxTxPwr = 0;
11843 tANI_U8 *pCountryInfo = NULL;
11844 eHalStatus status;
11845 tANI_U8 count = 0;
11846 tANI_U8 firstChannel;
11847 tANI_U8 maxChannels;
11848
11849 if (CSR_IS_CHANNEL_5GHZ(channel))
11850 {
11851 cfgId = WNI_CFG_MAX_TX_POWER_5;
11852 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11853 }
11854 else if (CSR_IS_CHANNEL_24GHZ(channel))
11855 {
11856 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11857 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11858 }
11859 else
11860 return maxTxPwr;
11861
Kiet Lam64c1b492013-07-12 13:56:44 +053011862 pCountryInfo = vos_mem_malloc(cfgLength);
11863 if ( NULL == pCountryInfo )
11864 status = eHAL_STATUS_FAILURE;
11865 else
11866 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011867 if (status != eHAL_STATUS_SUCCESS)
11868 {
11869 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011870 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011871 __FUNCTION__, status);
11872 goto error;
11873 }
11874 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11875 if (status != eHAL_STATUS_SUCCESS)
11876 {
11877 goto error;
11878 }
11879 /* Identify the channel and maxtxpower */
11880 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11881 {
11882 firstChannel = pCountryInfo[count++];
11883 maxChannels = pCountryInfo[count++];
11884 maxTxPwr = pCountryInfo[count++];
11885
11886 if ((channel >= firstChannel) &&
11887 (channel < (firstChannel + maxChannels)))
11888 {
11889 break;
11890 }
11891 }
11892
11893error:
11894 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011895 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011896
11897 return maxTxPwr;
11898}
11899
11900
Jeff Johnson295189b2012-06-20 16:38:30 -070011901tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11902{
11903 tANI_BOOLEAN fValid = FALSE;
11904 tANI_U32 idxValidChannels;
11905 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11906
11907 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11908 {
11909 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11910 {
11911 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11912 {
11913 fValid = TRUE;
11914 break;
11915 }
11916 }
11917 }
11918 pMac->roam.numValidChannels = len;
11919 return fValid;
11920}
11921
Jeff Johnson295189b2012-06-20 16:38:30 -070011922tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11923{
11924 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11925 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11927 {
11928 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11929 {
11930 fValid = eANI_BOOLEAN_TRUE;
11931 break;
11932 }
11933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 return (fValid);
11935}
11936
Jeff Johnson295189b2012-06-20 16:38:30 -070011937//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011938 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011939{
Jeff Johnsone7245742012-09-05 17:12:55 -070011940 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011941 tANI_U8 centerChn;
11942 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011943
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11945 {
11946 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11947 }
11948 else
11949 {
11950 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11951 }
11952 //Figure what the other side's CB mode
11953 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11954 {
11955 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11956 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011957 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11958 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11959 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11960 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011961 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11962 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011963 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011964 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011965
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011966 {
11967 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11968 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11969 }
11970
11971 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011973 /* This is called during INFRA STA/CLIENT and should use the merged value of
11974 * supported channel width and recommended tx width as per standard
11975 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011976 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011977 pIes->HTCaps.supportedChannelWidthSet,
11978 pIes->HTInfo.recommendedTxWidthSet,
11979 pIes->HTInfo.secondaryChannelOffset);
11980
11981 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11982 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011984 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11985 switch (eRet) {
11986 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11987 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11988 break;
11989 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11990 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11991 break;
11992 case PHY_SINGLE_CHANNEL_CENTERED:
11993 default:
11994 centerChn = primaryChn;
11995 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011997 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011999 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012000 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012002 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12003 {
12004 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12005 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 }
12008 }
12009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 return eRet;
12011}
Jeff Johnson295189b2012-06-20 16:38:30 -070012012tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12013{
12014 tANI_BOOLEAN fFound = FALSE;
12015 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012016 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12017 {
12018 if( pCipherList->encryptionType[idx] == encryptionType )
12019 {
12020 fFound = TRUE;
12021 break;
12022 }
12023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 return fFound;
12025}
Jeff Johnson295189b2012-06-20 16:38:30 -070012026tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12027{
12028 tANI_BOOLEAN fFound = FALSE;
12029 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12031 {
12032 if( pAuthList->authType[idx] == authType )
12033 {
12034 fFound = TRUE;
12035 break;
12036 }
12037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012038 return fFound;
12039}
Jeff Johnson295189b2012-06-20 16:38:30 -070012040tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12041{
12042 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12043 tCsrScanResultFilter *pScanFilter = NULL;
12044 eHalStatus status = eHAL_STATUS_SUCCESS;
12045
12046 if(pProfile1 && pProfile2)
12047 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012048 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12049 if ( NULL == pScanFilter )
12050 status = eHAL_STATUS_FAILURE;
12051 else
12052 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 if(HAL_STATUS_SUCCESS(status))
12054 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012055 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12057 if(HAL_STATUS_SUCCESS(status))
12058 {
12059 fCheck = eANI_BOOLEAN_FALSE;
12060 do
12061 {
12062 tANI_U32 i;
12063 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12064 {
12065 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12066 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12067 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12068 if ( fCheck ) break;
12069 }
12070 if(!fCheck)
12071 {
12072 break;
12073 }
12074 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12075 || pProfile2->BSSType != pProfile1->BSSType
12076 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12077 )
12078 {
12079 fCheck = eANI_BOOLEAN_FALSE;
12080 break;
12081 }
12082#ifdef WLAN_FEATURE_VOWIFI_11R
12083 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12084 {
12085 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12086 {
12087 fCheck = eANI_BOOLEAN_FALSE;
12088 break;
12089 }
12090 }
12091#endif
12092 //Match found
12093 fCheck = eANI_BOOLEAN_TRUE;
12094 }while(0);
12095 csrFreeScanFilter(pMac, pScanFilter);
12096 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012097 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 }
12099 }
12100
12101 return (fCheck);
12102}
12103
Jeff Johnson295189b2012-06-20 16:38:30 -070012104tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12105{
12106 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12107 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012108 do
12109 {
12110 //Only check for static WEP
12111 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12112 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12113 {
12114 fCheck = eANI_BOOLEAN_TRUE;
12115 break;
12116 }
12117 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12118 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12119 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12120 {
12121 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012122 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12123 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012124 {
12125 break;
12126 }
12127 }
12128 if( i == CSR_MAX_NUM_KEY)
12129 {
12130 fCheck = eANI_BOOLEAN_TRUE;
12131 }
12132 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 return (fCheck);
12134}
12135
Jeff Johnson295189b2012-06-20 16:38:30 -070012136//IBSS
12137
Jeff Johnson295189b2012-06-20 16:38:30 -070012138tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12139{
12140 tANI_U8 channel = 0;
12141 tANI_U32 idx;
12142 tANI_U32 idxValidChannels;
12143 tANI_BOOLEAN fFound = FALSE;
12144 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12145
12146 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12147 {
12148 channel = pMac->roam.configParam.AdHocChannel5G;
12149 if(!csrRoamIsChannelValid(pMac, channel))
12150 {
12151 channel = 0;
12152 }
12153 }
12154 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12155 {
12156 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12157 {
12158 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12159 {
12160 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12161 {
12162 fFound = TRUE;
12163 channel = csrStartIbssChannels50[ idx ];
12164 }
12165 }
12166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12168 if (!fFound)
12169 {
12170 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12171 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012172 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012174 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 break;
12176 }
12177 }
12178 }
12179 }//if
12180
12181 return( channel );
12182}
12183
Jeff Johnson295189b2012-06-20 16:38:30 -070012184tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12185{
12186 tANI_U8 channel = 1;
12187 tANI_U32 idx;
12188 tANI_U32 idxValidChannels;
12189 tANI_BOOLEAN fFound = FALSE;
12190 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12191
12192 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12193 {
12194 channel = pMac->roam.configParam.AdHocChannel24;
12195 if(!csrRoamIsChannelValid(pMac, channel))
12196 {
12197 channel = 0;
12198 }
12199 }
12200
12201 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12202 {
12203 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12204 {
12205 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12206 {
12207 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12208 {
12209 fFound = TRUE;
12210 channel = csrStartIbssChannels24[ idx ];
12211 }
12212 }
12213 }
12214 }
12215
12216 return( channel );
12217}
12218
Jeff Johnson295189b2012-06-20 16:38:30 -070012219static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12220 tCsrRoamStartBssParams *pParam )
12221{
12222 eCsrCfgDot11Mode cfgDot11Mode;
12223 eCsrBand eBand;
12224 tANI_U8 channel = 0;
12225 tSirNwType nwType;
12226 tANI_U8 operationChannel = 0;
12227
12228 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12229 {
12230 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12231 }
12232
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012234
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12236 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12237 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12238 )
12239 {
12240 /* This should never happen */
12241 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012242 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 pProfile->csrPersona);
12244 VOS_ASSERT(0);
12245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 switch( cfgDot11Mode )
12247 {
12248 case eCSR_CFG_DOT11_MODE_11G:
12249 nwType = eSIR_11G_NW_TYPE;
12250 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012251 case eCSR_CFG_DOT11_MODE_11B:
12252 nwType = eSIR_11B_NW_TYPE;
12253 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 case eCSR_CFG_DOT11_MODE_11A:
12255 nwType = eSIR_11A_NW_TYPE;
12256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012257 default:
12258 case eCSR_CFG_DOT11_MODE_11N:
12259 case eCSR_CFG_DOT11_MODE_TAURUS:
12260 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12261 if(eCSR_BAND_24 == eBand)
12262 {
12263 nwType = eSIR_11G_NW_TYPE;
12264 }
12265 else
12266 {
12267 nwType = eSIR_11A_NW_TYPE;
12268 }
12269 break;
12270 }
12271
12272 pParam->extendedRateSet.numRates = 0;
12273
12274 switch ( nwType )
12275 {
12276 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012277 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012278 case eSIR_11A_NW_TYPE:
12279
12280 pParam->operationalRateSet.numRates = 8;
12281
12282 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12283 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12284 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12285 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12286 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12287 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12288 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12289 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12290
12291 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12292 {
12293 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12294 if( 0 == channel &&
12295 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12296 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12297 )
12298 {
12299 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12300 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12301 nwType = eSIR_11B_NW_TYPE;
12302 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12303 pParam->operationalRateSet.numRates = 4;
12304 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12305 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12306 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12307 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12308 }
12309 }
12310 else
12311 {
12312 channel = operationChannel;
12313 }
12314 break;
12315
12316 case eSIR_11B_NW_TYPE:
12317 pParam->operationalRateSet.numRates = 4;
12318 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12319 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12320 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12321 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12323 {
12324 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12325 }
12326 else
12327 {
12328 channel = operationChannel;
12329 }
12330
12331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012333 /* For P2P Client and P2P GO, disable 11b rates */
12334 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12335 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12336 )
12337 {
12338 pParam->operationalRateSet.numRates = 8;
12339
12340 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12341 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12342 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12343 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12344 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12345 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12346 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12347 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12348 }
12349 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 {
12351 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12353 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12354 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12355 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12356
12357 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012358 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12359 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12360 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12361 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12362 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12363 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12364 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12365 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12366 }
12367
12368 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12369 {
12370 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12371 }
12372 else
12373 {
12374 channel = operationChannel;
12375 }
12376
12377 break;
12378 }
12379 pParam->operationChn = channel;
12380 pParam->sirNwType = nwType;
12381}
12382
Jeff Johnson295189b2012-06-20 16:38:30 -070012383static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12384 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12385{
12386
12387 if( pParam )
12388 {
12389 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012390 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012392 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012393
12394 if( pIes )
12395 {
12396 if(pIes->SuppRates.present)
12397 {
12398 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12399 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012401 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 -070012402 pIes->SuppRates.num_rates);
12403 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12404 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012405 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12406 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012408 if (pIes->ExtSuppRates.present)
12409 {
12410 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012411 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012412 {
12413 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12414 SIR_MAC_RATESET_EID_MAX, resetting to \
12415 SIR_MAC_RATESET_EID_MAX"),
12416 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012417 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012418 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012419 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012420 pIes->ExtSuppRates.rates,
12421 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 if( pIes->SSID.present )
12424 {
12425 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012426 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12427 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 }
12429 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 }
12431 else
12432 {
12433 pParam->ssId.length = 0;
12434 pParam->operationalRateSet.numRates = 0;
12435 }
12436 }
12437}
12438
Jeff Johnson295189b2012-06-20 16:38:30 -070012439static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12440{
12441 tANI_U8 MaxRate = 0;
12442 tANI_U32 i;
12443 tANI_U8 *pRate;
12444
12445 pRate = pSirRateSet->rate;
12446 for ( i = 0; i < pSirRateSet->numRates; i++ )
12447 {
12448 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12449 }
12450
12451 // Save the max rate in the connected state information...
12452
12453 // modify LastRates variable as well
12454
12455 return;
12456}
12457
Jeff Johnson295189b2012-06-20 16:38:30 -070012458eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12459 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12460{
12461 eHalStatus status = eHAL_STATUS_SUCCESS;
12462 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 // Set the roaming substate to 'Start BSS attempt'...
12464 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012465#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12466 //Need to figure out whether we need to log WDS???
12467 if( CSR_IS_IBSS( pProfile ) )
12468 {
12469 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12471 if(pIbssLog)
12472 {
12473 if(pBssDesc)
12474 {
12475 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012476 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 }
12478 else
12479 {
12480 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12481 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012482 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 if(pProfile->ChannelInfo.numOfChannels == 0)
12484 {
12485 pIbssLog->channelSetting = AUTO_PICK;
12486 }
12487 else
12488 {
12489 pIbssLog->channelSetting = SPECIFIED;
12490 }
12491 pIbssLog->operatingChannel = pParam->operationChn;
12492 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12493 }
12494 }
12495#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12496 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012497 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12498 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012499
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 pParam->privacy = pProfile->privacy;
12501 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12502 pParam->authType = pProfile->csr80211AuthType;
12503 pParam->beaconInterval = pProfile->beaconInterval;
12504 pParam->dtimPeriod = pProfile->dtimPeriod;
12505 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12506 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12507 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12508 {
12509 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12510 {
12511 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12512 }
12513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 pParam->protEnabled = pProfile->protEnabled;
12515 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12516 pParam->ht_protection = pProfile->cfg_protection;
12517 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012518
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12520 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012522
12523#ifdef WLAN_FEATURE_11W
12524 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12525 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12526#endif
12527
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 // When starting an IBSS, start on the channel from the Profile.
12529 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 return (status);
12531}
12532
Jeff Johnson295189b2012-06-20 16:38:30 -070012533static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012534 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012535{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012536 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012537 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012538 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012539
12540 if(!pSession)
12541 {
12542 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12543 return;
12544 }
12545
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 if( pBssDesc )
12547 {
12548 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12549 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12550 //The following code has to be do after that.
12551 //For WDS station, use selfMac as the self BSSID
12552 if( CSR_IS_WDS_STA( pProfile ) )
12553 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012554 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12555 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 }
12557 }
12558 else
12559 {
12560 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 //Use the first SSID
12562 if(pProfile->SSIDs.numOfSSIDs)
12563 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012564 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12565 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 }
12567 //For WDS station, use selfMac as the self BSSID
12568 if( CSR_IS_WDS_STA( pProfile ) )
12569 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012570 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12571 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 }
12573 //Use the first BSSID
12574 else if( pProfile->BSSIDs.numOfBSSIDs )
12575 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012576 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12577 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 }
12579 else
12580 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012581 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 }
12583 }
12584 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 //Set operating channel in pProfile which will be used
12586 //in csrRoamSetBssConfigCfg() to determine channel bonding
12587 //mode and will be configured in CFG later
12588 pProfile->operationChannel = Channel;
12589
12590 if(Channel == 0)
12591 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012592 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 }
12594 else
12595 {
12596
12597 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012598 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012599 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012600 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012601 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012602#ifdef WLAN_FEATURE_AP_HT40_24G
12603 if (CSR_IS_INFRA_AP(pProfile))
12604 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12605 else
12606 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12607#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012608 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012609#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012610 }
12611 else
12612 {
12613 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12614 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012615 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012616 pBssConfig->cbMode = cbMode;
12617 pSession->bssParams.cbMode = cbMode;
12618 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 }
12620}
12621
Jeff Johnson295189b2012-06-20 16:38:30 -070012622static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12623 tANI_BOOLEAN *pfSameIbss )
12624{
12625 eHalStatus status = eHAL_STATUS_SUCCESS;
12626 tANI_BOOLEAN fSameIbss = FALSE;
12627
12628 if ( csrIsConnStateIbss( pMac, sessionId ) )
12629 {
12630 // Check if any profile parameter has changed ? If any profile parameter
12631 // has changed then stop old BSS and start a new one with new parameters
12632 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12633 {
12634 fSameIbss = TRUE;
12635 }
12636 else
12637 {
12638 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12639 }
12640 }
12641 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12642 {
12643 // Disassociate from the connected Infrastructure network...
12644 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12645 }
12646 else
12647 {
12648 tBssConfigParam *pBssConfig;
12649
Kiet Lam64c1b492013-07-12 13:56:44 +053012650 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12651 if ( NULL == pBssConfig )
12652 status = eHAL_STATUS_FAILURE;
12653 else
12654 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 if(HAL_STATUS_SUCCESS(status))
12656 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012657 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 // there is no Bss description before we start an IBSS so we need to adopt
12659 // all Bss configuration parameters from the Profile.
12660 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12661 if(HAL_STATUS_SUCCESS(status))
12662 {
12663 //save dotMode
12664 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12665 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012666 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012667 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12668 NULL, pBssConfig,
12669 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012671
12672 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 }//Allocate memory
12674 }
12675
12676 if(pfSameIbss)
12677 {
12678 *pfSameIbss = fSameIbss;
12679 }
12680 return( status );
12681}
12682
Jeff Johnson295189b2012-06-20 16:38:30 -070012683static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12684 tSirSmeNewBssInfo *pNewBss )
12685{
12686 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012687
12688 if(!pSession)
12689 {
12690 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12691 return;
12692 }
12693
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 if( pNewBss )
12695 {
12696 // Set the operating channel.
12697 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12698 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012699 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12700 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 return;
12703}
12704
Jeff Johnson295189b2012-06-20 16:38:30 -070012705#ifdef FEATURE_WLAN_WAPI
12706eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12707 tANI_U32 numItems )
12708{
12709 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012710 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012713 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012714 return status;
12715 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012716 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 pSession = CSR_GET_SESSION( pMac, sessionId );
12718 if(numItems <= CSR_MAX_BKID_ALLOWED)
12719 {
12720 status = eHAL_STATUS_SUCCESS;
12721 //numItems may be 0 to clear the cache
12722 pSession->NumBkidCache = (tANI_U16)numItems;
12723 if(numItems && pBKIDCache)
12724 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012725 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12726 sizeof(tBkidCacheInfo) * numItems);
12727 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 }
12729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 return (status);
12731}
Jeff Johnson295189b2012-06-20 16:38:30 -070012732eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12733 tBkidCacheInfo *pBkidCache)
12734{
12735 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012736 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012739 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 return status;
12741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 pSession = CSR_GET_SESSION( pMac, sessionId );
12743 if(pNum && pBkidCache)
12744 {
12745 if(pSession->NumBkidCache == 0)
12746 {
12747 *pNum = 0;
12748 status = eHAL_STATUS_SUCCESS;
12749 }
12750 else if(*pNum >= pSession->NumBkidCache)
12751 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012752 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012754 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 -070012755 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012756 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012758 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12759 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 *pNum = pSession->NumBkidCache;
12761 status = eHAL_STATUS_SUCCESS;
12762 }
12763 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012765}
Jeff Johnson295189b2012-06-20 16:38:30 -070012766tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12767{
12768 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012769}
12770#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012771eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012772 tPmkidCacheInfo *pPMKIDCache,
12773 tANI_U32 numItems,
12774 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012775{
12776 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12777 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012778
12779 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012780 {
12781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12782 return eHAL_STATUS_FAILURE;
12783 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012784
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012785 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012786
12787 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 {
12789#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12790 {
12791 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012792 vos_mem_set(&secEvent,
12793 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12795 secEvent.encryptionModeMulticast =
12796 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12797 secEvent.encryptionModeUnicast =
12798 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012799 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 secEvent.authMode =
12801 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12802 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12803 }
12804#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012806 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012807 if (numItems && pPMKIDCache)
12808 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012809 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012810 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12811 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012812 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012813 }
12814 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012815 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012816 tPmkidCacheInfo *pmksa;
12817
12818 for (i = 0; i < numItems; i++) {
12819 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012820
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012821 /* Delete the entry if present */
12822 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12823
12824 /* Add entry to the cache */
12825 vos_mem_copy(
12826 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12827 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12828 vos_mem_copy(
12829 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12830 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12831
12832 /* Increment the CSR local cache index */
12833 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12834 pSession->CurCacheIndex++;
12835 else
12836 pSession->CurCacheIndex = 0;
12837
12838 pSession->NumPmkidCache++;
12839 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12840 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012841 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 }
12843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 return (status);
12845}
12846
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012847eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012848#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12849 const tANI_U8 *pBSSId,
12850#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012851 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012852#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012853 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012854{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012855 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12856 tANI_BOOLEAN fMatchFound = FALSE;
12857 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012858 tANI_U32 CurIndex;
12859 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012860
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012861 if(!pSession)
12862 {
12863 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12864 return eHAL_STATUS_FAILURE;
12865 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012866
12867 /* Check if there are no entries to delete */
12868 if (0 == pSession->NumPmkidCache) {
12869 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12870 return eHAL_STATUS_SUCCESS;
12871 }
12872
12873 if (!flush_cache) {
12874 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12875 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12876 pBSSId, VOS_MAC_ADDR_SIZE)) {
12877 fMatchFound = 1;
12878
12879 /* Clear this - the matched entry */
12880 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12881 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012882 break;
12883 }
12884 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012885
12886 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12887 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12888 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012889 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012890 else {
12891 /* Match Found */
12892 CurIndex = pSession->CurCacheIndex;
12893 if(Index < CurIndex) {
12894 for(i = Index; i < (CurIndex-1); i++) {
12895 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12896 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12897 }
12898 pSession->CurCacheIndex--;
12899 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12900 sizeof(tPmkidCacheInfo));
12901 } else if(Index > CurIndex) {
12902 for(i = Index; i > (CurIndex); i--) {
12903 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12904 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12905 }
12906 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12907 sizeof(tPmkidCacheInfo));
12908 }
12909 pSession->NumPmkidCache--;
12910 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012911 } else {
12912 /* Flush the entire cache */
12913 vos_mem_zero(pSession->PmkidCacheInfo,
12914 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12915 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012916 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012917 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012918
12919 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012920}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012921
Jeff Johnson295189b2012-06-20 16:38:30 -070012922tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12923{
12924 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12925}
12926
Jeff Johnson295189b2012-06-20 16:38:30 -070012927eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12928{
12929 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12930 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012931 tPmkidCacheInfo *pmksa;
12932 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012933
12934 if(!pSession)
12935 {
12936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12937 return eHAL_STATUS_FAILURE;
12938 }
12939
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 if(pNum && pPmkidCache)
12941 {
12942 if(pSession->NumPmkidCache == 0)
12943 {
12944 *pNum = 0;
12945 status = eHAL_STATUS_SUCCESS;
12946 }
12947 else if(*pNum >= pSession->NumPmkidCache)
12948 {
12949 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012951 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 -070012952 pSession->NumPmkidCache);
12953 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12954 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012955
12956 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12957 pmksa = &pSession->PmkidCacheInfo[i];
12958 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12959 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
12960 pPmkidCache++;
12961 j++;
12962 }
12963 }
12964
Jeff Johnson295189b2012-06-20 16:38:30 -070012965 *pNum = pSession->NumPmkidCache;
12966 status = eHAL_STATUS_SUCCESS;
12967 }
12968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 return (status);
12970}
12971
Jeff Johnson295189b2012-06-20 16:38:30 -070012972eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12973{
12974 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12975 tANI_U32 len;
12976 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012977
12978 if(!pSession)
12979 {
12980 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12981 return eHAL_STATUS_FAILURE;
12982 }
12983
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 if(pLen)
12985 {
12986 len = *pLen;
12987 *pLen = pSession->nWpaRsnReqIeLength;
12988 if(pBuf)
12989 {
12990 if(len >= pSession->nWpaRsnReqIeLength)
12991 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012992 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12993 pSession->nWpaRsnReqIeLength);
12994 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 }
12996 }
12997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 return (status);
12999}
13000
Jeff Johnson295189b2012-06-20 16:38:30 -070013001eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13002{
13003 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13004 tANI_U32 len;
13005 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013006
13007 if(!pSession)
13008 {
13009 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13010 return eHAL_STATUS_FAILURE;
13011 }
13012
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 if(pLen)
13014 {
13015 len = *pLen;
13016 *pLen = pSession->nWpaRsnRspIeLength;
13017 if(pBuf)
13018 {
13019 if(len >= pSession->nWpaRsnRspIeLength)
13020 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013021 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13022 pSession->nWpaRsnRspIeLength);
13023 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 }
13025 }
13026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 return (status);
13028}
Jeff Johnson295189b2012-06-20 16:38:30 -070013029#ifdef FEATURE_WLAN_WAPI
13030eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13031{
13032 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13033 tANI_U32 len;
13034 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013035
13036 if(!pSession)
13037 {
13038 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13039 return eHAL_STATUS_FAILURE;
13040 }
13041
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 if(pLen)
13043 {
13044 len = *pLen;
13045 *pLen = pSession->nWapiReqIeLength;
13046 if(pBuf)
13047 {
13048 if(len >= pSession->nWapiReqIeLength)
13049 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013050 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13051 pSession->nWapiReqIeLength);
13052 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 }
13054 }
13055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 return (status);
13057}
Jeff Johnson295189b2012-06-20 16:38:30 -070013058eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13059{
13060 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13061 tANI_U32 len;
13062 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013063
13064 if(!pSession)
13065 {
13066 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13067 return eHAL_STATUS_FAILURE;
13068 }
13069
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 if(pLen)
13071 {
13072 len = *pLen;
13073 *pLen = pSession->nWapiRspIeLength;
13074 if(pBuf)
13075 {
13076 if(len >= pSession->nWapiRspIeLength)
13077 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13079 pSession->nWapiRspIeLength);
13080 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 }
13082 }
13083 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 return (status);
13085}
13086#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013087eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13088{
13089 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13090 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013091
13092 if(!pSession)
13093 {
13094 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13095 return (retStatus);
13096 }
13097
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 if(CSR_IS_ROAMING(pSession))
13099 {
13100 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13101 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 return (retStatus);
13104}
13105
Jeff Johnson295189b2012-06-20 16:38:30 -070013106//This function remove the connected BSS from te cached scan result
13107eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13108 tCsrRoamConnectedProfile *pConnProfile)
13109{
13110 eHalStatus status = eHAL_STATUS_FAILURE;
13111 tCsrScanResultFilter *pScanFilter = NULL;
13112 tListElem *pEntry;
13113 tCsrScanResult *pResult;
13114 tDot11fBeaconIEs *pIes;
13115 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13117 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13118 {
13119 do
13120 {
13121 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013122 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13123 if ( NULL == pScanFilter )
13124 status = eHAL_STATUS_FAILURE;
13125 else
13126 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013128 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13129 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13130 if ( NULL == pScanFilter->BSSIDs.bssid )
13131 status = eHAL_STATUS_FAILURE;
13132 else
13133 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013135 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13136 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13138 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13139 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013140 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13141 if ( NULL == pScanFilter->SSIDs.SSIDList )
13142 status = eHAL_STATUS_FAILURE;
13143 else
13144 status = eHAL_STATUS_SUCCESS;
13145 if (!HAL_STATUS_SUCCESS(status)) break;
13146 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13147 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 }
13149 pScanFilter->authType.numEntries = 1;
13150 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13151 pScanFilter->BSSType = pConnProfile->BSSType;
13152 pScanFilter->EncryptionType.numEntries = 1;
13153 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13154 pScanFilter->mcEncryptionType.numEntries = 1;
13155 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13156 //We ignore the channel for now, BSSID should be enough
13157 pScanFilter->ChannelInfo.numOfChannels = 0;
13158 //Also ignore the following fields
13159 pScanFilter->uapsd_mask = 0;
13160 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013161 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 pScanFilter->countryCode[0] = 0;
13163 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 csrLLLock(&pMac->scan.scanResultList);
13165 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13166 while( pEntry )
13167 {
13168 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13169 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13170 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13171 pScanFilter, NULL, NULL, NULL, &pIes);
13172 //Release the IEs allocated by csrMatchBSS is needed
13173 if( !pResult->Result.pvIes )
13174 {
13175 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013176 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 }
13178 if(fMatch)
13179 {
13180 //We found the one
13181 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13182 {
13183 //Free the memory
13184 csrFreeScanResultEntry( pMac, pResult );
13185 }
13186 break;
13187 }
13188 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13189 }//while
13190 csrLLUnlock(&pMac->scan.scanResultList);
13191 }while(0);
13192 if(pScanFilter)
13193 {
13194 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013195 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013196 }
13197 }
13198 return (status);
13199}
13200
Jeff Johnson295189b2012-06-20 16:38:30 -070013201//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013202eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13203{
13204 eHalStatus status = eHAL_STATUS_SUCCESS;
13205 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13207 {
13208 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13209 {
13210 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13211 {
13212 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013213 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 status = eHAL_STATUS_CSR_WRONG_STATE;
13215 break;
13216 }
13217 if( csrIsConnStateInfra( pMac, sessionId ) )
13218 {
13219 if( chnId &&
13220 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013222 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13224 status = eHAL_STATUS_CSR_WRONG_STATE;
13225 break;
13226 }
13227 }
13228 }
13229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 return ( status );
13231}
13232
Jeff Johnson295189b2012-06-20 16:38:30 -070013233static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13234{
13235 eHalStatus status = eHAL_STATUS_SUCCESS;
13236 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13237 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013238
13239 if(!pSession)
13240 {
13241 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13242 return eHAL_STATUS_FAILURE;
13243 }
13244
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 if ( csrIsConnStateIbss( pMac, sessionId ) )
13246 {
13247 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13248 }
13249 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13250 {
13251 // Disassociate from the connected Infrastructure network...
13252 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13253 }
13254 else
13255 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13257 //Otherwise we need to add code to handle the
13258 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13259 //send stop_bss to PE, before we can continue.
13260 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013261 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013263 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13264 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 // there is no Bss description before we start an WDS so we need
13266 // to adopt all Bss configuration parameters from the Profile.
13267 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13268 if(HAL_STATUS_SUCCESS(status))
13269 {
13270 //Save profile for late use
13271 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013272 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13273 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013275 vos_mem_set(pSession->pCurRoamProfile,
13276 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013280 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013281 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13282 NULL, &bssConfig,
13283 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 }
13285 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013286
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 return( status );
13288}
13289
Jeff Johnson295189b2012-06-20 16:38:30 -070013290////////////////////Mail box
13291
Jeff Johnson295189b2012-06-20 16:38:30 -070013292//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13293//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013294static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13295 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13297{
13298 tCsrChannelSet channelGroup;
13299 tSirMacCapabilityInfo *pAP_capabilityInfo;
13300 tAniBool fTmp;
13301 tANI_BOOLEAN found = FALSE;
13302 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013303 tANI_S8 pwrLimit = 0;
13304 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13306 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13307 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13308 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 // 802.11h
13310 //We can do this because it is in HOST CPU order for now.
13311 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013312 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13313 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13314 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 fTmp = (tAniBool)pal_cpu_to_be32(1);
13316 }
13317 else
13318 fTmp = (tAniBool)0;
13319
13320 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013321 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013323 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013324 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 // This is required for 11k test VoWiFi Ent: Test 2.
13326 // We need the power capabilities for Assoc Req.
13327 // This macro is provided by the halPhyCfg.h. We pick our
13328 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013329 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13330 if (0 != pwrLimit)
13331 {
13332 *pBuf++ = pwrLimit;
13333 }
13334 else
13335 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013336 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 size = sizeof(pMac->roam.validChannelList);
13339 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013340 {
13341 tANI_U8 *actualSize = pBuf++;
13342 *actualSize = 0;
13343
13344 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013346 /* Only add 5ghz channels*/
13347 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13348 {
13349 *actualSize +=1;
13350 *pBuf++ = pMac->roam.validChannelList[ i ];
13351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 }
13353 }
13354 else
13355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013356 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 *pBuf++ = 0; //tSirSupChnl->numChnl
13358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 //Check whether it is ok to enter UAPSD
13360#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13361 if( btcIsReadyForUapsd(pMac) )
13362#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13363 {
13364 *pBuf++ = uapsdMask;
13365 }
13366#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13367 else
13368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013369 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 *pBuf++ = 0;
13371 }
13372#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13373
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013375 vos_mem_copy(pBuf, pBssDescription,
13376 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13378}
13379
Jeff Johnson295189b2012-06-20 16:38:30 -070013380/*
13381 * The communication between HDD and LIM is thru mailbox (MB).
13382 * Both sides will access the data structure "tSirSmeJoinReq".
13383 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13384 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13385 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13386 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13387 */
13388eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013389 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013390{
13391 eHalStatus status = eHAL_STATUS_SUCCESS;
13392 tSirSmeJoinReq *pMsg;
13393 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013394 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 tANI_U16 msgLen, wTmp, ieLen;
13396 tSirMacRateSet OpRateSet;
13397 tSirMacRateSet ExRateSet;
13398 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13399 tANI_U32 dwTmp;
13400 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013401 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013402 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013403 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013404
13405 if(!pSession)
13406 {
13407 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13408 return eHAL_STATUS_FAILURE;
13409 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013410 /* To satisfy klockworks */
13411 if (NULL == pBssDescription)
13412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013413 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013414 return eHAL_STATUS_FAILURE;
13415 }
13416
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 do {
13418 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13419 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013420 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013421 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13422 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13423 // IE fields, but the length field in the bssDescription needs to be interpreted to
13424 // determine length of the IE fields.
13425 //
13426 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13427 // add in the length from the bssDescription (then add the size of the 'length' field
13428 // itself because that is NOT included in the length field).
13429 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13430 pBssDescription->length + sizeof( pBssDescription->length ) +
13431 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 +053013432 pMsg = vos_mem_malloc(msgLen);
13433 if (NULL == pMsg)
13434 status = eHAL_STATUS_FAILURE;
13435 else
13436 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013438 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013439 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 pMsg->length = pal_cpu_to_be16(msgLen);
13441 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 // sessionId
13443 *pBuf = (tANI_U8)sessionId;
13444 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 // transactionId
13446 *pBuf = 0;
13447 *( pBuf + 1 ) = 0;
13448 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 // ssId
13450 if( pIes->SSID.present && pIes->SSID.num_ssid )
13451 {
13452 // ssId len
13453 *pBuf = pIes->SSID.num_ssid;
13454 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013455 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 pBuf += pIes->SSID.num_ssid;
13457 }
13458 else
13459 {
13460 *pBuf = 0;
13461 pBuf++;
13462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013464 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13465 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 pBuf += sizeof(tSirMacAddr);
13467 // bsstype
13468 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13469 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013470 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 pBuf += sizeof(tSirBssType);
13472 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013473 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13474 if (pBssDescription->channelId <= 14 &&
13475 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13476 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13477 {
13478 //Need to disable VHT operation in 2.4 GHz band
13479 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13480 }
13481 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 //Persona
13484 *pBuf = (tANI_U8)pProfile->csrPersona;
13485 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013486 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13487 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013488 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13489 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013490 //CBMode
13491 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13492 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013493
13494 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070013495 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
13496
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 // uapsdPerAcBitmask
13498 *pBuf = pProfile->uapsd_mask;
13499 pBuf++;
13500
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013501
13502
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013503 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013504 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 {
13506 // OperationalRateSet
13507 if (OpRateSet.numRates) {
13508 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013509 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 pBuf += OpRateSet.numRates;
13511 } else *pBuf++ = 0;
13512 // ExtendedRateSet
13513 if (ExRateSet.numRates) {
13514 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013515 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 pBuf += ExRateSet.numRates;
13517 } else *pBuf++ = 0;
13518 }
13519 else
13520 {
13521 *pBuf++ = 0;
13522 *pBuf++ = 0;
13523 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013524
13525 //rateBitmap
13526 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13527 pBuf += sizeof(tANI_U16);
13528
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 // rsnIE
13530 if ( csrIsProfileWpa( pProfile ) )
13531 {
13532 // Insert the Wpa IE into the join request
13533 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13534 (tCsrWpaIe *)( wpaRsnIE ) );
13535 }
13536 else if( csrIsProfileRSN( pProfile ) )
13537 {
13538 // Insert the RSN IE into the join request
13539 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13540 (tCsrRSNIe *)( wpaRsnIE ) );
13541 }
13542#ifdef FEATURE_WLAN_WAPI
13543 else if( csrIsProfileWapi( pProfile ) )
13544 {
13545 // Insert the WAPI IE into the join request
13546 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13547 (tCsrWapiIe *)( wpaRsnIE ) );
13548 }
13549#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 else
13551 {
13552 ieLen = 0;
13553 }
13554 //remember the IE for future use
13555 if( ieLen )
13556 {
13557 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013559 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 -070013560 ieLen = DOT11F_IE_RSN_MAX_LEN;
13561 }
13562#ifdef FEATURE_WLAN_WAPI
13563 if( csrIsProfileWapi( pProfile ) )
13564 {
13565 //Check whether we need to allocate more memory
13566 if(ieLen > pSession->nWapiReqIeLength)
13567 {
13568 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13569 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013570 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013572 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13573 if (NULL == pSession->pWapiReqIE)
13574 status = eHAL_STATUS_FAILURE;
13575 else
13576 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 if(!HAL_STATUS_SUCCESS(status)) break;
13578 }
13579 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013580 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013582 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013584 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 pBuf += ieLen;
13586 }
13587 else//should be WPA/WPA2 otherwise
13588#endif /* FEATURE_WLAN_WAPI */
13589 {
13590 //Check whether we need to allocate more memory
13591 if(ieLen > pSession->nWpaRsnReqIeLength)
13592 {
13593 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13594 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013595 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013597 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13598 if (NULL == pSession->pWpaRsnReqIE)
13599 status = eHAL_STATUS_FAILURE;
13600 else
13601 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 if(!HAL_STATUS_SUCCESS(status)) break;
13603 }
13604 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013605 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013607 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013609 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 pBuf += ieLen;
13611 }
13612 }
13613 else
13614 {
13615 //free whatever old info
13616 pSession->nWpaRsnReqIeLength = 0;
13617 if(pSession->pWpaRsnReqIE)
13618 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 pSession->pWpaRsnReqIE = NULL;
13621 }
13622#ifdef FEATURE_WLAN_WAPI
13623 pSession->nWapiReqIeLength = 0;
13624 if(pSession->pWapiReqIE)
13625 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013626 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 pSession->pWapiReqIE = NULL;
13628 }
13629#endif /* FEATURE_WLAN_WAPI */
13630 //length is two bytes
13631 *pBuf = 0;
13632 *(pBuf + 1) = 0;
13633 pBuf += 2;
13634 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013635#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013636 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013638 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 //length is two bytes
13640 *pBuf = 0;
13641 *(pBuf + 1) = 0;
13642 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013643 }
13644 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013646 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013647 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013648 {
13649 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013650#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013651 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013652 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013653 pSession->suppCckmIeInfo.cckmIe, ieLen);
13654#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013655 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013656 pSession,
13657 pProfile,
13658 pBssDescription,
13659 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 pSession->nWpaRsnReqIeLength,
13661 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013662#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013663 }
13664 else
13665 {
13666 ieLen = 0;
13667 }
13668 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13669 if( ieLen )
13670 {
13671 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13672 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013673 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013674 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013675 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013676 pBuf += ieLen;
13677 }
13678 else
13679 {
13680 //Indicate you have no CCKM IE
13681 //length is two bytes
13682 *pBuf = 0;
13683 *(pBuf + 1) = 0;
13684 pBuf += 2;
13685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013687#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013689 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 {
13691 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013692 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013694 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013696 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013698 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 pBuf += ieLen;
13700 }
13701 else
13702 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013703 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 *pBuf = 0;
13706 *(pBuf + 1) = 0;
13707 pBuf += 2;
13708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 // addIEAssoc
13710 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13711 {
13712 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013713 if(ieLen > pSession->nAddIEAssocLength)
13714 {
13715 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013716 {
13717 vos_mem_free(pSession->pAddIEAssoc);
13718 }
13719 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13720 if (NULL == pSession->pAddIEAssoc)
13721 status = eHAL_STATUS_FAILURE;
13722 else
13723 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013727 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013728 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013731 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 pBuf += ieLen;
13733 }
13734 else
13735 {
13736 pSession->nAddIEAssocLength = 0;
13737 if(pSession->pAddIEAssoc)
13738 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013739 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 pSession->pAddIEAssoc = NULL;
13741 }
13742 *pBuf = 0;
13743 *(pBuf + 1) = 0;
13744 pBuf += 2;
13745 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013746
13747 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013749 //Unmask any AC in reassoc that is ACM-set
13750 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13751 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013753 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13754 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013755#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013756 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013757#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013758 }
13759 else
13760 {
13761 uapsd_mask = 0;
13762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 }
13764 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013765
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013767 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013768 pBuf += sizeof(tANI_U32);
13769
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013771 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013772 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013773#ifdef WLAN_FEATURE_11W
13774 //MgmtEncryption
13775 if (pProfile->MFPEnabled)
13776 {
13777 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13778 }
13779 else
13780 {
13781 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13782 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013783 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013784 pBuf += sizeof(tANI_U32);
13785#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013786#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013787 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013788 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013789#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013790 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013791 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013792#endif
13793 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013794 {
13795 // is11Rconnection;
13796 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013797 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013798 pBuf += sizeof(tAniBool);
13799 }
13800 else
13801 {
13802 // is11Rconnection;
13803 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013804 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013805 pBuf += sizeof(tAniBool);
13806 }
13807#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013808#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013809
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013810 // isESEFeatureIniEnabled
13811 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013812 {
13813 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013814 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013815 pBuf += sizeof(tAniBool);
13816 }
13817 else
13818 {
13819 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013820 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013821 pBuf += sizeof(tAniBool);
13822 }
13823
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013824 /* A profile can not be both ESE and 11R. But an 802.11R AP
13825 * may be advertising support for ESE as well. So if we are
13826 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013827 * If we are associating explictly 11R only then we will get
13828 * 11R.
13829 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013830 if ((csrIsProfileESE(pProfile) ||
13831 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013832 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13833 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13834 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13835 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13836#ifdef WLAN_FEATURE_11W
13837 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013838 || (pProfile->negotiatedAuthType ==
13839 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013840#endif
13841 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013842 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013843 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013844 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013845 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013846 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013847 pBuf += sizeof(tAniBool);
13848 }
13849 else
13850 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013851 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013852 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013854 pBuf += sizeof(tAniBool);
13855 }
13856
13857 if (eWNI_SME_JOIN_REQ == messageType)
13858 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013859 tESETspecInfo eseTspec;
13860 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013861 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013862 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13863 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13864 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013865 }
13866 else if (eWNI_SME_REASSOC_REQ == messageType)
13867 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013868 if ((csrIsProfileESE(pProfile) ||
13869 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013870 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13871 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13872 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13873 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13874#ifdef WLAN_FEATURE_11W
13875 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013876 || (pProfile->negotiatedAuthType ==
13877 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013878#endif
13879 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013880 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013882 tESETspecInfo eseTspec;
13883 // ESE Tspec information
13884 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13885 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13886 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013889 if (eseTspec.numTspecs) {
13890 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13891 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013893 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013895 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013897 tESETspecInfo eseTspec;
13898 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013900 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13901 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13902 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 }
13904 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013905#endif // FEATURE_WLAN_ESE
13906#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013908 if (pMac->roam.configParam.isFastTransitionEnabled
13909#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013910 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013911#endif
13912 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013914 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013915 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013916 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 }
13918 else
13919 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013920 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013921 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013922 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 }
13924#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013925#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013926 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013927 {
13928 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013929 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013930 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013931 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013932 }
13933 else
13934 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013935 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013936 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013937 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013938 }
13939#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013940
13941 // txLdpcIniFeatureEnabled
13942 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13943 pBuf++;
13944
Kiran4a17ebe2013-01-31 10:43:43 -080013945 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13946 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13947 {
13948 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13949 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13950 csrApplyPower2Current(pMac);
13951 }
13952
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013953#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013954 // txBFIniFeatureEnabled
13955 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13956 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013957
13958 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053013959 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013960 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053013961 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13962 if (pIes->VHTCaps.numSoundingDim)
13963 txBFCsnValue = CSR_ROAM_MIN
13964 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013965 }
13966 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013967 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013968
13969 /* Only enable MuBf if no other MuBF session exist
13970 * and FW and HOST is MuBF capable.
13971 */
13972 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13973 {
13974 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13975 pBuf++;
13976 }
13977 else
13978 {
13979 *pBuf = 0;
13980 pBuf++;
13981 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013982#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013983 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13984 pBuf++;
13985
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013986 // WME
13987 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13988 {
13989 //WME enabled
13990 dwTmp = pal_cpu_to_be32(TRUE);
13991 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13992 pBuf += sizeof(tAniBool);
13993 }
13994 else
13995 {
13996 dwTmp = pal_cpu_to_be32(FALSE);
13997 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13998 pBuf += sizeof(tAniBool);
13999 }
14000
14001 // QOS
14002 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14003 {
14004 //QOS enabled
14005 dwTmp = pal_cpu_to_be32(TRUE);
14006 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14007 pBuf += sizeof(tAniBool);
14008 }
14009 else
14010 {
14011 dwTmp = pal_cpu_to_be32(FALSE);
14012 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14013 pBuf += sizeof(tAniBool);
14014 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014015 //BssDesc
14016 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14017 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014018
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014019 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014020 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14021 pMsg = NULL;
14022
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014023 if(!HAL_STATUS_SUCCESS(status))
14024 {
14025 break;
14026 }
14027 else
14028 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014029#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014030 if (eWNI_SME_JOIN_REQ == messageType)
14031 {
14032 //Tush-QoS: notify QoS module that join happening
14033 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14034 }
14035 else if (eWNI_SME_REASSOC_REQ == messageType)
14036 {
14037 //Tush-QoS: notify QoS module that reassoc happening
14038 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014040#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014043
14044 if (pMsg != NULL)
14045 {
14046 vos_mem_free( pMsg );
14047 }
14048
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014050}
14051
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014052#ifdef WLAN_FEATURE_LFR_MBB
14053/**
14054 * csr_prepare_reassoc_req () - Prepares reassoc request
14055 * @mac: MAC context
14056 * @session_id: session id
14057 * @pbss_description: bss description
14058 * @ies: pointer to beacon IE's
14059 * @reassoc_req: pointer to reassociation request
14060 *
14061 *Return: None
14062 */
14063eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14064 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14065 tSirSmeJoinReq **reassoc_req)
14066{
14067 eHalStatus status = eHAL_STATUS_SUCCESS;
14068 tSirSmeJoinReq *csr_join_req;
14069 tANI_U8 *buf;
14070 v_U8_t acm_mask = 0, uapsd_mask;
14071 tANI_U16 msg_len, w_tmp, ie_len;
14072 tSirMacRateSet op_rate_set;
14073 tSirMacRateSet ex_rate_set;
14074 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14075 tANI_U32 dw_tmp;
14076 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14077 tANI_U32 uc_dot11_mode = 0;
14078 tANI_U8 tx_bf_csn_value = 0;
14079 tANI_U16 rate_bitmap = 0;
14080 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014081 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014082
14083 if(!session) {
14084 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14085 return eHAL_STATUS_FAILURE;
14086 }
14087
14088 if (NULL == bss_description) {
14089 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14090 return eHAL_STATUS_FAILURE;
14091 }
14092
14093 smsLog(mac, LOG1,
14094 FL("session_id %d"), session_id);
14095
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014096 profile = vos_mem_malloc(sizeof(*profile));
14097 if (NULL == profile) {
14098 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14099 return eHAL_STATUS_RESOURCES;
14100 }
14101
14102 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014103 if(!HAL_STATUS_SUCCESS(status)) {
14104 smsLog(mac, LOGE, FL("Profile copy failed"));
14105 return eHAL_STATUS_FAILURE;
14106 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014107
14108 do {
14109 /*
14110 * There are a number of variable length fields to consider.
14111 * First, the tSirSmeJoinReq includes a single bssDescription.
14112 * bssDescription includes a single tANI_U32 for the IE fields,
14113 * but the length field in the bssDescription needs to be
14114 * interpreted to determine length of the IE fields.
14115 * So, take the size of the JoinReq, subtract the size of the
14116 * bssDescription and add in the length from the bssDescription
14117 * (then add the size of the 'length' field itself because that is
14118 * NOT included in the length field). msgLen =
14119 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14120 * pBssDescription->length + sizeof( pBssDescription->length ) +
14121 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14122 * add in the size of the WPA IE that we may build.
14123 */
14124
14125 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14126 bss_description->length + sizeof(bss_description->length) +
14127 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14128
14129 csr_join_req = vos_mem_malloc(msg_len);
14130 if (NULL == csr_join_req)
14131 status = eHAL_STATUS_FAILURE;
14132 else
14133 status = eHAL_STATUS_SUCCESS;
14134 if (!HAL_STATUS_SUCCESS(status)) break;
14135
14136 vos_mem_set(csr_join_req, msg_len, 0);
14137 *reassoc_req = csr_join_req;
14138
14139 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14140 csr_join_req->length = pal_cpu_to_be16(msg_len);
14141 buf = &csr_join_req->sessionId;
14142
14143 /* session_id */
14144 *buf = (tANI_U8)session_id;
14145 buf++;
14146
14147 /* transactionId */
14148 *buf = 0;
14149 *(buf + 1) = 0;
14150 buf += sizeof(tANI_U16);
14151
14152 /* ssId */
14153 if(ies->SSID.present && ies->SSID.num_ssid)
14154 {
14155 /* ssId len */
14156 *buf = ies->SSID.num_ssid;
14157 buf++;
14158 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14159 buf += ies->SSID.num_ssid;
14160 }
14161 else
14162 {
14163 *buf = 0;
14164 buf++;
14165 }
14166
14167 /* selfMacAddr */
14168 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14169 sizeof(tSirMacAddr));
14170 buf += sizeof(tSirMacAddr);
14171
14172 /* bsstype */
14173 dw_tmp =
14174 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14175 /* Override BssType for BTAMP */
14176 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14177 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14178 buf += sizeof(tSirBssType);
14179
14180 /* dot11mode */
14181 uc_dot11_mode =
14182 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14183 if (bss_description->channelId <= 14 &&
14184 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14185 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14186 {
14187 /* Need to disable VHT operation in 2.4 GHz band */
14188 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14189 }
14190 *buf = (tANI_U8)uc_dot11_mode;
14191 buf++;
14192
14193 /* Persona */
14194 *buf = (tANI_U8)profile->csrPersona;
14195 buf++;
14196 *buf = (tANI_U8)profile->bOSENAssociation;
14197 buf++;
14198 *buf = (tANI_U8)profile->bWPSAssociation;
14199 buf++;
14200
14201 /* CBMode */
14202 *buf = (tANI_U8)session->bssParams.cbMode;
14203 buf++;
14204
14205 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14206 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14207 session->bssParams.cbMode);
14208
14209 /* uapsdPerAcBitmask */
14210 *buf = profile->uapsd_mask;
14211 buf++;
14212
14213
14214 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14215 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14216 if (HAL_STATUS_SUCCESS(status))
14217 {
14218 /* OperationalRateSet */
14219 if (op_rate_set.numRates) {
14220 *buf++ = op_rate_set.numRates;
14221 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14222 buf += op_rate_set.numRates;
14223 } else *buf++ = 0;
14224
14225 /* ExtendedRateSet */
14226 if (ex_rate_set.numRates) {
14227 *buf++ = ex_rate_set.numRates;
14228 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14229 buf += ex_rate_set.numRates;
14230 } else *buf++ = 0;
14231 }
14232 else
14233 {
14234 *buf++ = 0;
14235 *buf++ = 0;
14236 }
14237
14238 /* rateBitmap */
14239 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14240 buf += sizeof(tANI_U16);
14241
14242 profile->negotiatedAuthType =
14243 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14244 profile->negotiatedUCEncryptionType =
14245 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14246
14247 /* rsnIE */
14248 if ( csrIsProfileWpa(profile))
14249 {
14250 /* Insert the Wpa IE into the join request */
14251 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14252 (tCsrWpaIe *)(wpa_rsn_ie));
14253 }
14254 else if( csrIsProfileRSN(profile))
14255 {
14256 /* Insert the RSN IE into the join request */
14257 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14258 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14259 }
14260#ifdef FEATURE_WLAN_WAPI
14261 else if( csrIsProfileWapi(profile))
14262 {
14263 /* Insert the WAPI IE into the join request */
14264 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14265 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14266 }
14267#endif
14268 else
14269 {
14270 ie_len = 0;
14271 }
14272 /* remember the IE for future use */
14273 if(ie_len)
14274 {
14275 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14276 {
14277 smsLog(mac, LOGE,
14278 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14279 ie_len, DOT11F_IE_RSN_MAX_LEN);
14280 ie_len = DOT11F_IE_RSN_MAX_LEN;
14281 }
14282#ifdef FEATURE_WLAN_WAPI
14283 if( csrIsProfileWapi(profile))
14284 {
14285 /* Check whether we need to allocate more memory */
14286 if(ie_len > session->nWapiReqIeLength)
14287 {
14288 if(session->pWapiReqIE && session->nWapiReqIeLength)
14289 {
14290 vos_mem_free(session->pWapiReqIE);
14291 }
14292 session->pWapiReqIE = vos_mem_malloc(ie_len);
14293 if (NULL == session->pWapiReqIE)
14294 status = eHAL_STATUS_FAILURE;
14295 else
14296 status = eHAL_STATUS_SUCCESS;
14297 if(!HAL_STATUS_SUCCESS(status)) break;
14298 }
14299 session->nWapiReqIeLength = ie_len;
14300 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14301 w_tmp = pal_cpu_to_be16(ie_len);
14302 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14303 buf += sizeof(tANI_U16);
14304 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14305 buf += ie_len;
14306 }
14307 else /* should be WPA/WPA2 otherwise */
14308#endif
14309 {
14310 /* Check whether we need to allocate more memory */
14311 if(ie_len > session->nWpaRsnReqIeLength)
14312 {
14313 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14314 {
14315 vos_mem_free(session->pWpaRsnReqIE);
14316 }
14317 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14318 if (NULL == session->pWpaRsnReqIE)
14319 status = eHAL_STATUS_FAILURE;
14320 else
14321 status = eHAL_STATUS_SUCCESS;
14322 if(!HAL_STATUS_SUCCESS(status)) break;
14323 }
14324 session->nWpaRsnReqIeLength = ie_len;
14325 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14326 w_tmp = pal_cpu_to_be16(ie_len);
14327 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14328 buf += sizeof(tANI_U16);
14329 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14330 buf += ie_len;
14331 }
14332 }
14333 else
14334 {
14335 /* free whatever old info */
14336 session->nWpaRsnReqIeLength = 0;
14337 if(session->pWpaRsnReqIE)
14338 {
14339 vos_mem_free(session->pWpaRsnReqIE);
14340 session->pWpaRsnReqIE = NULL;
14341 }
14342#ifdef FEATURE_WLAN_WAPI
14343 session->nWapiReqIeLength = 0;
14344 if(session->pWapiReqIE)
14345 {
14346 vos_mem_free(session->pWapiReqIE);
14347 session->pWapiReqIE = NULL;
14348 }
14349#endif
14350 /* length is two bytes */
14351 *buf = 0;
14352 *(buf + 1) = 0;
14353 buf += 2;
14354 }
14355#ifdef FEATURE_WLAN_ESE
14356 if(eWNI_SME_JOIN_REQ == message_type)
14357 {
14358 /*
14359 * Never include the cckmIE in an Join Request
14360 * length is two bytes
14361 */
14362 *buf = 0;
14363 *(buf + 1) = 0;
14364 buf += 2;
14365 }
14366 else if(eWNI_SME_REASSOC_REQ == message_type)
14367 {
14368 /* cckmIE */
14369 if( csrIsProfileESE(profile))
14370 {
14371 /* Insert the CCKM IE into the join request */
14372#ifdef FEATURE_WLAN_ESE_UPLOAD
14373 ie_len = session->suppCckmIeInfo.cckmIeLen;
14374 vos_mem_copy((void *) (wpa_rsn_ie),
14375 session->suppCckmIeInfo.cckmIe, ie_len);
14376#else
14377 ie_len = csrConstructEseCckmIe(mac,
14378 session,
14379 profile,
14380 bss_description,
14381 session->pWpaRsnReqIE,
14382 session->nWpaRsnReqIeLength,
14383 (void *)(wpa_rsn_ie));
14384#endif
14385 }
14386 else
14387 {
14388 ie_len = 0;
14389 }
14390 /*
14391 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14392 * message buffer
14393 */
14394 if(ie_len)
14395 {
14396 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14397 w_tmp = pal_cpu_to_be16(ie_len);
14398 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14399 buf += sizeof(tANI_U16);
14400 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14401 buf += ie_len;
14402 }
14403 else
14404 {
14405 /* Indicate you have no CCKM IE length is two bytes */
14406 *buf = 0;
14407 *(buf + 1) = 0;
14408 buf += 2;
14409 }
14410 }
14411#endif
14412 /* addIEScan */
14413 if (profile->nAddIEScanLength)
14414 {
14415 ie_len = profile->nAddIEScanLength;
14416 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14417 session->nAddIEScanLength = ie_len;
14418 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14419 w_tmp = pal_cpu_to_be16(ie_len);
14420 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14421 buf += sizeof(tANI_U16);
14422 vos_mem_copy(buf, profile->addIEScan, ie_len);
14423 buf += ie_len;
14424 }
14425 else
14426 {
14427 memset(session->addIEScan, 0, session->nAddIEScanLength);
14428 session->nAddIEScanLength = 0;
14429 *buf = 0;
14430 *(buf + 1) = 0;
14431 buf += 2;
14432 }
14433 /* addIEAssoc */
14434 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14435 {
14436 ie_len = profile->nAddIEAssocLength;
14437 if(ie_len > session->nAddIEAssocLength)
14438 {
14439 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14440 {
14441 vos_mem_free(session->pAddIEAssoc);
14442 }
14443 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14444 if (NULL == session->pAddIEAssoc)
14445 status = eHAL_STATUS_FAILURE;
14446 else
14447 status = eHAL_STATUS_SUCCESS;
14448 if(!HAL_STATUS_SUCCESS(status)) break;
14449 }
14450 session->nAddIEAssocLength = ie_len;
14451 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14452 w_tmp = pal_cpu_to_be16(ie_len);
14453 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14454 buf += sizeof(tANI_U16);
14455 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14456 buf += ie_len;
14457 }
14458 else
14459 {
14460 session->nAddIEAssocLength = 0;
14461 if(session->pAddIEAssoc)
14462 {
14463 vos_mem_free(session->pAddIEAssoc);
14464 session->pAddIEAssoc = NULL;
14465 }
14466 *buf = 0;
14467 *(buf + 1) = 0;
14468 buf += 2;
14469 }
14470
14471 if(eWNI_SME_REASSOC_REQ == message_type )
14472 {
14473 /*Unmask any AC in reassoc that is ACM-set */
14474 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14475 if( uapsd_mask && (NULL != bss_description))
14476 {
14477 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14478 {
14479#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14480 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14481#endif
14482 }
14483 else
14484 {
14485 uapsd_mask = 0;
14486 }
14487 }
14488 }
14489
14490 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14491 profile->negotiatedUCEncryptionType));
14492 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14493 buf += sizeof(tANI_U32);
14494
14495 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14496 profile->negotiatedMCEncryptionType));
14497 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14498 buf += sizeof(tANI_U32);
14499#ifdef WLAN_FEATURE_11W
14500 /* MgmtEncryption */
14501 if (profile->MFPEnabled)
14502 {
14503 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14504 }
14505 else
14506 {
14507 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14508 }
14509 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14510 buf += sizeof(tANI_U32);
14511#endif
14512#ifdef WLAN_FEATURE_VOWIFI_11R
14513 profile->MDID.mdiePresent = bss_description->mdiePresent;
14514 if (csrIsProfile11r(profile)
14515#ifdef FEATURE_WLAN_ESE
14516 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14517 (ies->ESEVersion.present) &&
14518 (mac->roam.configParam.isEseIniFeatureEnabled))
14519#endif
14520 )
14521 {
14522 /* is11Rconnection */
14523 dw_tmp = pal_cpu_to_be32(TRUE);
14524 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14525 buf += sizeof(tAniBool);
14526 }
14527 else
14528 {
14529 /* is11Rconnection */
14530 dw_tmp = pal_cpu_to_be32(FALSE);
14531 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14532 buf += sizeof(tAniBool);
14533 }
14534#endif
14535#ifdef FEATURE_WLAN_ESE
14536
14537 /* isESEFeatureIniEnabled */
14538 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14539 {
14540 dw_tmp = pal_cpu_to_be32(TRUE);
14541 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14542 buf += sizeof(tAniBool);
14543 }
14544 else
14545 {
14546 dw_tmp = pal_cpu_to_be32(FALSE);
14547 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14548 buf += sizeof(tAniBool);
14549 }
14550
14551 /* A profile can not be both ESE and 11R. But an 802.11R AP
14552 * may be advertising support for ESE as well. So if we are
14553 * associating Open or explicitly ESE then we will get ESE.
14554 * If we are associating explictly 11R only then we will get
14555 * 11R.
14556 */
14557 if ((csrIsProfileESE(profile) ||
14558 ((ies->ESEVersion.present)
14559 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14560 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14561 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14562 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14563#ifdef WLAN_FEATURE_11W
14564 || (profile->negotiatedAuthType ==
14565 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14566 || (profile->negotiatedAuthType ==
14567 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14568#endif
14569 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14570 && (mac->roam.configParam.isEseIniFeatureEnabled))
14571 {
14572 /* isESEconnection */
14573 dw_tmp = pal_cpu_to_be32(TRUE);
14574 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14575 buf += sizeof(tAniBool);
14576 }
14577 else
14578 {
14579 /* isESEconnection */
14580 dw_tmp = pal_cpu_to_be32(FALSE);
14581 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14582 buf += sizeof(tAniBool);
14583 }
14584
14585 if (eWNI_SME_JOIN_REQ == message_type)
14586 {
14587 tESETspecInfo eseTspec;
14588 /*
14589 * ESE-Tspec IEs in the ASSOC request is presently not supported
14590 * so nullify the TSPEC parameters
14591 */
14592 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14593 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14594 buf += sizeof(tESETspecInfo);
14595 }
14596 else if (eWNI_SME_REASSOC_REQ == message_type)
14597 {
14598 if ((csrIsProfileESE(profile) ||
14599 ((ies->ESEVersion.present)
14600 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14601 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14602 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14603 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14604#ifdef WLAN_FEATURE_11W
14605 || (profile->negotiatedAuthType ==
14606 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14607 || (profile->negotiatedAuthType ==
14608 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14609#endif
14610 || (profile->negotiatedAuthType ==
14611 eCSR_AUTH_TYPE_RSN_PSK))))
14612 && (mac->roam.configParam.isEseIniFeatureEnabled))
14613 {
14614 tESETspecInfo eseTspec;
14615 /* ESE Tspec information */
14616 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14617 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14618 (tTspecInfo *) &eseTspec.tspec[0]);
14619 *buf = eseTspec.numTspecs;
14620 buf += sizeof(tANI_U8);
14621 // Copy the TSPEC information only if present
14622 if (eseTspec.numTspecs) {
14623 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14624 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14625 }
14626 buf += sizeof(eseTspec.tspec);
14627 }
14628 else
14629 {
14630 tESETspecInfo eseTspec;
14631 /*
14632 * ESE-Tspec IEs in the ASSOC request is presently
14633 * not supported so nullify the TSPEC parameters
14634 */
14635 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14636 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14637 buf += sizeof(tESETspecInfo);
14638 }
14639 }
14640#endif
14641#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14642 /* Fill in isFastTransitionEnabled */
14643 if (mac->roam.configParam.isFastTransitionEnabled
14644#ifdef FEATURE_WLAN_LFR
14645 || csrRoamIsFastRoamEnabled(mac, session_id)
14646#endif
14647 )
14648 {
14649 dw_tmp = pal_cpu_to_be32(TRUE);
14650 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14651 buf += sizeof(tAniBool);
14652 }
14653 else
14654 {
14655 dw_tmp = pal_cpu_to_be32(FALSE);
14656 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14657 buf += sizeof(tAniBool);
14658 }
14659#endif
14660#ifdef FEATURE_WLAN_LFR
14661 if(csrRoamIsFastRoamEnabled(mac, session_id))
14662 {
14663 /* legacy fast roaming enabled */
14664 dw_tmp = pal_cpu_to_be32(TRUE);
14665 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14666 buf += sizeof(tAniBool);
14667 }
14668 else
14669 {
14670 dw_tmp = pal_cpu_to_be32(FALSE);
14671 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14672 buf += sizeof(tAniBool);
14673 }
14674#endif
14675
14676 /* txLdpcIniFeatureEnabled */
14677 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14678 buf++;
14679
14680 if ((csrIs11hSupported(mac)) &&
14681 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14682 (ies->Country.present) &&\
14683 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14684 {
14685 csrSaveToChannelPower2G_5G(mac,
14686 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14687 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14688 csrApplyPower2Current(mac);
14689 }
14690
14691#ifdef WLAN_FEATURE_11AC
14692 /* txBFIniFeatureEnabled */
14693 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14694 buf++;
14695
14696 /* txBFCsnValue */
14697 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14698 {
14699 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14700 if (ies->VHTCaps.numSoundingDim)
14701 tx_bf_csn_value = CSR_ROAM_MIN
14702 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14703 }
14704 *buf = tx_bf_csn_value;
14705 buf++;
14706
14707 /* Only enable MuBf if no other MuBF session exist
14708 * and FW and HOST is MuBF capable.
14709 */
14710 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14711 {
14712 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14713 buf++;
14714 }
14715 else
14716 {
14717 *buf = 0;
14718 buf++;
14719 }
14720#endif
14721 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14722 buf++;
14723
14724 /* WME */
14725 if(mac->roam.roamSession[session_id].fWMMConnection)
14726 {
14727 /* WME enabled */
14728 dw_tmp = pal_cpu_to_be32(TRUE);
14729 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14730 buf += sizeof(tAniBool);
14731 }
14732 else
14733 {
14734 dw_tmp = pal_cpu_to_be32(FALSE);
14735 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14736 buf += sizeof(tAniBool);
14737 }
14738
14739 /* QOS */
14740 if(mac->roam.roamSession[session_id].fQOSConnection)
14741 {
14742 /* QOS enabled */
14743 dw_tmp = pal_cpu_to_be32(TRUE);
14744 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14745 buf += sizeof(tAniBool);
14746 }
14747 else
14748 {
14749 dw_tmp = pal_cpu_to_be32(FALSE);
14750 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14751 buf += sizeof(tAniBool);
14752 }
14753 /* BssDesc */
14754 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14755 (tANI_U8)profile->uapsd_mask);
14756 } while( 0 );
14757
14758 smsLog(mac, LOG1, FL("status %d"), status);
14759
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014760 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014761 return status;
14762}
14763#endif
14764
Jeff Johnson295189b2012-06-20 16:38:30 -070014765//
14766eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14767{
14768 eHalStatus status = eHAL_STATUS_SUCCESS;
14769 tSirSmeDisassocReq *pMsg;
14770 tANI_U8 *pBuf;
14771 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14773 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14774 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014776 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14777 if (NULL == pMsg)
14778 status = eHAL_STATUS_FAILURE;
14779 else
14780 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014781 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014782 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14784 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014785 pBuf = &pMsg->sessionId;
14786 // sessionId
14787 *pBuf++ = (tANI_U8)sessionId;
14788 // transactionId
14789 *pBuf = 0;
14790 *( pBuf + 1 ) = 0;
14791 pBuf += sizeof(tANI_U16);
14792
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014793 if ( (pSession->pCurRoamProfile != NULL) &&
14794 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14795 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014796 {
14797 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014798 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14799 sizeof( tSirMacAddr ));
14800 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014803 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14804 //perMacAddr is passed as bssId for softAP
14805 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 pBuf = pBuf + sizeof ( tSirMacAddr );
14807 }
14808 else
14809 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014810 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014811 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14812 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053014814 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
14815 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014817 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 if(!HAL_STATUS_SUCCESS(status))
14819 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014820 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 break;
14822 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 // reasonCode
14824 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014825 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
14826 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 if(!HAL_STATUS_SUCCESS(status))
14828 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014829 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 break;
14831 }
14832 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14834 Here we should not send the disassoc over the air to the AP */
14835 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14836#ifdef WLAN_FEATURE_VOWIFI_11R
14837 && csrRoamIs11rAssoc(pMac)
14838#endif
14839 )
14840 {
14841 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14842 }
14843 pBuf += sizeof(tANI_U8);
14844 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 return( status );
14847}
Jeff Johnson295189b2012-06-20 16:38:30 -070014848eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14849{
14850 eHalStatus status = eHAL_STATUS_SUCCESS;
14851 tSirSmeTkipCntrMeasReq *pMsg;
14852 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 do
14854 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014855 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14856 if ( NULL == pMsg )
14857 status = eHAL_STATUS_FAILURE;
14858 else
14859 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014861 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14863 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 pBuf = &pMsg->sessionId;
14865 // sessionId
14866 *pBuf++ = (tANI_U8)sessionId;
14867 // transactionId
14868 *pBuf = 0;
14869 *( pBuf + 1 ) = 0;
14870 pBuf += sizeof(tANI_U16);
14871 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014872 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14873 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 pBuf = pBuf + sizeof ( tSirMacAddr );
14875 // bEnable
14876 *pBuf = (tANI_BOOLEAN)bEnable;
14877 if(!HAL_STATUS_SUCCESS(status))
14878 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014879 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 break;
14881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014884 return( status );
14885}
Jeff Johnson295189b2012-06-20 16:38:30 -070014886eHalStatus
14887csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
14888 VOS_MODULE_ID modId, tSirMacAddr bssId,
14889 void *pUsrContext, void *pfnSapEventCallback,
14890 tANI_U8 *pAssocStasBuf )
14891{
14892 eHalStatus status = eHAL_STATUS_SUCCESS;
14893 tSirSmeGetAssocSTAsReq *pMsg;
14894 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14895 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 do
14897 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014898 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
14899 if ( NULL == pMsg )
14900 status = eHAL_STATUS_FAILURE;
14901 else
14902 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014903 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014904 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 pBuf = (tANI_U8 *)&pMsg->bssId;
14907 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014909 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014911 // modId
14912 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014913 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014916 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
14917 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014918 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014919 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
14920 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014921 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080014922 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
14923 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 status = palSendMBMessage( pMac->hHdd, pMsg );
14926 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 return( status );
14928 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014929eHalStatus
14930csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
14931 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
14932 {
14933 eHalStatus status = eHAL_STATUS_SUCCESS;
14934 tSirSmeGetWPSPBCSessionsReq *pMsg;
14935 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080014936
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 do
14938 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014939 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
14940 if ( NULL == pMsg )
14941 status = eHAL_STATUS_FAILURE;
14942 else
14943 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014945 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070014948 VOS_ASSERT(pBuf);
14949
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014952 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
14953 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014955 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
14956 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014958 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053014961 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 return( status );
14967}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014968
14969eHalStatus
14970csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
14971{
14972 tpSirChangeBIParams pMsg;
14973 tANI_U16 len = 0;
14974 eHalStatus status = eHAL_STATUS_SUCCESS;
14975 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14976
14977 if(!pSession)
14978 {
14979 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14980 return eHAL_STATUS_FAILURE;
14981 }
14982
14983 //NO need to update the Beacon Params if update beacon parameter flag is not set
14984 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
14985 return eHAL_STATUS_SUCCESS;
14986
14987 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
14988
14989 /* Create the message and send to lim */
14990 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053014991 pMsg = vos_mem_malloc(len);
14992 if ( NULL == pMsg )
14993 status = eHAL_STATUS_FAILURE;
14994 else
14995 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014996 if(HAL_STATUS_SUCCESS(status))
14997 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014998 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014999 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15000 pMsg->length = len;
15001
15002 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015003 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15004 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015005 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15006 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015007 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015008 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015009 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15010 status = palSendMBMessage(pMac->hHdd, pMsg);
15011 }
15012 return status;
15013}
15014
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015015#ifdef WLAN_FEATURE_AP_HT40_24G
15016eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15017{
15018 tpSirSetHT2040Mode pMsg;
15019 tANI_U16 len = 0;
15020 eHalStatus status = eHAL_STATUS_SUCCESS;
15021 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15022
15023 if(!pSession)
15024 {
15025 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15026 return eHAL_STATUS_FAILURE;
15027 }
15028
15029 /* Create the message and send to lim */
15030 len = sizeof(tSirSetHT2040Mode);
15031 pMsg = vos_mem_malloc(len);
15032
15033 if ( NULL == pMsg )
15034 {
15035 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15036 status = eHAL_STATUS_FAILURE;
15037 }
15038 else
15039 status = eHAL_STATUS_SUCCESS;
15040
15041 if(HAL_STATUS_SUCCESS(status))
15042 {
15043 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15044 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15045 pMsg->length = len;
15046
15047 // bssId
15048 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15049 sizeof(tSirMacAddr));
15050
15051 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15052 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15053 MAC_ADDR_ARRAY(pMsg->bssId));
15054
15055 pMsg->sessionId = sessionId;
15056 pMsg->cbMode = cbMode;
15057
15058 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15059 sessionId, cbMode);
15060
15061 status = palSendMBMessage(pMac->hHdd, pMsg);
15062 }
15063 return status;
15064}
15065#endif
15066
Jeff Johnson295189b2012-06-20 16:38:30 -070015067eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15068{
15069 eHalStatus status = eHAL_STATUS_SUCCESS;
15070 tSirSmeDeauthReq *pMsg;
15071 tANI_U8 *pBuf;
15072 tANI_U16 wTmp;
15073 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15074 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15075 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015076 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015077 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15078 if ( NULL == pMsg )
15079 status = eHAL_STATUS_FAILURE;
15080 else
15081 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015083 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15085 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15086 //sessionId
15087 pBuf = &pMsg->sessionId;
15088 *pBuf++ = (tANI_U8)sessionId;
15089
15090 //tansactionId
15091 *pBuf = 0;
15092 *(pBuf + 1 ) = 0;
15093 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015094 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15097 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015098 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15099 sizeof( pMsg->peerMacAddr ) );
15100 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 pBuf = pBuf + sizeof(tSirMacAddr);
15102 }
15103 else
15104 {
15105 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015106 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15107 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015109 }
15110 if(!HAL_STATUS_SUCCESS(status))
15111 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015112 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 break;
15114 }
15115 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015116 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15117 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 pBuf = pBuf + sizeof(tSirMacAddr);
15119 if(!HAL_STATUS_SUCCESS(status))
15120 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015121 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 break;
15123 }
15124 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015125 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15126 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 if(!HAL_STATUS_SUCCESS(status))
15128 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015129 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 break;
15131 }
15132 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015134 return( status );
15135}
15136
Jeff Johnson295189b2012-06-20 16:38:30 -070015137eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15138{
15139 eHalStatus status = eHAL_STATUS_SUCCESS;
15140 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015142 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15143 if ( NULL == pMsg )
15144 status = eHAL_STATUS_FAILURE;
15145 else
15146 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015148 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15150 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15151 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015152 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015153 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15154 sizeof(pMsg->peerMacAddr));
15155 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 if(!HAL_STATUS_SUCCESS(status))
15157 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015158 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 break;
15160 }
15161//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015162 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15163 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 if(!HAL_STATUS_SUCCESS(status))
15165 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015166 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 break;
15168 }
15169//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015171 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015172 return( status );
15173}
15174
Jeff Johnson295189b2012-06-20 16:38:30 -070015175eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15176{
15177 eHalStatus status = eHAL_STATUS_SUCCESS;
15178 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015180 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15181 if ( NULL == pMsg )
15182 status = eHAL_STATUS_FAILURE;
15183 else
15184 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015186 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15188 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15189 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015190 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015191 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15192 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 if(!HAL_STATUS_SUCCESS(status))
15194 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015195 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 break;
15197 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015198 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15199 sizeof(pMsg->peerMacAddr));
15200 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 if(!HAL_STATUS_SUCCESS(status))
15202 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015203 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 break;
15205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 return( status );
15209}
Jeff Johnson295189b2012-06-20 16:38:30 -070015210eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15211{
15212 eHalStatus status = eHAL_STATUS_SUCCESS;
15213 tSirSmeAssocCnf *pMsg;
15214 tANI_U8 *pBuf;
15215 tSirResultCodes statusCode;
15216 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015217
15218 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15219 "HalStatus : %d"),
15220 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015221 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015222 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15223 if ( NULL == pMsg )
15224 status = eHAL_STATUS_FAILURE;
15225 else
15226 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015228 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15230 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015231 pBuf = (tANI_U8 *)&pMsg->statusCode;
15232 if(HAL_STATUS_SUCCESS(Halstatus))
15233 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15234 else
15235 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015236 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015237 pBuf += sizeof(tSirResultCodes);
15238 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015239 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15240 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 pBuf += sizeof (tSirMacAddr);
15242 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015243 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15244 sizeof(tSirMacAddr));
15245 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 pBuf += sizeof (tSirMacAddr);
15247 // aid
15248 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015249 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 pBuf += sizeof (tANI_U16);
15251 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015252 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15253 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 pBuf += sizeof (tSirMacAddr);
15255 // alternateChannelId
15256 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 status = palSendMBMessage( pMac->hHdd, pMsg );
15258 if(!HAL_STATUS_SUCCESS(status))
15259 {
15260 //pMsg is freed by palSendMBMessage
15261 break;
15262 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015263 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015264 return( status );
15265}
Jeff Johnson295189b2012-06-20 16:38:30 -070015266eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15267 tpSirSmeAssocInd pAssocInd,
15268 eHalStatus Halstatus,
15269 tANI_U8 sessionId)
15270{
15271 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15273 tANI_U8 *pBuf;
15274 tSirResultCodes statusCode;
15275 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015276 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015277 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15278 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15279 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015280
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15282 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15283
15284 pMsg->sessionId = sessionId;
15285
15286 pBuf = (tANI_U8 *)&pMsg->statusCode;
15287 if(HAL_STATUS_SUCCESS(Halstatus))
15288 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15289 else
15290 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015291 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015292 pBuf += sizeof(tSirResultCodes);
15293 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015294 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015295 pBuf += sizeof (tSirMacAddr);
15296 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015297 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15298 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 pBuf += sizeof (tSirMacAddr);
15300 // StaId
15301 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015302 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 pBuf += sizeof (tANI_U16);
15304 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015305 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 pBuf += sizeof (tSirMacAddr);
15307 // alternateChannelId
15308 *pBuf = 11;
15309 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015310 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 //Wmm
15312 *pBuf = pAssocInd->wmmEnabledSta;
15313 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015315 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015318 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 //reassocReq
15321 *pBuf = pAssocInd->reassocReq;
15322 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015323#ifdef WLAN_FEATURE_AP_HT40_24G
15324 // 40 MHz Intolerant
15325 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15326 pBuf += sizeof (tANI_U8);
15327#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015328 *pBuf = pAssocInd->rate_flags;
15329 pBuf += sizeof (uint32_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15331 msgQ.bodyptr = pMsg;
15332 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015333 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015335 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015336}
Jeff Johnson295189b2012-06-20 16:38:30 -070015337
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015338eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15340 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15341 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15342 tANI_U8 *pKeyRsc )
15343{
15344 tSirSmeSetContextReq *pMsg;
15345 tANI_U16 msgLen;
15346 eHalStatus status = eHAL_STATUS_FAILURE;
15347 tAniEdType tmpEdType;
15348 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015349 tANI_U8 *pBuf = NULL;
15350 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015352 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15353 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15357 // key set. Since we only support upto one key, we always allocate memory for 1 key
15358 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15359 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15360 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15361 ( sizeof( pMsg->keyMaterial.key ) );
15362
Kiet Lam64c1b492013-07-12 13:56:44 +053015363 pMsg = vos_mem_malloc(msgLen);
15364 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15365 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15367 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 //sessionId
15369 pBuf = &pMsg->sessionId;
15370 *pBuf = (tANI_U8)sessionId;
15371 pBuf++;
15372 // transactionId
15373 *pBuf = 0;
15374 *(pBuf + 1) = 0;
15375 pBuf += sizeof(tANI_U16);
15376 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015377 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015378
15379 pBuf += sizeof(tSirMacAddr);
15380
15381 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015382 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15383 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015384
15385 pBuf += sizeof(tSirMacAddr);
15386
15387 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15389 // in the tSirKeyMaterial keyMaterial; field).
15390 //
15391 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15392 // shorter than this max size. Is LIM interpreting this ok ?
15393 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 -070015394 // set pMsg->keyMaterial.edType
15395 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015396 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 // set the pMsg->keyMaterial.numKeys field
15399 *p = numKeys;
15400 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 // set pSirKey->keyId = keyId;
15402 *p = keyId;
15403 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 // set pSirKey->unicast = (tANI_U8)fUnicast;
15405 *p = (tANI_U8)fUnicast;
15406 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 // set pSirKey->keyDirection = aniKeyDirection;
15408 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015409 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 p += sizeof(tAniKeyDirection);
15411 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015412 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 // set pSirKey->paeRole
15415 *p = paeRole; // 0 is Supplicant
15416 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 // set pSirKey->keyLength = keyLength;
15418 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015420 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 return( status );
15424}
15425
Jeff Johnson295189b2012-06-20 16:38:30 -070015426eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15427 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15428{
15429 eHalStatus status;
15430 tSirSmeStartBssReq *pMsg;
15431 tANI_U8 *pBuf = NULL;
15432 tANI_U8 *wTmpBuf = NULL;
15433 tANI_U16 msgLen, wTmp;
15434 tANI_U32 dwTmp;
15435 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015436 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015439
15440 if(!pSession)
15441 {
15442 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15443 return eHAL_STATUS_FAILURE;
15444 }
15445
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 do {
15447 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15448 pSession->joinFailStatusCode.reasonCode = 0;
15449 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015450 pMsg = vos_mem_malloc(msgLen);
15451 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15452 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 //sessionId
15457 *pBuf = (tANI_U8)sessionId;
15458 pBuf++;
15459 // transactionId
15460 *pBuf = 0;
15461 *(pBuf + 1) = 0;
15462 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015464 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015465 pBuf += sizeof(tSirMacAddr);
15466 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015467 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015468 pBuf += sizeof(tSirMacAddr);
15469 // beaconInterval
15470 if( pBssDesc && pBssDesc->beaconInterval )
15471 {
15472 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 else if(pParam->beaconInterval)
15475 {
15476 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 else
15479 {
15480 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15481 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015482 if(csrIsconcurrentsessionValid (pMac, sessionId,
15483 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015484 == eHAL_STATUS_SUCCESS )
15485 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015486 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015487 pParam->bssPersona);
15488 //Update the beacon Interval
15489 pParam->beaconInterval = wTmp;
15490 }
15491 else
15492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015493 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015494 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015495 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015496 return status;
15497 }
15498
Kiet Lam64c1b492013-07-12 13:56:44 +053015499 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015500 pBuf += sizeof(tANI_U16);
15501 // dot11mode
15502 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15503 pBuf += 1;
15504 // bssType
15505 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015506 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015507 pBuf += sizeof(tSirBssType);
15508 // ssId
15509 if( pParam->ssId.length )
15510 {
15511 // ssId len
15512 *pBuf = pParam->ssId.length;
15513 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015514 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 pBuf += pParam->ssId.length;
15516 }
15517 else
15518 {
15519 *pBuf = 0;
15520 pBuf++;
15521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 // set the channel Id
15523 *pBuf = pParam->operationChn;
15524 pBuf++;
15525 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015526 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015527 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015528 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015529
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 // Set privacy
15531 *pBuf = pParam->privacy;
15532 pBuf++;
15533
15534 //Set Uapsd
15535 *pBuf = pParam->ApUapsdEnable;
15536 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015537 //Set SSID hidden
15538 *pBuf = pParam->ssidHidden;
15539 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15541 pBuf++;
15542
15543 //Ht protection Enable/Disable
15544 *pBuf = (tANI_U8)pParam->protEnabled;
15545 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 //Enable Beacons to Receive for OBSS protection Enable/Disable
15547 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15548 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 //set cfg related to protection
15550 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015551 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 // Set Auth type
15554 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015555 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015556 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 // Set DTIM
15558 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015559 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015560 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015561 // Set wps_state
15562 *pBuf = pParam->wps_state;
15563 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015564 // set isCoalesingInIBSSAllowed
15565 *pBuf = pMac->isCoalesingInIBSSAllowed;
15566 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 //Persona
15568 *pBuf = (tANI_U8)pParam->bssPersona;
15569 pBuf++;
15570
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015571 //txLdpcIniFeatureEnabled
15572 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15573 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015574
Chet Lanctot8cecea22014-02-11 19:09:36 -080015575#ifdef WLAN_FEATURE_11W
15576 // Set MFP capable/required
15577 *pBuf = (tANI_U8)pParam->mfpCapable;
15578 pBuf++;
15579 *pBuf = (tANI_U8)pParam->mfpRequired;
15580 pBuf++;
15581#endif
15582
krunal soni4f087d22013-07-29 16:32:26 -070015583 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015584 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15585 {
15586 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015587 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015588 break;
15589 }
15590 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015591 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015592 pBuf += sizeof(tANI_U16);
15593 if( wTmp )
15594 {
15595 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015596 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015597 pBuf += wTmp;
15598 }
15599 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015600 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15603 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015604 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15605 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 pBuf += pParam->operationalRateSet.numRates ;
15607 *pBuf++ = pParam->extendedRateSet.numRates;
15608 if(0 != pParam->extendedRateSet.numRates)
15609 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015610 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15611 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 pBuf += pParam->extendedRateSet.numRates;
15613 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015614#ifdef WLAN_FEATURE_AP_HT40_24G
15615 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15616#endif
krunal sonie9002db2013-11-25 14:24:17 -080015617
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15619 pMsg->length = pal_cpu_to_be16(msgLen);
15620
15621 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015623 return( status );
15624}
15625
Jeff Johnson295189b2012-06-20 16:38:30 -070015626eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15627{
15628 eHalStatus status = eHAL_STATUS_FAILURE;
15629 tSirSmeStopBssReq *pMsg;
15630 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15631 tANI_U8 *pBuf;
15632 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015633
15634 if(!pSession)
15635 {
15636 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15637 return eHAL_STATUS_FAILURE;
15638 }
15639
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015640 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15641 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15642 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15643 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15644 pBuf = &pMsg->sessionId;
15645 //sessionId
15646 *pBuf = (tANI_U8)sessionId;
15647 pBuf++;
15648 // transactionId
15649 *pBuf = 0;
15650 pBuf += sizeof(tANI_U16);
15651 //reason code
15652 *pBuf = 0;
15653 pBuf += sizeof(tSirResultCodes);
15654 // bssid
15655 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15656 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15657 {
15658 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15659 sizeof(tSirMacAddr));
15660 }
15661 else
15662 {
15663 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15664 sizeof(tSirMacAddr));
15665 }
15666 pBuf += sizeof(tSirMacAddr);
15667 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15668 pMsg->length = pal_cpu_to_be16(msgLen);
15669 status = palSendMBMessage( pMac->hHdd, pMsg );
15670
Jeff Johnson295189b2012-06-20 16:38:30 -070015671 return( status );
15672}
15673
Jeff Johnson295189b2012-06-20 16:38:30 -070015674eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15675 tCsrRoamModifyProfileFields *pModProfileFields,
15676 tANI_U32 *pRoamId, v_BOOL_t fForce)
15677{
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 eHalStatus status = eHAL_STATUS_FAILURE;
15679 tANI_U32 roamId = 0;
15680 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015681 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015682 (fForce || (!vos_mem_compare( &pModProfileFields,
15683 &pSession->connectedProfile.modifyProfileFields,
15684 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015685 {
15686 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15687 if(pRoamId)
15688 {
15689 *pRoamId = roamId;
15690 }
15691
Jeff Johnson295189b2012-06-20 16:38:30 -070015692 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15693 eCsrSmeIssuedReassocToSameAP, roamId,
15694 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015696 return status;
15697}
Jeff Johnson295189b2012-06-20 16:38:30 -070015698static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15699{
15700 eHalStatus status = eHAL_STATUS_SUCCESS;
15701 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015702 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15704 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15705 return (status);
15706}
Jeff Johnson295189b2012-06-20 16:38:30 -070015707eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15708{
15709 eHalStatus status = eHAL_STATUS_SUCCESS;
15710 tListElem *pEntry = NULL;
15711 tSmeCmd *pCommand = NULL;
15712 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015713 do
15714 {
15715 if(pMsg == NULL)
15716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015717 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015718 status = eHAL_STATUS_FAILURE;
15719 break;
15720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015721 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15722 if(pEntry)
15723 {
15724 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15725 if(eSmeCommandAddStaSession == pCommand->command)
15726 {
15727 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015728 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015729 if (pRsp->status == eSIR_FAILURE) {
15730 VOS_ASSERT( 0 );
15731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015732 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015733 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015734 //Remove this command out of the active list
15735 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15736 {
15737 //Now put this command back on the avilable command list
15738 csrReleaseCommand(pMac, pCommand);
15739 }
15740 smeProcessPendingQueue( pMac );
15741 }
15742 else
15743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015744 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 -070015745 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015746 status = eHAL_STATUS_FAILURE;
15747 break;
15748 }
15749 }
15750 else
15751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015752 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 -070015753 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 status = eHAL_STATUS_FAILURE;
15755 break;
15756 }
15757 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015758 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015759}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015760eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15761 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015762{
15763 tSirSmeAddStaSelfReq *pMsg;
15764 tANI_U16 msgLen;
15765 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015766 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015767 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015768 pMsg = vos_mem_malloc(msgLen);
15769 if ( NULL == pMsg ) break;
15770 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015771 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15772 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015773 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015774 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015775 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15776
15777 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
15778
Arif Hussain24bafea2013-11-15 15:10:03 -080015779 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
15780 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015782 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 return( status );
15784}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015785eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
15786 tANI_U32 sessionId,
15787 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070015788{
15789 eHalStatus status = eHAL_STATUS_SUCCESS;
15790 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 pCommand = csrGetCommandBuffer(pMac);
15792 if(NULL == pCommand)
15793 {
15794 status = eHAL_STATUS_RESOURCES;
15795 }
15796 else
15797 {
15798 pCommand->command = eSmeCommandAddStaSession;
15799 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053015800 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
15801 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015802 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015803 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
15804 if( !HAL_STATUS_SUCCESS( status ) )
15805 {
15806 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015807 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 }
15809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 return (status);
15811}
Jeff Johnson295189b2012-06-20 16:38:30 -070015812eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15813{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015814 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070015815}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015816eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
15817 csrRoamCompleteCallback callback,
15818 void *pContext, tANI_U8 *pSelfMacAddr,
15819 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070015820{
15821 eHalStatus status = eHAL_STATUS_SUCCESS;
15822 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053015823 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 *pbSessionId = CSR_SESSION_ID_INVALID;
15825 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15826 {
15827 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15828 {
15829 pSession = CSR_GET_SESSION( pMac, i );
15830 status = eHAL_STATUS_SUCCESS;
15831 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15832 pSession->sessionId = (tANI_U8)i;
15833 pSession->callback = callback;
15834 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015835 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015837 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15838 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015840 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015842 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015843 break;
15844 }
15845#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015846 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15847 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015848 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015849 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015850 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015851 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015852 break;
15853 }
15854#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015855 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 break;
15857 }
15858 }
15859 if( CSR_ROAM_SESSION_MAX == i )
15860 {
15861 //No session is available
15862 status = eHAL_STATUS_RESOURCES;
15863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 return ( status );
15865}
Jeff Johnson295189b2012-06-20 16:38:30 -070015866eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15867{
15868 eHalStatus status = eHAL_STATUS_SUCCESS;
15869 tListElem *pEntry = NULL;
15870 tSmeCmd *pCommand = NULL;
15871 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015872 do
15873 {
15874 if(pMsg == NULL)
15875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015876 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015877 status = eHAL_STATUS_FAILURE;
15878 break;
15879 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15881 if(pEntry)
15882 {
15883 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15884 if(eSmeCommandDelStaSession == pCommand->command)
15885 {
15886 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015887 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015888 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015889 //This session is done.
15890 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015891 if(pCommand->u.delStaSessionCmd.callback)
15892 {
15893
15894 status = sme_ReleaseGlobalLock( &pMac->sme );
15895 if ( HAL_STATUS_SUCCESS( status ) )
15896 {
15897 pCommand->u.delStaSessionCmd.callback(
15898 pCommand->u.delStaSessionCmd.pContext);
15899 status = sme_AcquireGlobalLock( &pMac->sme );
15900 if (! HAL_STATUS_SUCCESS( status ) )
15901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015902 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015903 return status;
15904 }
15905 }
15906 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015907 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015908 }
15909 }
15910
15911 //Remove this command out of the active list
15912 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15913 {
15914 //Now put this command back on the avilable command list
15915 csrReleaseCommand(pMac, pCommand);
15916 }
15917 smeProcessPendingQueue( pMac );
15918 }
15919 else
15920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015921 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 -070015922 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015923 status = eHAL_STATUS_FAILURE;
15924 break;
15925 }
15926 }
15927 else
15928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015929 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 -070015930 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 status = eHAL_STATUS_FAILURE;
15932 break;
15933 }
15934 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015935 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015936}
Jeff Johnson295189b2012-06-20 16:38:30 -070015937eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
15938{
15939 tSirSmeDelStaSelfReq *pMsg;
15940 tANI_U16 msgLen;
15941 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015942 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
15944 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053015945 pMsg = vos_mem_malloc(msgLen);
15946 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15947 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015948 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
15949 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015950 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015951 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
15952 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015953 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015955 return( status );
15956}
Jeff Johnson295189b2012-06-20 16:38:30 -070015957eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053015958 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070015959 tSirMacAddr sessionMacAddr,
15960 csrRoamSessionCloseCallback callback,
15961 void *pContext)
15962{
15963 eHalStatus status = eHAL_STATUS_SUCCESS;
15964 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 pCommand = csrGetCommandBuffer(pMac);
15966 if(NULL == pCommand)
15967 {
15968 status = eHAL_STATUS_RESOURCES;
15969 }
15970 else
15971 {
15972 pCommand->command = eSmeCommandDelStaSession;
15973 pCommand->sessionId = (tANI_U8)sessionId;
15974 pCommand->u.delStaSessionCmd.callback = callback;
15975 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015976 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
15977 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053015978 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070015979 if( !HAL_STATUS_SUCCESS( status ) )
15980 {
15981 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015982 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015983 }
15984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 return (status);
15986}
Jeff Johnson295189b2012-06-20 16:38:30 -070015987eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15988{
15989 return csrSendMBDelSelfStaReqMsg( pMac,
15990 pCommand->u.delStaSessionCmd.selfMacAddr );
15991}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015992static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
15993 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070015994{
15995 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
15996 tListElem *pEntry, *pNext;
15997 tSmeCmd *pCommand;
15998 tDblLinkList localList;
15999
16000 vos_mem_zero(&localList, sizeof(tDblLinkList));
16001 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16002 {
16003 smsLog(pMac, LOGE, FL(" failed to open list"));
16004 return;
16005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016006 csrLLLock(pList);
16007 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16008 while(pEntry != NULL)
16009 {
16010 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16011 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016012
16013 if (!flush_all &&
16014 csr_is_disconnect_full_power_cmd(pCommand)) {
16015 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16016 pEntry = pNext;
16017 continue;
16018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 if(pCommand->sessionId == sessionId)
16020 {
16021 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16022 {
16023 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16024 }
16025 }
16026 pEntry = pNext;
16027 }
16028 csrLLUnlock(pList);
16029
16030 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16031 {
16032 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16033 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16034 }
16035 csrLLClose(&localList);
16036}
16037
Jeff Johnson295189b2012-06-20 16:38:30 -070016038void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16039{
16040 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16041 {
16042 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 csrRoamStop(pMac, sessionId);
16044 csrFreeConnectBssDesc(pMac, sessionId);
16045 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16046 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016047 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016048#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016049 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016050#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016051 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016052 csrInitSession(pMac, sessionId);
16053 }
16054}
16055
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016056void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16057 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016058{
16059 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016060 &pMac->sme.smeCmdPendingList,
16061 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016062 if (pMac->fScanOffload)
16063 {
16064 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016065 &pMac->sme.smeScanCmdPendingList,
16066 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016067 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016068 purgeCsrSessionCmdList(pMac, sessionId,
16069 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016070}
16071
Jeff Johnson295189b2012-06-20 16:38:30 -070016072eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016073 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016074 csrRoamSessionCloseCallback callback,
16075 void *pContext )
16076{
16077 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016078 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16079 {
16080 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16081 if(fSync)
16082 {
16083 csrCleanupSession(pMac, sessionId);
16084 }
16085 else
mukul sharmabab477d2015-06-11 17:14:55 +053016086 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016087 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016088 /* If bPurgeList is FALSE, it means HDD already free all the
16089 * cmd and later queue few essential cmd. Now sme should process
16090 * the cmd in pending queue order only.Hence we should
16091 * avoid DEL_SELF_STA as high priority cmd.
16092 */
16093 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016094 pSession->selfMacAddr, callback, pContext);
16095 }
16096 }
16097 else
16098 {
16099 status = eHAL_STATUS_INVALID_PARAMETER;
16100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016101 return ( status );
16102}
16103
Jeff Johnson295189b2012-06-20 16:38:30 -070016104static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16105{
16106 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016107
16108 if(!pSession)
16109 {
16110 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16111 return;
16112 }
16113
Jeff Johnson295189b2012-06-20 16:38:30 -070016114 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16115 pSession->sessionId = CSR_SESSION_ID_INVALID;
16116 pSession->callback = NULL;
16117 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016118 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16119 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16120 csrFreeRoamProfile( pMac, sessionId );
16121 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16122 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16123 csrFreeConnectBssDesc(pMac, sessionId);
16124 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016125 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16126 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016127 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016128 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016129 pSession->pWpaRsnReqIE = NULL;
16130 }
16131 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016132 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016133 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016134 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016135 pSession->pWpaRsnRspIE = NULL;
16136 }
16137 pSession->nWpaRsnRspIeLength = 0;
16138#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016139 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016140 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016141 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016142 pSession->pWapiReqIE = NULL;
16143 }
16144 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016145 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016146 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016147 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016148 pSession->pWapiRspIE = NULL;
16149 }
16150 pSession->nWapiRspIeLength = 0;
16151#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016152 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016153 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016154 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016155 }
16156 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016157
Kiet Lam64c1b492013-07-12 13:56:44 +053016158 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016159 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016160 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016161 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016163 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016164}
16165
Jeff Johnson295189b2012-06-20 16:38:30 -070016166eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16167{
16168 eHalStatus status = eHAL_STATUS_FAILURE;
16169 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016170 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16171 {
16172 if( CSR_IS_SESSION_VALID( pMac, i ) )
16173 {
16174 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16175 {
16176 //Found it
16177 status = eHAL_STATUS_SUCCESS;
16178 *pSessionId = i;
16179 break;
16180 }
16181 }
16182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016183 return( status );
16184}
16185
Jeff Johnson295189b2012-06-20 16:38:30 -070016186//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16187//session because for IBSS, the bssid changes.
16188static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16189{
16190 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16191 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016192 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16193 {
16194 if( CSR_IS_SESSION_VALID( pMac, i ) )
16195 {
16196 pSession = CSR_GET_SESSION( pMac, i );
16197 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16198 {
16199 //Found it
16200 nRet = i;
16201 break;
16202 }
16203 }
16204 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 return (nRet);
16206}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016207void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016208{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016209 VOS_STATUS status = VOS_STATUS_SUCCESS;
16210
16211 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016212 profile info from pmac global structure */
16213
Arif Hussain24bafea2013-11-15 15:10:03 -080016214 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16215 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016216 /* Check for user misconfig of RSSI trigger threshold */
16217 pMac->roam.configParam.vccRssiThreshold =
16218 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16219 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16220 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016221 /* Check for user misconfig of UL MAC Loss trigger threshold */
16222 pMac->roam.configParam.vccUlMacLossThreshold =
16223 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16224 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016225#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16226 {
16227 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016228 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016229 /* Indicate the neighbor roal algorithm about the connect indication */
16230 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16231 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016232
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016233 /* Making sure we are roaming force fully to 5GHz AP only once and
16234 * only when we connected to 2.4GH AP only during initial association.
16235 */
16236 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16237 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16238 SIR_BAND_2_4_GHZ)
16239 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016240 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016241 status = vos_timer_start(
16242 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16243 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016244 if ( status != VOS_STATUS_SUCCESS )
16245 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016246 smsLog(pMac, LOGE,
16247 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16248 status);
16249 //Send RSO start because in case 5G roaming
16250 //host have not enabled at initial connection
16251 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016252 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016253 else
16254 {
16255 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16256 __func__);
16257 }
16258 }
16259 /*
16260 * Making ini value to false here only so we just roam to
16261 * only once for whole driver load to unload tenure
16262 * This feature is only applicable for first connection only
16263 */
16264 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16265 {
16266 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16267 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016268 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016269 }
16270#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016271}
16272
Jeff Johnson295189b2012-06-20 16:38:30 -070016273static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16274{
16275 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016276
16277 if(!pSession)
16278 {
16279 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16280 return;
16281 }
16282
Jeff Johnson295189b2012-06-20 16:38:30 -070016283 //Only to handle the case for Handover on infra link
16284 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16285 {
16286 return;
16287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016288 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16289 csrRoamDeregStatisticsReq(pMac);
16290 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16291#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16292 /* Indicate the neighbor roal algorithm about the disconnect indication */
16293 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16294#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016295
16296 //Remove this code once SLM_Sessionization is supported
16297 //BMPS_WORKAROUND_NOT_NEEDED
16298 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016299 csrIsInfraApStarted( pMac ) &&
16300 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016301 {
16302 pMac->roam.configParam.doBMPSWorkaround = 0;
16303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016304}
16305
Jeff Johnson295189b2012-06-20 16:38:30 -070016306void csrRoamTlStatsTimerHandler(void *pv)
16307{
16308 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16309 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16311
Jeff Johnsone7245742012-09-05 17:12:55 -070016312 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16313
Jeff Johnson295189b2012-06-20 16:38:30 -070016314#if 0
16315 // TODO Persession .???
16316 //req TL for stats
16317 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16318 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016319 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016320 }
16321 else
16322 {
16323 //save in SME
16324 csrRoamSaveStatsFromTl(pMac, tlStats);
16325 }
16326#endif
16327 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16328 {
16329 if(pMac->roam.tlStatsReqInfo.periodicity)
16330 {
16331 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016332 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16333 pMac->roam.tlStatsReqInfo.periodicity);
16334 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016336 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016337 return;
16338 }
16339 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16340 }
16341 }
16342}
Jeff Johnson295189b2012-06-20 16:38:30 -070016343void csrRoamPeStatsTimerHandler(void *pv)
16344{
16345 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16346 eHalStatus status;
16347 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16348 VOS_STATUS vosStatus;
16349 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016350 pPeStatsReqListEntry->timerRunning = FALSE;
16351 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16352 {
16353 // If we entered here, meaning the timer could not be successfully
16354 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16355
16356 /* Destroy the timer */
16357 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16358 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016360 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016361 }
16362
16363 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016364 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 pPeStatsReqListEntry = NULL;
16366 }
16367 else
16368 {
16369 if(!pPeStatsReqListEntry->rspPending)
16370 {
16371 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16372 pPeStatsReqListEntry->staId);
16373 if(!HAL_STATUS_SUCCESS(status))
16374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016375 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 }
16377 else
16378 {
16379 pPeStatsReqListEntry->rspPending = TRUE;
16380 }
16381 }
16382
16383 //send down a req
16384 if(pPeStatsReqListEntry->periodicity &&
16385 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16386 {
16387 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16388 if(ePMC_FULL_POWER == powerState)
16389 {
16390 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16391 {
16392 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16393 }
16394 }
16395 else
16396 {
16397 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16398 {
16399 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16400 }
16401 }
16402 //start timer
16403 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16404 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016406 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016407 return;
16408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 pPeStatsReqListEntry->timerRunning = TRUE;
16410
16411 }
16412
16413 }
16414}
Jeff Johnson295189b2012-06-20 16:38:30 -070016415void csrRoamStatsClientTimerHandler(void *pv)
16416{
16417 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016418 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16419 {
16420#if 0
16421 // TODO Stats fix for multisession
16422 //start the timer
16423 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16424
16425 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16426 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016427 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016428 }
16429#endif
16430 }
16431#if 0
16432 //send up the stats report
16433 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16434 pStaEntry->staId, pStaEntry->pContext);
16435#endif
16436}
16437
16438
16439
Jeff Johnson295189b2012-06-20 16:38:30 -070016440eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16441{
16442 tAniGetPEStatsReq *pMsg;
16443 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016444 tSirMsgQ msgQ;
16445
Kiet Lam64c1b492013-07-12 13:56:44 +053016446 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16447 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016449 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016450 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016451 }
16452 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016453 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16455 pMsg->staId = staId;
16456 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016457
16458 msgQ.type = WDA_GET_STATISTICS_REQ;
16459 msgQ.reserved = 0;
16460 msgQ.bodyptr = pMsg;
16461 msgQ.bodyval = 0;
16462 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 if(!HAL_STATUS_SUCCESS(status))
16464 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016465 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016466 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016467 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 return status;
16469}
Jeff Johnson295189b2012-06-20 16:38:30 -070016470void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16471{
16472 tAniGetPEStatsRsp *pSmeStatsRsp;
16473 eHalStatus status = eHAL_STATUS_FAILURE;
16474 tListElem *pEntry = NULL;
16475 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16476 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16477 tANI_U32 tempMask = 0;
16478 tANI_U8 counter = 0;
16479 tANI_U8 *pStats = NULL;
16480 tANI_U32 length = 0;
16481 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016482 v_S7_t rssi = 0, snr = 0;
16483 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016484 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016485 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016486 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16487 if(pSmeStatsRsp->rc)
16488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016489 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 goto post_update;
16491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016492 tempMask = pSmeStatsRsp->statsMask;
16493 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 /* subtract all statistics from this length, and after processing the entire
16495 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16496 * in this 'stats' message.
16497 */
16498 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 //new stats info from PE, fill up the stats strucutres in PMAC
16500 while(tempMask)
16501 {
16502 if(tempMask & 1)
16503 {
16504 switch(counter)
16505 {
16506 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016507 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016508 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16509 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016510 pStats += sizeof(tCsrSummaryStatsInfo);
16511 length -= sizeof(tCsrSummaryStatsInfo);
16512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016514 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016515 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16516 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016517 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16518 length -= sizeof(tCsrGlobalClassAStatsInfo);
16519 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016521 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016522 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16523 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016524 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16525 length -= sizeof(tCsrGlobalClassBStatsInfo);
16526 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016528 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016529 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16530 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016531 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16532 length -= sizeof(tCsrGlobalClassCStatsInfo);
16533 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016535 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016536 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16537 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016538 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016539 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16540 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016541 }
16542 else
16543 {
16544 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016545 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 VOS_ASSERT( 0 );
16547 }
16548 if(!HAL_STATUS_SUCCESS(status))
16549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016550 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016551 }
16552 pStats += sizeof(tCsrPerStaStatsInfo);
16553 length -= sizeof(tCsrPerStaStatsInfo);
16554 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016555 case eCsrPerPktStats:
16556 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16557 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16558 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16559 {
16560 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16561 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16562 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016563 /* for reserved bytes */
16564 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16565 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016566 }
16567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016568 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016569 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016570 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016571 }
16572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 tempMask >>=1;
16574 counter++;
16575 }
16576 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16577 if (length != 0)
16578 {
16579 pRssi = (tANI_U32*)pStats;
16580 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016581 pStats += sizeof(tANI_U32);
16582 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016583 }
16584 else
16585 {
16586 /* If riva is not sending rssi, continue to use the hack */
16587 rssi = RSSI_HACK_BMPS;
16588 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016589 /* send positive value of rssi to wifi_hal */
16590 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016591 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016592 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016593
16594 if (length != 0)
16595 {
16596 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016597 pStats += sizeof(tANI_U32);
16598 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016599 }
16600 else
16601 {
16602 linkCapacity = 0;
16603 }
16604
16605 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016606
16607 if (length != 0)
16608 {
16609 pSnr = (tANI_U32*)pStats;
16610 snr = (v_S7_t)*pSnr;
16611 }
16612 else
16613 {
16614 snr = SNR_HACK_BMPS;
16615 }
16616
16617 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016618post_update:
16619 //make sure to update the pe stats req list
16620 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16621 if(pEntry)
16622 {
16623 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16624 pPeStaEntry->rspPending = FALSE;
16625
16626 }
16627 //check the one timer cases
16628 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16629 if(pEntry)
16630 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016632 if(pTempStaEntry->timerExpired)
16633 {
16634 //send up the stats report
16635 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16636 pTempStaEntry->staId, pTempStaEntry->pContext);
16637 //also remove from the client list
16638 csrRoamRemoveStatListEntry(pMac, pEntry);
16639 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016640 }
16641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016642}
Jeff Johnson295189b2012-06-20 16:38:30 -070016643tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16644{
16645 tListElem *pEntry = NULL;
16646 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016648 if(!pEntry)
16649 {
16650 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016651 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016652 return NULL;
16653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016654 while( pEntry )
16655 {
16656 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016657 if(pTempStaEntry->statsMask == statsMask)
16658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016659 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 break;
16661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016662 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016664 return pEntry;
16665}
16666
Jeff Johnson295189b2012-06-20 16:38:30 -070016667tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16668 tANI_BOOLEAN update)
16669{
16670 tListElem *pEntry;
16671 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016672 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016673 if(!pEntry)
16674 {
16675 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016676 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016677 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016678 return NULL;
16679 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016680 while( pEntry )
16681 {
16682 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016683 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16684 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016686 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016687 if(update)
16688 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016689 pTempStaEntry->periodicity = pStaEntry->periodicity;
16690 pTempStaEntry->callback = pStaEntry->callback;
16691 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016692 }
16693 break;
16694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016695 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 return pEntry;
16698}
Jeff Johnson295189b2012-06-20 16:38:30 -070016699tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16700{
16701 tListElem *pEntry;
16702 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016703 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016704 if(!pEntry)
16705 {
16706 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016707 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016708 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016709 return NULL;
16710 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016711 while( pEntry )
16712 {
16713 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016716 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016717 break;
16718 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016719 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016721 return pEntry;
16722}
Jeff Johnson295189b2012-06-20 16:38:30 -070016723eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16724 csrRoamLinkQualityIndCallback callback,
16725 void *pContext)
16726{
16727 pMac->roam.linkQualityIndInfo.callback = callback;
16728 pMac->roam.linkQualityIndInfo.context = pContext;
16729 if( NULL == callback )
16730 {
16731 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16732 }
16733 else
16734 {
16735 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 /* do we need to invoke the callback to notify client of initial value ?? */
16737 }
16738 return eHAL_STATUS_SUCCESS;
16739}
Jeff Johnson295189b2012-06-20 16:38:30 -070016740void csrRoamVccTrigger(tpAniSirGlobal pMac)
16741{
16742 eCsrRoamLinkQualityInd newVccLinkQuality;
16743 tANI_U32 ul_mac_loss = 0;
16744 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016745 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16746 /*-------------------------------------------------------------------------
16747 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016748 Check for a change in link quality and notify client if necessary
16749 -------------------------------------------------------------------------*/
16750 ul_mac_loss_trigger_threshold =
16751 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016753 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016755 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016757 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16759 }
16760 else
16761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016762 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16766 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016767 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016769 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016772 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016773 newVccLinkQuality );
16774
16775 /* we now invoke the callback once to notify client of initial value */
16776 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16777 pMac->roam.linkQualityIndInfo.context );
16778 //event: EVENT_WLAN_VCC
16779 }
16780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016781 pMac->roam.vccLinkQuality = newVccLinkQuality;
16782
Jeff Johnson295189b2012-06-20 16:38:30 -070016783}
Jeff Johnson295189b2012-06-20 16:38:30 -070016784VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
16785 v_U8_t rssiNotification,
16786 void * context)
16787{
16788 tpAniSirGlobal pMac = PMAC_STRUCT( context );
16789 eCsrRoamLinkQualityInd newVccLinkQuality;
16790 // TODO : Session info unavailable
16791 tANI_U32 sessionId = 0;
16792 VOS_STATUS status = VOS_STATUS_SUCCESS;
16793 /*-------------------------------------------------------------------------
16794 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 Check for a change in link quality and notify client if necessary
16796 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016797 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016798 pMac->roam.configParam.vccRssiThreshold);
16799 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
16800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016801 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 return VOS_STATUS_SUCCESS;
16803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016804 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
16805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016806 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16808 }
16809 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
16810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016811 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016812 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16813 }
16814 else
16815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016816 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 //Set to this so the code below won't do anything
16818 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 VOS_ASSERT(0);
16820 }
16821
Jeff Johnson295189b2012-06-20 16:38:30 -070016822 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16823 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016824 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016825 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016827 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016828 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016829 /* we now invoke the callback once to notify client of initial value */
16830 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16831 pMac->roam.linkQualityIndInfo.context );
16832 //event: EVENT_WLAN_VCC
16833 }
16834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016836 return status;
16837}
Jeff Johnson295189b2012-06-20 16:38:30 -070016838tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16839 tDblLinkList *pStaList,
16840 tCsrStatsClientReqInfo *pStaEntry)
16841{
16842 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 //if same entity requested for same set of stats with different periodicity &
16844 // callback update it
16845 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16846 {
16847
Kiet Lam64c1b492013-07-12 13:56:44 +053016848 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16849 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 {
16851 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016852 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016853 return NULL;
16854 }
16855
Jeff Johnson295189b2012-06-20 16:38:30 -070016856 pNewStaEntry->callback = pStaEntry->callback;
16857 pNewStaEntry->pContext = pStaEntry->pContext;
16858 pNewStaEntry->periodicity = pStaEntry->periodicity;
16859 pNewStaEntry->requesterId = pStaEntry->requesterId;
16860 pNewStaEntry->statsMask = pStaEntry->statsMask;
16861 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16862 pNewStaEntry->pMac = pStaEntry->pMac;
16863 pNewStaEntry->staId = pStaEntry->staId;
16864 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16865
16866 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
16867 }
16868 return pNewStaEntry;
16869}
16870
Jeff Johnson295189b2012-06-20 16:38:30 -070016871tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
16872 tDblLinkList *pStaList,
16873 tCsrPeStatsReqInfo *pStaEntry)
16874{
16875 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016876 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
16877 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 {
16879 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016880 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016881 return NULL;
16882 }
16883
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
16885 pNewStaEntry->numClient = pStaEntry->numClient;
16886 pNewStaEntry->periodicity = pStaEntry->periodicity;
16887 pNewStaEntry->statsMask = pStaEntry->statsMask;
16888 pNewStaEntry->pMac = pStaEntry->pMac;
16889 pNewStaEntry->staId = pStaEntry->staId;
16890 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
16891 pNewStaEntry->rspPending = pStaEntry->rspPending;
16892
16893 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 return pNewStaEntry;
16895}
Jeff Johnson295189b2012-06-20 16:38:30 -070016896eHalStatus csrGetRssi(tpAniSirGlobal pMac,
16897 tCsrRssiCallback callback,
16898 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16899{
16900 eHalStatus status = eHAL_STATUS_SUCCESS;
16901 vos_msg_t msg;
16902 tANI_U32 sessionId;
16903
16904 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016905 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016906 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16907 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016909 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016910 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016912 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
16913
16914 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
16915 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
16916 pMsg->sessionId = sessionId;
16917 pMsg->staId = staId;
16918 pMsg->rssiCallback = callback;
16919 pMsg->pDevContext = pContext;
16920 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 msg.type = eWNI_SME_GET_RSSI_REQ;
16922 msg.bodyptr = pMsg;
16923 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016924 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016926 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016927 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016928 status = eHAL_STATUS_FAILURE;
16929 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016930 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016931 return status;
16932}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016933
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016934eHalStatus csrGetSnr(tpAniSirGlobal pMac,
16935 tCsrSnrCallback callback,
16936 tANI_U8 staId, tCsrBssid bssId,
16937 void *pContext)
16938{
16939 eHalStatus status = eHAL_STATUS_SUCCESS;
16940 vos_msg_t msg;
16941 tANI_U32 sessionId;
16942
16943 tAniGetSnrReq *pMsg;
16944
16945 smsLog(pMac, LOG2, FL("called"));
16946
16947 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
16948 if (NULL == pMsg )
16949 {
16950 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
16951 return status;
16952 }
16953
16954 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
16955
16956 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
16957 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
16958 pMsg->sessionId = sessionId;
16959 pMsg->staId = staId;
16960 pMsg->snrCallback = callback;
16961 pMsg->pDevContext = pContext;
16962 msg.type = eWNI_SME_GET_SNR_REQ;
16963 msg.bodyptr = pMsg;
16964 msg.reserved = 0;
16965
16966 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16967 {
16968 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
16969 vos_mem_free((v_VOID_t *)pMsg);
16970 status = eHAL_STATUS_FAILURE;
16971 }
16972
16973 smsLog(pMac, LOG2, FL("returned"));
16974 return status;
16975}
16976
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016977#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016978eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
16979 tCsrRssiCallback callback,
16980 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16981{
16982 eHalStatus status = eHAL_STATUS_SUCCESS;
16983 tAniGetRssiReq *pMsg;
16984
Kiet Lam64c1b492013-07-12 13:56:44 +053016985 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16986 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016987 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016988 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016989 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016990 }
16991 // need to initiate a stats request to PE
16992 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
16993 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
16994 pMsg->staId = staId;
16995 pMsg->rssiCallback = callback;
16996 pMsg->pDevContext = pContext;
16997 pMsg->pVosContext = pVosContext;
16998 status = palSendMBMessage(pMac->hHdd, pMsg );
16999 if(!HAL_STATUS_SUCCESS(status))
17000 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017001 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017002 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017003 status = eHAL_STATUS_FAILURE;
17004 }
17005 return status;
17006}
17007#endif
17008
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017009
17010
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017011#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017012eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17013 tCsrTsmStatsCallback callback,
17014 tANI_U8 staId,
17015 tCsrBssid bssId,
17016 void *pContext,
17017 void* pVosContext,
17018 tANI_U8 tid)
17019{
17020 eHalStatus status = eHAL_STATUS_SUCCESS;
17021 tAniGetTsmStatsReq *pMsg = NULL;
17022
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017023 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17024 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017025 {
17026 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017027 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017028 }
17029 // need to initiate a stats request to PE
17030 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17031 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17032 pMsg->staId = staId;
17033 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017034 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017035 pMsg->tsmStatsCallback = callback;
17036 pMsg->pDevContext = pContext;
17037 pMsg->pVosContext = pVosContext;
17038 status = palSendMBMessage(pMac->hHdd, pMsg );
17039 if(!HAL_STATUS_SUCCESS(status))
17040 {
17041 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17042 //pMsg is freed by palSendMBMessage
17043 status = eHAL_STATUS_FAILURE;
17044 }
17045 return status;
17046}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017047#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017048
17049
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017050/* ---------------------------------------------------------------------------
17051 \fn csrGetTLSTAState
17052 \helper function to get teh TL STA State whenever the function is called.
17053
17054 \param staId - The staID to be passed to the TL
17055 to get the relevant TL STA State
17056 \return the state as tANI_U16
17057 ---------------------------------------------------------------------------*/
17058tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17059{
17060 WLANTL_STAStateType tlSTAState;
17061 tlSTAState = WLANTL_STA_INIT;
17062
17063 //request TL for STA State
17064 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17065 {
17066 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17067 }
17068
17069 return tlSTAState;
17070}
17071
Jeff Johnson295189b2012-06-20 16:38:30 -070017072eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17073 tANI_U32 statsMask,
17074 tCsrStatsCallback callback,
17075 tANI_U32 periodicity, tANI_BOOLEAN cache,
17076 tANI_U8 staId, void *pContext)
17077{
17078 tCsrStatsClientReqInfo staEntry;
17079 tCsrStatsClientReqInfo *pStaEntry = NULL;
17080 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17081 tListElem *pEntry = NULL;
17082 tANI_BOOLEAN found = FALSE;
17083 eHalStatus status = eHAL_STATUS_SUCCESS;
17084 tANI_BOOLEAN insertInClientList = FALSE;
17085 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017086 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017087
17088 if( csrIsAllSessionDisconnected(pMac) )
17089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017090 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017091 return eHAL_STATUS_FAILURE;
17092 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017093
17094 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17095 {
17096 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17097 return eHAL_STATUS_FAILURE;
17098 }
17099
Jeff Johnson295189b2012-06-20 16:38:30 -070017100 if((!statsMask) && (!callback))
17101 {
17102 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017103 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017104 return eHAL_STATUS_FAILURE;
17105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017106 //for the search list method for deregister
17107 staEntry.requesterId = requesterId;
17108 staEntry.statsMask = statsMask;
17109 //requester wants to deregister or just an error
17110 if((statsMask) && (!callback))
17111 {
17112 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17113 if(!pEntry)
17114 {
17115 //msg
17116 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017117 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017118 return eHAL_STATUS_FAILURE;
17119 }
17120 else
17121 {
17122 //clean up & return
17123 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017124 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017125 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017126 pStaEntry->pPeStaEntry->numClient--;
17127 //check if we need to delete the entry from peStatsReqList too
17128 if(!pStaEntry->pPeStaEntry->numClient)
17129 {
17130 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017132 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017133
Jeff Johnson295189b2012-06-20 16:38:30 -070017134 //check if we need to stop the tl stats timer too
17135 pMac->roam.tlStatsReqInfo.numClient--;
17136 if(!pMac->roam.tlStatsReqInfo.numClient)
17137 {
17138 if(pMac->roam.tlStatsReqInfo.timerRunning)
17139 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017140 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17141 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017143 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017144 return eHAL_STATUS_FAILURE;
17145 }
17146 }
17147 pMac->roam.tlStatsReqInfo.periodicity = 0;
17148 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17149 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017150 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017151 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017152 vos_timer_stop(&pStaEntry->timer);
17153 // Destroy the vos timer
17154 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17155 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17156 {
17157 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017160 csrRoamRemoveStatListEntry(pMac, pEntry);
17161 pStaEntry = NULL;
17162 return eHAL_STATUS_SUCCESS;
17163 }
17164 }
17165
17166 if(cache && !periodicity)
17167 {
17168 //return the cached stats
17169 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17170 }
17171 else
17172 {
17173 //add the request in the client req list
17174 staEntry.callback = callback;
17175 staEntry.pContext = pContext;
17176 staEntry.periodicity = periodicity;
17177 staEntry.pPeStaEntry = NULL;
17178 staEntry.staId = staId;
17179 staEntry.pMac = pMac;
17180 staEntry.timerExpired = FALSE;
17181
17182
Jeff Johnson295189b2012-06-20 16:38:30 -070017183 //if periodic report requested with non cached result from PE/TL
17184 if(periodicity)
17185 {
17186
17187 //if looking for stats from PE
17188 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17189 {
17190
17191 //check if same request made already & waiting for rsp
17192 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17193 periodicity, &found, staId);
17194 if(!pPeStaEntry)
17195 {
17196 //bail out, maxed out on number of req for PE
17197 return eHAL_STATUS_FAILURE;
17198 }
17199 else
17200 {
17201 staEntry.pPeStaEntry = pPeStaEntry;
17202 }
17203
17204 }
17205 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17206 if(statsMask & (1 << eCsrGlobalClassDStats))
17207 {
17208 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017210 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017211 }
17212 else
17213 {
17214
17215 //update periodicity
17216 if(pMac->roam.tlStatsReqInfo.periodicity)
17217 {
17218 pMac->roam.tlStatsReqInfo.periodicity =
17219 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17220 }
17221 else
17222 {
17223 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17224 }
17225 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17226 {
17227 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17228 }
17229
17230 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17231 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017232 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017233 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017234 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017235 //req TL for class D stats
17236 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017238 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017239 }
17240 else
17241 {
17242 //save in SME
17243 csrRoamSaveStatsFromTl(pMac, pTlStats);
17244 }
17245 vos_mem_free(pTlStats);
17246 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017247 }
17248 else
17249 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017250 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017251 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017252
Jeff Johnson295189b2012-06-20 16:38:30 -070017253 if(pMac->roam.tlStatsReqInfo.periodicity)
17254 {
17255 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017256 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17257 pMac->roam.tlStatsReqInfo.periodicity);
17258 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017260 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017261 return eHAL_STATUS_FAILURE;
17262 }
17263 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17264 }
17265 }
17266 }
17267 pMac->roam.tlStatsReqInfo.numClient++;
17268 }
17269
17270 insertInClientList = TRUE;
17271 }
17272 //if one time report requested with non cached result from PE/TL
17273 else if(!cache && !periodicity)
17274 {
17275 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17276 {
17277 //send down a req
17278 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17279 if(!HAL_STATUS_SUCCESS(status))
17280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017281 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017282 }
17283 //so that when the stats rsp comes back from PE we respond to upper layer
17284 //right away
17285 staEntry.timerExpired = TRUE;
17286 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017287 }
17288 if(statsMask & (1 << eCsrGlobalClassDStats))
17289 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017290 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017291 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017292 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017293 //req TL for class D stats
17294 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017296 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017297 }
17298 else
17299 {
17300 //save in SME
17301 csrRoamSaveStatsFromTl(pMac, pTlStats);
17302 }
17303 vos_mem_free(pTlStats);
17304 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017305 }
17306 else
17307 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017308 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017310
17311 }
17312 //if looking for stats from TL only
17313 if(!insertInClientList)
17314 {
17315 //return the stats
17316 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017319 if(insertInClientList)
17320 {
17321 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17322 if(!pStaEntry)
17323 {
17324 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017325 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017326 return eHAL_STATUS_FAILURE;
17327 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017328 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017329 //Init & start timer if needed
17330 if(periodicity)
17331 {
17332 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17333 csrRoamStatsClientTimerHandler, pStaEntry );
17334 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017336 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017337 return eHAL_STATUS_FAILURE;
17338 }
17339 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17340 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017342 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017343 return eHAL_STATUS_FAILURE;
17344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017347 }
17348 return eHAL_STATUS_SUCCESS;
17349}
17350
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017351#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17352
17353static tSirRetStatus
17354csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17355 tANI_U8* pBD,
17356 tANI_U8 type,
17357 tANI_U8 subType,
17358 tSirMacAddr peerAddr,
17359 tSirMacAddr selfMacAddr)
17360{
17361 tSirRetStatus statusCode = eSIR_SUCCESS;
17362 tpSirMacMgmtHdr pMacHdr;
17363
17364 /* Prepare MAC management header */
17365 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17366
17367 /* Prepare FC */
17368 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17369 pMacHdr->fc.type = type;
17370 pMacHdr->fc.subType = subType;
17371
17372 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017373 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17374 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017375
17376 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17377
17378 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017379 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17380 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017381 return statusCode;
17382} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17383
17384static tSirRetStatus
17385csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17386 tANI_U8 nChannelNum,
17387 tANI_U32 dot11mode,
17388 tSirMacAddr selfMacAddr,
17389 tANI_U8 *pFrame,
17390 tANI_U16 *pusLen)
17391{
17392 tDot11fProbeRequest pr;
17393 tANI_U32 nStatus, nBytes, nPayload;
17394 tSirRetStatus nSirStatus;
17395 /*Bcast tx*/
17396 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17397 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17398
17399
Kiet Lam64c1b492013-07-12 13:56:44 +053017400 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017401
17402 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17403
17404 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17405 {
17406 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17407 }
17408
17409
17410 if (IS_DOT11_MODE_HT(dot11mode))
17411 {
17412 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17413 }
17414
17415
17416 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17417 if ( DOT11F_FAILED( nStatus ) )
17418 {
17419 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17420 "Failed to calculate the packed size f"
17421 "or a Probe Request (0x%08x).\n", nStatus );
17422
17423
17424 nPayload = sizeof( tDot11fProbeRequest );
17425 }
17426 else if ( DOT11F_WARNED( nStatus ) )
17427 {
17428 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17429 "There were warnings while calculating"
17430 "the packed size for a Probe Request ("
17431 "0x%08x).\n", nStatus );
17432 }
17433
17434 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17435
17436 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017437 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017438
17439
17440 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017441 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017442
17443 if ( eSIR_SUCCESS != nSirStatus )
17444 {
17445 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17446 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17447 nSirStatus );
17448 return nSirStatus;
17449 }
17450
17451
17452 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17453 sizeof( tSirMacMgmtHdr ),
17454 nPayload, &nPayload );
17455 if ( DOT11F_FAILED( nStatus ) )
17456 {
17457 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17458 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17459 return eSIR_FAILURE;
17460 }
17461 else if ( DOT11F_WARNED( nStatus ) )
17462 {
17463 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017464 "There were warnings while packing a Probe Request (0x%08x).\n",
17465 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017466 }
17467
17468 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17469 return eSIR_SUCCESS;
17470}
17471
Mukul Sharmad68cda62015-03-20 21:25:41 +053017472/*
17473 * Below Table describe whether RSO command can be send down to fimrware or not.
17474 * Host check it on the basis of previous RSO command sent down to firmware.
17475||===========================================================================||
17476|| New cmd | LAST SENT COMMAND ---> ||
17477||====|======================================================================||
17478|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17479|| --------------------------------------------------------------------------||
17480|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017481|| RSO_STOP | YES | NO | YES | YES ||
17482|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017483|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17484||===========================================================================||
17485*/
17486
17487#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17488#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17489#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17490#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17491
17492#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17493#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017494 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017495#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17496 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017497#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017498 RSO_START_BIT)
17499
17500tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17501{
17502 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17503 tANI_U8 desiredMask = 0;
17504 switch(command)
17505 {
17506 case ROAM_SCAN_OFFLOAD_START:
17507 desiredMask = RSO_START_ALLOW_MASK;
17508 break;
17509 case ROAM_SCAN_OFFLOAD_STOP:
17510 desiredMask = RSO_STOP_ALLOW_MASK;
17511 break;
17512 case ROAM_SCAN_OFFLOAD_RESTART:
17513 desiredMask = RSO_RESTART_ALLOW_MASK;
17514 break;
17515 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17516 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17517 break;
17518 default:
17519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17520 FL("Wrong RSO command %d, not allowed"), command);
17521 return 0;/*Cmd Not allowed*/
17522 }
17523 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17524}
17525
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017526eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17527{
17528 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017529 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017530 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017531 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017532 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017533 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017534 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017535 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017536 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017537 eHalStatus status = eHAL_STATUS_SUCCESS;
17538 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017539 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017540 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017541 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017542 tSirBssDescription *pBssDesc = NULL;
17543 tDot11fBeaconIEs *pIes = NULL;
17544 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017545 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017546
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017547 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17548
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017549 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017550 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017551 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017552 return eHAL_STATUS_FAILURE;
17553 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017554
17555 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17556 {
17557 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17558 return eHAL_STATUS_FAILURE;
17559 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017560
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017561 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17562 * It is important to ensure that the command is passed down to the FW only
17563 * if the Infra Station is in a connected state.A connected station could also be
17564 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17565 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17566 * irrespective of whichever state we are in.*/
17567 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17568 (command != ROAM_SCAN_OFFLOAD_STOP))
17569 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017570 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17571 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17572 macTraceGetNeighbourRoamState(
17573 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017574 return eHAL_STATUS_FAILURE;
17575 }
17576
Mukul Sharmad68cda62015-03-20 21:25:41 +053017577 if (!CsrIsRSOCommandAllowed(pMac, command))
17578 {
17579 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17580 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17581 command, pNeighborRoamInfo->lastSentCmd);
17582 return eHAL_STATUS_FAILURE;
17583 }
17584
Abhishek Singh3e915632014-11-01 17:14:50 +053017585 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17586 * Also there are cases where pNeighborRoamInfo->currAPbssid
17587 * is set to 0 during disconnect and so we might return without stopping
17588 * the roam scan. So no need to find the session if command is
17589 * ROAM_SCAN_OFFLOAD_STOP.
17590 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017591 status = csrRoamGetSessionIdFromBSSID(pMac,
17592 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17593 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017594 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017595 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017596 if ( !HAL_STATUS_SUCCESS( status ) )
17597 {
17598 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17599 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17600 return eHAL_STATUS_FAILURE;
17601 }
17602 pSession = CSR_GET_SESSION( pMac, sessionId );
17603 if (NULL == pSession)
17604 {
17605 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080017606 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053017607 return eHAL_STATUS_FAILURE;
17608 }
17609 pBssDesc = pSession->pConnectBssDesc;
17610 if (pBssDesc == NULL)
17611 {
17612 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17613 "%s: pBssDesc not found for current session", __func__);
17614 return eHAL_STATUS_FAILURE;
17615 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017616 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017617 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17618 if (NULL == pRequestBuf)
17619 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017620 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17621 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17622 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017623 }
17624
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017625#ifdef FEATURE_WLAN_DIAG_SUPPORT
17626 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17627 eSIR_SUCCESS, eSIR_SUCCESS);
17628#endif
17629
Abhishek Singh3e915632014-11-01 17:14:50 +053017630 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17631 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17632 * host driver reloads, but Riva still up and running*/
17633 pRequestBuf->Command = command;
17634 if(command == ROAM_SCAN_OFFLOAD_STOP)
17635 {
17636 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017637 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017638 /*For a STOP Command, there is no need to
17639 * go through filling up all the below parameters
17640 * since they are not required for the STOP command*/
17641 goto send_roam_scan_offload_cmd;
17642 }
17643 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017644 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017645 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17646 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017647 sizeof(tCsrBssid));
17648 pRequestBuf->ConnectedNetwork.ssId.length =
17649 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17650 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17651 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17652 pRequestBuf->ConnectedNetwork.ssId.length);
17653 pRequestBuf->ConnectedNetwork.authentication =
17654 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17655 pRequestBuf->ConnectedNetwork.encryption =
17656 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17657 pRequestBuf->ConnectedNetwork.mcencryption =
17658 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017659 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17660 {
17661 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017662 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017663 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17664 }
17665 else
17666 {
17667 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
17668 operationChannel = pSession->connectedProfile.operationChannel;
17669
17670 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17671 {
17672 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17673 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17674 vos_mem_free(pRequestBuf);
17675 return eHAL_STATUS_FAILURE;
17676 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017677 if(NULL == pIes)
17678 {
17679 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17680 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017681 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017682 return eHAL_STATUS_FAILURE;
17683 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017684 if (pIes->SuppRates.present)
17685 {
17686 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17687 /*Check for both basic rates and extended rates.*/
17688 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17689 {
17690 /*Check if the Rate is Mandatory or Not*/
17691 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17692 && (pIes->SuppRates.rates[i] & 0x80))
17693 {
17694 /*Retrieve the actual data rate*/
17695 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17696 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17697 if (minRate == 0)
17698 minRate = dataRate;
17699 else
17700 minRate = (minRate < dataRate) ? minRate:dataRate;
17701 }
17702 }
17703
17704 if (pIes->ExtSuppRates.present)
17705 {
17706 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17707 {
17708 /*Check if the Rate is Mandatory or Not*/
17709 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17710 && (pIes->ExtSuppRates.rates[i] & 0x80))
17711 {
17712 /*Retrieve the actual data rate*/
17713 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17714 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17715 if (minRate == 0)
17716 minRate = dataRate;
17717 else
17718 minRate = (minRate < dataRate) ? minRate:dataRate;
17719 }
17720 }
17721 }
17722 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17723 }
17724 else
17725 {
17726 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17727 "%s: Supp Rates not present in pIes", __func__);
17728 vos_mem_free(pRequestBuf);
17729 return eHAL_STATUS_FAILURE;
17730 }
17731 if (NULL != pIes)
17732 {
17733 vos_mem_free(pIes);
17734 pIes = NULL;
17735 }
17736 switch (minRate)
17737 {
17738 case 1:
17739 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
17740 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
17741 break;
17742 case 2:
17743 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
17744 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
17745 break;
17746 case 5:
17747 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
17748 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
17749 break;
17750 case 6:
17751 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17752 {
17753 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
17754 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
17755 }
17756 else
17757 {
17758 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
17759 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
17760 }
17761 break;
17762 case 11:
17763 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
17764 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
17765 break;
17766 case 12:
17767 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17768 {
17769 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
17770 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
17771 }
17772 else
17773 {
17774 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
17775 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
17776 }
17777 break;
17778 case 24:
17779 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17780 {
17781 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
17782 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
17783 }
17784 else
17785 {
17786 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
17787 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
17788 }
17789 break;
17790 default:
17791 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
17792 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17793 break;
17794 }
17795 }
17796 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17797 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
17798 operationChannel, minRate,
17799 pRequestBuf->RxSensitivityThreshold,
17800 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017801 pRequestBuf->RoamRssiDiff =
17802 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017803 pRequestBuf->StartScanReason = reason;
17804 pRequestBuf->NeighborScanTimerPeriod =
17805 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
17806 pRequestBuf->NeighborRoamScanRefreshPeriod =
17807 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
17808 pRequestBuf->NeighborScanChannelMinTime =
17809 pNeighborRoamInfo->cfgParams.minChannelScanTime;
17810 pRequestBuf->NeighborScanChannelMaxTime =
17811 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
17812 pRequestBuf->EmptyRefreshScanPeriod =
17813 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080017814 /* MAWC feature */
17815 pRequestBuf->MAWCEnabled =
17816 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017817
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017818#ifdef FEATURE_WLAN_ESE
17819 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017820#endif
17821 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017822#ifdef FEATURE_WLAN_ESE
17823 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017824 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17825 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017826 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17827#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017828 currChannelListInfo->numOfChannels == 0)
17829 {
17830
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017831 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
17832 * Give Preference to INI Channels.*/
17833 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
17834 {
17835 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
17836 /*The INI channels need to be filtered with respect to the current
17837 * band that is supported.*/
17838 eBand = pMac->roam.configParam.bandCapability;
17839 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017840 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017841 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17842 "Invalid band, No operation carried out (Band %d)", eBand);
17843 vos_mem_free(pRequestBuf);
17844 return eHAL_STATUS_FAILURE;
17845 }
17846 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
17847 {
17848 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17849 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
17850 (eCSR_BAND_ALL == eBand))
17851 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017852 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
17853 ((pMac->roam.configParam.allowDFSChannelRoam) ||
17854 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
17855 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017856 {
17857 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
17858 }
17859 }
17860 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017861 }
17862 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17863 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017864 }
17865 else
17866 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017867 ChannelList = pMac->scan.occupiedChannels.channelList;
17868 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
17869 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053017870 /*Allow DFS channels only if the DFS channel roam flag is enabled */
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017871 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053017872 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017873 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017874 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017875 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017876 }
17877 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017878 }
17879 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17880 /* If the profile changes as to what it was earlier, inform the FW through
17881 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
17882 * for the earlier profile and try to learn them afresh.*/
17883 if (reason == REASON_FLUSH_CHANNEL_LIST)
17884 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
17885 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017886 if (csrNeighborRoamIsNewConnectedProfile(pMac))
17887 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
17888 else
17889 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017890 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017891 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017892 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017893#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017894 else
17895 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017896 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017897 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017898 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017899 if (currChannelListInfo->numOfChannels != 0)
17900 {
17901 ChannelList = currChannelListInfo->ChannelList;
17902 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017903 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017904 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
17905 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
17906 {
17907 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
17908 *ChannelList;
17909 }
17910 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017911 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017912 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17913 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
17914 }
17915 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017916#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017917 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
17918 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017919 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053017920 if (j < sizeof(ChannelCacheStr))
17921 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017922 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
17923 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053017924 }
17925 else
17926 {
17927 break;
17928 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017929 }
17930 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17931 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
17932 pRequestBuf->ChannelCacheType,
17933 pRequestBuf->ConnectedNetwork.ChannelCount,
17934 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017935 num_channels = 0;
17936 ChannelList = NULL;
17937
17938 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070017939 host_channels = sizeof(pMac->roam.validChannelList);
17940 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017941 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070017942 ChannelList = pMac->roam.validChannelList;
17943 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017944 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070017945 else
17946 {
17947 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17948 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070017949 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070017950 return eHAL_STATUS_FAILURE;
17951 }
17952 for(i=0; i<pMac->roam.numValidChannels; i++)
17953 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017954 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
17955 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
Srinivas Girigowda56076852013-08-20 14:00:50 -070017956 {
17957 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
17958 }
17959 ChannelList++;
17960 }
17961 pRequestBuf->ValidChannelCount = num_channels;
17962
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017963 pRequestBuf->MDID.mdiePresent =
17964 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
17965 pRequestBuf->MDID.mobilityDomain =
17966 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017967 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
17968
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017969 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017970 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
17971 * where RFS is the RF Switching time. It is twice RFS to consider the
17972 * time to go off channel and return to the home channel. */
17973 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
17974 {
17975 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
17976 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
17977 " Hence enforcing home away time to disable (0)",
17978 __func__, pRequestBuf->HomeAwayTime,
17979 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
17980 pRequestBuf->HomeAwayTime = 0;
17981 }
17982 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070017983
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017984 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
17985 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
17986 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
17987 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
17988 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
17989
17990 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
17991 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017992send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017993 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017994 msg.reserved = 0;
17995 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053017996 MTRACE(vos_trace(VOS_MODULE_ID_SME,
17997 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017998 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
17999 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018000 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18001 vos_mem_free(pRequestBuf);
18002 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018003 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018004 else
18005 {
18006 if (ROAM_SCAN_OFFLOAD_START == command)
18007 bRoamScanOffloadStarted = VOS_TRUE;
18008 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18009 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018010
18011 /*update the last sent cmd*/
18012 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018013 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018014
18015 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
Kapil Gupta04ab1992016-06-26 13:36:51 +053018016
18017 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018018 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18019 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018020 {
18021
18022 /* PER ROAM SCAN */
18023 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18024 if (!PERRoamReqBuf)
18025 {
18026 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18027 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18028 return eHAL_STATUS_FAILURE;
18029 }
18030 /* PER Roam Config */
18031 PERRoamReqBuf->rateUpThreshold =
18032 pMac->roam.configParam.rateUpThreshold;
18033 PERRoamReqBuf->rateDownThreshold =
18034 pMac->roam.configParam.rateDownThreshold;
18035 PERRoamReqBuf->waitPeriodForNextPERScan =
18036 pMac->roam.configParam.waitPeriodForNextPERScan;
18037 PERRoamReqBuf->PERtimerThreshold =
18038 pMac->roam.configParam.PERtimerThreshold;
18039 PERRoamReqBuf->isPERRoamCCAEnabled =
18040 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018041 PERRoamReqBuf->PERRoamFullScanThreshold =
18042 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018043 PERRoamReqBuf->PERroamTriggerPercent =
18044 pMac->roam.configParam.PERroamTriggerPercent;
18045 PERRoamReqBuf->sessionId = sessionId;
18046
18047 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18048 PERroamScanConfigMsg.reserved = 0;
18049 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18050 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18051 &PERroamScanConfigMsg))) {
18052 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18053 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18054 vos_mem_free(PERRoamReqBuf);
18055 return eHAL_STATUS_FAILURE;
18056 }
18057 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18058 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18059 PERRoamReqBuf->rateUpThreshold,
18060 PERRoamReqBuf->rateDownThreshold,
18061 PERRoamReqBuf->waitPeriodForNextPERScan,
18062 PERRoamReqBuf->PERtimerThreshold);
18063 }
18064
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018065 return status;
18066}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018067
18068eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18069{
18070 switch(reason)
18071 {
18072 case 0:
18073 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18074 break;
18075 case REASON_OS_REQUESTED_ROAMING_NOW:
18076 csrNeighborRoamProceedWithHandoffReq(pMac);
18077 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018078 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18079 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18080 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018081 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018082 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 -070018083 }
18084 return eHAL_STATUS_SUCCESS;
18085}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018086#endif
18087
Jeff Johnson295189b2012-06-20 16:38:30 -070018088tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18089 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18090{
18091 tANI_BOOLEAN found = FALSE;
18092 eHalStatus status = eHAL_STATUS_SUCCESS;
18093 tCsrPeStatsReqInfo staEntry;
18094 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18095 tListElem *pStaEntry = NULL;
18096 VOS_STATUS vosStatus;
18097 tPmcPowerState powerState;
18098 *pFound = FALSE;
18099
18100 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18101 if(pStaEntry)
18102 {
18103 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18104 if(pTempStaEntry->periodicity)
18105 {
18106 pTempStaEntry->periodicity =
18107 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18108 }
18109 else
18110 {
18111 pTempStaEntry->periodicity = periodicity;
18112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018113 pTempStaEntry->numClient++;
18114 found = TRUE;
18115 }
18116 else
18117 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018118 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018119 staEntry.numClient = 1;
18120 staEntry.periodicity = periodicity;
18121 staEntry.pMac = pMac;
18122 staEntry.rspPending = FALSE;
18123 staEntry.staId = staId;
18124 staEntry.statsMask = statsMask;
18125 staEntry.timerRunning = FALSE;
18126 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18127 if(!pTempStaEntry)
18128 {
18129 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018130 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018131 return NULL;
18132 }
18133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018134 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18135 if(ePMC_FULL_POWER == powerState)
18136 {
18137 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18138 {
18139 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18140 }
18141 }
18142 else
18143 {
18144 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18145 {
18146 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18147 }
18148 }
18149 if(!pTempStaEntry->timerRunning)
18150 {
18151 //send down a req in case of one time req, for periodic ones wait for timer to expire
18152 if(!pTempStaEntry->rspPending &&
18153 !pTempStaEntry->periodicity)
18154 {
18155 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18156 if(!HAL_STATUS_SUCCESS(status))
18157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018158 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018159 }
18160 else
18161 {
18162 pTempStaEntry->rspPending = TRUE;
18163 }
18164 }
18165 if(pTempStaEntry->periodicity)
18166 {
18167 if(!found)
18168 {
18169
18170 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18171 csrRoamPeStatsTimerHandler, pTempStaEntry );
18172 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018174 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018175 return NULL;
18176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018177 }
18178 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018179 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018180 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18181 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018183 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018184 return NULL;
18185 }
18186 pTempStaEntry->timerRunning = TRUE;
18187 }
18188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018189 *pFound = found;
18190 return pTempStaEntry;
18191}
18192
Jeff Johnson295189b2012-06-20 16:38:30 -070018193/*
18194 pStaEntry is no longer invalid upon the return of this function.
18195*/
18196static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18197{
18198 if(pEntry)
18199 {
18200 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18201 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018202 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018204 }
18205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018206
18207void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18208{
18209 tListElem *pEntry;
18210 tCsrPeStatsReqInfo *pTempStaEntry;
18211 VOS_STATUS vosStatus;
18212 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018213 if(!pEntry)
18214 {
18215 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018216 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018217 return;
18218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018219 while( pEntry )
18220 {
18221 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018222 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18223 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018224 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018225 if(pTempStaEntry->timerRunning)
18226 {
18227 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18228 /* If we are not able to stop the timer here, just remove
18229 * the entry from the linked list. Destroy the timer object
18230 * and free the memory in the timer CB
18231 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018232 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018233 {
18234 /* the timer is successfully stopped */
18235 pTempStaEntry->timerRunning = FALSE;
18236
18237 /* Destroy the timer */
18238 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18239 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018241 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018242 }
18243 }
18244 else
18245 {
18246 // the timer could not be stopped. Hence destroy and free the
18247 // memory for the PE stat entry in the timer CB.
18248 pTempStaEntry->timerStopFailed = TRUE;
18249 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018251
18252 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18253 {
18254 // Only free the memory if we could stop the timer successfully
18255 if(!pTempStaEntry->timerStopFailed)
18256 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018257 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018258 pTempStaEntry = NULL;
18259 }
18260 break;
18261 }
18262
18263 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18264 }
18265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018266 return;
18267}
18268
18269
Jeff Johnsone7245742012-09-05 17:12:55 -070018270void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018271{
18272
Jeff Johnsone7245742012-09-05 17:12:55 -070018273 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18274 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18275 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18276 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18277 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18278 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18279 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018280 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018281 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18282 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18283 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18284 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18285 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18286 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018287 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018288 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18289 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018290
18291}
18292
Jeff Johnson295189b2012-06-20 16:38:30 -070018293void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18294 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18295{
18296 tANI_U8 stats[500];
18297 tANI_U8 *pStats = NULL;
18298 tANI_U32 tempMask = 0;
18299 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018300 if(!callback)
18301 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018302 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018303 return;
18304 }
18305 if(!statsMask)
18306 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018307 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018308 return;
18309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018310 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018311 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018312 while(tempMask)
18313 {
18314 if(tempMask & 1)
18315 {
18316 //new stats info from PE, fill up the stats strucutres in PMAC
18317 switch(counter)
18318 {
18319 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018320 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018321 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18322 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018323 pStats += sizeof(tCsrSummaryStatsInfo);
18324 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018325 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018326 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018327 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18328 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018329 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018331 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018332 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018333 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18334 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018335 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018336 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018337 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018338 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018339 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18340 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018341 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018342 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018343 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018344 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018345 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18346 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018347 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018348 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018349 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018350 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018351 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18352 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018353 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018354 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018355 case eCsrPerPktStats:
18356 smsLog( pMac, LOG2, FL("PerPkt stats"));
18357 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18358 sizeof(tPerTxPacketFrmFw));
18359 pStats += sizeof(tPerTxPacketFrmFw);
18360 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018361 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018362 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018363 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018364 }
18365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018366 tempMask >>=1;
18367 counter++;
18368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018369 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018370}
18371
Jeff Johnson295189b2012-06-20 16:38:30 -070018372eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18373{
18374 tListElem *pEntry = NULL;
18375 tListElem *pPrevEntry = NULL;
18376 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18377 eHalStatus status = eHAL_STATUS_SUCCESS;
18378 VOS_STATUS vosStatus;
18379 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018380 if(!pEntry)
18381 {
18382 //list empty
18383 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018384 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018385 return status;
18386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018387 while( pEntry )
18388 {
18389 if(pPrevEntry)
18390 {
18391 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18392 //send up the stats report
18393 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18394 pTempStaEntry->staId, pTempStaEntry->pContext);
18395 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018397 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018398 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18399 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018400 pTempStaEntry->pPeStaEntry->numClient--;
18401 //check if we need to delete the entry from peStatsReqList too
18402 if(!pTempStaEntry->pPeStaEntry->numClient)
18403 {
18404 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018407 //check if we need to stop the tl stats timer too
18408 pMac->roam.tlStatsReqInfo.numClient--;
18409 if(!pMac->roam.tlStatsReqInfo.numClient)
18410 {
18411 if(pMac->roam.tlStatsReqInfo.timerRunning)
18412 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018413 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18414 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018416 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018417 //we will continue
18418 }
18419 }
18420 pMac->roam.tlStatsReqInfo.periodicity = 0;
18421 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018423 if (pTempStaEntry->periodicity)
18424 {
18425 //While creating StaEntry in csrGetStatistics,
18426 //Initializing and starting timer only when periodicity is set.
18427 //So Stop and Destroy timer only when periodicity is set.
18428
Jeff Johnsone7245742012-09-05 17:12:55 -070018429 vos_timer_stop( &pTempStaEntry->timer );
18430 // Destroy the vos timer...
18431 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18432 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018434 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018436 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018437
Jeff Johnson295189b2012-06-20 16:38:30 -070018438
18439 pPrevEntry = pEntry;
18440 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18441 }
18442 //the last one
18443 if(pPrevEntry)
18444 {
18445 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18446 //send up the stats report
18447 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18448 pTempStaEntry->staId, pTempStaEntry->pContext);
18449 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018451 return status;
18452
18453}
18454
Jeff Johnson295189b2012-06-20 16:38:30 -070018455eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18456 tRequestFullPowerReason *pReason,
18457 tANI_BOOLEAN *pfNeedPower )
18458{
18459 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18460 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18461 tPmcState pmcState;
18462 eHalStatus status = eHAL_STATUS_SUCCESS;
18463 // TODO : Session info unavailable
18464 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018465 if( pfNeedPower )
18466 {
18467 *pfNeedPower = eANI_BOOLEAN_FALSE;
18468 }
18469 //We only handle CSR commands
18470 if( !(eSmeCsrCommandMask & pCommand->command) )
18471 {
18472 return eHAL_STATUS_SUCCESS;
18473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018474 //Check PMC state first
18475 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018476 switch( pmcState )
18477 {
18478 case REQUEST_IMPS:
18479 case IMPS:
18480 if( eSmeCommandScan == pCommand->command )
18481 {
18482 switch( pCommand->u.scanCmd.reason )
18483 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018484#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18485 case eCsrScanGetLfrResult:
18486#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018487 case eCsrScanGetResult:
18488 case eCsrScanBGScanAbort:
18489 case eCsrScanBGScanEnable:
18490 case eCsrScanGetScanChnInfo:
18491 //Internal process, no need for full power
18492 fNeedFullPower = eANI_BOOLEAN_FALSE;
18493 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018494 default:
18495 //Other scans are real scan, ask for power
18496 fNeedFullPower = eANI_BOOLEAN_TRUE;
18497 break;
18498 } //switch
18499 }
18500 else
18501 {
18502 //ask for power for roam and status change
18503 fNeedFullPower = eANI_BOOLEAN_TRUE;
18504 }
18505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018506 case REQUEST_BMPS:
18507 case BMPS:
18508 case REQUEST_START_UAPSD:
18509 case UAPSD:
18510 //We treat WOWL same as BMPS
18511 case REQUEST_ENTER_WOWL:
18512 case WOWL:
18513 if( eSmeCommandRoam == pCommand->command )
18514 {
18515 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18516 tCsrScanResult *pScanResult;
18517 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018518 switch ( pCommand->u.roamCmd.roamReason )
18519 {
18520 case eCsrForcedDisassoc:
18521 case eCsrForcedDisassocMICFailure:
18522 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18523 fNeedFullPower = eANI_BOOLEAN_TRUE;
18524 break;
18525 case eCsrSmeIssuedDisassocForHandoff:
18526 case eCsrForcedDeauth:
18527 case eCsrHddIssuedReassocToSameAP:
18528 case eCsrSmeIssuedReassocToSameAP:
18529 fNeedFullPower = eANI_BOOLEAN_TRUE;
18530 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018531 case eCsrCapsChange:
18532 fNeedFullPower = eANI_BOOLEAN_TRUE;
18533 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018534 case eCsrForcedDisassocSta:
18535 case eCsrForcedDeauthSta:
18536 fNeedFullPower = eANI_BOOLEAN_FALSE;
18537 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018538 default:
18539 //Check whether the profile is already connected. If so, no need for full power
18540 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18541 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18542 {
18543 //Only need to check the first one
18544 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18545 if( pEntry )
18546 {
18547 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18548#if 0
18549 // TODO : Session Specific info pConnectBssDesc
18550 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18551 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18552 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18553 {
18554 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18555 // with Authenticating first. To force this, stop the current association (Disassociate) and
18556 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18557 // a new Association.
18558 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18559 {
18560 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18561 {
18562 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18563 //No need for full power
18564 //Set the flag so the code later can avoid to do the above
18565 //check again.
18566 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18567 break;
18568 }
18569 }
18570 }
18571#endif
18572 }
18573 }
18574 //If we are here, full power is needed
18575 fNeedFullPower = eANI_BOOLEAN_TRUE;
18576 break;
18577 }
18578 }
18579 else if( eSmeCommandWmStatusChange == pCommand->command )
18580 {
18581 //need full power for all
18582 fNeedFullPower = eANI_BOOLEAN_TRUE;
18583 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18584 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018585#ifdef FEATURE_WLAN_TDLS
18586 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18587 {
18588 //TDLS link is getting established. need full power
18589 fNeedFullPower = eANI_BOOLEAN_TRUE;
18590 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18591 }
18592#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018593 else if (eSmeCommandDelStaSession == pCommand->command)
18594 {
18595 //need full power for all
18596 fNeedFullPower = eANI_BOOLEAN_TRUE;
18597 }
18598
Jeff Johnson295189b2012-06-20 16:38:30 -070018599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018600 case REQUEST_STOP_UAPSD:
18601 case REQUEST_EXIT_WOWL:
18602 if( eSmeCommandRoam == pCommand->command )
18603 {
18604 fNeedFullPower = eANI_BOOLEAN_TRUE;
18605 switch ( pCommand->u.roamCmd.roamReason )
18606 {
18607 case eCsrForcedDisassoc:
18608 case eCsrForcedDisassocMICFailure:
18609 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18610 break;
18611 default:
18612 break;
18613 }
18614 }
18615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018616 case STOPPED:
18617 case REQUEST_STANDBY:
18618 case STANDBY:
18619 case LOW_POWER:
18620 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018621 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18622 " stopped/standby state %s (%d)" ),
18623 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018624 status = eHAL_STATUS_FAILURE;
18625 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018626 case FULL_POWER:
18627 case REQUEST_FULL_POWER:
18628 default:
18629 //No need to ask for full power. This has to be FULL_POWER state
18630 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018631 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018632 if( pReason )
18633 {
18634 *pReason = reason;
18635 }
18636 if( pfNeedPower )
18637 {
18638 *pfNeedPower = fNeedFullPower;
18639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018640 return ( status );
18641}
18642
Jeff Johnson295189b2012-06-20 16:38:30 -070018643static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18644{
18645 eHalStatus status = eHAL_STATUS_SUCCESS;
18646 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18647 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018648 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018649 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18650 {
18651 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018653 return ( status );
18654}
18655
Jeff Johnson295189b2012-06-20 16:38:30 -070018656tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18657{
18658 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018659 if( pCmd )
18660 {
18661 pMac->roam.sPendingCommands++;
18662 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018663 return ( pCmd );
18664}
18665
Jeff Johnson295189b2012-06-20 16:38:30 -070018666void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18667{
18668 if (pMac->roam.sPendingCommands > 0)
18669 {
18670 //All command allocated through csrGetCommandBuffer need to
18671 //decrement the pending count when releasing.
18672 pMac->roam.sPendingCommands--;
18673 smeReleaseCommand( pMac, pCommand );
18674 }
18675 else
18676 {
18677 smsLog(pMac, LOGE, FL( "no pending commands"));
18678 VOS_ASSERT(0);
18679 }
18680}
18681
Jeff Johnson295189b2012-06-20 16:38:30 -070018682//Return SUCCESS is the command is queued, failed
18683eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
18684{
18685 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053018686
18687 if (!SME_IS_START(pMac))
18688 {
18689 smsLog( pMac, LOGE, FL("Sme in stop state"));
18690 return eHAL_STATUS_FAILURE;
18691 }
18692
Jeff Johnson295189b2012-06-20 16:38:30 -070018693 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
18694 {
18695 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
18696 pCommand->u.scanCmd.reason);
18697 return eHAL_STATUS_CSR_WRONG_STATE;
18698 }
18699
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018700 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
18701 {
18702 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
18703 &pCommand->Link, LL_ACCESS_LOCK);
18704 // process the command queue...
18705 smeProcessPendingQueue(pMac);
18706 status = eHAL_STATUS_SUCCESS;
18707 goto end;
18708 }
18709
Jeff Johnson295189b2012-06-20 16:38:30 -070018710 //We can call request full power first before putting the command into pending Q
18711 //because we are holding SME lock at this point.
18712 status = csrRequestFullPower( pMac, pCommand );
18713 if( HAL_STATUS_SUCCESS( status ) )
18714 {
18715 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070018716 //make sure roamCmdPendingList is not empty first
18717 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
18718 if( fNoCmdPending )
18719 {
18720 smePushCommand( pMac, pCommand, fHighPriority );
18721 }
18722 else
18723 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018724 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070018725 //no list lock is needed since SME lock is held
18726 if( !fHighPriority )
18727 {
18728 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18729 }
18730 else {
18731 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18732 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018734 }
18735 else if( eHAL_STATUS_PMC_PENDING == status )
18736 {
18737 //no list lock is needed since SME lock is held
18738 if( !fHighPriority )
18739 {
18740 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18741 }
18742 else {
18743 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18744 }
18745 //Let caller know the command is queue
18746 status = eHAL_STATUS_SUCCESS;
18747 }
18748 else
18749 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018750 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070018751 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018752 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070018753 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018754end:
Jeff Johnson295189b2012-06-20 16:38:30 -070018755 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070018756}
Jeff Johnson295189b2012-06-20 16:38:30 -070018757eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
18758{
18759 eHalStatus status = eHAL_STATUS_SUCCESS;
18760 tSirUpdateAPWPSIEsReq *pMsg;
18761 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
18762
18763 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18764 if (NULL == pSession)
18765 {
18766 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18767 return eHAL_STATUS_FAILURE;
18768 }
18769
Jeff Johnson295189b2012-06-20 16:38:30 -070018770 do
18771 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018772 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
18773 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18774 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018775 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
18776
18777 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070018778 VOS_ASSERT(pBuf);
18779
Jeff Johnson295189b2012-06-20 16:38:30 -070018780 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018781 // transactionId
18782 *pBuf = 0;
18783 *( pBuf + 1 ) = 0;
18784 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070018785 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018786 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18787 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070018788 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018789 //sessionId
18790 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018791 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018792 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070018793 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070018794 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018795 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018796 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018797 return ( status );
18798}
Jeff Johnson295189b2012-06-20 16:38:30 -070018799eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
18800{
18801 eHalStatus status = eHAL_STATUS_SUCCESS;
18802 tSirUpdateAPWPARSNIEsReq *pMsg;
18803 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018804 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18805 if (NULL == pSession)
18806 {
18807 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18808 return eHAL_STATUS_FAILURE;
18809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018810 do
18811 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018812 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
18813 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18814 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018815 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070018816 pBuf = (tANI_U8 *)&pMsg->transactionId;
18817 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018818 // transactionId
18819 *pBuf = 0;
18820 *( pBuf + 1 ) = 0;
18821 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070018822 VOS_ASSERT(pBuf);
18823
Jeff Johnson295189b2012-06-20 16:38:30 -070018824 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018825 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18826 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070018827 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018828 // sessionId
18829 *pBuf++ = (tANI_U8)sessionId;
18830
18831 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018832 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070018833 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070018834 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018835 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018836 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018837 return ( status );
18838}
Jeff Johnson295189b2012-06-20 16:38:30 -070018839
18840#ifdef WLAN_FEATURE_VOWIFI_11R
18841//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
18842eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
18843{
18844 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
18845 tpSirFTPreAuthReq pftPreAuthReq;
18846 tANI_U16 auth_req_len = 0;
18847 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070018848 auth_req_len = sizeof(tSirFTPreAuthReq);
18849 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053018850 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070018851 {
18852 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
18853 return eHAL_STATUS_RESOURCES;
18854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018855 // Save the SME Session ID here. We need it while processing the preauth response
18856 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018857 vos_mem_zero(pftPreAuthReq, auth_req_len);
18858
18859 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
18860 sizeof(pBssDescription->length) + pBssDescription->length);
18861
18862 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
18863
18864 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
18865
Kiet Lam64c1b492013-07-12 13:56:44 +053018866 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
18867 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
18868 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
18869 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070018870
Jeff Johnson295189b2012-06-20 16:38:30 -070018871#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080018872 if (csrRoamIs11rAssoc(pMac) &&
18873 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070018874 {
18875 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053018876 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
18877 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070018878 }
18879 else
18880#endif
18881 {
18882 pftPreAuthReq->ft_ies_length = 0;
18883 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070018884 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
18885 sizeof(pBssDescription->length) + pBssDescription->length);
18886 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070018887 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
18888}
Jeff Johnson295189b2012-06-20 16:38:30 -070018889/*--------------------------------------------------------------------------
18890 * This will receive and process the FT Pre Auth Rsp from the current
18891 * associated ap.
18892 *
18893 * This will invoke the hdd call back. This is so that hdd can now
18894 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
18895 ------------------------------------------------------------------------*/
18896void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
18897{
18898 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
18899 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018900#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018901 tCsrRoamInfo roamInfo;
18902#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053018903 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070018904
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070018905#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080018906 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070018907 if (status != eHAL_STATUS_SUCCESS) {
18908 /*
18909 * Bail out if pre-auth was not even processed.
18910 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018911 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
18912 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070018913 return;
18914 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018915#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018916 /* The below function calls/timers should be invoked only if the pre-auth is successful */
18917 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
18918 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070018919 // Implies a success
18920 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070018921 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
18922 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053018923 /* No need to notify qos module if this is a non 11r & ESE roam*/
18924 if (csrRoamIs11rAssoc(pMac)
18925#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
18926 || csrRoamIsESEAssoc(pMac)
18927#endif
18928 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070018929 {
18930 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
18931 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053018932 if (pMac->roam.configParam.roamDelayStatsEnabled)
18933 {
18934 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
18935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018936 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
18937 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018938 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
18939 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053018940 if (pMac->roam.configParam.roamDelayStatsEnabled)
18941 {
18942 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
18943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018944 if (eHAL_STATUS_SUCCESS != status)
18945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018946 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070018947 return;
18948 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018949 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053018950 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
18951 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070018952 if (csrRoamIs11rAssoc(pMac))
18953 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
18954 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
18955
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018956#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
18957 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018958 {
18959 /* read TSF */
18960 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
18961
18962 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080018963 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018964 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
18965 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018966#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018967#ifdef FEATURE_WLAN_LFR
18968 // If Legacy Fast Roaming is enabled, signal the supplicant
18969 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053018970 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018971 {
18972 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053018973 vos_mem_copy((void *)&roamInfo.bssid,
18974 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018975 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
18976 }
18977
18978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018979
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053018980 // If its an Open Auth, FT IEs are not provided by supplicant
18981 // Hence populate them here
18982 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
18983 pMac->ft.ftSmeContext.addMDIE = FALSE;
18984 if( csrRoamIs11rAssoc(pMac) &&
18985 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
18986 {
18987 tANI_U16 ft_ies_length;
18988 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
18989
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053018990 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
18991 connectedProfile.MDID.mdiePresent)
18992 pMac->ft.ftSmeContext.addMDIE = TRUE;
18993
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053018994 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
18995 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
18996 {
18997 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
18998 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
18999 }
19000
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019001 if (!ft_ies_length)
19002 {
19003 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19004 return;
19005 }
19006
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019007 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19008 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19009 {
19010 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19011 }
19012 else
19013 {
19014 // Copy the RIC IEs to reassoc IEs
19015 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19016 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19017 pFTPreAuthRsp->ric_ies_length);
19018 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19019 pMac->ft.ftSmeContext.addMDIE = TRUE;
19020 }
19021 }
19022
Jeff Johnson295189b2012-06-20 16:38:30 -070019023 // Done with it, init it.
19024 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19025}
19026#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019027
Jeff Johnson295189b2012-06-20 16:38:30 -070019028#ifdef FEATURE_WLAN_BTAMP_UT_RF
19029void csrRoamJoinRetryTimerHandler(void *pv)
19030{
19031 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19032 tpAniSirGlobal pMac = pInfo->pMac;
19033 tANI_U32 sessionId = pInfo->sessionId;
19034 tCsrRoamSession *pSession;
19035
19036 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019038 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019039 pSession = CSR_GET_SESSION( pMac, sessionId );
19040 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19041 {
19042 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019044 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019045 }
19046 }
19047 }
19048}
Jeff Johnson295189b2012-06-20 16:38:30 -070019049eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19050{
19051 eHalStatus status = eHAL_STATUS_FAILURE;
19052 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19053
19054 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019056 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019057 pSession->maxRetryCount--;
19058 pSession->joinRetryTimerInfo.pMac = pMac;
19059 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019060 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19061 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019063 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019064 }
19065 }
19066 else
19067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019068 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019069 pSession->maxRetryCount);
19070 }
19071
19072 return (status);
19073}
Jeff Johnson295189b2012-06-20 16:38:30 -070019074eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19075{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019076 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019077 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19078 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019079 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019080 }
19081
19082 return eHAL_STATUS_SUCCESS;
19083}
19084#endif
19085
19086
19087/*
19088 pBuf points to the beginning of the message
19089 LIM packs disassoc rsp as below,
19090 messageType - 2 bytes
19091 messageLength - 2 bytes
19092 sessionId - 1 byte
19093 transactionId - 2 bytes (tANI_U16)
19094 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19095 peerMacAddr - 6 bytes
19096 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19097*/
19098static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19099{
19100 if(pBuf && pRsp)
19101 {
19102 pBuf += 4; //skip type and length
19103 pRsp->sessionId = *pBuf++;
19104 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19105 pBuf += 2;
19106 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19107 pBuf += 4;
19108 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19109 }
19110}
19111
Jeff Johnsond13512a2012-07-17 11:42:19 -070019112eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19113{
19114 static uNvTables nvTables;
19115 eHalStatus status = eHAL_STATUS_SUCCESS;
19116 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19117
19118 /* read the country code from NV and use it */
19119 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19120 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019121 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19122 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019123 return status;
19124 }
19125 else
19126 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019127 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019128 status = eHAL_STATUS_FAILURE;
19129 return status;
19130 }
19131}
19132
19133eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19134{
Kiet Lam64c1b492013-07-12 13:56:44 +053019135 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019136 return eHAL_STATUS_SUCCESS;
19137}
schang86c22c42013-03-13 18:41:24 -070019138
19139eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19140{
19141 tSirSetTxPowerReq *pMsg = NULL;
19142 eHalStatus status = eHAL_STATUS_SUCCESS;
19143 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19144
19145 if (!pSession)
19146 {
19147 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19148 return eHAL_STATUS_FAILURE;
19149 }
19150
Kiet Lam64c1b492013-07-12 13:56:44 +053019151 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19152 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19153 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19154 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19155 pMsg->length = sizeof(tSirSetTxPowerReq);
19156 pMsg->mwPower = mW;
19157 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19158 sizeof(tSirMacAddr));
19159 status = palSendMBMessage(pMac->hHdd, pMsg);
19160 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019161 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019162 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19163 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019164 }
19165 return status;
19166}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019167
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019168eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19169{
19170 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19171 eHalStatus status = eHAL_STATUS_SUCCESS;
19172 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19173
19174 if (!pSession)
19175 {
19176 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19177 return eHAL_STATUS_FAILURE;
19178 }
19179 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19180 {
19181 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019182
19183 if( NULL == pMsg )
19184 {
19185 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19186 return eHAL_STATUS_FAILURE;
19187 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019188 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19189 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019190 pMsg->length =
19191 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019192 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019193 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19194 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019195 status = palSendMBMessage(pMac->hHdd, pMsg);
19196 if (!HAL_STATUS_SUCCESS(status))
19197 {
19198 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19199 //pMsg is freed by palSendMBMessage
19200 }
19201 }
19202 else
19203 {
19204 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19205 status = eHAL_STATUS_FAILURE;
19206 }
19207 return status;
19208}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019209/* Returns whether a session is in VOS_STA_MODE...or not */
19210tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19211{
19212 tCsrRoamSession *pSession = NULL;
19213 pSession = CSR_GET_SESSION ( pMac, sessionId );
19214 if(!pSession)
19215 {
19216 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19217 return eANI_BOOLEAN_FALSE;
19218 }
19219 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19220 {
19221 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19222 return eANI_BOOLEAN_FALSE;
19223 }
19224 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19225 {
19226 return eANI_BOOLEAN_FALSE;
19227 }
19228 /* There is a possibility that the above check may fail,because
19229 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19230 * when it is connected.So,we may sneak through the above check even
19231 * if we are not a STA mode INFRA station. So, if we sneak through
19232 * the above condition, we can use the following check if we are
19233 * really in STA Mode.*/
19234
19235 if ( NULL != pSession->pCurRoamProfile )
19236 {
19237 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19238 {
19239 return eANI_BOOLEAN_TRUE;
19240 } else {
19241 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19242 return eANI_BOOLEAN_FALSE;
19243 }
19244 }
19245
19246 return eANI_BOOLEAN_FALSE;
19247}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019248
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019249/**
19250 * csr_set_src_handoff_request() - Set handoff source to
19251 * SME handoff request
19252 * @pHandoffInfo: Pointer to Handoff info
19253 * @pMsg: Pointer to SME handoff request message
19254 *
19255 * Return: None
19256 */
19257#ifndef QCA_WIFI_ISOC
19258static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19259 tCsrHandoffRequest *pHandoffInfo)
19260{
19261 pMsg->handoff_src = pHandoffInfo->src;
19262}
19263#else
19264static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19265 tCsrHandoffRequest *pHandoffInfo)
19266{
19267}
19268#endif
19269
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019270#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19271eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19272 tCsrHandoffRequest *pHandoffInfo)
19273{
19274 eHalStatus status = eHAL_STATUS_SUCCESS;
19275 vos_msg_t msg;
19276
19277 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019278 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19279 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019280 {
19281 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019282 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019283 }
19284 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19285 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19286 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19287 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019288 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019289 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019290 pHandoffInfo->bssid,
19291 6);
19292 msg.type = eWNI_SME_HANDOFF_REQ;
19293 msg.bodyptr = pMsg;
19294 msg.reserved = 0;
19295 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19296 {
19297 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019298 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019299 status = eHAL_STATUS_FAILURE;
19300 }
19301 return status;
19302}
19303#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019304
Abhishek Singh00b71972016-01-07 10:51:04 +053019305#ifdef WLAN_FEATURE_RMC
19306eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19307{
19308 tSirSetRMCReq *pMsg = NULL;
19309 eHalStatus status = eHAL_STATUS_SUCCESS;
19310 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19311
19312 if (!pSession)
19313 {
19314 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19315 return eHAL_STATUS_FAILURE;
19316 }
19317
19318 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19319 if (NULL != pMsg)
19320 {
19321 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19322 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19323 pMsg->msgLen = sizeof(tSirSetRMCReq);
19324 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19325 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19326
19327 status = palSendMBMessage(pMac->hHdd, pMsg);
19328 if (!HAL_STATUS_SUCCESS(status))
19329 {
19330 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19331 //pMsg is freed by palSendMBMessage
19332 }
19333 }
19334 else
19335 {
19336 return eHAL_STATUS_FAILURE;
19337 }
19338 return status;
19339}
19340
19341eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19342{
19343 tSirSetRMCReq *pMsg = NULL;
19344 eHalStatus status = eHAL_STATUS_SUCCESS;
19345 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19346
19347 if (!pSession)
19348 {
19349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19350 return eHAL_STATUS_FAILURE;
19351 }
19352
19353 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19354 if (NULL != pMsg)
19355 {
19356 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19357 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19358 pMsg->msgLen = sizeof(tSirSetRMCReq);
19359 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19360 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19361
19362 status = palSendMBMessage(pMac->hHdd, pMsg);
19363 if (!HAL_STATUS_SUCCESS(status))
19364 {
19365 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19366 //pMsg is freed by palSendMBMessage
19367 }
19368 }
19369 else
19370 {
19371 return eHAL_STATUS_FAILURE;
19372 }
19373 return status;
19374}
19375
19376#endif /* WLAN_FEATURE_RMC */
19377
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019378
19379#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019380/* ---------------------------------------------------------------------------
19381 \fn csrSetCCKMIe
19382 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19383 data structure and this IE will be packed inside reassociation request
19384 \param pMac - pMac global structure
19385 \param sessionId - Current session id
19386 \param pCckmIe - pointer to CCKM IE data
19387 \param ccKmIeLen - length of the CCKM IE
19388 \- return Success or failure
19389 -------------------------------------------------------------------------*/
19390VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19391 const tANI_U8 *pCckmIe,
19392 const tANI_U8 ccKmIeLen)
19393{
19394 eHalStatus status = eHAL_STATUS_SUCCESS;
19395 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19396
19397 if (!pSession)
19398 {
19399 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19400 return eHAL_STATUS_FAILURE;
19401 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019402 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019403 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19404 return status;
19405}
19406
19407/* ---------------------------------------------------------------------------
19408 \fn csrRoamReadTSF
19409 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19410 probe response reception from the hand off AP to arrive at the latest TSF value.
19411 \param pMac - pMac global structure
19412 \param pTimestamp - output TSF timestamp
19413 \- return Success or failure
19414 -------------------------------------------------------------------------*/
19415VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19416{
19417 eHalStatus status = eHAL_STATUS_SUCCESS;
19418 tCsrNeighborRoamBSSInfo handoffNode;
19419 tANI_U32 timer_diff = 0;
19420 tANI_U32 timeStamp[2];
19421 tpSirBssDescription pBssDescription = NULL;
19422
19423 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19424 pBssDescription = handoffNode.pBssDescription;
19425
19426 // Get the time diff in milli seconds
19427 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19428 // Convert msec to micro sec timer
19429 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19430
19431 timeStamp[0] = pBssDescription->timeStamp[0];
19432 timeStamp[1] = pBssDescription->timeStamp[1];
19433
19434 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19435
Kiet Lamf2f201e2013-11-16 21:24:16 +053019436 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019437 sizeof (tANI_U32) * 2);
19438 return status;
19439}
19440
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019441#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019442
Agarwal Ashish738843c2014-09-25 12:27:56 +053019443/* ---------------------------------------------------------------------------
19444 \fn csrDisableDfsChannel
19445 \brief This function will call csrApplyChannelPowerCountryInfo to
19446 \ to trim the list on basis of NO_DFS flag.
19447 \param pMac - pMac global structure
19448 \- return void
19449 -------------------------------------------------------------------------*/
19450void csrDisableDfsChannel(tpAniSirGlobal pMac)
19451{
19452 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19453 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19454}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019455
19456/* ---------------------------------------------------------------------------
19457 \fn csrGetStaticUapsdMask
19458 \brief This function will get the static uapsd settings for an existing
19459 \ Infra session.
19460 \param pMac - pMac global structure
19461 \- return void
19462 -------------------------------------------------------------------------*/
19463void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19464{
19465 tANI_S8 sessionId;
19466 tCsrRoamSession *pSession = NULL;
19467
19468 *staticUapsdMask = 0;
19469 sessionId = csrGetInfraSessionId(pMac);
19470 if(sessionId == -1)
19471 smsLog(pMac, LOGE, FL("Valid session not present."));
19472 else
19473 pSession = CSR_GET_SESSION(pMac, sessionId);
19474
19475 if(!pSession || !pSession->pCurRoamProfile)
19476 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
19477 " pSession:%p"), pSession);
19478 else
19479 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19480}
19481