blob: 31e038e17ccbca19546e65fab8455c66f43825e0 [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 );
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530767 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE, i);
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 }
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 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530858 vos_spin_lock_init(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 return (status);
861}
862
Jeff Johnson295189b2012-06-20 16:38:30 -0700863eHalStatus csrRoamClose(tpAniSirGlobal pMac)
864{
865 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
867 {
mukul sharmabab477d2015-06-11 17:14:55 +0530868 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530870 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
871 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
872 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
873 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530874 vos_spin_lock_destroy(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 return (eHAL_STATUS_SUCCESS);
876}
877
Jeff Johnson295189b2012-06-20 16:38:30 -0700878eHalStatus csrRoamStart(tpAniSirGlobal pMac)
879{
880 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 return (eHAL_STATUS_SUCCESS);
882}
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
885{
886 csrRoamStopRoamingTimer(pMac, sessionId);
887 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
888 csrRoamDeregStatisticsReq(pMac);
889}
Jeff Johnson295189b2012-06-20 16:38:30 -0700890eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
891{
892 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800893 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 {
895 status = eHAL_STATUS_SUCCESS;
896 *pState = pMac->roam.roamSession[sessionId].connectState;
897 }
898 return (status);
899}
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
902{
903 eHalStatus status = eHAL_STATUS_FAILURE;
904 tANI_U32 size = 0;
905 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700906
907 if(!pSession)
908 {
909 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
910 return eHAL_STATUS_FAILURE;
911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913 if(pProfile)
914 {
915 if(pSession->pConnectBssDesc)
916 {
917 do
918 {
919 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
920 if(size)
921 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530922 pProfile->pBssDesc = vos_mem_malloc(size);
923 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530925 vos_mem_copy(pProfile->pBssDesc,
926 pSession->pConnectBssDesc, size);
927 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 }
929 else
930 break;
931 }
932 else
933 {
934 pProfile->pBssDesc = NULL;
935 }
936 pProfile->AuthType = pSession->connectedProfile.AuthType;
937 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
938 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
939 pProfile->BSSType = pSession->connectedProfile.BSSType;
940 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
941 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530942 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
943 sizeof(tCsrBssid));
944 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
945 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700946#ifdef WLAN_FEATURE_VOWIFI_11R
947 if (pSession->connectedProfile.MDID.mdiePresent)
948 {
949 pProfile->MDID.mdiePresent = 1;
950 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
951 }
952 else
953 {
954 pProfile->MDID.mdiePresent = 0;
955 pProfile->MDID.mobilityDomain = 0;
956 }
957#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800958#ifdef FEATURE_WLAN_ESE
959 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
960 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800962 vos_mem_copy (pProfile->eseCckmInfo.krk,
963 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530964 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800965 pProfile->eseCckmInfo.reassoc_req_num=
966 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
967 pProfile->eseCckmInfo.krk_plumbed =
968 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 }
970#endif
971 }while(0);
972 }
973 }
974
975 return (status);
976}
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
979{
980 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700981
982 if((csrIsConnStateConnected(pMac, sessionId)) ||
983 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 {
985 if(pProfile)
986 {
987 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
988 }
989 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 return (status);
991}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700992
Jeff Johnson295189b2012-06-20 16:38:30 -0700993eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
994{
995 eHalStatus status = eHAL_STATUS_SUCCESS;
996
Kiet Lam64c1b492013-07-12 13:56:44 +0530997 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530999 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301001 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001002 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301003 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001004 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301005 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
1006
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
1008 return (status);
1009}
1010
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301011eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -07001012{
1013 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 if( pConnectedInfo->pbFrames )
1015 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301016 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 pConnectedInfo->pbFrames = NULL;
1018 }
1019 pConnectedInfo->nBeaconLength = 0;
1020 pConnectedInfo->nAssocReqLength = 0;
1021 pConnectedInfo->nAssocRspLength = 0;
1022 pConnectedInfo->staId = 0;
1023#ifdef WLAN_FEATURE_VOWIFI_11R
1024 pConnectedInfo->nRICRspLength = 0;
1025#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001026#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pConnectedInfo->nTspecIeLength = 0;
1028#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 return ( status );
1030}
1031
Jeff Johnson295189b2012-06-20 16:38:30 -07001032
1033
Jeff Johnsone7245742012-09-05 17:12:55 -07001034
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001035void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1036{
1037 csrReinitPreauthCmd(pMac, pCommand);
1038 csrReleaseCommand( pMac, pCommand );
1039}
1040
Jeff Johnson295189b2012-06-20 16:38:30 -07001041void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1042{
1043 csrReinitRoamCmd(pMac, pCommand);
1044 csrReleaseCommand( pMac, pCommand );
1045}
1046
Jeff Johnson295189b2012-06-20 16:38:30 -07001047void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1048{
1049 csrReinitScanCmd(pMac, pCommand);
1050 csrReleaseCommand( pMac, pCommand );
1051}
1052
Jeff Johnson295189b2012-06-20 16:38:30 -07001053void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1054{
1055 csrReinitWmStatusChangeCmd(pMac, pCommand);
1056 csrReleaseCommand( pMac, pCommand );
1057}
1058
Jeff Johnson295189b2012-06-20 16:38:30 -07001059void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1060{
Kiet Lam64c1b492013-07-12 13:56:44 +05301061 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062}
1063
Jeff Johnson295189b2012-06-20 16:38:30 -07001064void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1065{
Kiet Lam64c1b492013-07-12 13:56:44 +05301066 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001067}
1068
Jeff Johnson295189b2012-06-20 16:38:30 -07001069void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1070{
1071 csrReinitSetKeyCmd(pMac, pCommand);
1072 csrReleaseCommand( pMac, pCommand );
1073}
Jeff Johnson295189b2012-06-20 16:38:30 -07001074void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1075{
1076 csrReinitRemoveKeyCmd(pMac, pCommand);
1077 csrReleaseCommand( pMac, pCommand );
1078}
Abhishek Singh7b2d0812016-04-28 11:44:29 +05301079
1080/**
1081 * csr_is_disconnect_full_power_cmd() - Check if command is for
1082 * disconnect or for fullpower
1083 * @command: command to check
1084 *
1085 * Return: true if disconnect or full power command else false
1086 */
1087bool csr_is_disconnect_full_power_cmd(tSmeCmd *command)
1088{
1089 switch (command->command) {
1090 case eSmeCommandRoam:
1091 if (CSR_IS_DISCONNECT_COMMAND(command))
1092 return true;
1093 break;
1094 case eSmeCommandWmStatusChange:
1095 case eSmeCommandExitImps:
1096 case eSmeCommandExitBmps:
1097 case eSmeCommandExitUapsd:
1098 case eSmeCommandExitWowl:
1099 return true;
1100 default:
1101 return false;
1102 }
1103 return false;
1104}
1105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1107{
1108
1109 if( eSmeCsrCommandMask & pCommand->command )
1110 {
1111 switch (pCommand->command)
1112 {
1113 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001114 // We need to inform the requester before dropping the scan command
Jeff Johnson89477502017-09-19 08:35:23 -07001115 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %pK",
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001116 __func__, pCommand->u.scanCmd.reason,
1117 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 if (NULL != pCommand->u.scanCmd.callback)
1119 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001120 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1122 }
1123 csrReleaseCommandScan( pMac, pCommand );
1124 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 case eSmeCommandRoam:
1126 csrReleaseCommandRoam( pMac, pCommand );
1127 break;
1128
1129 case eSmeCommandWmStatusChange:
1130 csrReleaseCommandWmStatusChange( pMac, pCommand );
1131 break;
1132
1133 case eSmeCommandSetKey:
1134 csrReleaseCommandSetKey( pMac, pCommand );
1135 break;
1136
1137 case eSmeCommandRemoveKey:
1138 csrReleaseCommandRemoveKey( pMac, pCommand );
1139 break;
1140
1141 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001142 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 csrReleaseCommand( pMac, pCommand );
1144 break;
1145 }
1146 }
1147}
1148
Jeff Johnson295189b2012-06-20 16:38:30 -07001149void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1150{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301151 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1152 macTraceGetcsrRoamSubState(NewSubstate),
1153 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1156 {
1157 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001158 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301159 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 pMac->roam.curSubState[sessionId] = NewSubstate;
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301161 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001162}
1163
Jeff Johnson295189b2012-06-20 16:38:30 -07001164eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1165{
1166 eCsrRoamState PreviousState;
1167
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301168 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1169 macTraceGetcsrRoamState(NewRoamState),
1170 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001171
1172 PreviousState = pMac->roam.curState[sessionId];
1173
1174 if ( NewRoamState != pMac->roam.curState[sessionId] )
1175 {
1176 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1177 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1178 {
1179 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1180 }
1181
1182 pMac->roam.curState[sessionId] = NewRoamState;
1183 }
1184 return( PreviousState );
1185}
1186
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001187void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001188{
1189 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 if(catOffset)
1191 {
1192 pMac->roam.configParam.bCatRssiOffset = catOffset;
1193 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1194 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001195 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 -07001196 }
1197 }
1198}
1199
Jeff Johnson295189b2012-06-20 16:38:30 -07001200static void initConfigParam(tpAniSirGlobal pMac)
1201{
1202 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301204 pMac->roam.configParam.channelBondingMode24GHz =
1205 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1206 pMac->roam.configParam.channelBondingMode5GHz =
1207 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1209 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1210 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1211 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1212 pMac->roam.configParam.HeartbeatThresh24 = 40;
1213 pMac->roam.configParam.HeartbeatThresh50 = 40;
1214 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1215 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1216 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001217 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 pMac->roam.configParam.RTSThreshold = 2346;
1219 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1220 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1221 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1222 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1223 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1224 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1225 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1226 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1227 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1228 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1229 {
1230 pMac->roam.configParam.BssPreferValue[i] = i;
1231 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001232 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1234 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1235 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1237 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301238 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1240 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1241 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1242 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301243 pMac->roam.configParam.max_chntime_btc_esco =
1244 CSR_ACTIVE_MAX_CHANNEL_TIME_ESCO_BTC;
1245 pMac->roam.configParam.min_chntime_btc_esco =
1246 CSR_ACTIVE_MIN_CHANNEL_TIME_ESCO_BTC;
1247 pMac->roam.configParam.min_chntime_btc_sco =
1248 CSR_ACTIVE_MIN_CHANNEL_TIME_SCO_BTC;
1249 pMac->roam.configParam.max_chntime_btc_sco=
1250 CSR_ACTIVE_MAX_CHANNEL_TIME_SCO_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001251 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001252#ifdef WLAN_AP_STA_CONCURRENCY
1253 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1254 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1255 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1256 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1257 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001258 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1259 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001260#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1262 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1263 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1264 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001265#ifdef WLAN_FEATURE_VOWIFI_11R
1266 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1267#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001268#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1269 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1270 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1271 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1272 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1273 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1274 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1275 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1276 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1277 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1278 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1279 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001280 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301281 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05301282 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001283#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001284#ifdef WLAN_FEATURE_11AC
1285 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1286#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001287
1288 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1289 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001290
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001291 //Remove this code once SLM_Sessionization is supported
1292 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001293 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
Jeff Johnsone7245742012-09-05 17:12:55 -07001295}
Jeff Johnson295189b2012-06-20 16:38:30 -07001296eCsrBand csrGetCurrentBand(tHalHandle hHal)
1297{
1298 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1299 return pMac->roam.configParam.bandCapability;
1300}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001301
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001302
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001303#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001304/*
1305 This function flushes the roam scan cache
1306*/
1307eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1308{
1309 eHalStatus status = eHAL_STATUS_SUCCESS;
1310 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1311
1312 /* Free up the memory first (if required) */
1313 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1314 {
1315 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1316 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1317 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1318 }
1319 return status;
1320}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001321#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001322
1323
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001324#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001325/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001326 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001327*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001328eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001329{
1330 eHalStatus status = eHAL_STATUS_SUCCESS;
1331 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1332
1333 /* Free up the memory first (if required) */
1334 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1335 {
1336 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1337 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001338 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001339 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001340 return status;
1341}
1342
1343
1344
1345/*
1346 This function flushes the roam scan cache and creates fresh cache
1347 based on the input channel list
1348*/
1349eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1350 const tANI_U8 *pChannelList,
1351 const tANI_U8 numChannels)
1352{
1353 eHalStatus status = eHAL_STATUS_SUCCESS;
1354 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1355
Srinivas Girigowdade697412013-02-14 16:31:48 -08001356 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1357
1358 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1359 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1360
1361 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1362 {
1363 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1364 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1365 return eHAL_STATUS_RESOURCES;
1366 }
1367
1368 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301369 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1370 pChannelList,
1371 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001372 return status;
1373}
1374
1375/* This function modifies the bgscan channel list set via config ini or
1376 runtime, whenever the band changes.
1377 if the band is auto, then no operation is performed on the channel list
1378 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1379 if the band is 5G, then make sure channel list contains only 5G valid channels
1380*/
1381eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1382 eCsrBand eBand)
1383{
1384 eHalStatus status = eHAL_STATUS_SUCCESS;
1385 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1386 tANI_U8 outNumChannels = 0;
1387 tANI_U8 inNumChannels = 0;
1388 tANI_U8 *inPtr = NULL;
1389 tANI_U8 i = 0;
1390 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1391
1392 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1393
1394 {
1395 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1396 "No update required for channel list "
1397 "either cfg.ini channel list is not set up or "
1398 "auto band (Band %d)", eBand);
1399 return status;
1400 }
1401
1402 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1403 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1404 if (eCSR_BAND_24 == eBand)
1405 {
1406 for (i = 0; i < inNumChannels; i++)
1407 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001408 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001409 {
1410 ChannelList[outNumChannels++] = inPtr[i];
1411 }
1412 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001413 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001414 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001415 }
1416 else if (eCSR_BAND_5G == eBand)
1417 {
1418 for (i = 0; i < inNumChannels; i++)
1419 {
1420 /* Add 5G Non-DFS channel */
1421 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001422 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001423 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1424 {
1425 ChannelList[outNumChannels++] = inPtr[i];
1426 }
1427 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001428 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001429 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001430 }
1431 else if (eCSR_BAND_ALL == eBand)
1432 {
1433 for (i = 0; i < inNumChannels; i++)
1434 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001435 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001436 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1437 {
1438 ChannelList[outNumChannels++] = inPtr[i];
1439 }
1440 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001441 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001442 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001443 }
1444 else
1445 {
1446 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1447 "Invalid band, No operation carried out (Band %d)", eBand);
1448 status = eHAL_STATUS_INVALID_PARAMETER;
1449 }
1450
1451 return status;
1452}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001453#endif
1454
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001455#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001456/* This function modifies the roam scan channel list as per AP neighbor
1457 report; AP neighbor report may be empty or may include only other AP
1458 channels; in any case, we merge the channel list with the learned occupied
1459 channels list.
1460 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1461 if the band is 5G, then make sure channel list contains only 5G valid channels
1462*/
1463eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1464 tANI_U8 *pChannelList,
1465 tANI_U8 numChannels,
1466 const eCsrBand eBand)
1467{
1468 eHalStatus status = eHAL_STATUS_SUCCESS;
1469 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1470 tANI_U8 outNumChannels = 0;
1471 tANI_U8 inNumChannels = numChannels;
1472 tANI_U8 *inPtr = pChannelList;
1473 tANI_U8 i = 0;
1474 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1475 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1476 tANI_U8 mergedOutputNumOfChannels = 0;
1477 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1478
1479 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1480 * report Channels. This increases the chances of the DUT to get a candidate AP while
1481 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1482 if (pMac->scan.occupiedChannels.numChannels)
1483 {
1484 csrNeighborRoamMergeChannelLists(pMac,
1485 &pMac->scan.occupiedChannels.channelList[0],
1486 pMac->scan.occupiedChannels.numChannels,
1487 inPtr,
1488 inNumChannels,
1489 &mergedOutputNumOfChannels);
1490 inNumChannels = mergedOutputNumOfChannels;
1491 }
1492
1493 if (eCSR_BAND_24 == eBand)
1494 {
1495 for (i = 0; i < inNumChannels; i++)
1496 {
1497 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1498 {
1499 ChannelList[outNumChannels++] = inPtr[i];
1500 }
1501 }
1502 }
1503 else if (eCSR_BAND_5G == eBand)
1504 {
1505 for (i = 0; i < inNumChannels; i++)
1506 {
1507 /* Add 5G Non-DFS channel */
1508 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1509 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1510 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1511 {
1512 ChannelList[outNumChannels++] = inPtr[i];
1513 }
1514 }
1515 }
1516 else if (eCSR_BAND_ALL == eBand)
1517 {
1518 for (i = 0; i < inNumChannels; i++)
1519 {
1520 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1521 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1522 {
1523 ChannelList[outNumChannels++] = inPtr[i];
1524 }
1525 }
1526 }
1527 else
1528 {
1529 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1530 "Invalid band, No operation carried out (Band %d)", eBand);
1531 return eHAL_STATUS_INVALID_PARAMETER;
1532 }
1533
1534 /* if roaming within band is enabled, then select only the
1535 in band channels .
1536 This is required only if the band capability is set to ALL,
1537 E.g., if band capability is only 2.4G then all the channels in the
1538 list are already filtered for 2.4G channels, hence ignore this check*/
1539
1540 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1541 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301542 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001543 pMac,
1544 ChannelList,
1545 outNumChannels,
1546 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301547 &outNumChannels,
1548 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301549 vos_mem_copy(ChannelList,
1550 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001551 }
1552
1553 /* Prepare final roam scan channel list */
1554 if(outNumChannels)
1555 {
1556 /* Clear the channel list first */
1557 if (NULL != currChannelListInfo->ChannelList)
1558 {
1559 vos_mem_free(currChannelListInfo->ChannelList);
1560 currChannelListInfo->ChannelList = NULL;
1561 currChannelListInfo->numOfChannels = 0;
1562 }
1563
1564 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1565 if (NULL == currChannelListInfo->ChannelList)
1566 {
1567 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1568 "Failed to allocate memory for roam scan channel list");
1569 currChannelListInfo->numOfChannels = 0;
1570 return VOS_STATUS_E_RESOURCES;
1571 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301572 vos_mem_copy(currChannelListInfo->ChannelList,
1573 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001574 }
1575 return status;
1576}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001577#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001578
Jeff Johnson295189b2012-06-20 16:38:30 -07001579eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1580{
1581 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1582 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1584 (eBand == eCSR_BAND_24))
1585 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001586 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001588 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001589 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 pMac->roam.configParam.uCfgDot11Mode, eBand);
1591 return eHAL_STATUS_INVALID_PARAMETER;
1592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1594 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1595 (eBand == eCSR_BAND_5G))
1596 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001597 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001599 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001600 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 pMac->roam.configParam.uCfgDot11Mode, eBand);
1602 return eHAL_STATUS_INVALID_PARAMETER;
1603 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001604 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001605 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001606 pMac->roam.configParam.eBand = eBand;
1607 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001609#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001610 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1611 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 status = csrInitGetChannels( pMac );
1614 if (eHAL_STATUS_SUCCESS == status)
1615 csrInitChannelList( hHal );
1616 return status;
1617}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001618
1619
Jeff Johnsone7245742012-09-05 17:12:55 -07001620/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1621 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1622 * Ideally we should have kept the ini value and enum value same and representing the same
1623 * cb values as in 11n standard i.e.
1624 * Set to 1 (SCA) if the secondary channel is above the primary channel
1625 * Set to 3 (SCB) if the secondary channel is below the primary channel
1626 * Set to 0 (SCN) if no secondary channel is present
1627 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1628 * 0 - secondary none
1629 * 1 - secondary LOW
1630 * 2 - secondary HIGH
1631 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1632 * The enum values are as follows:
1633 * PHY_SINGLE_CHANNEL_CENTERED = 0
1634 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1635 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1636 */
1637ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1638{
1639
1640 ePhyChanBondState phyCbState;
1641 switch (cbIniValue) {
1642 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301643 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1645 break;
1646 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301647 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001648 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1649 break;
1650 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301651 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001652 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1653 break;
1654#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301655 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1656 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001657 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301658 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001659 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1660 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301661 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1662 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1663 break;
1664 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001665 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1666 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301667 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001668 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301669 break;
1670 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1672 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301673 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001674 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301675 break;
1676#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001677 default:
1678 // If an invalid value is passed, disable CHANNEL BONDING
1679 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1680 break;
1681 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301682
Jeff Johnsone7245742012-09-05 17:12:55 -07001683 return phyCbState;
1684}
1685
1686v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1687{
1688
1689 v_U32_t cbIniValue;
1690 switch (phyCbState) {
1691 // secondary none
1692 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301693 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001694 break;
1695 // secondary LOW
1696 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301697 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001698 break;
1699 // secondary HIGH
1700 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301701 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001702 break;
1703#ifdef WLAN_FEATURE_11AC
1704 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301705 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001706 break;
1707 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301708 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001709 break;
1710 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301711 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001712 break;
1713 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301714 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001715 break;
1716 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301717 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001718 break;
1719 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301720 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001721 break;
1722 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301723 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001724 break;
1725#endif
1726 default:
1727 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301728 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001729 break;
1730 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301731
Jeff Johnsone7245742012-09-05 17:12:55 -07001732 return cbIniValue;
1733}
Jeff Johnson295189b2012-06-20 16:38:30 -07001734
1735eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1736{
1737 eHalStatus status = eHAL_STATUS_SUCCESS;
1738
1739 if(pParam)
1740 {
1741 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1742 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1743 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1744 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1745 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1746 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1747
1748 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001749 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1750
Jeff Johnsone7245742012-09-05 17:12:55 -07001751 /* channelBondingMode5GHz plays a dual role right now
1752 * 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
1753 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1754 */
1755 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001757 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001758 }
1759 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1760 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001762 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001763 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301764#ifdef WLAN_FEATURE_AP_HT40_24G
1765 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1766#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001767 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1769 pMac->roam.configParam.phyMode = pParam->phyMode;
1770 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1771 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1772 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1773 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1774 pMac->roam.configParam.TxRate = pParam->TxRate;
1775 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1776 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1777 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1778 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1779 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001780 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 //if HDD passed down non zero values then only update,
1782 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301783 if (pParam->nInitialDwellTime)
1784 {
1785 pMac->roam.configParam.nInitialDwellTime =
1786 pParam->nInitialDwellTime;
1787 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001788 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 {
1790 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301791 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1792 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001794 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 {
1796 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301797 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1798 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001800 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 {
1802 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301803 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1804 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001806 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 {
1808 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301809 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1810 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301812 if (pParam->nOBSSScanWidthTriggerInterval)
1813 {
1814 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1815 pParam->nOBSSScanWidthTriggerInterval;
1816 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1817 pParam->nOBSSScanWidthTriggerInterval);
1818 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301819 if (pParam->max_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001820 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301821 pMac->roam.configParam.max_chntime_btc_esco =
1822 pParam->max_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_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001825 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301826 pMac->roam.configParam.min_chntime_btc_esco =
1827 pParam->min_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001828 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301829 if (pParam->min_chntime_btc_sco)
1830 pMac->roam.configParam.min_chntime_btc_sco =
1831 pParam->min_chntime_btc_sco;
1832 if (pParam->max_chntime_btc_sco)
1833 pMac->roam.configParam.max_chntime_btc_sco =
1834 pParam->max_chntime_btc_sco;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001835#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001836 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001837 {
1838 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1839 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001840 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001841 {
1842 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1843 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001844 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001845 {
1846 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1847 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001848 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001849 {
1850 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1851 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001852 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001853 {
1854 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1855 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001856 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001857 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001858 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1859 }
1860 if (pParam->nNumP2PChanCombinedConc)
1861 {
1862 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001863 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001864#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001866 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 {
1868 //Change the unit from second to microsecond
1869 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1871 {
1872 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1873 }
1874 else
1875 {
1876 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1877 }
1878 }
1879 else
1880 {
1881 pMac->roam.configParam.impsSleepTime = 0;
1882 }
1883 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1885 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 //if HDD passed down non zero values for age params, then only update,
1887 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001888 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 {
1890 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 if(pParam->scanAgeTimeNCNPS)
1893 {
1894 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 if(pParam->scanAgeTimeNCPS)
1897 {
1898 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 if(pParam->scanAgeTimeCNPS)
1901 {
1902 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1903 }
1904 if(pParam->scanAgeTimeCPS)
1905 {
1906 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1907 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301908 if (pParam->initialScanSkipDFSCh)
1909 {
1910 pMac->roam.configParam.initialScanSkipDFSCh =
1911 pParam->initialScanSkipDFSCh;
1912 }
1913
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001914 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1916 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1917 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1918 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1919 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1921 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1923 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1924 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1925 //Assign this before calling CsrInit11dInfo
1926 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 if( csrIs11dSupported( pMac ) )
1928 {
1929 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1930 }
1931 else
1932 {
1933 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1934 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001935
1936 /* Initialize the power + channel information if 11h is enabled.
1937 If 11d is enabled this information has already been initialized */
1938 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1939 {
1940 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1941 }
1942
1943
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301944#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301945 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1946 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001947 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001948#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001949#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001951 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001952 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001953 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001954 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001955 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001956 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001957 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001958 pMac->roam.configParam.nProbes = pParam->nProbes;
1959 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001960#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001961#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301962 pMac->roam.configParam.isRoamOffloadScanEnabled =
1963 pParam->isRoamOffloadScanEnabled;
1964 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1965 pParam->bFastRoamInConIniFeatureEnabled;
1966 pMac->roam.configParam.isPERRoamEnabled =
1967 pParam->isPERRoamEnabled;
1968 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
1969 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
1970 pMac->roam.configParam.waitPeriodForNextPERScan =
1971 pParam->waitPeriodForNextPERScan;
1972 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
1973 pMac->roam.configParam.isPERRoamCCAEnabled =
1974 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05301975 pMac->roam.configParam.PERRoamFullScanThreshold =
1976 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05301977 pMac->roam.configParam.PERroamTriggerPercent =
1978 pParam->PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05301979 pMac->roam.configParam.PERMinRssiThresholdForRoam =
1980 pParam->PERMinRssiThresholdForRoam;
1981 pMac->PERroamTimeout = pParam->waitPeriodForNextPERScan;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001982#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301983
1984#ifdef WLAN_FEATURE_LFR_MBB
1985 pMac->roam.configParam.enable_lfr_mbb = pParam->enable_lfr_mbb;
1986#endif
1987
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001988#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001989 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001990 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001991#endif
1992
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001993#ifdef FEATURE_WLAN_ESE
1994 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001995#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001996#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301997 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1998 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001999 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
2000 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
2001 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
2002 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
2003 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
2004 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
2005 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
2006 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302007 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05302008 smsLog( pMac, LOG1, "nWeakZoneRssiThresholdForRoam = %d", pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam);
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 {
2010 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002011 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 -07002012 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2013 {
2014 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 }
2017#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
2019 pMac->scan.fValidateList = pParam->fValidateList;
2020 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2021 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302022 pMac->scan.disable_scan_during_sco = pParam->disable_scan_during_sco;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08002023 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002025 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05302026 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07002027 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2028 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2029 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2030 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2031 * single session
2032 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002033 //Remove this code once SLM_Sessionization is supported
2034 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002035 pMac->roam.configParam.doBMPSWorkaround = 0;
2036
Jeff Johnsone7245742012-09-05 17:12:55 -07002037#ifdef WLAN_FEATURE_11AC
2038 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002039 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002040 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002041 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302042 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2043 if ( pParam->enableTxBF )
2044 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2045 else
2046 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002047#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002048 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002049
2050 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002051 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302052 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302053 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302054 pMac->roam.configParam.disableP2PMacSpoofing =
2055 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302056 pMac->roam.configParam.enableFatalEvent =
2057 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002058 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2059 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302060 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302061 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302062#ifdef WLAN_FEATURE_AP_HT40_24G
2063 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2064#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302065 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302066 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2067 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302068
2069 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2070 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2071 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2072 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2073 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2074
2075 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2076 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2077 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2078 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2079
2080 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2081 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2082 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2083 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 }
2085
2086 return status;
2087}
2088
Jeff Johnson295189b2012-06-20 16:38:30 -07002089eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2090{
2091 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 if(pParam)
2093 {
2094 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2095 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2096 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2097 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2098 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2099 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002100 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302101#ifdef WLAN_FEATURE_AP_HT40_24G
2102 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2103#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002104 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2106 pParam->phyMode = pMac->roam.configParam.phyMode;
2107 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2108 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2109 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2110 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2111 pParam->TxRate = pMac->roam.configParam.TxRate;
2112 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2113 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2114 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2115 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2116 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2118 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2119 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2120 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05302121 pParam->max_chntime_btc_esco =
2122 pMac->roam.configParam.max_chntime_btc_esco;
2123 pParam->min_chntime_btc_esco =
2124 pMac->roam.configParam.min_chntime_btc_esco;
2125 pParam->min_chntime_btc_sco =
2126 pMac->roam.configParam.min_chntime_btc_sco;
2127 pParam->max_chntime_btc_sco =
2128 pMac->roam.configParam.max_chntime_btc_sco;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002129 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002130#ifdef WLAN_AP_STA_CONCURRENCY
2131 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2132 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2133 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2134 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2135 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002136 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2137 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 //Change the unit from microsecond to second
2140 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2141 pParam->eBand = pMac->roam.configParam.eBand;
2142 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2143 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2144 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2145 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2146 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2147 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2148 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2149 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2150 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2151 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2152 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2153 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2154 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2156 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2157 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2158 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2160 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2161 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2162 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302163 pParam->disable_scan_during_sco = pMac->scan.disable_scan_during_sco;
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002165 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002166 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002167 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002168 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302169 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302171 vos_mem_copy(&pParam->neighborRoamConfig,
2172 &pMac->roam.configParam.neighborRoamConfig,
2173 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002174#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002175#ifdef WLAN_FEATURE_11AC
2176 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002177 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002178 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002179 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302180 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2181 if ( pParam->enableTxBF )
2182 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2183 else
2184 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002185#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002186#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302187 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2188 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002189#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002190#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002191 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2192 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2193 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2194 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2195 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002196 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002197 pParam->nProbes = pMac->roam.configParam.nProbes;
2198 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002199#endif
2200#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2201 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2202 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302203 pParam->isPERRoamEnabled =
2204 pMac->roam.configParam.isPERRoamEnabled;
2205 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2206 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2207 pParam->waitPeriodForNextPERScan =
2208 pMac->roam.configParam.waitPeriodForNextPERScan;
2209 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2210 pParam->isPERRoamCCAEnabled =
2211 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302212 pParam->PERRoamFullScanThreshold =
2213 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302214 pParam->PERroamTriggerPercent =
2215 pMac->roam.configParam.PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302216 pParam->PERMinRssiThresholdForRoam =
2217 pMac->roam.configParam.PERMinRssiThresholdForRoam;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002218#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302219
2220#ifdef WLAN_FEATURE_LFR_MBB
2221 pParam->enable_lfr_mbb = pMac->roam.configParam.enable_lfr_mbb;
2222#endif
2223
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002224#ifdef FEATURE_WLAN_LFR
2225 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2226#endif
2227
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002228#ifdef FEATURE_WLAN_ESE
2229 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002230#endif
2231#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302232 vos_mem_copy(&pParam->neighborRoamConfig,
2233 &pMac->roam.configParam.neighborRoamConfig,
2234 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002235 {
2236 int i;
2237 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2238 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2239 {
2240 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2241 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002242 }
2243#endif
2244
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002245 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002246
krunal soni5afa96c2013-09-06 22:19:02 -07002247 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002248 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302249 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302250 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302251 pParam->disableP2PMacSpoofing =
2252 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302253 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002254
krunal sonie9002db2013-11-25 14:24:17 -08002255 pParam->isCoalesingInIBSSAllowed =
2256 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302257 pParam->allowDFSChannelRoam =
2258 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302259 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302261#ifdef WLAN_FEATURE_AP_HT40_24G
2262 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2263#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302264 pParam->max_chan_for_dwell_time_cfg =
2265 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002266
Abhishek Singh48cd3402016-03-30 15:20:19 +05302267 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2268 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2269 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2270 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2271 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2272
2273 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2274 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2275 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2276 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2277
2278 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2279 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2280 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2281 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
2282
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 status = eHAL_STATUS_SUCCESS;
2284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 return (status);
2286}
2287
Jeff Johnson295189b2012-06-20 16:38:30 -07002288eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2289{
2290 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2291 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2292 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2293 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 do
2295 {
2296 if(eCSR_BAND_24 == eBand)
2297 {
2298 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2299 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2300 }
2301 if(eCSR_BAND_5G == eBand)
2302 {
2303 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2304 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2305 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2306 )
2307 {
2308 break;
2309 }
2310 }
2311 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2312 {
2313 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2314 }
2315 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2316 {
2317 newPhyMode = eCSR_DOT11_MODE_AUTO;
2318 }
2319 else
2320 {
2321 //Check for dual band and higher capability first
2322 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2323 {
2324 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2325 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2326 }
2327 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2328 {
2329 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2330 if(eCSR_BAND_24 == eBand) break;
2331 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2332 eBand = eCSR_BAND_5G;
2333 }
2334 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2335 {
2336 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2337 if(eCSR_BAND_5G == eBand) break;
2338 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2339 eBand = eCSR_BAND_24;
2340 }
2341 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2342 {
2343 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2344 if(eCSR_BAND_5G == eBand) break;
2345 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2346 eBand = eCSR_BAND_24;
2347 }
2348 else if(eCSR_DOT11_MODE_11n & phyMode)
2349 {
2350 newPhyMode = eCSR_DOT11_MODE_11n;
2351 }
2352 else if(eCSR_DOT11_MODE_abg & phyMode)
2353 {
2354 newPhyMode = eCSR_DOT11_MODE_abg;
2355 }
2356 else if(eCSR_DOT11_MODE_11a & phyMode)
2357 {
2358 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2359 {
2360 if(eCSR_BAND_ALL == eBand)
2361 {
2362 newPhyMode = eCSR_DOT11_MODE_abg;
2363 }
2364 else
2365 {
2366 //bad setting
2367 break;
2368 }
2369 }
2370 else
2371 {
2372 newPhyMode = eCSR_DOT11_MODE_11a;
2373 eBand = eCSR_BAND_5G;
2374 }
2375 }
2376 else if(eCSR_DOT11_MODE_11g & phyMode)
2377 {
2378 newPhyMode = eCSR_DOT11_MODE_11g;
2379 eBand = eCSR_BAND_24;
2380 }
2381 else if(eCSR_DOT11_MODE_11b & phyMode)
2382 {
2383 newPhyMode = eCSR_DOT11_MODE_11b;
2384 eBand = eCSR_BAND_24;
2385 }
2386 else
2387 {
2388 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002389 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 newPhyMode = eCSR_DOT11_MODE_AUTO;
2391 }
2392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 //Done validating
2394 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 //Now we need to check whether a restart is needed.
2396 if(eBand != pMac->roam.configParam.eBand)
2397 {
2398 fRestartNeeded = eANI_BOOLEAN_TRUE;
2399 break;
2400 }
2401 if(newPhyMode != pMac->roam.configParam.phyMode)
2402 {
2403 fRestartNeeded = eANI_BOOLEAN_TRUE;
2404 break;
2405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 if(HAL_STATUS_SUCCESS(status))
2408 {
2409 pMac->roam.configParam.eBand = eBand;
2410 pMac->roam.configParam.phyMode = newPhyMode;
2411 if(pfRestartNeeded)
2412 {
2413 *pfRestartNeeded = fRestartNeeded;
2414 }
2415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 return (status);
2417}
2418
Jeff Johnson295189b2012-06-20 16:38:30 -07002419void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2420{
2421 tANI_U8 Index;
2422 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 // for dual band NICs, don't need to trim the channel list....
2424 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2425 {
2426 // 2.4 GHz band operation requires the channel list to be trimmed to
2427 // the 2.4 GHz channels only...
2428 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2429 {
2430 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2431 Index++ )
2432 {
2433 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2434 {
2435 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2436 cChannels++;
2437 }
2438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2440 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2441 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2442 // only if we need to.
2443 //
2444 // The amount of memory to clear is the number of channesl that we trimmed
2445 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2446
2447 if ( pChannelList->numChannels > cChannels )
2448 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302449 vos_mem_set(&pChannelList->channelList[ cChannels ],
2450 sizeof( pChannelList->channelList[ 0 ] ) *
2451 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 }
2453
2454 pChannelList->numChannels = cChannels;
2455 }
2456 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2457 {
2458 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2459 {
2460 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2461 {
2462 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2463 cChannels++;
2464 }
2465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2467 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2468 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2469 // only if we need to.
2470 //
2471 // The amount of memory to clear is the number of channesl that we trimmed
2472 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2473 if ( pChannelList->numChannels > cChannels )
2474 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302475 vos_mem_set(&pChannelList->channelList[ cChannels ],
2476 sizeof( pChannelList->channelList[ 0 ] ) *
2477 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 }
2479
2480 pChannelList->numChannels = cChannels;
2481 }
2482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002483}
Jeff Johnson295189b2012-06-20 16:38:30 -07002484#define INFRA_AP_DEFAULT_CHANNEL 6
2485eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2486{
2487 tANI_U8 index= 0;
2488 eHalStatus status = eHAL_STATUS_FAILURE;
2489 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2490 {
2491 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2492 status = eHAL_STATUS_SUCCESS;
2493 break;
2494 }
2495 }
2496 return status;
2497}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002498
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002499
Jeff Johnson295189b2012-06-20 16:38:30 -07002500eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2501{
2502 eHalStatus status = eHAL_STATUS_SUCCESS;
2503 tANI_U8 num20MHzChannelsFound = 0;
2504 VOS_STATUS vosStatus;
2505 tANI_U8 Index = 0;
2506 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002507
Jeff Johnson295189b2012-06-20 16:38:30 -07002508
2509 //TODO: this interface changed to include the 40MHz channel list
2510 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2511 // Read the scan channel list (including the power limit) from EEPROM
2512 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2513 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2514 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002516 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 status = eHAL_STATUS_FAILURE;
2518 }
2519 else
2520 {
2521 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2522 {
2523 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2524 }
2525 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2526 // Move the channel list to the global data
2527 // structure -- this will be used as the scan list
2528 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2529 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002531 }
2532 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2533 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2534 {
2535 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2536 }
2537 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2538 {
2539 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2540 }
2541 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 return (status);
2544}
Jeff Johnson295189b2012-06-20 16:38:30 -07002545eHalStatus csrInitChannelList( tHalHandle hHal )
2546{
2547 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2548 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2550 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002551 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2552 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002554 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302555 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 return (status);
2557}
Jeff Johnson295189b2012-06-20 16:38:30 -07002558eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2559 tCsrUpdateConfigParam *pUpdateConfigParam)
2560{
2561 eHalStatus status = eHAL_STATUS_FAILURE;
2562 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2564 status = CsrInit11dInfo(pMac, ps11dinfo);
2565 return status;
2566}
2567
Jeff Johnson295189b2012-06-20 16:38:30 -07002568static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2569{
2570 eHalStatus status = eHAL_STATUS_FAILURE;
2571 tANI_U8 index;
2572 tANI_U32 count=0;
2573 tSirMacChanInfo *pChanInfo;
2574 tSirMacChanInfo *pChanInfoStart;
2575 tANI_BOOLEAN applyConfig = TRUE;
2576
Mihir Shetebc866f62014-02-13 16:08:53 +05302577 pMac->scan.currentCountryRSSI = -128;
2578
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 if(!ps11dinfo)
2580 {
2581 return (status);
2582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2584 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302585 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2586 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2587 ps11dinfo->Channels.channelList,
2588 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 }
2590 else
2591 {
2592 //No change
2593 return (eHAL_STATUS_SUCCESS);
2594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302596
2597 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2598 WNI_CFG_COUNTRY_CODE_LEN);
2599
2600
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 //Tush: at csropen get this initialized with default, during csr reset if this
2602 // already set with some value no need initilaize with default again
2603 if(0 == pMac->scan.countryCodeCurrent[0])
2604 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302605 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2606 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302609 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2610 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302612 vos_mem_set(pChanInfo,
2613 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2614 0);
2615
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002617 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2618 {
2619 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2620 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2621 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2622 pChanInfo++;
2623 count++;
2624 }
2625 if(count)
2626 {
2627 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2628 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302629 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002630 }
2631 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2632 if( HAL_STATUS_SUCCESS(status) )
2633 {
2634 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2635 {
2636 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2637 {
2638 applyConfig = FALSE;
2639 }
2640 }
2641
2642 if(TRUE == applyConfig)
2643 {
2644 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002645 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002646 }
2647
2648 }
2649 return (status);
2650}
2651/* Initialize the Channel + Power List in the local cache and in the CFG */
2652eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2653{
2654 tANI_U8 index;
2655 tANI_U32 count=0;
2656 tSirMacChanInfo *pChanInfo;
2657 tSirMacChanInfo *pChanInfoStart;
2658
2659 if(!ps11dinfo || !pMac)
2660 {
2661 return eHAL_STATUS_FAILURE;
2662 }
2663
Kiet Lam64c1b492013-07-12 13:56:44 +05302664 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2665 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002666 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302667 vos_mem_set(pChanInfo,
2668 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2669 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002670 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002671
2672 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2673 {
2674 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2675 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2676 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2677 pChanInfo++;
2678 count++;
2679 }
2680 if(count)
2681 {
2682 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2683 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302684 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 }
2686
Jeff Johnsone7245742012-09-05 17:12:55 -07002687 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002688}
2689
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302690/**
2691 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2692 * list
2693 *
2694 * @pMac: pointer to global mac
2695 * @sessionId: session id for the cmd
2696 * @pList: pending list from which cmd needs to be removed
2697 * @pCommand: cmd to be removed, can be NULL
2698 * @eRoamReason: cmd with reason to be removed
2699 *
2700 * Remove duplicate command from the pending list.
2701 *
2702 * Return: void
2703 */
2704void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2705 tANI_U32 sessionId, tDblLinkList *pList,
2706 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002707{
2708 tListElem *pEntry, *pNextEntry;
2709 tSmeCmd *pDupCommand;
2710 tDblLinkList localList;
2711
2712 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302713 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302715 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 return;
2717 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302718 csrLLLock(pList);
2719 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2720 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302722 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2723 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2724 /*
2725 * Remove the previous command if..
2726 * - the new roam command is for the same RoamReason...
2727 * - the new roam command is a NewProfileList.
2728 * - the new roam command is a Forced Dissoc
2729 * - the new roam command is from an 802.11 OID
2730 * (OID_SSID or OID_BSSID).
2731 */
2732 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2733 ((pCommand->command == pDupCommand->command) &&
2734 /*
2735 * This peermac check is requried for Softap/GO scenarios
2736 * For STA scenario below OR check will suffice as pCommand
2737 * will always be NULL for STA scenarios
2738 */
2739 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2740 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2741 ((pCommand->u.roamCmd.roamReason ==
2742 pDupCommand->u.roamCmd.roamReason) ||
2743 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2744 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2745 /* OR if pCommand is NULL */
2746 ((sessionId == pDupCommand->sessionId) &&
2747 (eSmeCommandRoam == pDupCommand->command) &&
2748 ((eCsrForcedDisassoc == eRoamReason) ||
2749 (eCsrHddIssued == eRoamReason))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302751 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2752 pDupCommand->u.roamCmd.roamReason);
2753 /* Remove the 'stale' roam command from the pending list */
2754 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 }
2757 pEntry = pNextEntry;
2758 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302759 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002760
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302761 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 {
2763 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302764 /* Tell caller that the command is cancelled */
2765 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2766 pDupCommand->u.roamCmd.roamId,
2767 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 csrReleaseCommandRoam(pMac, pDupCommand);
2769 }
2770 csrLLClose(&localList);
2771}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302772
2773/**
2774 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2775 * from pending lists.
2776 *
2777 * @pMac: pointer to global mac
2778 * @sessionId: session id for the cmd
2779 * @pCommand: cmd to be removed, can be null
2780 * @eRoamReason: cmd with reason to be removed
2781 *
2782 * Remove duplicate command from the sme and roam pending list.
2783 *
2784 * Return: void
2785 */
2786void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2787 tANI_U32 sessionId, tSmeCmd *pCommand,
2788 eCsrRoamReason eRoamReason)
2789{
2790 /* Always lock active list before locking pending lists */
2791 csrLLLock(&pMac->sme.smeCmdActiveList);
2792 csr_roam_remove_duplicate_cmd_from_list(pMac,
2793 sessionId, &pMac->sme.smeCmdPendingList,
2794 pCommand, eRoamReason);
2795 csr_roam_remove_duplicate_cmd_from_list(pMac,
2796 sessionId, &pMac->roam.roamCmdPendingList,
2797 pCommand, eRoamReason);
2798 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2799}
2800
Jeff Johnson295189b2012-06-20 16:38:30 -07002801eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2802 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2803{
2804 eHalStatus status = eHAL_STATUS_SUCCESS;
2805#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2806 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2807#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302808 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2810 {
2811 pSession = CSR_GET_SESSION( pMac, sessionId );
2812 }
2813 else
2814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002815 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 VOS_ASSERT(0);
2817 return eHAL_STATUS_FAILURE;
2818 }
krunal soni587bf012014-02-04 12:35:11 -08002819
2820 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2821 {
2822 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2823 return eHAL_STATUS_FAILURE;
2824 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002825
krunal soni587bf012014-02-04 12:35:11 -08002826 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2827
krunal soni7f7d2c92014-02-06 15:08:43 -08002828 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002830 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002832 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2833 /*
2834 * Decrement bRefAssocStartCnt for FT reassoc failure.
2835 * Reason: For FT reassoc failures, we first call
2836 * csrRoamCallCallback before notifying a failed roam
2837 * completion through csrRoamComplete. The latter in
2838 * turn calls csrRoamProcessResults which tries to
2839 * once again call csrRoamCallCallback if bRefAssocStartCnt
2840 * is non-zero. Since this is redundant for FT reassoc
2841 * failure, decrement bRefAssocStartCnt.
2842 */
2843 pSession->bRefAssocStartCnt--;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302844 } else if (u1 == eCSR_ROAM_ECSA_CHAN_CHANGE_RSP && u2 ==
2845 eCSR_ROAM_RESULT_NONE)
2846 pSession->connectedProfile.operationChannel =
2847 pRoamInfo->ap_chan_change_rsp->new_channel;
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002848
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05302849 if (eCSR_ROAM_RESULT_LOSTLINK == u2 ||
2850 eCSR_ROAM_LOSTLINK_DETECTED == u1)
2851 smsLog(pMac, LOG1, "eCSR_ROAM_RESULT_LOSTLINK ");
2852
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 if(NULL != pSession->callback)
2854 {
2855 if( pRoamInfo )
2856 {
2857 pRoamInfo->sessionId = (tANI_U8)sessionId;
2858 }
2859
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302860 /* avoid holding the global lock when making the roaming callback, original change came
2861 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2862 is possible on other OS ports where the callback may need to take locks to protect
2863 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2865 that may actually depend on the lock being held */
2866 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2867 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2868 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2869 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302870 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2871 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002872#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302873 vos_mem_set(&connectionStatus,
2874 sizeof(vos_event_wlan_status_payload_type), 0);
2875
krunal soni7f7d2c92014-02-06 15:08:43 -08002876 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 {
2878 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2879 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2880 if(NULL != pRoamInfo->pBssDesc)
2881 {
2882 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2883 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2886 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2887 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302888 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302889 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2890 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302891
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302893 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2896 {
2897 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2898 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302899 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 if(eCSR_ROAM_RESULT_FORCED == u2)
2902 {
2903 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2904 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302905 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2908 {
2909 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2910 connectionStatus.reason = eCSR_REASON_DISASSOC;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302911 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2914 {
2915 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2916 connectionStatus.reason = eCSR_REASON_DEAUTH;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302917 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002919#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2920
2921 return (status);
2922}
Jeff Johnson295189b2012-06-20 16:38:30 -07002923// Returns whether handoff is currently in progress or not
2924tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2925{
2926#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2927 return csrNeighborRoamIsHandoffInProgress(pMac);
2928#else
2929 return eANI_BOOLEAN_FALSE;
2930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002931}
Jeff Johnson295189b2012-06-20 16:38:30 -07002932eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2933 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2934{
2935 eHalStatus status = eHAL_STATUS_SUCCESS;
2936 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2937 tANI_U16 reasonCode;
2938 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002939
2940 if(!pSession)
2941 {
2942 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2943 return eHAL_STATUS_FAILURE;
2944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002945
2946 //Restore AC weight in case we change it
2947 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2948 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002949 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 -07002950 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2951 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2952 }
2953
2954 if ( fMICFailure )
2955 {
2956 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2957 }
2958 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2959 {
2960 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002961 }
2962 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 {
2964 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002966#ifdef WLAN_FEATURE_VOWIFI_11R
2967 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2968 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2969 {
2970 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302971 vos_mem_copy(&bssId,
2972 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2973 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002974 }
2975 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002976#endif
2977 if(pSession->pConnectBssDesc)
2978 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302979 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002981
Jeff Johnson295189b2012-06-20 16:38:30 -07002982
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302983 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2984 " subState = %s reason=%d"),
2985 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2986 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002987
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2989
2990 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2991
2992 if(HAL_STATUS_SUCCESS(status))
2993 {
2994 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002995#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2996 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2997 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2998 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002999 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
3001 }
3002#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003003 }
3004 else
3005 {
3006 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
3007 }
3008
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 return (status);
3010}
Jeff Johnson295189b2012-06-20 16:38:30 -07003011
Jeff Johnson295189b2012-06-20 16:38:30 -07003012/* ---------------------------------------------------------------------------
3013 \fn csrRoamIssueDisassociateStaCmd
3014 \brief csr function that HDD calls to disassociate a associated station
3015 \param sessionId - session Id for Soft AP
3016 \param pPeerMacAddr - MAC of associated station to delete
3017 \param reason - reason code, be one of the tSirMacReasonCodes
3018 \return eHalStatus
3019 ---------------------------------------------------------------------------*/
3020eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303021 tANI_U32 sessionId,
3022#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3023 const tANI_U8 *pPeerMacAddr,
3024#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 tANI_U32 reason)
3028{
3029 eHalStatus status = eHAL_STATUS_SUCCESS;
3030 tSmeCmd *pCommand;
3031
3032 do
3033 {
3034 pCommand = csrGetCommandBuffer( pMac );
3035 if ( !pCommand )
3036 {
3037 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3038 status = eHAL_STATUS_RESOURCES;
3039 break;
3040 }
3041 pCommand->command = eSmeCommandRoam;
3042 pCommand->sessionId = (tANI_U8)sessionId;
3043 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
3044 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
3045 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
3046 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3047 if( !HAL_STATUS_SUCCESS( status ) )
3048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003049 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 csrReleaseCommandRoam( pMac, pCommand );
3051 }
3052 }while(0);
3053
3054 return status;
3055}
3056
3057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058/* ---------------------------------------------------------------------------
3059 \fn csrRoamIssueDeauthSta
3060 \brief csr function that HDD calls to delete a associated station
3061 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303062 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 \return eHalStatus
3064 ---------------------------------------------------------------------------*/
3065eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303066 tANI_U32 sessionId,
3067 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003068{
3069 eHalStatus status = eHAL_STATUS_SUCCESS;
3070 tSmeCmd *pCommand;
3071
3072 do
3073 {
3074 pCommand = csrGetCommandBuffer( pMac );
3075 if ( !pCommand )
3076 {
3077 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3078 status = eHAL_STATUS_RESOURCES;
3079 break;
3080 }
3081 pCommand->command = eSmeCommandRoam;
3082 pCommand->sessionId = (tANI_U8)sessionId;
3083 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303084 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3085 sizeof(tSirMacAddr));
3086 pCommand->u.roamCmd.reason =
3087 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3089 if( !HAL_STATUS_SUCCESS( status ) )
3090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003091 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 csrReleaseCommandRoam( pMac, pCommand );
3093 }
3094 }while(0);
3095
3096 return status;
3097}
Jeff Johnson295189b2012-06-20 16:38:30 -07003098eHalStatus
3099csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3100 tANI_BOOLEAN bEnable )
3101{
3102 eHalStatus status = eHAL_STATUS_FAILURE;
3103 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3104 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 if (!pSession)
3106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003107 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 return (status);
3109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 if (pSession->pConnectBssDesc)
3111 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303112 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 }
3114 else
3115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003116 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 return (status);
3118 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003119 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3120 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3122 return (status);
3123}
Jeff Johnson295189b2012-06-20 16:38:30 -07003124eHalStatus
3125csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3126 VOS_MODULE_ID modId, void *pUsrContext,
3127 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3128{
3129 eHalStatus status = eHAL_STATUS_SUCCESS;
3130 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 if (!pSession)
3133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003134 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 return (status);
3136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 if(pSession->pConnectBssDesc)
3138 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303139 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 }
3141 else
3142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003143 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 return (status);
3145 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003146 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3147 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3149 return (status);
3150}
Jeff Johnson295189b2012-06-20 16:38:30 -07003151eHalStatus
3152csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3153 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3154{
3155 eHalStatus status = eHAL_STATUS_SUCCESS;
3156 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3157 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3158
3159 if (!pSession)
3160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003161 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 return (status);
3163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 if(pSession->pConnectBssDesc)
3165 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303166 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 }
3168 else
3169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003170 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 return (status);
3172 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003173 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3174 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003175
3176 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3177
3178 return (status);
3179}
Jeff Johnson295189b2012-06-20 16:38:30 -07003180eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3181{
3182 eHalStatus status = eHAL_STATUS_SUCCESS;
3183 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3184 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003185
3186 if (!pSession)
3187 {
3188 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3189 return eHAL_STATUS_FAILURE;
3190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003191
3192 if(pSession->pConnectBssDesc)
3193 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303194 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003196 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3197 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3199
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303200 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303201 if(HAL_STATUS_SUCCESS(status))
3202 {
3203 csrRoamLinkDown(pMac, sessionId);
3204 }
3205 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003206 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303207 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3208 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003209 }
3210
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 return (status);
3212}
3213
Jeff Johnson295189b2012-06-20 16:38:30 -07003214eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3215{
3216 eHalStatus status = eHAL_STATUS_SUCCESS;
3217 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3218 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003219
3220 if(!pSession)
3221 {
3222 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3223 return eHAL_STATUS_FAILURE;
3224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003225
3226 // If no BSS description was found in this connection (happens with start IBSS), then
3227 // nix the BSS description that we keep around for the connected BSS) and get out...
3228 if(NULL == pBssDesc)
3229 {
3230 csrFreeConnectBssDesc(pMac, sessionId);
3231 }
3232 else
3233 {
3234 size = pBssDesc->length + sizeof( pBssDesc->length );
3235 if(NULL != pSession->pConnectBssDesc)
3236 {
3237 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3238 {
3239 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3240 csrFreeConnectBssDesc(pMac, sessionId);
3241 }
3242 }
3243 if(NULL == pSession->pConnectBssDesc)
3244 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303245 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303247 if (NULL == pSession->pConnectBssDesc)
3248 status = eHAL_STATUS_FAILURE;
3249 else
3250 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 return (status);
3253}
3254
Jeff Johnson295189b2012-06-20 16:38:30 -07003255eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3256 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3257 tDot11fBeaconIEs *pIes)
3258{
3259 eHalStatus status = eHAL_STATUS_SUCCESS;
3260 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303262 if (pIes == NULL)
3263 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003264
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 do
3266 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303267 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3268 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 //get qos
3270 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3271 //get SSID
3272 if(pIes->SSID.present)
3273 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303274 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3276 }
3277 else
3278 pBssConfig->SSID.length = 0;
3279 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003281 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 //Return failed if profile doesn't have an SSID either.
3283 if(pProfile->SSIDs.numOfSSIDs == 0)
3284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003285 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 status = eHAL_STATUS_FAILURE;
3287 break;
3288 }
3289 }
3290 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3291 {
3292 pBssConfig->eBand = eCSR_BAND_5G;
3293 }
3294 else
3295 {
3296 pBssConfig->eBand = eCSR_BAND_24;
3297 }
3298 //phymode
3299 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3300 {
3301 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3302 }
3303 else
3304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003305 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 //force it
3307 if(eCSR_BAND_24 == pBssConfig->eBand)
3308 {
3309 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3310 }
3311 else
3312 {
3313 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3314 }
3315 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +05303316 smsLog(pMac, LOG1, FL("phyMode %d uCfgDot11Mode %d"),
3317 pProfile->phyMode, pBssConfig->uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 //Qos
3319 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3320 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3321 {
3322 //Joining BSS is not 11n capable and WMM is disabled on client.
3323 //Disable QoS and WMM
3324 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3325 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303326
3327 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303328 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303329 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3330 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3331 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3332 {
3333 //Joining BSS is 11n capable and WMM is disabled on AP.
3334 //Assume all HT AP's are QOS AP's and enable WMM
3335 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3336 }
3337
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 //auth type
3339 switch( pProfile->negotiatedAuthType )
3340 {
3341 default:
3342 case eCSR_AUTH_TYPE_WPA:
3343 case eCSR_AUTH_TYPE_WPA_PSK:
3344 case eCSR_AUTH_TYPE_WPA_NONE:
3345 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3346 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3347 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 case eCSR_AUTH_TYPE_SHARED_KEY:
3349 pBssConfig->authType = eSIR_SHARED_KEY;
3350 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 case eCSR_AUTH_TYPE_AUTOSWITCH:
3352 pBssConfig->authType = eSIR_AUTO_SWITCH;
3353 break;
3354 }
3355 //short slot time
3356 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3357 {
3358 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3359 }
3360 else
3361 {
3362 pBssConfig->uShortSlotTime = 0;
3363 }
3364 if(pBssConfig->BssCap.ibss)
3365 {
3366 //We don't support 11h on IBSS
3367 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3368 }
3369 else
3370 {
3371 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3372 }
3373 //power constraint
3374 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3375 //heartbeat
3376 if ( CSR_IS_11A_BSS( pBssDesc ) )
3377 {
3378 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3379 }
3380 else
3381 {
3382 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3383 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303384 /*
3385 * Join timeout, if we find a BeaconInterval in the BssDescription,
3386 * then set the Join Timeout to be 3 BeaconInterval.
3387 */
3388 if (pBssDesc->beaconInterval)
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 {
3390 //Make sure it is bigger than the minimal
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303391 pBssConfig->uJoinTimeOut =
3392 CSR_ROAM_MAX(3 * pBssDesc->beaconInterval,
3393 CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303395 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 {
3397 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3398 }
3399 //validate CB
3400 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Abhishek Singhe3beee22017-07-31 15:35:40 +05303401 if (CSR_IS_CHANNEL_24GHZ(pBssDesc->channelId) &&
3402 pProfile->force_24ghz_in_ht20) {
3403 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
3404 smsLog(pMac, LOG1,
3405 FL("force_24ghz_in_ht20 is set so set cbmode to 0"));
3406 }
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303407 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3408 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 return (status);
3411}
3412
Jeff Johnson295189b2012-06-20 16:38:30 -07003413static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3414 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3415{
3416 eHalStatus status = eHAL_STATUS_SUCCESS;
3417 tANI_U8 operationChannel = 0;
3418 tANI_U8 qAPisEnabled = FALSE;
3419 //SSID
3420 pBssConfig->SSID.length = 0;
3421 if(pProfile->SSIDs.numOfSSIDs)
3422 {
3423 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303424 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3425 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 }
3427 else
3428 {
3429 //SSID must present
3430 return eHAL_STATUS_FAILURE;
3431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 //Settomg up the capabilities
3433 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3434 {
3435 pBssConfig->BssCap.ibss = 1;
3436 }
3437 else
3438 {
3439 pBssConfig->BssCap.ess = 1;
3440 }
3441 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3442 {
3443 pBssConfig->BssCap.privacy = 1;
3444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 pBssConfig->eBand = pMac->roam.configParam.eBand;
3446 //phymode
3447 if(pProfile->ChannelInfo.ChannelList)
3448 {
3449 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3452 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 //QOS
3454 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 if ( pBssConfig->BssCap.ess == 1 )
3456 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 /*For Softap case enable WMM*/
3458 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3459 qAPisEnabled = TRUE;
3460 }
3461 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3463 qAPisEnabled = TRUE;
3464 } else {
3465 qAPisEnabled = FALSE;
3466 }
3467 } else {
3468 qAPisEnabled = TRUE;
3469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3471 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3472 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3473 )
3474 {
3475 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3476 } else {
3477 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3478 }
3479
3480 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003481 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 {
3483 default:
3484 case eCSR_AUTH_TYPE_WPA:
3485 case eCSR_AUTH_TYPE_WPA_PSK:
3486 case eCSR_AUTH_TYPE_WPA_NONE:
3487 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3488 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3489 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 case eCSR_AUTH_TYPE_SHARED_KEY:
3491 pBssConfig->authType = eSIR_SHARED_KEY;
3492 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 case eCSR_AUTH_TYPE_AUTOSWITCH:
3494 pBssConfig->authType = eSIR_AUTO_SWITCH;
3495 break;
3496 }
3497 //short slot time
3498 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3499 {
3500 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3501 }
3502 else
3503 {
3504 pBssConfig->uShortSlotTime = 0;
3505 }
3506 //power constraint. We don't support 11h on IBSS
3507 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3508 pBssConfig->uPowerLimit = 0;
3509 //heartbeat
3510 if ( eCSR_BAND_5G == pBssConfig->eBand )
3511 {
3512 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3513 }
3514 else
3515 {
3516 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3517 }
3518 //Join timeout
3519 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003520
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 return (status);
3522}
Jeff Johnson295189b2012-06-20 16:38:30 -07003523static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3524{
3525 eHalStatus status = eHAL_STATUS_FAILURE;
3526 tDot11fBeaconIEs *pIes = NULL;
3527
3528 do
3529 {
3530 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3531 {
3532 //err msg
3533 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003534 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 break;
3536 }
3537 //check if the AP is QAP & it supports APSD
3538 if( CSR_IS_QOS_BSS(pIes) )
3539 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303540 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 }
3542 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303543
3544 if (NULL != pIes)
3545 {
3546 vos_mem_free(pIes);
3547 }
3548
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 return status;
3550}
3551
Jeff Johnson295189b2012-06-20 16:38:30 -07003552void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3553{
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3555 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3556 // See !!Note: below in this function...
3557 tANI_U32 PrivacyEnabled = 0;
3558 tANI_U32 RsnEnabled = 0;
3559 tANI_U32 WepDefaultKeyId = 0;
3560 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3561 tANI_U32 Key0Length = 0;
3562 tANI_U32 Key1Length = 0;
3563 tANI_U32 Key2Length = 0;
3564 tANI_U32 Key3Length = 0;
3565
3566 // Reserve for the biggest key
3567 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3568 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3569 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3570 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3571
3572 switch ( pProfile->negotiatedUCEncryptionType )
3573 {
3574 case eCSR_ENCRYPT_TYPE_NONE:
3575
3576 // for NO encryption, turn off Privacy and Rsn.
3577 PrivacyEnabled = 0;
3578 RsnEnabled = 0;
3579
3580 // WEP key length and Wep Default Key ID don't matter in this case....
3581
3582 // clear out the WEP keys that may be hanging around.
3583 Key0Length = 0;
3584 Key1Length = 0;
3585 Key2Length = 0;
3586 Key3Length = 0;
3587
3588 break;
3589
3590 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303591 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003592
3593 // Privacy is ON. NO RSN for Wep40 static key.
3594 PrivacyEnabled = 1;
3595 RsnEnabled = 0;
3596
3597 // Set the Wep default key ID.
3598 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 // Wep key size if 5 bytes (40 bits).
3600 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3601
3602 // set encryption keys in the CFG database or clear those that are not present in this profile.
3603 if ( pProfile->Keys.KeyLength[0] )
3604 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303605 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3606 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3608 }
3609 else
3610 {
3611 Key0Length = 0;
3612 }
3613
3614 if ( pProfile->Keys.KeyLength[1] )
3615 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303616 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3617 WNI_CFG_WEP_KEY_LENGTH_5);
3618 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 }
3620 else
3621 {
3622 Key1Length = 0;
3623 }
3624
3625 if ( pProfile->Keys.KeyLength[2] )
3626 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303627 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3628 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3630 }
3631 else
3632 {
3633 Key2Length = 0;
3634 }
3635
3636 if ( pProfile->Keys.KeyLength[3] )
3637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303638 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3639 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3641 }
3642 else
3643 {
3644 Key3Length = 0;
3645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 break;
3647
3648 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303649 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003650
3651 // Privacy is ON. NO RSN for Wep40 static key.
3652 PrivacyEnabled = 1;
3653 RsnEnabled = 0;
3654
3655 // Set the Wep default key ID.
3656 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3657
3658 // Wep key size if 13 bytes (104 bits).
3659 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3660
3661 // set encryption keys in the CFG database or clear those that are not present in this profile.
3662 if ( pProfile->Keys.KeyLength[0] )
3663 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303664 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3665 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3667 }
3668 else
3669 {
3670 Key0Length = 0;
3671 }
3672
3673 if ( pProfile->Keys.KeyLength[1] )
3674 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303675 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3676 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3678 }
3679 else
3680 {
3681 Key1Length = 0;
3682 }
3683
3684 if ( pProfile->Keys.KeyLength[2] )
3685 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303686 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3687 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3689 }
3690 else
3691 {
3692 Key2Length = 0;
3693 }
3694
3695 if ( pProfile->Keys.KeyLength[3] )
3696 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303697 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3698 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3700 }
3701 else
3702 {
3703 Key3Length = 0;
3704 }
3705
3706 break;
3707
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 case eCSR_ENCRYPT_TYPE_TKIP:
3709 case eCSR_ENCRYPT_TYPE_AES:
3710#ifdef FEATURE_WLAN_WAPI
3711 case eCSR_ENCRYPT_TYPE_WPI:
3712#endif /* FEATURE_WLAN_WAPI */
3713 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3714 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3715 PrivacyEnabled = (0 != fPrivacy);
3716
3717 // turn on RSN enabled for WPA associations
3718 RsnEnabled = 1;
3719
3720 // WEP key length and Wep Default Key ID don't matter in this case....
3721
3722 // clear out the static WEP keys that may be hanging around.
3723 Key0Length = 0;
3724 Key1Length = 0;
3725 Key2Length = 0;
3726 Key3Length = 0;
3727
3728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 default:
3730 PrivacyEnabled = 0;
3731 RsnEnabled = 0;
3732 break;
3733 }
3734
3735 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3736 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3737 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3738 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3739 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3740 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3741 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3742 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3743}
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3746{
3747 tANI_U32 len = 0;
3748 if(pSSID->length <= WNI_CFG_SSID_LEN)
3749 {
3750 len = pSSID->length;
3751 }
3752 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3753}
3754
Jeff Johnson295189b2012-06-20 16:38:30 -07003755eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3756{
3757 eHalStatus status = eHAL_STATUS_SUCCESS;
3758 tANI_U32 QoSEnabled;
3759 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 // set the CFG enable/disable variables based on the qosType being configured...
3761 switch( qosType )
3762 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3764 QoSEnabled = FALSE;
3765 WmeEnabled = TRUE;
3766 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3768 QoSEnabled = FALSE;
3769 WmeEnabled = TRUE;
3770 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3772 QoSEnabled = FALSE;
3773 WmeEnabled = TRUE;
3774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3776 QoSEnabled = TRUE;
3777 WmeEnabled = FALSE;
3778 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 case eCSR_MEDIUM_ACCESS_11e_HCF:
3780 QoSEnabled = TRUE;
3781 WmeEnabled = FALSE;
3782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 default:
3784 case eCSR_MEDIUM_ACCESS_DCF:
3785 QoSEnabled = FALSE;
3786 WmeEnabled = FALSE;
3787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 }
3789 //save the WMM setting for later use
3790 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303791 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 return (status);
3793}
Jeff Johnson295189b2012-06-20 16:38:30 -07003794static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303795 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003796{
3797 eHalStatus status = eHAL_STATUS_FAILURE;
3798 int i;
3799 eCsrCfgDot11Mode cfgDot11Mode;
3800 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303801 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303802 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3803 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003805
3806 if( NULL != pIes )
3807 {
3808 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 // Originally, we thought that for 11a networks, the 11a rates are always
3810 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3811 // appear in the Operational Rate set. Consequently, in either case, we
3812 // would blindly put the rates we support into our Operational Rate set
3813 // (including the basic rates, which we have already verified are
3814 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 // However, it turns out that this is not always the case. Some AP's
3816 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3817 // too. Now, we're a little more careful:
3818 pDstRate = pOpRateSet->rate;
3819 if(pIes->SuppRates.present)
3820 {
3821 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3822 {
3823 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3824 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003825 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3826 {
3827 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3828 *pDstRate++ = pIes->SuppRates.rates[ i ];
3829 pOpRateSet->numRates++;
3830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 }
3832 }
3833 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303834 /* If there are Extended Rates in the beacon, we will reflect those
3835 * extended rates that we support in out Extended Operational Rate
3836 * set*/
3837 pDstRate = pExRateSet->rate;
3838 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303840 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303842 if (csrRatesIsDot11RateSupported(pMac,
3843 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303845 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3846 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303848 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3849 &rateBitmap);
3850 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3851 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 }
3853 }
3854 }
3855 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303856 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 }//Parsing BSSDesc
3858 else
3859 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003860 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 }
3862 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3863 return status;
3864}
3865
3866static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3867 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3868{
3869 int i;
3870 tANI_U8 *pDstRate;
3871 eCsrCfgDot11Mode cfgDot11Mode;
3872 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3873 tANI_U32 OperationalRatesLength = 0;
3874 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3875 tANI_U32 ExtendedOperationalRatesLength = 0;
3876 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3877 tANI_U32 ProprietaryOperationalRatesLength = 0;
3878 tANI_U32 PropRatesEnable = 0;
3879 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3880 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 if( NULL != pIes )
3883 {
3884 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 // Originally, we thought that for 11a networks, the 11a rates are always
3886 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3887 // appear in the Operational Rate set. Consequently, in either case, we
3888 // would blindly put the rates we support into our Operational Rate set
3889 // (including the basic rates, which we have already verified are
3890 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 // However, it turns out that this is not always the case. Some AP's
3892 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3893 // too. Now, we're a little more careful:
3894 pDstRate = OperationalRates;
3895 if(pIes->SuppRates.present)
3896 {
3897 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3898 {
3899 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3900 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3901 {
3902 *pDstRate++ = pIes->SuppRates.rates[ i ];
3903 OperationalRatesLength++;
3904 }
3905 }
3906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3908 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3909 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3910 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3911 {
3912 // If there are Extended Rates in the beacon, we will reflect those
3913 // extended rates that we support in out Extended Operational Rate
3914 // set:
3915 pDstRate = ExtendedOperationalRates;
3916 if(pIes->ExtSuppRates.present)
3917 {
3918 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3919 {
3920 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3921 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3922 {
3923 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3924 ExtendedOperationalRatesLength++;
3925 }
3926 }
3927 }
3928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 // Enable proprietary MAC features if peer node is Airgo node and STA
3930 // user wants to use them
3931 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3932 {
3933 PropRatesEnable = 1;
3934 }
3935 else
3936 {
3937 PropRatesEnable = 0;
3938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 // For ANI network companions, we need to populate the proprietary rate
3940 // set with any proprietary rates we found in the beacon, only if user
3941 // allows them...
3942 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3943 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3944 {
3945 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3946 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3947 {
3948 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3949 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303950 vos_mem_copy(ProprietaryOperationalRates,
3951 pIes->Airgo.PropSuppRates.rates,
3952 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 }
3954 else {
3955 // No proprietary modes...
3956 ProprietaryOperationalRatesLength = 0;
3957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 /* Get MCS Rate */
3959 pDstRate = MCSRateIdxSet;
3960 if ( pIes->HTCaps.present )
3961 {
3962 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3963 {
3964 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3965 {
3966 MCSRateLength++;
3967 *pDstRate++ = i;
3968 }
3969 }
3970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 // Set the operational rate set CFG variables...
3972 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3973 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3974 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3975 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3976 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3977 ProprietaryOperationalRates,
3978 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3979 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3980 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3981 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3982 }//Parsing BSSDesc
3983 else
3984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003985 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987}
3988
Jeff Johnson295189b2012-06-20 16:38:30 -07003989static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3990 tCsrRoamProfile *pProfile )
3991{
3992 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3993 { 8,
3994 { SIR_MAC_RATE_6,
3995 SIR_MAC_RATE_9,
3996 SIR_MAC_RATE_12,
3997 SIR_MAC_RATE_18,
3998 SIR_MAC_RATE_24,
3999 SIR_MAC_RATE_36,
4000 SIR_MAC_RATE_48,
4001 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4003 { 4,
4004 { SIR_MAC_RATE_1,
4005 SIR_MAC_RATE_2,
4006 SIR_MAC_RATE_5_5,
4007 SIR_MAC_RATE_11 } } };
4008
4009
4010 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4011 { SIR_MAC_RATE_72,
4012 SIR_MAC_RATE_96,
4013 SIR_MAC_RATE_108 } };
4014 eCsrCfgDot11Mode cfgDot11Mode;
4015 eCsrBand eBand;
4016 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4017 tANI_U32 OperationalRatesLength = 0;
4018 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4019 tANI_U32 ExtendedOperationalRatesLength = 0;
4020 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
4021 tANI_U32 ProprietaryOperationalRatesLength = 0;
4022 tANI_U32 PropRatesEnable = 0;
4023 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 if(pProfile->ChannelInfo.ChannelList)
4025 {
4026 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4030 // networks, the 11b rates appear in the Operational Rate set. In either case,
4031 // we can blindly put the rates we support into our Operational Rate set
4032 // (including the basic rates, which we have already verified are supported
4033 // earlier in the roaming decision).
4034 if ( eCSR_BAND_5G == eBand )
4035 {
4036 // 11a rates into the Operational Rate Set.
4037 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4038 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304039 vos_mem_copy(OperationalRates,
4040 DefaultSupportedRates11a.supportedRateSet.rate,
4041 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004042
4043 // Nothing in the Extended rate set.
4044 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 // populate proprietary rates if user allows them
4046 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4047 {
4048 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4049 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304050 vos_mem_copy(ProprietaryOperationalRates,
4051 DefaultSupportedPropRates.propRate,
4052 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 }
4054 else
4055 {
4056 // No proprietary modes
4057 ProprietaryOperationalRatesLength = 0;
4058 }
4059 }
4060 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4061 {
4062 // 11b rates into the Operational Rate Set.
4063 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4064 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304065 vos_mem_copy(OperationalRates,
4066 DefaultSupportedRates11b.supportedRateSet.rate,
4067 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 // Nothing in the Extended rate set.
4069 ExtendedOperationalRatesLength = 0;
4070 // No proprietary modes
4071 ProprietaryOperationalRatesLength = 0;
4072 }
4073 else
4074 {
4075 // 11G
4076
4077 // 11b rates into the Operational Rate Set.
4078 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4079 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304080 vos_mem_copy(OperationalRates,
4081 DefaultSupportedRates11b.supportedRateSet.rate,
4082 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004083
4084 // 11a rates go in the Extended rate set.
4085 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4086 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304087 vos_mem_copy(ExtendedOperationalRates,
4088 DefaultSupportedRates11a.supportedRateSet.rate,
4089 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004090
4091 // populate proprietary rates if user allows them
4092 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4093 {
4094 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4095 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304096 vos_mem_copy(ProprietaryOperationalRates,
4097 DefaultSupportedPropRates.propRate,
4098 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 }
4100 else
4101 {
4102 // No proprietary modes
4103 ProprietaryOperationalRatesLength = 0;
4104 }
4105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4107 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4108 {
4109 PropRatesEnable = 1;
4110 }
4111 else
4112 {
4113 PropRatesEnable = 0;
4114 }
4115
4116 // Set the operational rate set CFG variables...
4117 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4118 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4119 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4120 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4121 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4122 ProprietaryOperationalRates,
4123 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4124 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004125}
Jeff Johnson295189b2012-06-20 16:38:30 -07004126void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4127{
4128 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004129
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4131 tANI_U32 sessionId;
4132 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 if(NULL == pEntry)
4134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004135 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 return;
4137 }
4138 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4139 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304140 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4141 " current state : %d sub state : %d "),
4142 result, pMac->roam.curState[sessionId],
4143 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4145 {
4146 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4147 }
4148}
4149
Jeff Johnson295189b2012-06-20 16:38:30 -07004150//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4151tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4152{
4153 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4154 {
4155 return (WNI_CFG_PHY_MODE_11B);
4156 }
4157 else
4158 {
4159 if(eCSR_BAND_24 == band)
4160 return (WNI_CFG_PHY_MODE_11G);
4161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 return (WNI_CFG_PHY_MODE_11A);
4163}
Jeff Johnson295189b2012-06-20 16:38:30 -07004164
Jeff Johnsone7245742012-09-05 17:12:55 -07004165
4166#ifdef WLAN_FEATURE_11AC
4167ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4168{
4169 switch ( aniCBMode )
4170 {
4171 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4172 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4173 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4174 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4175 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4176 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4177 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4178 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4179 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004180 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004181 return PHY_SINGLE_CHANNEL_CENTERED;
4182 }
4183}
4184#endif
4185
Jeff Johnson295189b2012-06-20 16:38:30 -07004186//pIes may be NULL
4187eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4188 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304189 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004190{
4191 eHalStatus status = eHAL_STATUS_SUCCESS;
4192 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4193 tANI_U8 channel = 0;
4194 //Make sure we have the domain info for the BSS we try to connect to.
4195 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304196 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304198 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 {
4200 //Make sure the 11d info from this BSSDesc can be applied
4201 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304202 if (VOS_TRUE == resetCountry)
4203 {
4204 csrApplyCountryInformation(pMac, FALSE);
4205 }
4206 else
4207 {
4208 csrApplyCountryInformation(pMac, TRUE);
4209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 }
Kiran4a17ebe2013-01-31 10:43:43 -08004211 if ((csrIs11dSupported (pMac)) && pIes)
4212 {
4213 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004214 {
Kiran4a17ebe2013-01-31 10:43:43 -08004215 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004216 }
4217 else
4218 {
4219 //Let's also update the below to make sure we don't update CC while
4220 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304221 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004222 pBssDesc->bssId, sizeof(tSirMacAddr));
4223 }
Kiran4a17ebe2013-01-31 10:43:43 -08004224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 //Qos
4227 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4228 //SSID
4229 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4230 //fragment threshold
4231 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4232 //RTS threshold
4233 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4234
4235 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 //Auth type
4237 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4238 //encryption type
4239 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4240 //short slot time
4241 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 //11d
4243 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4244 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4245 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 /*//11h
4247 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4248 */
4249 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4250 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004251
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004252 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 {
4254 channel = pProfile->operationChannel;
4255 }
4256 else
4257 {
4258 if(pBssDesc)
4259 {
4260 channel = pBssDesc->channelId;
4261 }
4262 }
4263 if(0 != channel)
4264 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304265 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4266 !pMac->roam.configParam.channelBondingMode24GHz &&
4267 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4268 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304270 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4271 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4272 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 }
4274 else
4275 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004276 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 }
4278 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004279#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004280 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4281 // in function csrConvertCBIniValueToPhyCBState()
4282 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4283 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004284 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004285 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004286 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004287 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304288 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004289 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004290 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004291 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004292 }
4293 else
4294#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4296 //Rate
4297 //Fixed Rate
4298 if(pBssDesc)
4299 {
4300 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4301 }
4302 else
4303 {
4304 csrSetCfgRateSetFromProfile(pMac, pProfile);
4305 }
4306 //Make this the last CFG to set. The callback will trigger a join_req
4307 //Join time out
4308 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4309
4310 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 return (status);
4312}
4313
Jeff Johnson295189b2012-06-20 16:38:30 -07004314eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4315 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4316{
4317 eHalStatus status;
4318 tBssConfigParam *pBssConfig;
4319 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004320
4321 if(!pSession)
4322 {
4323 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4324 return eHAL_STATUS_FAILURE;
4325 }
4326
Kiet Lam64c1b492013-07-12 13:56:44 +05304327 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4328 if ( NULL == pBssConfig )
4329 status = eHAL_STATUS_FAILURE;
4330 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304332 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4334 if(HAL_STATUS_SUCCESS(status))
4335 {
4336 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004337 /* This will allow to pass cbMode during join req */
4338 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 //For IBSS, we need to prepare some more information
4340 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 )
4343 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004344 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 }
4346 // If we are in an IBSS, then stop the IBSS...
4347 ////Not worry about WDS connection for now
4348 if ( csrIsConnStateIbss( pMac, sessionId ) )
4349 {
4350 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4351 }
4352 else
4353 {
4354 // if we are in an Infrastructure association....
4355 if ( csrIsConnStateInfra( pMac, sessionId ) )
4356 {
4357 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4358 // across SSIDs (roaming to a new SSID)... //
4359 //Not worry about WDS connection for now
4360 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304361 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 {
4363 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304364 status = csrRoamIssueDisassociate( pMac, sessionId,
4365 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304367 else
4368 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4370 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304371 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304373 // Set parameters for this Bss.
4374 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4375 pBssDesc, pBssConfig,
4376 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304380 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 {
4382 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4383 // Nothing to stop.
4384 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304386 )
4387 {
4388 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4389 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4390 // Set parameters for this Bss.
4391 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4392 pBssDesc, pBssConfig,
4393 pIes, is11rRoamingFlag);
4394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 }
4396 }
4397 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304398 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 return (status);
4401}
4402
Jeff Johnson295189b2012-06-20 16:38:30 -07004403eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4404 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4405{
4406 eCsrJoinState eRoamState = eCsrContinueRoaming;
4407 eHalStatus status;
4408 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4409 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4410 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004411
4412 if(!pSession)
4413 {
4414 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4415 return (eCsrStopRoaming);
4416 }
4417
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 if( CSR_IS_WDS_STA( pProfile ) )
4419 {
4420 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4421 if( !HAL_STATUS_SUCCESS( status ) )
4422 {
4423 eRoamState = eCsrStopRoaming;
4424 }
4425 }
4426 else
4427 {
4428 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4429 {
4430 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4431 return (eCsrStopRoaming);
4432 }
4433 if ( csrIsInfraBssDesc( pBssDesc ) )
4434 {
4435 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4436 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4437 // have changed and handle the changes (without disturbing the current association).
4438
4439 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4440 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4441 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4442 )
4443 {
4444 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4445 // with Authenticating first. To force this, stop the current association (Disassociate) and
4446 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4447 // a new Association.
4448 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4449 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004450 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4452 {
4453 eRoamState = eCsrReassocToSelfNoCapChange;
4454 }
4455 else
4456 {
4457 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304459 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4461 if(HAL_STATUS_SUCCESS(status))
4462 {
4463 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004464 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304466 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4467 pBssDesc, &bssConfig,
4468 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 if(!HAL_STATUS_SUCCESS(status))
4470 {
4471 eRoamState = eCsrStopRoaming;
4472 }
4473 }
4474 else
4475 {
4476 eRoamState = eCsrStopRoaming;
4477 }
4478 }//same profile
4479 }
4480 else
4481 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304482 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4484 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304485 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4486 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304490 }
4491 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 {
4493 // 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 -07004494 // stop the existing network before attempting to join the new network...
4495 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4496 {
4497 eRoamState = eCsrStopRoaming;
4498 }
4499 }
4500 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304501 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 {
4503 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4504 {
4505 eRoamState = eCsrStopRoaming;
4506 }
4507 }
4508 if( pIesLocal && !pScanResult->pvIes )
4509 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304510 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 return( eRoamState );
4514}
4515
Jeff Johnson295189b2012-06-20 16:38:30 -07004516eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4517 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4518{
4519 eHalStatus status = eHAL_STATUS_SUCCESS;
4520 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304521 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 roamInfo.pBssDesc = pBssDesc;
4523 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4524 return (status);
4525}
Jeff Johnson295189b2012-06-20 16:38:30 -07004526//In case no matching BSS is found, use whatever default we can find
4527static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4528{
4529 //Need to get all negotiated types in place first
4530 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004531 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 {
4533 default:
4534 case eCSR_AUTH_TYPE_WPA:
4535 case eCSR_AUTH_TYPE_WPA_PSK:
4536 case eCSR_AUTH_TYPE_WPA_NONE:
4537 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4538 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4539 break;
4540
4541 case eCSR_AUTH_TYPE_SHARED_KEY:
4542 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4543 break;
4544
4545 case eCSR_AUTH_TYPE_AUTOSWITCH:
4546 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4547 break;
4548 }
4549 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4550 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4551 //In this case, the multicast encryption needs to follow the uncast ones.
4552 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4553 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4554}
4555
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004556
4557static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4558{
4559 switch(pCommand->u.roamCmd.roamReason)
4560 {
4561 case eCsrLostLink1:
4562 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4563 break;
4564 case eCsrLostLink2:
4565 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4566 break;
4567 case eCsrLostLink3:
4568 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4569 break;
4570 default:
4571 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4572 pCommand->u.roamCmd.roamReason);
4573 break;
4574 }
4575}
4576
Jeff Johnson295189b2012-06-20 16:38:30 -07004577static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4578{
4579 eHalStatus status;
4580 tCsrScanResult *pScanResult = NULL;
4581 eCsrJoinState eRoamState = eCsrStopRoaming;
4582 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4583 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4584 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4585#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4586 v_U8_t acm_mask = 0;
4587#endif
4588 tANI_U32 sessionId = pCommand->sessionId;
4589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4590 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4591 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004592
4593 if(!pSession)
4594 {
4595 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4596 return (eCsrStopRoaming);
4597 }
4598
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 do
4600 {
4601 // Check for Cardbus eject condition, before trying to Roam to any BSS
4602 //***if( !balIsCardPresent(pAdapter) ) break;
4603
Kiet Lam64c1b492013-07-12 13:56:44 +05304604 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304605 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 if(NULL != pBSSList)
4607 {
4608 // When handling AP's capability change, continue to associate to
4609 // same BSS and make sure pRoamBssEntry is not Null.
4610 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4611 {
4612 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4613 {
4614 //Try the first BSS
4615 pCommand->u.roamCmd.pLastRoamBss = NULL;
4616 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4617 }
4618 else
4619 {
4620 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4621 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4622 {
4623 //Done with all the BSSs
4624 //In this case, will tell HDD the completion
4625 break;
4626 }
4627 else
4628 {
4629 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304630 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4632 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4633 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4634 pRoamInfo = &roamInfo;
4635 }
4636 }
4637 while(pCommand->u.roamCmd.pRoamBssEntry)
4638 {
4639 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 /*If concurrency enabled take the concurrent connected channel first. */
4641 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304642 if (vos_concurrent_open_sessions_running() &&
4643 !csrIsValidMcConcurrentSession(pMac, sessionId,
4644 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 {
4646 concurrentChannel =
4647 csrGetConcurrentOperationChannel(pMac);
4648 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004649 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 if ((concurrentChannel) &&
4651 (concurrentChannel ==
4652 pScanResult->Result.BssDescriptor.channelId))
4653 {
4654 //make this 0 because we do not want the
4655 //below check to pass as we don't want to
4656 //connect on other channel
4657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4658 FL("Concurrent channel match =%d"),
4659 concurrentChannel);
4660 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 }
4662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004663
4664 if (!concurrentChannel)
4665 {
4666
4667 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4668 sessionId, &pScanResult->Result.BssDescriptor,
4669 pCommand->u.roamCmd.roamId)))
4670 {
4671 //Ok to roam this
4672 break;
4673 }
4674 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004675 else
4676 {
4677 eRoamState = eCsrStopRoamingDueToConcurrency;
4678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4680 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4681 {
4682 //Done with all the BSSs
4683 fDone = eANI_BOOLEAN_TRUE;
4684 break;
4685 }
4686 }
4687 if(fDone)
4688 {
4689 break;
4690 }
4691 }
4692 }
4693 //We have something to roam, tell HDD when it is infra.
4694 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4695 //For WDS, the indication is eCSR_ROAM_WDS_IND
4696 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4697 {
4698 if(pRoamInfo)
4699 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004700 if(pSession->bRefAssocStartCnt)
4701 {
4702 pSession->bRefAssocStartCnt--;
4703 //Complete the last association attemp because a new one is about to be tried
4704 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4705 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004707 }
4708 }
4709 /* If the roaming has stopped, not to continue the roaming command*/
4710 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4711 {
4712 //No need to complete roaming here as it already completes
4713 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4714 pCommand->u.roamCmd.roamReason);
4715 eRoamState = eCsrStopRoaming;
4716 csrSetAbortRoamingCommand(pMac, pCommand);
4717 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304719 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 if(pScanResult)
4721 {
4722 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004725 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 fDone = eANI_BOOLEAN_TRUE;
4727 eRoamState = eCsrStopRoaming;
4728 break;
4729 }
4730 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4731 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4732 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4733 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4734 CSR_IS_QOS_BSS(pIesLocal) &&
4735 CSR_IS_UAPSD_BSS(pIesLocal) )
4736 {
4737#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4739 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004740#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 }
4742 else
4743 {
4744 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4745 }
4746 if( pIesLocal && !pScanResult->Result.pvIes)
4747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304748 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 }
4750 }
4751 else
4752 {
4753 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4754 }
4755 roamInfo.pProfile = pProfile;
4756 pSession->bRefAssocStartCnt++;
4757 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4758 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4761 {
4762 // If this is a start IBSS profile, then we need to start the IBSS.
4763 if ( CSR_IS_START_IBSS(pProfile) )
4764 {
4765 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 // Attempt to start this IBSS...
4767 csrRoamAssignDefaultParam( pMac, pCommand );
4768 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4769 if(HAL_STATUS_SUCCESS(status))
4770 {
4771 if ( fSameIbss )
4772 {
4773 eRoamState = eCsrStartIbssSameIbss;
4774 }
4775 else
4776 {
4777 eRoamState = eCsrContinueRoaming;
4778 }
4779 }
4780 else
4781 {
4782 //it somehow fail need to stop
4783 eRoamState = eCsrStopRoaming;
4784 }
4785 break;
4786 }
4787 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 )
4790 {
4791 // Attempt to start this WDS...
4792 csrRoamAssignDefaultParam( pMac, pCommand );
4793 /* For AP WDS, we dont have any BSSDescription */
4794 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4795 if(HAL_STATUS_SUCCESS(status))
4796 {
4797 eRoamState = eCsrContinueRoaming;
4798 }
4799 else
4800 {
4801 //it somehow fail need to stop
4802 eRoamState = eCsrStopRoaming;
4803 }
4804 }
4805 else
4806 {
4807 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004808 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 eRoamState = eCsrStopRoaming;
4810 break;
4811 }
4812 }
4813 else //We have BSS
4814 {
4815 //Need to assign these value because they are used in csrIsSameProfile
4816 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004817 /* The OSEN IE doesn't provide the cipher suite.
4818 * Therefore set to constant value of AES */
4819 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4820 {
4821 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4822 eCSR_ENCRYPT_TYPE_AES;
4823 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4824 eCSR_ENCRYPT_TYPE_AES;
4825 }
4826 else
4827 {
4828 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4829 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4830 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4831 pScanResult->mcEncryptionType;
4832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4834 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4835 {
4836 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4837 {
4838 eRoamState = eCsrStartIbssSameIbss;
4839 break;
4840 }
4841 }
4842 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4843 {
4844 //trying to connect to the one already connected
4845 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4846 eRoamState = eCsrReassocToSelfNoCapChange;
4847 break;
4848 }
4849 // Attempt to Join this Bss...
4850 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4851 break;
4852 }
4853
4854 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4856 {
4857 //Need to indicate association_completion if association_start has been done
4858 if(pSession->bRefAssocStartCnt > 0)
4859 {
4860 pSession->bRefAssocStartCnt--;
4861 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004862 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4864 eCSR_ROAM_ASSOCIATION_COMPLETION,
4865 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4866 }
4867 }
4868
4869 return( eRoamState );
4870}
4871
Jeff Johnson295189b2012-06-20 16:38:30 -07004872static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4873{
4874 eHalStatus status = eHAL_STATUS_SUCCESS;
4875 eCsrJoinState RoamState;
4876 tANI_U32 sessionId = pCommand->sessionId;
4877
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 //***if( hddIsRadioStateOn( pAdapter ) )
4879 {
4880 // Attept to join a Bss...
4881 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004882
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004884 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 {
4886 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 // and if connected in Infrastructure mode...
4888 if ( csrIsConnStateInfra(pMac, sessionId) )
4889 {
4890 //... then we need to issue a disassociation
4891 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4892 if(!HAL_STATUS_SUCCESS(status))
4893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004894 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 //roam command is completed by caller in the failed case
4896 fComplete = eANI_BOOLEAN_TRUE;
4897 }
4898 }
4899 else if( csrIsConnStateIbss(pMac, sessionId) )
4900 {
4901 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4902 if(!HAL_STATUS_SUCCESS(status))
4903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004904 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 //roam command is completed by caller in the failed case
4906 fComplete = eANI_BOOLEAN_TRUE;
4907 }
4908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4910 {
4911 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4912 if(!HAL_STATUS_SUCCESS(status))
4913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004914 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 //roam command is completed by caller in the failed case
4916 fComplete = eANI_BOOLEAN_TRUE;
4917 }
4918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 else
4920 {
4921 fComplete = eANI_BOOLEAN_TRUE;
4922 }
4923 if(fComplete)
4924 {
4925 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004926 if(eCsrStopRoamingDueToConcurrency == RoamState)
4927 {
4928 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4929 }
4930 else
4931 {
4932 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 }
4935 }
4936 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4937 {
4938 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4939 }
4940 else if ( eCsrStartIbssSameIbss == RoamState )
4941 {
4942 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4943 }
4944 }//hddIsRadioStateOn
4945
4946 return status;
4947}
Jeff Johnson295189b2012-06-20 16:38:30 -07004948eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4949{
4950 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05304951 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 tCsrScanResult *pScanResult = NULL;
4953 tSirBssDescription *pBssDesc = NULL;
4954 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 sessionId = pCommand->sessionId;
4956 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004957
4958 if(!pSession)
4959 {
4960 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4961 return eHAL_STATUS_FAILURE;
4962 }
4963
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4965 {
4966 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004967 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4969 return eHAL_STATUS_FAILURE;
4970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 if (pCommand->u.roamCmd.pRoamBssEntry)
4972 {
4973 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4974 pBssDesc = &pScanResult->Result.BssDescriptor;
4975 }
4976 else
4977 {
4978 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004979 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4981 return eHAL_STATUS_FAILURE;
4982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4984 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4985 return status;
4986}
4987
Jeff Johnson295189b2012-06-20 16:38:30 -07004988eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4989{
4990 eHalStatus status = eHAL_STATUS_SUCCESS;
4991 tCsrRoamInfo roamInfo;
4992 tANI_U32 sessionId = pCommand->sessionId;
4993 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004994
4995 if(!pSession)
4996 {
4997 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4998 return eHAL_STATUS_FAILURE;
4999 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05305000 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5001 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 switch ( pCommand->u.roamCmd.roamReason )
5003 {
5004 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005006 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 case eCsrSmeIssuedDisassocForHandoff:
5009 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
5010#if 0 // TODO : Confirm this change
5011 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
5012#else
5013 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
5014#endif
5015
5016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005019 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005023 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 case eCsrHddIssuedReassocToSameAP:
5026 case eCsrSmeIssuedReassocToSameAP:
5027 {
5028 tDot11fBeaconIEs *pIes = NULL;
5029
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 if( pSession->pConnectBssDesc )
5031 {
5032 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5033 if(!HAL_STATUS_SUCCESS(status) )
5034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005035 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 }
5037 else
5038 {
5039 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5040 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5041 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5043 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5044 pSession->bRefAssocStartCnt++;
5045 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5046 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5047
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005048 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005049 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5050 &pCommand->u.roamCmd.roamProfile );
5051 if(!HAL_STATUS_SUCCESS(status))
5052 {
5053 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005054 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005055 }
5056
Kiet Lam64c1b492013-07-12 13:56:44 +05305057 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 pIes = NULL;
5059 }
5060 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305061 else
5062 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 break;
5064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005066 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5068 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5069 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005071 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5073 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005074
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 case eCsrStopBss:
5076 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5077 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5078 break;
5079
5080 case eCsrForcedDisassocSta:
5081 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5082 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5083 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5084 pCommand->u.roamCmd.reason);
5085 break;
5086
5087 case eCsrForcedDeauthSta:
5088 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5089 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5090 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5091 pCommand->u.roamCmd.reason);
5092 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005093
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005094 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005095 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005096 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5097 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005098 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005099
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305100#ifdef WLAN_FEATURE_LFR_MBB
5101 case ecsr_mbb_perform_preauth_reassoc:
5102 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5103 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5104 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305105 if (eHAL_STATUS_SUCCESS != status)
5106 {
5107 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5108 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5109 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5110 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305111 break;
5112#endif
5113
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 default:
5115 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5116
5117 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5118 {
5119 //Remember the roaming profile
5120 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305121 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5122 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305124 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5126 }
5127 }
5128
5129 //At this point, original uapsd_mask is saved in pCurRoamProfile
5130 //uapsd_mask in the pCommand may change from this point on.
5131
5132 // Attempt to roam with the new scan results (if we need to..)
5133 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005134 if(!HAL_STATUS_SUCCESS(status))
5135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005136 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 break;
5139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 return (status);
5141}
5142
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005143void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5144{
5145 pCommand->u.roamCmd.pLastRoamBss = NULL;
5146 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5147 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305148 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005149}
5150
Jeff Johnson295189b2012-06-20 16:38:30 -07005151void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5152{
5153 if(pCommand->u.roamCmd.fReleaseBssList)
5154 {
5155 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5156 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5157 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5158 }
5159 if(pCommand->u.roamCmd.fReleaseProfile)
5160 {
5161 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5162 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5163 }
5164 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5165 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305166 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005167}
5168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5170{
Kiet Lam64c1b492013-07-12 13:56:44 +05305171 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005172}
Jeff Johnson295189b2012-06-20 16:38:30 -07005173void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5174{
5175 tListElem *pEntry;
5176 tSmeCmd *pCommand;
5177 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005178 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5180 if ( pEntry )
5181 {
5182 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 // If the head of the queue is Active and it is a ROAM command, remove
5184 // and put this on the Free queue.
5185 if ( eSmeCommandRoam == pCommand->command )
5186 {
5187 //we need to process the result first before removing it from active list because state changes
5188 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5189 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5190 if( fReleaseCommand )
5191 {
5192 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5193 {
5194 csrReleaseCommandRoam( pMac, pCommand );
5195 }
5196 else
5197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005198 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005199 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 }
5201 }
5202 else
5203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005204 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005205 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 }
5207 }
5208 else
5209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005210 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 }
5212 }
5213 else
5214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005215 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 if( fReleaseCommand )
5218 {
5219 smeProcessPendingQueue( pMac );
5220 }
5221}
5222
Jeff Johnson295189b2012-06-20 16:38:30 -07005223void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5224{
5225 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005226 if(!pSession)
5227 {
5228 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5229 return;
5230 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305231 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5232 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 pSession->NumPmkidCandidate = 0;
5234}
Jeff Johnson295189b2012-06-20 16:38:30 -07005235#ifdef FEATURE_WLAN_WAPI
5236void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5237{
5238 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005239 if(!pSession)
5240 {
5241 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5242 return;
5243 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305244 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5245 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 pSession->NumBkidCandidate = 0;
5247}
5248#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005249extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5250
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305251eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5252 tANI_U32 sessionId, eCsrAuthType authType,
5253 tSirBssDescription *pSirBssDesc,
5254 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005255{
5256 eHalStatus status = eHAL_STATUS_SUCCESS;
5257 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5258 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005259
5260 if(!pSession)
5261 {
5262 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5263 return eHAL_STATUS_FAILURE;
5264 }
5265
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 if((eCSR_AUTH_TYPE_WPA == authType) ||
5267 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5268 (eCSR_AUTH_TYPE_RSN == authType) ||
5269 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5270#if defined WLAN_FEATURE_VOWIFI_11R
5271 ||
5272 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5273 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5274#endif /* FEATURE_WLAN_WAPI */
5275#ifdef FEATURE_WLAN_WAPI
5276 ||
5277 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5278 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5279#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005280#ifdef WLAN_FEATURE_11W
5281 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305282 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5283 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005284#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 )
5286 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005289 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 }
5291 if( pIesLocal )
5292 {
5293 tANI_U32 nIeLen;
5294 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 if((eCSR_AUTH_TYPE_RSN == authType) ||
5296#if defined WLAN_FEATURE_VOWIFI_11R
5297 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5298 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5299#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005300#if defined WLAN_FEATURE_11W
5301 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305302 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5305 {
5306 if(pIesLocal->RSN.present)
5307 {
5308 //Calculate the actual length
5309 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5310 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5311 + 2 //akm_suite_count
5312 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5313 + 2; //reserved
5314 if( pIesLocal->RSN.pmkid_count )
5315 {
5316 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5317 }
5318 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305319 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5320 if (NULL == pSession->pWpaRsnRspIE)
5321 status = eHAL_STATUS_FAILURE;
5322 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305324 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5326 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5327 //copy upto akm_suites
5328 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305329 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5330 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005331 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305332 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5333 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005334 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305335 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5336 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005337 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 if( pIesLocal->RSN.pwise_cipher_suite_count )
5339 {
5340 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305341 vos_mem_copy(pIeBuf,
5342 pIesLocal->RSN.pwise_cipher_suites,
5343 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5345 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305346 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 pIeBuf += 2;
5348 if( pIesLocal->RSN.akm_suite_count )
5349 {
5350 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305351 vos_mem_copy(pIeBuf,
5352 pIesLocal->RSN.akm_suites,
5353 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5355 }
5356 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305357 vos_mem_copy(pIeBuf,
5358 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5359 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5361 }
5362 }
5363 }
5364 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5365 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5366 {
5367 if(pIesLocal->WPA.present)
5368 {
5369 //Calculate the actual length
5370 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5371 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5372 + 2 //auth_suite_count
5373 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5374 // The WPA capabilities follows the Auth Suite (two octects)--
5375 // this field is optional, and we always "send" zero, so just
5376 // remove it. This is consistent with our assumptions in the
5377 // frames compiler; c.f. bug 15234:
5378 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305379
5380 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5381 if ( NULL == pSession->pWpaRsnRspIE )
5382 status = eHAL_STATUS_FAILURE;
5383 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 {
5385 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5386 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5387 pIeBuf = pSession->pWpaRsnRspIE + 2;
5388 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305389 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305391 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5392 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305394 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5395 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5397 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5398 }
5399 }
5400 }
5401#ifdef FEATURE_WLAN_WAPI
5402 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5403 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5404 {
5405 if(pIesLocal->WAPI.present)
5406 {
5407 //Calculate the actual length
5408 nIeLen = 4 //version + akm_suite_count
5409 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5410 + 2 //pwise_cipher_suite_count
5411 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5412 + 6; //gp_cipher_suite + preauth + reserved
5413 if( pIesLocal->WAPI.bkid_count )
5414 {
5415 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5416 }
5417
5418 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305419 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5420 if ( NULL == pSession->pWapiRspIE )
5421 status = eHAL_STATUS_FAILURE;
5422 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 {
5424 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5425 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5426 pIeBuf = pSession->pWapiRspIE + 2;
5427 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305428 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 pIeBuf += 4;
5430 if( pIesLocal->WAPI.akm_suite_count )
5431 {
5432 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305433 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5434 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305436 }
5437 vos_mem_copy(pIeBuf,
5438 &pIesLocal->WAPI.unicast_cipher_suite_count,
5439 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5442 {
5443 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305444 vos_mem_copy( pIeBuf,
5445 pIesLocal->WAPI.unicast_cipher_suites,
5446 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5448 }
lukez3c809222013-05-03 10:23:02 -07005449 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305450 vos_mem_copy(pIeBuf,
5451 pIesLocal->WAPI.multicast_cipher_suite,
5452 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005453 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305454 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305455 vos_mem_copy(pIeBuf,
5456 pIesLocal->WAPI.multicast_cipher_suite + 4,
5457 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005458 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305459 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305461 //bkid_count
5462 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5463 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305465 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5466 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5468 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305469 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 }
5472 }
5473#endif /* FEATURE_WLAN_WAPI */
5474 if( !pIes )
5475 {
5476 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305477 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 }
5479 }
5480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 return (status);
5482}
5483
Jeff Johnson295189b2012-06-20 16:38:30 -07005484static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5485{
5486 v_U8_t bACWeights[WLANTL_MAX_AC];
5487 v_U8_t paramBk, paramBe, paramVi, paramVo;
5488 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5490 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5491 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5492 //This doesn't address the case where the lower AC needs a real higher weight
5493 if( pIEs->WMMParams.present )
5494 {
5495 //no change to the lowest ones
5496 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5497 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5498 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5499 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5500 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5501 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5502 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5503 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5504 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5505 {
5506 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5507 fWeightChange = VOS_TRUE;
5508 }
5509 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5510 {
5511 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5512 fWeightChange = VOS_TRUE;
5513 }
5514 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5515 {
5516 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5517 fWeightChange = VOS_TRUE;
5518 }
5519 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5520 {
5521 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5522 fWeightChange = VOS_TRUE;
5523 }
5524 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5525 {
5526 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5527 fWeightChange = VOS_TRUE;
5528 }
5529 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5530 {
5531 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5532 fWeightChange = VOS_TRUE;
5533 }
5534 if(fWeightChange)
5535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005536 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 bACWeights[2], bACWeights[3]);
5538 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5539 }
5540 }
5541}
Jeff Johnson295189b2012-06-20 16:38:30 -07005542#ifdef WLAN_FEATURE_VOWIFI_11R
5543//Returns whether the current association is a 11r assoc or not
5544tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5545{
5546#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5547 return csrNeighborRoamIs11rAssoc(pMac);
5548#else
5549 return eANI_BOOLEAN_FALSE;
5550#endif
5551}
5552#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005553#ifdef FEATURE_WLAN_ESE
5554//Returns whether the current association is a ESE assoc or not
5555tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005556{
5557#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005558 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005559#else
5560 return eANI_BOOLEAN_FALSE;
5561#endif
5562}
5563#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005564#ifdef FEATURE_WLAN_LFR
5565//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305566tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005567{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305568 tCsrRoamSession *pSession = NULL;
5569
5570 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5571 {
5572 pSession = CSR_GET_SESSION( pMac, sessionId );
5573 if (NULL != pSession->pCurRoamProfile)
5574 {
5575 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5576 {
5577 return eANI_BOOLEAN_FALSE;
5578 }
5579 }
5580 }
5581
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005582#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5583 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5584 {
5585 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5586 }
5587 else
5588#endif
5589 {
5590 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005591 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005592 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005593}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005594
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005595#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005596/* ---------------------------------------------------------------------------
5597
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005598 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005599
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005600 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005601
5602 \param pMac - The handle returned by macOpen.
5603
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005604 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005605
5606---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005607tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005608{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005609 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005610}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005611#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005612
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005613#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5614//Returns whether "FW based BG scan" is currently enabled...or not
5615tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5616{
5617 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5618}
5619#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005620#endif
5621
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005622#if defined(FEATURE_WLAN_ESE)
5623tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005624{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005625 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005626}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005627#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005628
Jeff Johnson295189b2012-06-20 16:38:30 -07005629//Return true means the command can be release, else not
5630static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5631 eCsrRoamCompleteResult Result, void *Context )
5632{
5633 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5634 tSirBssDescription *pSirBssDesc = NULL;
5635 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5636 tCsrScanResult *pScanResult = NULL;
5637 tCsrRoamInfo roamInfo;
5638 sme_QosAssocInfo assocInfo;
5639 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5640 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5641 tDot11fBeaconIEs *pIes = NULL;
5642 tANI_U32 sessionId = pCommand->sessionId;
5643 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5644 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5645 eRoamCmdStatus roamStatus;
5646 eCsrRoamResult roamResult;
5647 eHalStatus status;
5648 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005650
Jeff Johnson32d95a32012-09-10 13:15:23 -07005651 if(!pSession)
5652 {
5653 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5654 return eANI_BOOLEAN_FALSE;
5655 }
5656
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005657 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 switch( Result )
5659 {
5660 case eCsrJoinSuccess:
5661 // reset the IDLE timer
5662 // !!
5663 // !! fall through to the next CASE statement here is intentional !!
5664 // !!
5665 case eCsrReassocSuccess:
5666 if(eCsrReassocSuccess == Result)
5667 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305668 roamInfo.reassoc = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5670 }
5671 else
5672 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305673 roamInfo.reassoc = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5675 }
5676 // Success Join Response from LIM. Tell NDIS we are connected and save the
5677 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005678 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305679 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 //always free the memory here
5681 if(pSession->pWpaRsnRspIE)
5682 {
5683 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305684 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 pSession->pWpaRsnRspIE = NULL;
5686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005687#ifdef FEATURE_WLAN_WAPI
5688 if(pSession->pWapiRspIE)
5689 {
5690 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305691 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 pSession->pWapiRspIE = NULL;
5693 }
5694#endif /* FEATURE_WLAN_WAPI */
5695#ifdef FEATURE_WLAN_BTAMP_UT_RF
5696 //Reset counter so no join retry is needed.
5697 pSession->maxRetryCount = 0;
5698 csrRoamStopJoinRetryTimer(pMac, sessionId);
5699#endif
5700 /* This creates problem since we have not saved the connected profile.
5701 So moving this after saving the profile
5702 */
5703 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305704
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305705 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305706 * by last failed secured connection.
5707 * It should be set only for secured connection.
5708 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305709 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5711 {
5712 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5713 }
5714 else
5715 {
5716 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 //Use the last connected bssdesc for reassoc-ing to the same AP.
5719 //NOTE: What to do when reassoc to a different AP???
5720 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5721 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5722 {
5723 pSirBssDesc = pSession->pConnectBssDesc;
5724 if(pSirBssDesc)
5725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305726 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5727 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 }
5729 }
5730 else
5731 {
5732
5733 if(pCommand->u.roamCmd.pRoamBssEntry)
5734 {
5735 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5736 if(pScanResult != NULL)
5737 {
5738 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5739 //this can be NULL
5740 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305741 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5742 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 }
5744 }
5745 }
5746 if( pSirBssDesc )
5747 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5750 //Save WPA/RSN IE
5751 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005752#ifdef FEATURE_WLAN_ESE
5753 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305755#ifdef WLAN_FEATURE_VOWIFI_11R
5756 if (pSirBssDesc->mdiePresent)
5757 {
5758 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5759#ifdef FEATURE_WLAN_ESE
5760 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5761 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5762#endif
5763 )
5764 {
5765 // is11Rconnection;
5766 roamInfo.is11rAssoc = VOS_TRUE;
5767 }
5768 else
5769 {
5770 // is11Rconnection;
5771 roamInfo.is11rAssoc = VOS_FALSE;
5772 }
5773 }
5774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5776 // substate change.
5777 // Moving even save profile above so that below mentioned conditon is also met.
5778 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5779 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5781 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5782 // will be dropped for the security context may not be set properly.
5783 //
5784 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5785 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5786 //
5787 // this reordering was done on titan_prod_usb branch and is being replicated here.
5788 //
5789
5790 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5791 !pProfile->bWPSAssociation)
5792 {
5793 // Issue the set Context request to LIM to establish the Unicast STA context
5794 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5795 pProfile->negotiatedUCEncryptionType,
5796 pSirBssDesc, &(pSirBssDesc->bssId),
5797 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005799 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5801 }
5802 // Issue the set Context request to LIM to establish the Broadcast STA context
5803 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5804 pSirBssDesc, &BroadcastMac,
5805 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5806 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305807 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 {
5809 //Need to wait for supplicant authtication
5810 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 //Set the subestate to WaitForKey in case authentiation is needed
5812 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5813
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 if(pProfile->bWPSAssociation)
5815 {
5816 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5817 }
5818 else
5819 {
5820 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5821 }
5822
5823 //Save sessionId in case of timeout
5824 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5825 //This time should be long enough for the rest of the process plus setting key
5826 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5827 {
5828 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005829 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5831 }
5832 }
5833
5834 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5835 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 if(Context)
5837 {
5838 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5839 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5841 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5842#ifdef WLAN_FEATURE_VOWIFI_11R
5843 len += pJoinRsp->parsedRicRspLen;
5844#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005845#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 len += pJoinRsp->tspecIeLen;
5847#endif
5848 if(len)
5849 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305850 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5851 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305853 vos_mem_copy(pSession->connectedInfo.pbFrames,
5854 pJoinRsp->frames, len);
5855 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5856 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5857 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005858#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305859 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005860#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005861#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305862 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005863#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305864 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5865 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5866 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5867 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 }
5869 }
5870 if(pCommand->u.roamCmd.fReassoc)
5871 {
5872 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5873 }
5874 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5875 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5876 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5877 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305878 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305879 roamInfo.vht_caps = pJoinRsp->vht_caps;
5880 roamInfo.ht_caps = pJoinRsp->ht_caps;
5881 roamInfo.hs20vendor_ie = pJoinRsp->hs20vendor_ie;
5882 roamInfo.ht_operation = pJoinRsp->ht_operation;
5883 roamInfo.vht_operation = pJoinRsp->vht_operation;
5884
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 }
5886 else
5887 {
5888 if(pCommand->u.roamCmd.fReassoc)
5889 {
5890 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5891 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5892 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5893 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5894 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5895 }
5896 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305897 /* Update the staId from the previous connected profile info
5898 as the reassociation is triggred at SME/HDD */
5899 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5900 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5901 {
5902 roamInfo.staId = pSession->connectedInfo.staId;
5903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005904#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5905 // Indicate SME-QOS with reassoc success event, only after
5906 // copying the frames
5907 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 roamInfo.pBssDesc = pSirBssDesc;
5910 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5911 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5912#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5913 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5914#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5915 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5917 //It may be better to let QoS do this????
5918 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005920 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5922 pmcStartUapsd( pMac, NULL, NULL );
5923 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305924 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5926 if( pSession->bRefAssocStartCnt > 0 )
5927 {
5928 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005929 //Remove this code once SLM_Sessionization is supported
5930 //BMPS_WORKAROUND_NOT_NEEDED
5931 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005932 {
5933 pMac->roam.configParam.doBMPSWorkaround = 1;
5934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5936 }
5937
5938 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 // reset the PMKID candidate list
5940 csrResetPMKIDCandidateList( pMac, sessionId );
5941 //Update TL's AC weight base on the current EDCA parameters
5942 //These parameters may change in the course of the connection, that sictuation
5943 //is not taken care here. This change is mainly to address a WIFI WMM test where
5944 //BE has a equal or higher TX priority than VI.
5945 //We only do this for infra link
5946 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5947 {
5948 csrCheckAndUpdateACWeight(pMac, pIes);
5949 }
5950#ifdef FEATURE_WLAN_WAPI
5951 // reset the BKID candidate list
5952 csrResetBKIDCandidateList( pMac, sessionId );
5953#endif /* FEATURE_WLAN_WAPI */
5954 }
5955 else
5956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005957 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 csrScanCancelIdleScan(pMac);
5960 //Not to signal link up because keys are yet to be set.
5961 //The linkup function will overwrite the sub-state that we need to keep at this point.
5962 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5963 {
5964 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5967 //enough to let security and DHCP handshake succeed before entry into BMPS
5968 if (pmcShouldBmpsTimerRun(pMac))
5969 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305970 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05305971 * until keys are set before going into BMPS.
5972 */
5973 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5974 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305975 pMac->pmc.full_power_till_set_key = true;
5976 smsLog(pMac, LOG1,
5977 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 +05305978 }
5979
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5981 != eHAL_STATUS_SUCCESS)
5982 {
5983 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5984 }
5985 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 break;
5988
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 case eCsrStartBssSuccess:
5990 // on the StartBss Response, LIM is returning the Bss Description that we
5991 // are beaconing. Add this Bss Description to our scan results and
5992 // chain the Profile to this Bss Description. On a Start BSS, there was no
5993 // detected Bss description (no partner) so we issued the Start Bss to
5994 // start the Ibss without any Bss description. Lim was kind enough to return
5995 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005996 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305999 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 if( CSR_IS_IBSS( pProfile ) )
6001 {
6002 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 else if (CSR_IS_INFRA_AP(pProfile))
6005 {
6006 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 else
6009 {
6010 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6011 }
6012 if( !CSR_IS_WDS_STA( pProfile ) )
6013 {
6014 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
6017 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306018 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 roamInfo.pBssDesc = pSirBssDesc;
6020 //We need to associate_complete it first, becasue Associate_start already indicated.
6021 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6022 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
6023 break;
6024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07006027 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 }
6029 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6030 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6031 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6032 if(pSirBssDesc)
6033 {
6034 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306035 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6036 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 }
6038 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306039 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006040#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6041 {
6042 vos_log_ibss_pkt_type *pIbssLog;
6043 tANI_U32 bi;
6044
6045 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6046 if(pIbssLog)
6047 {
6048 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6049 {
6050 //We start the IBSS (didn't find any matched IBSS out there)
6051 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6052 }
6053 else
6054 {
6055 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6056 }
6057 if(pSirBssDesc)
6058 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306059 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6061 }
6062 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6063 {
6064 //***U8 is not enough for beacon interval
6065 pIbssLog->beaconInterval = (v_U8_t)bi;
6066 }
6067 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6068 }
6069 }
6070#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6071 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6072 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6074 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6076 csrRoamIssueSetContextReq( pMac, sessionId,
6077 pProfile->negotiatedMCEncryptionType,
6078 pSirBssDesc, &BroadcastMac,
6079 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6080 }
6081 }
6082 else
6083 {
6084 //Keep the state to eCSR_ROAMING_STATE_JOINING
6085 //Need to send join_req.
6086 if(pCommand->u.roamCmd.pRoamBssEntry)
6087 {
6088 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6089 {
6090 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6091 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6092 // Set the roaming substate to 'join attempt'...
6093 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006094 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 }
6096 }
6097 else
6098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006099 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 VOS_ASSERT( 0 );
6101 }
6102 }
6103 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6104 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6105 //trigger the connection start indication in Vista
6106 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6107 {
6108 roamStatus = eCSR_ROAM_IBSS_IND;
6109 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6110 if( CSR_IS_WDS( pProfile ) )
6111 {
6112 roamStatus = eCSR_ROAM_WDS_IND;
6113 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 if( CSR_IS_INFRA_AP( pProfile ) )
6116 {
6117 roamStatus = eCSR_ROAM_INFRA_IND;
6118 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120
6121 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6122 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6123 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306124 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6126 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006127 //We start the IBSS (didn't find any matched IBSS out there)
6128 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306130 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6131 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006132 //Remove this code once SLM_Sessionization is supported
6133 //BMPS_WORKAROUND_NOT_NEEDED
6134 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006135 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006136 {
6137 pMac->roam.configParam.doBMPSWorkaround = 1;
6138 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006139
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6141 }
6142
6143 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006144
6145 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 {
6147 //need to send stop BSS because we fail to send join_req
6148 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6149 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6150 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 case eCsrStartBssFailure:
6154#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6155 {
6156 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6158 if(pIbssLog)
6159 {
6160 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6161 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6162 }
6163 }
6164#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 roamStatus = eCSR_ROAM_IBSS_IND;
6166 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6167 if( CSR_IS_WDS( pProfile ) )
6168 {
6169 roamStatus = eCSR_ROAM_WDS_IND;
6170 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 if( CSR_IS_INFRA_AP( pProfile ) )
6173 {
6174 roamStatus = eCSR_ROAM_INFRA_IND;
6175 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 if(Context)
6178 {
6179 pSirBssDesc = (tSirBssDescription *)Context;
6180 }
6181 else
6182 {
6183 pSirBssDesc = NULL;
6184 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306185 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 roamInfo.pBssDesc = pSirBssDesc;
6187 //We need to associate_complete it first, becasue Associate_start already indicated.
6188 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6189 csrSetDefaultDot11Mode( pMac );
6190 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 case eCsrSilentlyStopRoaming:
6192 // We are here because we try to start the same IBSS
6193 //No message to PE
6194 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006195 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6197 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306198 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6200 if( roamInfo.pBssDesc )
6201 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306202 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6203 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 }
6205 //Since there is no change in the current state, simply pass back no result otherwise
6206 //HDD may be mistakenly mark to disconnected state.
6207 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6208 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 case eCsrSilentlyStopRoamingSaveState:
6211 //We are here because we try to connect to the same AP
6212 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006213 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306214 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006215
6216 //to aviod resetting the substate to NONE
6217 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6218 //No need to change substate to wai_for_key because there is no state change
6219 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6220 if( roamInfo.pBssDesc )
6221 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306222 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6223 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6226 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6227 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6228 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6229 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6230 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6231 roamInfo.staId = pSession->connectedInfo.staId;
6232 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 pSession->bRefAssocStartCnt--;
6235 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6236 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6237 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6238 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 case eCsrReassocFailure:
6240#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6241 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6242#endif
6243 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006244 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 csrFreeConnectBssDesc(pMac, sessionId);
6246 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6247 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306248 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6250 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6251 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6252 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6253 eCSR_ROAM_WDS_IND,
6254 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6255 //Need to issue stop_bss
6256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 case eCsrJoinFailure:
6258 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006259 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 default:
6261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006262 smsLog(pMac, LOGW, FL("receives no association indication"));
6263 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006264 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6266 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6267 {
6268 //do not free for the other profiles as we need to send down stop BSS later
6269 csrFreeConnectBssDesc(pMac, sessionId);
6270 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6271 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6272 csrSetDefaultDot11Mode( pMac );
6273 }
6274
6275 switch( pCommand->u.roamCmd.roamReason )
6276 {
6277 // If this transition is because of an 802.11 OID, then we transition
6278 // back to INIT state so we sit waiting for more OIDs to be issued and
6279 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006280 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 case eCsrSmeIssuedAssocToSimilarAP:
6282 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006283 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306285 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6287 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6288 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306289 vos_mem_copy(&roamInfo.bssid,
6290 &pSession->joinFailStatusCode.bssId,
6291 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006292
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 /* Defeaturize this later if needed */
6294#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6295 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6296 if (csrRoamIsHandoffInProgress(pMac))
6297 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 /* Should indicate neighbor roam algorithm about the connect failure here */
6299 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 if(pSession->bRefAssocStartCnt > 0)
6303 {
6304 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006305 if(eCsrJoinFailureDueToConcurrency == Result)
6306 {
6307 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6308 eCSR_ROAM_ASSOCIATION_COMPLETION,
6309 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6310 }
6311 else
6312 {
6313 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 eCSR_ROAM_ASSOCIATION_COMPLETION,
6315 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006318 else
6319 {
6320 /* bRefAssocStartCnt is not incremented when
6321 * eRoamState == eCsrStopRoamingDueToConcurrency
6322 * in csrRoamJoinNextBss API. so handle this in
6323 * else case by sending assoc failure
6324 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006325 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006326 pCommand->u.scanCmd.roamId,
6327 eCSR_ROAM_ASSOCIATION_FAILURE,
6328 eCSR_ROAM_RESULT_FAILURE);
6329 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006330 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306332 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6334#endif
6335 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6336 csrScanStartIdleScan(pMac);
6337#ifdef FEATURE_WLAN_BTAMP_UT_RF
6338 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6339 //BT activity and not able to recevie WLAN traffic. Retry the join
6340 if( CSR_IS_WDS_STA(pProfile) )
6341 {
6342 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6343 }
6344#endif
6345 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 case eCsrHddIssuedReassocToSameAP:
6347 case eCsrSmeIssuedReassocToSameAP:
6348 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6349
6350 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6351#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6352 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6353#endif
6354 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6355 csrScanStartIdleScan(pMac);
6356 break;
6357 case eCsrForcedDisassoc:
6358 case eCsrForcedDeauth:
6359 case eCsrSmeIssuedIbssJoinFailure:
6360 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6361
6362 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6363 {
6364 // Notify HDD that IBSS join failed
6365 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6366 }
6367 else
6368 {
6369 csrRoamCallCallback(pMac, sessionId, NULL,
6370 pCommand->u.roamCmd.roamId,
6371 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6372 }
6373#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6374 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6375#endif
6376 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006377 /*
6378 *DelSta not done FW still in conneced state so dont
6379 *issue IMPS req
6380 */
6381 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6382 {
6383 smsLog(pMac, LOGW, FL("FW still in connected state "));
6384 break;
6385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 csrScanStartIdleScan(pMac);
6387 break;
6388 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306389 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 csrRoamCallCallback(pMac, sessionId, NULL,
6391 pCommand->u.roamCmd.roamId,
6392 eCSR_ROAM_IBSS_LEAVE,
6393 eCSR_ROAM_RESULT_IBSS_STOP);
6394 break;
6395 case eCsrForcedDisassocMICFailure:
6396 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6397
6398 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6399#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6400 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6401#endif
6402 csrScanStartIdleScan(pMac);
6403 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 case eCsrStopBss:
6405 csrRoamCallCallback(pMac, sessionId, NULL,
6406 pCommand->u.roamCmd.roamId,
6407 eCSR_ROAM_INFRA_IND,
6408 eCSR_ROAM_RESULT_INFRA_STOPPED);
6409 break;
6410 case eCsrForcedDisassocSta:
6411 case eCsrForcedDeauthSta:
6412 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306413 pSession = CSR_GET_SESSION(pMac, sessionId);
6414 if (pSession)
6415 {
6416 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306418 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6419 {
6420 roamInfo.u.pConnectedProfile =
6421 &pSession->connectedProfile;
6422 vos_mem_copy(roamInfo.peerMac,
6423 pCommand->u.roamCmd.peerMac,
6424 sizeof(tSirMacAddr));
6425 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6426 roamInfo.statusCode = eSIR_SME_SUCCESS;
6427 status = csrRoamCallCallback(pMac, sessionId,
6428 &roamInfo, pCommand->u.roamCmd.roamId,
6429 eCSR_ROAM_LOSTLINK,
6430 eCSR_ROAM_RESULT_FORCED);
6431 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306432 }
6433 else
6434 {
6435 smsLog(pMac, LOGE, FL("Inactive session %d"),
6436 sessionId);
6437 return eHAL_STATUS_FAILURE;
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306440 else
6441 {
6442 smsLog(pMac, LOGE, FL("Invalid session"));
6443 return eHAL_STATUS_FAILURE;
6444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 case eCsrLostLink1:
6447 // if lost link roam1 failed, then issue lost link Scan2 ...
6448 csrScanRequestLostLink2(pMac, sessionId);
6449 break;
6450 case eCsrLostLink2:
6451 // if lost link roam2 failed, then issue lost link scan3 ...
6452 csrScanRequestLostLink3(pMac, sessionId);
6453 break;
6454 case eCsrLostLink3:
6455 default:
6456 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6457
6458 //We are done with one round of lostlink roaming here
6459 csrScanHandleFailedLostlink3(pMac, sessionId);
6460 break;
6461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 break;
6463 }
6464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 return ( fReleaseCommand );
6466}
6467
Jeff Johnson295189b2012-06-20 16:38:30 -07006468eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6469{
6470 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 return (status);
6472}
6473
Jeff Johnson295189b2012-06-20 16:38:30 -07006474eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6475{
6476 eHalStatus status = eHAL_STATUS_SUCCESS;
6477 tANI_U32 size = 0;
6478
6479 do
6480 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306481 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6483 {
6484 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306485 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6486 if ( NULL == pDstProfile->BSSIDs.bssid )
6487 status = eHAL_STATUS_FAILURE;
6488 else
6489 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 if(!HAL_STATUS_SUCCESS(status))
6491 {
6492 break;
6493 }
6494 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306495 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6496 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 }
6498 if(pSrcProfile->SSIDs.numOfSSIDs)
6499 {
6500 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306501 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6502 if ( NULL == pDstProfile->SSIDs.SSIDList )
6503 status = eHAL_STATUS_FAILURE;
6504 else
6505 status = eHAL_STATUS_SUCCESS;
6506 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 {
6508 break;
6509 }
6510 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306511 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6512 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 }
6514 if(pSrcProfile->nWPAReqIELength)
6515 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306516 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6517 if ( NULL == pDstProfile->pWPAReqIE )
6518 status = eHAL_STATUS_FAILURE;
6519 else
6520 status = eHAL_STATUS_SUCCESS;
6521
6522 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 {
6524 break;
6525 }
6526 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306527 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6528 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 }
6530 if(pSrcProfile->nRSNReqIELength)
6531 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306532 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6533 if ( NULL == pDstProfile->pRSNReqIE )
6534 status = eHAL_STATUS_FAILURE;
6535 else
6536 status = eHAL_STATUS_SUCCESS;
6537
6538 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 {
6540 break;
6541 }
6542 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306543 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6544 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 }
6546#ifdef FEATURE_WLAN_WAPI
6547 if(pSrcProfile->nWAPIReqIELength)
6548 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306549 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6550 if ( NULL == pDstProfile->pWAPIReqIE )
6551 status = eHAL_STATUS_FAILURE;
6552 else
6553 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 if(!HAL_STATUS_SUCCESS(status))
6555 {
6556 break;
6557 }
6558 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306559 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6560 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 }
6562#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 if(pSrcProfile->nAddIEScanLength)
6564 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306565 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6566 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306568 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306569 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306570 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6571 }
6572 else
6573 {
6574 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6575 FL(" AddIEScanLength is not valid %u"),
6576 pSrcProfile->nAddIEScanLength);
6577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 if(pSrcProfile->nAddIEAssocLength)
6580 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306581 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6582 if ( NULL == pDstProfile->pAddIEAssoc )
6583 status = eHAL_STATUS_FAILURE;
6584 else
6585 status = eHAL_STATUS_SUCCESS;
6586
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 if(!HAL_STATUS_SUCCESS(status))
6588 {
6589 break;
6590 }
6591 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306592 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6593 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 if(pSrcProfile->ChannelInfo.ChannelList)
6596 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306597 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6598 pSrcProfile->ChannelInfo.numOfChannels);
6599 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6600 status = eHAL_STATUS_FAILURE;
6601 else
6602 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 if(!HAL_STATUS_SUCCESS(status))
6604 {
6605 break;
6606 }
6607 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306608 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6609 pSrcProfile->ChannelInfo.ChannelList,
6610 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 pDstProfile->AuthType = pSrcProfile->AuthType;
6613 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6614 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6615 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6616 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6617 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006618#ifdef WLAN_FEATURE_11W
6619 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6620 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6621 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6622#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 pDstProfile->BSSType = pSrcProfile->BSSType;
6624 pDstProfile->phyMode = pSrcProfile->phyMode;
6625 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6626
6627#ifdef FEATURE_WLAN_WAPI
6628 if(csrIsProfileWapi(pSrcProfile))
6629 {
6630 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6631 {
6632 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6633 }
6634 }
6635#endif /* FEATURE_WLAN_WAPI */
6636 pDstProfile->CBMode = pSrcProfile->CBMode;
6637 /*Save the WPS info*/
6638 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006639 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 pDstProfile->privacy = pSrcProfile->privacy;
6643 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6644 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6645 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6646 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6647 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6648 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6649 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6650 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6651 pDstProfile->wps_state = pSrcProfile->wps_state;
6652 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Abhishek Singhe3beee22017-07-31 15:35:40 +05306653 pDstProfile->force_24ghz_in_ht20 =
6654 pSrcProfile->force_24ghz_in_ht20;
Kiet Lam64c1b492013-07-12 13:56:44 +05306655 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6656 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006657#ifdef WLAN_FEATURE_VOWIFI_11R
6658 if (pSrcProfile->MDID.mdiePresent)
6659 {
6660 pDstProfile->MDID.mdiePresent = 1;
6661 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6662 }
6663#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }while(0);
6665
6666 if(!HAL_STATUS_SUCCESS(status))
6667 {
6668 csrReleaseProfile(pMac, pDstProfile);
6669 pDstProfile = NULL;
6670 }
6671
6672 return (status);
6673}
Jeff Johnson295189b2012-06-20 16:38:30 -07006674eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6675{
6676 eHalStatus status = eHAL_STATUS_SUCCESS;
6677 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6678 do
6679 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306680 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 if(pSrcProfile->bssid)
6682 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306683 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6684 if ( NULL == pDstProfile->BSSIDs.bssid )
6685 status = eHAL_STATUS_FAILURE;
6686 else
6687 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 if(!HAL_STATUS_SUCCESS(status))
6689 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306690 smsLog( pMac, LOGE,
6691 FL("failed to allocate memory for BSSID"
6692 "%02x:%02x:%02x:%02x:%02x:%02x"),
6693 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6694 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 break;
6696 }
6697 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306698 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6699 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 }
6701 if(pSrcProfile->SSID.ssId)
6702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306703 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6704 if ( NULL == pDstProfile->SSIDs.SSIDList )
6705 status = eHAL_STATUS_FAILURE;
6706 else
6707 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 if(!HAL_STATUS_SUCCESS(status))
6709 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306710 smsLog( pMac, LOGE,
6711 FL("failed to allocate memory for SSIDList"
6712 "%02x:%02x:%02x:%02x:%02x:%02x"),
6713 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6714 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 break;
6716 }
6717 pDstProfile->SSIDs.numOfSSIDs = 1;
6718 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6719 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306720 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6721 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006723 if(pSrcProfile->nAddIEAssocLength)
6724 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306725 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6726 if ( NULL == pDstProfile->pAddIEAssoc)
6727 status = eHAL_STATUS_FAILURE;
6728 else
6729 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006730 if(!HAL_STATUS_SUCCESS(status))
6731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006732 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006733 break;
6734 }
6735 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306736 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6737 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006738 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306739 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6740 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6741 status = eHAL_STATUS_FAILURE;
6742 else
6743 status = eHAL_STATUS_SUCCESS;
6744
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 if(!HAL_STATUS_SUCCESS(status))
6746 {
6747 break;
6748 }
6749 pDstProfile->ChannelInfo.numOfChannels = 1;
6750 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 pDstProfile->AuthType.numEntries = 1;
6752 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6753 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6754 pDstProfile->EncryptionType.numEntries = 1;
6755 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6756 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6757 pDstProfile->mcEncryptionType.numEntries = 1;
6758 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6759 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6760 pDstProfile->BSSType = pSrcProfile->BSSType;
6761 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306762 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6763 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306764#ifdef WLAN_FEATURE_11W
6765 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6766 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6767 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6768#endif
6769
Jeff Johnson295189b2012-06-20 16:38:30 -07006770#ifdef WLAN_FEATURE_VOWIFI_11R
6771 if (pSrcProfile->MDID.mdiePresent)
6772 {
6773 pDstProfile->MDID.mdiePresent = 1;
6774 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6775 }
6776#endif
6777
6778 }while(0);
6779
6780 if(!HAL_STATUS_SUCCESS(status))
6781 {
6782 csrReleaseProfile(pMac, pDstProfile);
6783 pDstProfile = NULL;
6784 }
6785
6786 return (status);
6787}
6788
Jeff Johnson295189b2012-06-20 16:38:30 -07006789eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6790 tScanResultHandle hBSSList,
6791 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6792 tANI_BOOLEAN fClearScan)
6793{
6794 eHalStatus status = eHAL_STATUS_SUCCESS;
6795 tSmeCmd *pCommand;
6796
6797 pCommand = csrGetCommandBuffer(pMac);
6798 if(NULL == pCommand)
6799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006800 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 status = eHAL_STATUS_RESOURCES;
6802 }
6803 else
6804 {
6805 if( fClearScan )
6806 {
6807 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306808 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 }
6810 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6811 if(NULL == pProfile)
6812 {
6813 //We can roam now
6814 //Since pProfile is NULL, we need to build our own profile, set everything to default
6815 //We can only support open and no encryption
6816 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6817 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6818 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6819 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6820 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6821 }
6822 else
6823 {
6824 //make a copy of the profile
6825 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6826 if(HAL_STATUS_SUCCESS(status))
6827 {
6828 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6829 }
6830 }
6831 pCommand->command = eSmeCommandRoam;
6832 pCommand->sessionId = (tANI_U8)sessionId;
6833 pCommand->u.roamCmd.hBSSList = hBSSList;
6834 pCommand->u.roamCmd.roamId = roamId;
6835 pCommand->u.roamCmd.roamReason = reason;
6836 //We need to free the BssList when the command is done
6837 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6838 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6840 FL("CSR PERSONA=%d"),
6841 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6843 if( !HAL_STATUS_SUCCESS( status ) )
6844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006845 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 csrReleaseCommandRoam( pMac, pCommand );
6847 }
6848 }
6849
6850 return (status);
6851}
Jeff Johnson295189b2012-06-20 16:38:30 -07006852eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6853 tCsrRoamModifyProfileFields *pMmodProfileFields,
6854 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6855{
6856 eHalStatus status = eHAL_STATUS_SUCCESS;
6857 tSmeCmd *pCommand;
6858
6859 pCommand = csrGetCommandBuffer(pMac);
6860 if(NULL == pCommand)
6861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006862 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 status = eHAL_STATUS_RESOURCES;
6864 }
6865 else
6866 {
6867 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306868 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 if(pProfile)
6870 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 //This is likely trying to reassoc to different profile
6872 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6873 //make a copy of the profile
6874 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6875 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 }
6877 else
6878 {
6879 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6880 //how to update WPA/WPA2 info in roamProfile??
6881 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 if(HAL_STATUS_SUCCESS(status))
6884 {
6885 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6886 }
6887 pCommand->command = eSmeCommandRoam;
6888 pCommand->sessionId = (tANI_U8)sessionId;
6889 pCommand->u.roamCmd.roamId = roamId;
6890 pCommand->u.roamCmd.roamReason = reason;
6891 //We need to free the BssList when the command is done
6892 //For reassoc there is no BSS list, so the boolean set to false
6893 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6894 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6895 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6897 if( !HAL_STATUS_SUCCESS( status ) )
6898 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006899 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006900 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6901 csrReleaseCommandRoam( pMac, pCommand );
6902 }
6903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 return (status);
6905}
6906
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006907eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6908 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306909// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006910{
6911 eHalStatus status = eHAL_STATUS_SUCCESS;
6912 tSmeCmd *pCommand;
6913
6914 pCommand = csrGetCommandBuffer(pMac);
6915 if(NULL == pCommand)
6916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006917 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006918 status = eHAL_STATUS_RESOURCES;
6919 }
6920 else
6921 {
6922 if(pBssDescription)
6923 {
6924 //copy over the parameters we need later
6925 pCommand->command = eSmeCommandRoam;
6926 pCommand->sessionId = (tANI_U8)sessionId;
6927 pCommand->u.roamCmd.roamReason = reason;
6928 //this is the important parameter
6929 //in this case we are using this field for the "next" BSS
6930 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6931 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6932 if( !HAL_STATUS_SUCCESS( status ) )
6933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006934 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006935 csrReleaseCommandPreauth( pMac, pCommand );
6936 }
6937 }
6938 else
6939 {
6940 //Return failure
6941 status = eHAL_STATUS_RESOURCES;
6942 }
6943 }
6944 return (status);
6945}
6946
6947eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6948{
6949 tListElem *pEntry;
6950 tSmeCmd *pCommand;
6951 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6952 if ( pEntry )
6953 {
6954 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6955 if ( (eSmeCommandRoam == pCommand->command) &&
6956 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6957 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006958 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006959 pCommand->command, pCommand->u.roamCmd.roamReason);
6960 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6961 csrReleaseCommandPreauth( pMac, pCommand );
6962 }
6963 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006964 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006965 pCommand->command, pCommand->u.roamCmd.roamReason);
6966 }
6967 }
6968 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006969 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006970 }
6971 smeProcessPendingQueue( pMac );
6972 return eHAL_STATUS_SUCCESS;
6973}
6974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6976 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6977{
6978 eHalStatus status = eHAL_STATUS_FAILURE;
6979 tScanResultHandle hBSSList;
6980 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6982 if(HAL_STATUS_SUCCESS(status))
6983 {
6984 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6985 if(pRoamId)
6986 {
6987 *pRoamId = roamId;
6988 }
6989 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6990 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6991 if(!HAL_STATUS_SUCCESS(status))
6992 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006993 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 csrScanResultPurge(pMac, hBSSList);
6995 }
6996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 return (status);
6998}
6999
Jeff Johnson295189b2012-06-20 16:38:30 -07007000eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7001 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7002{
7003 eHalStatus status = eHAL_STATUS_SUCCESS;
7004 tScanResultHandle hBSSList;
7005 tCsrScanResultFilter *pScanFilter;
7006 tANI_U32 roamId = 0;
7007 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
7008 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 if (NULL == pProfile)
7010 {
7011 smsLog(pMac, LOGP, FL("No profile specified"));
7012 return eHAL_STATUS_FAILURE;
7013 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307014 if(!pSession)
7015 {
7016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7017 return eHAL_STATUS_FAILURE;
7018 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307019 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7020 "encryType = %d"),
7021 lim_BssTypetoString(pProfile->BSSType),
7022 pProfile->BSSType,
7023 pProfile->AuthType.authType[0],
7024 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 if( CSR_IS_WDS( pProfile ) &&
7026 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
7027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007028 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007029 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 return status;
7031 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307032 /* Reset abortConnection for the fresh connection */
7033 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 csrRoamCancelRoaming(pMac, sessionId);
7035 csrScanRemoveFreshScanCommand(pMac, sessionId);
7036 csrScanCancelIdleScan(pMac);
7037 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307038 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307039
7040 if (!vos_concurrent_open_sessions_running() &&
7041 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307043 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 csrScanDisable(pMac);
7045 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307046
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7048 //Check whether ssid changes
7049 if(csrIsConnStateConnected(pMac, sessionId))
7050 {
7051 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7052 {
7053 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7054 }
7055 }
7056#ifdef FEATURE_WLAN_BTAMP_UT_RF
7057 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7058#endif
Abhishek Singh5de9efd2017-06-15 10:22:39 +05307059
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7061 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007062 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7064 if(pRoamId)
7065 {
7066 roamId = *pRoamId;
7067 }
7068 if(!HAL_STATUS_SUCCESS(status))
7069 {
7070 fCallCallback = eANI_BOOLEAN_TRUE;
7071 }
7072 }
7073 else
7074 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307075 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7076 if ( NULL == pScanFilter )
7077 status = eHAL_STATUS_FAILURE;
7078 else
7079 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 if(HAL_STATUS_SUCCESS(status))
7081 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307082 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 //Try to connect to any BSS
7084 if(NULL == pProfile)
7085 {
7086 //No encryption
7087 pScanFilter->EncryptionType.numEntries = 1;
7088 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7089 }//we don't have a profile
7090 else
7091 {
7092 //Here is the profile we need to connect to
7093 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7094 }//We have a profile
7095 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7096 if(pRoamId)
7097 {
7098 *pRoamId = roamId;
7099 }
7100
7101 if(HAL_STATUS_SUCCESS(status))
7102 {
7103 /*Save the WPS info*/
7104 if(NULL != pProfile)
7105 {
7106 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007107 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 }
7109 else
7110 {
7111 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007112 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 do
7115 {
7116 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 )
7119 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007120 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7122 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7123 if(!HAL_STATUS_SUCCESS(status))
7124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007125 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 fCallCallback = eANI_BOOLEAN_TRUE;
7127 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007128 else
7129 {
7130 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 break;
7133 }
7134 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007135 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 if(HAL_STATUS_SUCCESS(status))
7137 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7139 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7140 if(!HAL_STATUS_SUCCESS(status))
7141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007142 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 csrScanResultPurge(pMac, hBSSList);
7144 fCallCallback = eANI_BOOLEAN_TRUE;
7145 }
7146 }//Have scan result
7147 else if(NULL != pProfile)
7148 {
7149 //Check whether it is for start ibss
7150 if(CSR_IS_START_IBSS(pProfile))
7151 {
7152 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7153 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7154 if(!HAL_STATUS_SUCCESS(status))
7155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007156 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 fCallCallback = eANI_BOOLEAN_TRUE;
7158 }
7159 }
7160 else
7161 {
7162 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007163 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 if(!HAL_STATUS_SUCCESS(status))
7165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007166 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 fCallCallback = eANI_BOOLEAN_TRUE;
7168 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007169 else
7170 {
7171 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 }
7174 }
7175 else
7176 {
7177 fCallCallback = eANI_BOOLEAN_TRUE;
7178 }
7179 } while (0);
7180 if(NULL != pProfile)
7181 {
7182 //we need to free memory for filter if profile exists
7183 csrFreeScanFilter(pMac, pScanFilter);
7184 }
7185 }//Got the scan filter from profile
7186
Kiet Lam64c1b492013-07-12 13:56:44 +05307187 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 }//allocated memory for pScanFilter
7189 }//No Bsslist coming in
7190 //tell the caller if we fail to trigger a join request
7191 if( fCallCallback )
7192 {
7193 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7194 }
7195
7196 return (status);
7197}
Jeff Johnson295189b2012-06-20 16:38:30 -07007198eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7199 tCsrRoamModifyProfileFields modProfileFields,
7200 tANI_U32 *pRoamId)
7201{
7202 eHalStatus status = eHAL_STATUS_SUCCESS;
7203 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7204 tANI_U32 roamId = 0;
7205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 if (NULL == pProfile)
7207 {
7208 smsLog(pMac, LOGP, FL("No profile specified"));
7209 return eHAL_STATUS_FAILURE;
7210 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307211 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7212 "encryType = %d"),
7213 lim_BssTypetoString(pProfile->BSSType),
7214 pProfile->BSSType,
7215 pProfile->AuthType.authType[0],
7216 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 csrRoamCancelRoaming(pMac, sessionId);
7218 csrScanRemoveFreshScanCommand(pMac, sessionId);
7219 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307220 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 if(csrIsConnStateConnected(pMac, sessionId))
7223 {
7224 if(pProfile)
7225 {
7226 if(pProfile->SSIDs.numOfSSIDs &&
7227 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7228 {
7229 fCallCallback = eANI_BOOLEAN_FALSE;
7230 }
7231 else
7232 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007233 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 }
7235 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307236 else if (!vos_mem_compare(&modProfileFields,
7237 &pSession->connectedProfile.modifyProfileFields,
7238 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 {
7240 fCallCallback = eANI_BOOLEAN_FALSE;
7241 }
7242 else
7243 {
7244 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007245 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 }
7247 }
7248 else
7249 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007250 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 if(!fCallCallback)
7253 {
7254 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7255 if(pRoamId)
7256 {
7257 *pRoamId = roamId;
7258 }
7259
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7261 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 }
7263 else
7264 {
7265 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7266 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 return status;
7269}
Jeff Johnson295189b2012-06-20 16:38:30 -07007270eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7271{
7272 eHalStatus status = eHAL_STATUS_FAILURE;
7273 tScanResultHandle hBSSList = NULL;
7274 tCsrScanResultFilter *pScanFilter = NULL;
7275 tANI_U32 roamId;
7276 tCsrRoamProfile *pProfile = NULL;
7277 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007278
7279 if(!pSession)
7280 {
7281 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7282 return eHAL_STATUS_FAILURE;
7283 }
7284
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 do
7286 {
7287 if(pSession->pCurRoamProfile)
7288 {
7289 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307290 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307292 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7293 if ( NULL == pProfile )
7294 status = eHAL_STATUS_FAILURE;
7295 else
7296 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 if(!HAL_STATUS_SUCCESS(status))
7298 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307299 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307301 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307303 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7304 if ( NULL == pScanFilter )
7305 status = eHAL_STATUS_FAILURE;
7306 else
7307 status = eHAL_STATUS_SUCCESS;
7308
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 if(!HAL_STATUS_SUCCESS(status))
7310 {
7311 break;
7312 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307313 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7315 if(!HAL_STATUS_SUCCESS(status))
7316 {
7317 break;
7318 }
7319 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7320 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7321 if(HAL_STATUS_SUCCESS(status))
7322 {
7323 //we want to put the last connected BSS to the very beginning, if possible
7324 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7325 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7326 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7327 if(!HAL_STATUS_SUCCESS(status))
7328 {
7329 csrScanResultPurge(pMac, hBSSList);
7330 break;
7331 }
7332 }
7333 else
7334 {
7335 //Do a scan on this profile
7336 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007337 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 if(!HAL_STATUS_SUCCESS(status))
7339 {
7340 break;
7341 }
7342 }
7343 }//We have a profile
7344 else
7345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007346 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 break;
7348 }
7349 }while(0);
7350 if(pScanFilter)
7351 {
7352 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307353 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 }
7355 if(NULL != pProfile)
7356 {
7357 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307358 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 return (status);
7361}
Jeff Johnson295189b2012-06-20 16:38:30 -07007362eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7363{
7364 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 if(csrIsConnStateConnected(pMac, sessionId))
7366 {
7367 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7368 if(HAL_STATUS_SUCCESS(status))
7369 {
7370 status = csrRoamJoinLastProfile(pMac, sessionId);
7371 }
7372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 return (status);
7374}
7375
Jeff Johnson295189b2012-06-20 16:38:30 -07007376eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7377{
7378 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007379 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 csrRoamCancelRoaming(pMac, sessionId);
7381 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7382 if(csrIsConnStateDisconnected(pMac, sessionId))
7383 {
7384 status = csrRoamJoinLastProfile(pMac, sessionId);
7385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 return (status);
7387}
7388
Jeff Johnson295189b2012-06-20 16:38:30 -07007389eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7390{
7391 eHalStatus status = eHAL_STATUS_SUCCESS;
7392 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7393 eCsrRoamSubState NewSubstate;
7394 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307395
7396 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7397 {
7398 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7399 " eCSR_ROAM_SUBSTATE_NONE"));
7400 csrRoamStopWaitForKeyTimer( pMac );
7401 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 // change state to 'Roaming'...
7404 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7405
7406 if ( csrIsConnStateIbss( pMac, sessionId ) )
7407 {
7408 // If we are in an IBSS, then stop the IBSS...
7409 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7410 fComplete = (!HAL_STATUS_SUCCESS(status));
7411 }
7412 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007414 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 -07007415 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7416 //Restore AC weight in case we change it
7417 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7418 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7419 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7420 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7421 {
7422 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7423 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307424 else
7425 {
7426 // If we are in neighbor preauth done state then on receiving
7427 // disassoc or deauth we dont roam instead we just disassoc
7428 // from current ap and then go to disconnected state
7429 // This happens for ESE and 11r FT connections ONLY.
7430#ifdef WLAN_FEATURE_VOWIFI_11R
7431 if (csrRoamIs11rAssoc(pMac) &&
7432 (csrNeighborRoamStatePreauthDone(pMac)))
7433 {
7434 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7435 }
7436#endif
7437#ifdef FEATURE_WLAN_ESE
7438 if (csrRoamIsESEAssoc(pMac) &&
7439 (csrNeighborRoamStatePreauthDone(pMac)))
7440 {
7441 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7442 }
7443#endif
7444#ifdef FEATURE_WLAN_LFR
7445 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7446 (csrNeighborRoamStatePreauthDone(pMac)))
7447 {
7448 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7449 }
7450#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307451#ifdef WLAN_FEATURE_LFR_MBB
7452 csr_stop_preauth_reassoc_mbb_timer(pMac);
7453#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307454 }
7455
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 if( fDisassoc )
7457 {
7458 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307459 if (pMac->roam.configParam.roamDelayStatsEnabled)
7460 {
7461 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 }
7464 else
7465 {
7466 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7467 }
7468 fComplete = (!HAL_STATUS_SUCCESS(status));
7469 }
7470 else if ( csrIsConnStateWds( pMac, sessionId ) )
7471 {
7472 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7473 {
7474 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7475 fComplete = (!HAL_STATUS_SUCCESS(status));
7476 }
7477 //This has to be WDS station
7478 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7479 {
7480
7481 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7482 if( fDisassoc )
7483 {
7484 status = csrRoamIssueDisassociate( pMac, sessionId,
7485 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7486 fComplete = (!HAL_STATUS_SUCCESS(status));
7487 }
7488 }
7489 } else {
7490 // we got a dis-assoc request while not connected to any peer
7491 // just complete the command
7492 fComplete = eANI_BOOLEAN_TRUE;
7493 status = eHAL_STATUS_FAILURE;
7494 }
7495 if(fComplete)
7496 {
7497 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7498 }
7499
7500 if(HAL_STATUS_SUCCESS(status))
7501 {
7502 if ( csrIsConnStateInfra( pMac, sessionId ) )
7503 {
7504 //Set the state to disconnect here
7505 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307506#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7507 //we don't need to run this timer any more
7508 if (VOS_TIMER_STATE_RUNNING ==
7509 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7510 {
7511 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7512 if (status != eHAL_STATUS_SUCCESS)
7513 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7514 }
7515#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 }
7517 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007518 else
7519 {
7520 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007522 return (status);
7523}
7524
Jeff Johnson295189b2012-06-20 16:38:30 -07007525/* This is been removed from latest code base */
7526/*
7527static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7528{
7529 eHalStatus status;
7530 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7532 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 return ( status );
7534}
7535*/
7536
Jeff Johnson295189b2012-06-20 16:38:30 -07007537eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7538{
7539 eHalStatus status = eHAL_STATUS_SUCCESS;
7540 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307541
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 do
7543 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 pCommand = csrGetCommandBuffer( pMac );
7545 if ( !pCommand )
7546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007547 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 status = eHAL_STATUS_RESOURCES;
7549 break;
7550 }
7551 //Change the substate in case it is wait-for-key
7552 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7553 {
7554 csrRoamStopWaitForKeyTimer( pMac );
7555 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7556 }
7557 pCommand->command = eSmeCommandRoam;
7558 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307559 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7560 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 switch ( reason )
7562 {
7563 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7564 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7565 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 case eCSR_DISCONNECT_REASON_DEAUTH:
7567 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7568 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7573 case eCSR_DISCONNECT_REASON_DISASSOC:
7574 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7577 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7580 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7581 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 default:
7583 break;
7584 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307585 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 if( !HAL_STATUS_SUCCESS( status ) )
7587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007588 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 csrReleaseCommandRoam( pMac, pCommand );
7590 }
7591 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 return( status );
7593}
7594
Jeff Johnson295189b2012-06-20 16:38:30 -07007595eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7596{
7597 eHalStatus status = eHAL_STATUS_SUCCESS;
7598 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 pCommand = csrGetCommandBuffer( pMac );
7600 if ( NULL != pCommand )
7601 {
7602 //Change the substate in case it is wait-for-key
7603 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7604 {
7605 csrRoamStopWaitForKeyTimer( pMac );
7606 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7607 }
7608 pCommand->command = eSmeCommandRoam;
7609 pCommand->sessionId = (tANI_U8)sessionId;
7610 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7611 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7612 if( !HAL_STATUS_SUCCESS( status ) )
7613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007614 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 csrReleaseCommandRoam( pMac, pCommand );
7616 }
7617 }
7618 else
7619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007620 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 status = eHAL_STATUS_RESOURCES;
7622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 return ( status );
7624}
7625
Jeff Johnson295189b2012-06-20 16:38:30 -07007626eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7627{
7628 eHalStatus status = eHAL_STATUS_SUCCESS;
7629 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007630
7631 if(!pSession)
7632 {
7633 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7634 return eHAL_STATUS_FAILURE;
7635 }
7636
Jeff Johnson295189b2012-06-20 16:38:30 -07007637#ifdef FEATURE_WLAN_BTAMP_UT_RF
7638 //Stop te retry
7639 pSession->maxRetryCount = 0;
7640 csrRoamStopJoinRetryTimer(pMac, sessionId);
7641#endif
7642 //Not to call cancel roaming here
7643 //Only issue disconnect when necessary
7644 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7645 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7646 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7647
7648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007649 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7651 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307652 else
7653 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307654 csrScanAbortScanForSSID(pMac, sessionId);
Mukul Sharma11841b42017-07-05 13:10:09 +05307655 csrScanStartIdleScan(pMac);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307656 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307657 smsLog(pMac, LOGE,
7658 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 return (status);
7661}
7662
Jeff Johnson295189b2012-06-20 16:38:30 -07007663eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7664{
7665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007666
7667 if(!pSession)
7668 {
7669 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7670 return eHAL_STATUS_FAILURE;
7671 }
7672
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7675
7676 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7677}
7678
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307679void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7680{
7681 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7682 if(!pSession)
7683 {
7684 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7685 return;
7686 }
7687 pSession->abortConnection = TRUE;
7688 return;
7689}
7690
Jeff Johnson295189b2012-06-20 16:38:30 -07007691eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7692 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7693{
7694 eHalStatus status = eHAL_STATUS_SUCCESS;
7695 tDot11fBeaconIEs *pIesTemp = pIes;
7696 tANI_U8 index;
7697 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7698 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007699
7700 if(!pSession)
7701 {
7702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7703 return eHAL_STATUS_FAILURE;
7704 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007705 if(pConnectProfile->pAddIEAssoc)
7706 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307707 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007708 pConnectProfile->pAddIEAssoc = NULL;
7709 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307710 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007711 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7712 pConnectProfile->AuthInfo = pProfile->AuthType;
7713 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7714 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7715 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7716 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7717 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7718 pConnectProfile->BSSType = pProfile->BSSType;
7719 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7720 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007721 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307722 if (!pConnectProfile->beaconInterval)
7723 {
7724 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7725 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307726 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007727 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7728 if(pProfile->nAddIEAssocLength)
7729 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307730 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7731 if ( NULL == pConnectProfile->pAddIEAssoc )
7732 status = eHAL_STATUS_FAILURE;
7733 else
7734 status = eHAL_STATUS_SUCCESS;
7735 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007736 {
7737 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7738 return eHAL_STATUS_FAILURE;
7739 }
7740 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307741 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7742 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007743 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307744
7745#ifdef WLAN_FEATURE_11W
7746 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7747 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7748 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7749#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007750
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 //Save bssid
7752 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7753#ifdef WLAN_FEATURE_VOWIFI_11R
7754 if (pSirBssDesc->mdiePresent)
7755 {
7756 pConnectProfile->MDID.mdiePresent = 1;
7757 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7758 }
7759#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007760 if( NULL == pIesTemp )
7761 {
7762 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7763 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007764#ifdef FEATURE_WLAN_ESE
7765 if ((csrIsProfileESE(pProfile) ||
7766 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307767 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7768 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7769 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7770 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7771#ifdef WLAN_FEATURE_11W
7772 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307773 || (pProfile->negotiatedAuthType ==
7774 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307775#endif
7776 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007777 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007779 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 }
7781#endif
7782 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 if(HAL_STATUS_SUCCESS(status))
7784 {
7785 if(pIesTemp->SSID.present)
7786 {
7787 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307788 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7789 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 }
7791
7792 //Save the bss desc
7793 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307794
7795 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307797 //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 -07007798 pConnectProfile->qap = TRUE;
7799 }
7800 else
7801 {
7802 pConnectProfile->qap = FALSE;
7803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 if ( NULL == pIes )
7805 {
7806 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307807 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 }
7809 }
7810 //Save Qos connection
7811 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7812
7813 if(!HAL_STATUS_SUCCESS(status))
7814 {
7815 csrFreeConnectBssDesc(pMac, sessionId);
7816 }
7817 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7818 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307819 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7820 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7821 pConnectProfile->SSID.ssId,
7822 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007823 {
7824 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7825 break;
7826 }
7827 pConnectProfile->handoffPermitted = FALSE;
7828 }
7829
7830 return (status);
7831}
7832
Jeff Johnson295189b2012-06-20 16:38:30 -07007833static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7834{
7835 tListElem *pEntry = NULL;
7836 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307837 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 //The head of the active list is the request we sent
7839 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7840 if(pEntry)
7841 {
7842 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7843 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307844 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7846 {
7847 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7848 {
7849#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7850 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7851#endif
7852 }
7853 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307854 if(!pSession)
7855 {
7856 smsLog(pMac, LOGE, FL(" session %d not found "),
7857 pSmeJoinRsp->sessionId);
7858 return;
7859 }
7860 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 }
7862 else
7863 {
7864 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007865 if(!pSession)
7866 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307867 smsLog(pMac, LOGE, FL(" session %d not found "),
7868 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007869 return;
7870 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307871 if (pSession->abortConnection)
7872 {
7873 smsLog(pMac, LOG1, FL("Disconnection in progess"
7874 "abort Join request"));
7875 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7876 pSession->abortConnection = FALSE;
7877 return;
7878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 //The head of the active list is the request we sent
7880 //Try to get back the same profile and roam again
7881 if(pCommand)
7882 {
7883 roamId = pCommand->u.roamCmd.roamId;
7884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7886 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007887 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007888#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7889 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7890 if (csrRoamIsHandoffInProgress(pMac))
7891 {
7892 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7893 /* Should indicate neighbor roam algorithm about the connect failure here */
7894 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7895 }
7896#endif
7897 if (pCommand)
7898 {
7899 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7900 {
7901 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7902 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7903 csrRoamReissueRoamCommand(pMac);
7904 }
7905 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7906 {
7907 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7908 }
7909 else
7910 {
7911 csrRoam(pMac, pCommand);
7912 }
7913 }
7914 else
7915 {
7916 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7917 }
7918 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7919}
7920
Jeff Johnson295189b2012-06-20 16:38:30 -07007921eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7922 tDot11fBeaconIEs *pIes,
7923 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7924{
7925 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007926 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7927 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007928
7929 // Set the roaming substate to 'join attempt'...
7930 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007932 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 return (status);
7934}
7935
Jeff Johnson295189b2012-06-20 16:38:30 -07007936static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7937 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7938{
7939 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 // Set the roaming substate to 'join attempt'...
7941 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7942
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307943 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7944 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307945 if (pMac->roam.configParam.roamDelayStatsEnabled)
7946 {
7947 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7948 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007951 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007952}
7953
Jeff Johnson295189b2012-06-20 16:38:30 -07007954void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7955{
7956 tListElem *pEntry;
7957 tSmeCmd *pCommand;
7958 tCsrRoamInfo roamInfo;
7959 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307960 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007961
7962 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7963 if(pEntry)
7964 {
7965 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7966 if ( eSmeCommandRoam == pCommand->command )
7967 {
7968 sessionId = pCommand->sessionId;
7969 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007970
7971 if(!pSession)
7972 {
7973 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7974 return;
7975 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307976 /* While switching between two AP, csr will reissue roam command again
7977 to the nextbss if it was interrupted by the dissconnect req for the
7978 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7979 so reset the bRefAssocStartCnt.
7980 */
7981 if(pSession->bRefAssocStartCnt > 0)
7982 {
7983 pSession->bRefAssocStartCnt--;
7984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 if( pCommand->u.roamCmd.fStopWds )
7986 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307987 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7989 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7990 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7993 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7994 eCSR_ROAM_WDS_IND,
7995 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007996 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7997 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7998 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7999 eCSR_ROAM_INFRA_IND,
8000 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
8001 }
8002
Jeff Johnson295189b2012-06-20 16:38:30 -07008003
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
8005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008006 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8008 }
8009 }
8010 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
8011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008012 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8014 }
8015 }
8016 else
8017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008018 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 }
8020 }
8021 else
8022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008023 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 }
8025}
8026
Jeff Johnson295189b2012-06-20 16:38:30 -07008027tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
8028{
8029 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8030 tListElem *pEntry;
8031 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 //alwasy lock active list before locking pending list
8033 csrLLLock( &pMac->sme.smeCmdActiveList );
8034 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8035 if(pEntry)
8036 {
8037 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8038 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8039 {
8040 fRet = eANI_BOOLEAN_TRUE;
8041 }
8042 }
8043 if(eANI_BOOLEAN_FALSE == fRet)
8044 {
8045 csrLLLock(&pMac->sme.smeCmdPendingList);
8046 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8047 while(pEntry)
8048 {
8049 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8050 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8051 {
8052 fRet = eANI_BOOLEAN_TRUE;
8053 break;
8054 }
8055 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8056 }
8057 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8058 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308059 if (eANI_BOOLEAN_FALSE == fRet)
8060 {
8061 csrLLLock(&pMac->roam.roamCmdPendingList);
8062 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8063 while (pEntry)
8064 {
8065 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8066 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8067 {
8068 fRet = eANI_BOOLEAN_TRUE;
8069 break;
8070 }
8071 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8072 }
8073 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 return (fRet);
8077}
8078
Jeff Johnson295189b2012-06-20 16:38:30 -07008079tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8080{
8081 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8082 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8084 {
8085 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8086 {
8087 break;
8088 }
8089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 return ( fRet );
8091}
8092
Jeff Johnson295189b2012-06-20 16:38:30 -07008093tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8094{
8095 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008096 //alwasy lock active list before locking pending list
8097 csrLLLock( &pMac->sme.smeCmdActiveList );
8098 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8099 if(eANI_BOOLEAN_FALSE == fRet)
8100 {
8101 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8102 }
8103 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 return (fRet);
8105}
8106
Jeff Johnson295189b2012-06-20 16:38:30 -07008107tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8108{
8109 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8110 tListElem *pEntry;
8111 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 //alwasy lock active list before locking pending list
8113 csrLLLock( &pMac->sme.smeCmdActiveList );
8114 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8115 if( pEntry )
8116 {
8117 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8118 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8119 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8120 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8121 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8122 {
8123 fRet = eANI_BOOLEAN_TRUE;
8124 }
8125 }
8126 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 return (fRet);
8128}
Jeff Johnson295189b2012-06-20 16:38:30 -07008129eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8130{
8131 eHalStatus status = eHAL_STATUS_SUCCESS;
8132 tSmeCmd *pCommand = NULL;
8133 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8134 tANI_BOOLEAN fRemoveCmd = FALSE;
8135 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 // Delete the old assoc command. All is setup for reassoc to be serialized
8137 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8138 if ( pEntry )
8139 {
8140 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8141 if ( !pCommand )
8142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008143 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 return eHAL_STATUS_RESOURCES;
8145 }
8146 if ( eSmeCommandRoam == pCommand->command )
8147 {
8148 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8149 {
8150 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8151 }
8152 else
8153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008154 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 }
8156 if (fRemoveCmd == FALSE)
8157 {
8158 // Implies we did not get the serialized assoc command we
8159 // were expecting
8160 pCommand = NULL;
8161 }
8162 }
8163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 if(NULL == pCommand)
8165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008166 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 return eHAL_STATUS_RESOURCES;
8168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 do
8170 {
8171 //Change the substate in case it is wait-for-key
8172 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8173 {
8174 csrRoamStopWaitForKeyTimer( pMac );
8175 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8176 }
8177 pCommand->command = eSmeCommandRoam;
8178 pCommand->sessionId = (tANI_U8)sessionId;
8179 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8181 if( !HAL_STATUS_SUCCESS( status ) )
8182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008183 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 csrReleaseCommandRoam( pMac, pCommand );
8185 }
8186 } while( 0 );
8187
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 return( status );
8189}
8190static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8191{
8192 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8193 tCsrScanResult *pScanResult = NULL;
8194 tSirBssDescription *pBssDesc = NULL;
8195 tSmeCmd *pCommand = NULL;
8196 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308197 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 if(NULL == pEntry)
8199 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308200 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 return;
8202 }
8203 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8204 sessionId = pCommand->sessionId;
8205 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008206
8207 if(!pSession)
8208 {
8209 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8210 return;
8211 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308212 smsLog(pMac, LOG1, FL("CFG return value is %d "
8213 " current state is : %d substate is : %d "),
8214 result, pMac->roam.curState[sessionId],
8215 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8217 {
8218 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008219 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8221 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008222 /* If the roaming has stopped, not to continue the roaming command*/
8223 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8224 {
8225 //No need to complete roaming here as it already completes
8226 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8227 pCommand->u.roamCmd.roamReason);
8228 csrSetAbortRoamingCommand( pMac, pCommand );
8229 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 else
8232 {
8233 if ( CCM_IS_RESULT_SUCCESS(result) )
8234 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308235 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 // Successfully set the configuration parameters for the new Bss. Attempt to
8237 // join the roaming Bss.
8238 if(pCommand->u.roamCmd.pRoamBssEntry)
8239 {
8240 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308241 if (!pScanResult)
8242 {
8243 smsLog(pMac, LOGE,
8244 FL("Failed to get base address for pScanResult"));
8245 return;
8246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008247 pBssDesc = &pScanResult->Result.BssDescriptor;
8248 }
8249 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8250 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 )
8253 {
8254 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8255 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8256 pBssDesc, pCommand->u.roamCmd.roamId )))
8257 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308258 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 //We need to complete the command
8260 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8261 }
8262 }
8263 else
8264 {
8265 if (!pCommand->u.roamCmd.pRoamBssEntry)
8266 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308267 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 //We need to complete the command
8269 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8270 return;
8271 }
8272 // If we are roaming TO an Infrastructure BSS...
8273 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308274 if( !pScanResult->Result.pvIes )
8275 {
8276 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8277 return;
8278 }
8279
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 if ( csrIsInfraBssDesc( pBssDesc ) )
8281 {
8282 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308283 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8285 {
8286 // ..and currently in an Infrastructure connection....
8287 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8288 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308289 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 // ...and the SSIDs are equal, then we Reassoc.
8291 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8292 pIesLocal ) )
8293 // ..and currently in an infrastructure connection
8294 {
8295 // then issue a Reassoc.
8296 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8297 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8298 &pCommand->u.roamCmd.roamProfile );
8299 }
8300 else
8301 {
8302
8303 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8304 // previously associated AP.
8305 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8306 pIesLocal,
8307 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8308 {
8309 //try something else
8310 csrRoam( pMac, pCommand );
8311 }
8312 }
8313 }
8314 else
8315 {
8316 eHalStatus status = eHAL_STATUS_SUCCESS;
8317
8318 /* We need to come with other way to figure out that this is because of HO in BMP
8319 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008320 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 * use join request */
8322#ifdef WLAN_FEATURE_VOWIFI_11R
8323 if (csrRoamIsHandoffInProgress(pMac) &&
8324 csrRoamIs11rAssoc(pMac))
8325 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308326 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8328 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8329 }
8330 else
8331#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008332#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008334 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308336 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 // Now serialize the reassoc command.
8338 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8339 }
8340 else
8341#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008342#ifdef FEATURE_WLAN_LFR
8343 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308344 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008345 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308346 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008347 // Now serialize the reassoc command.
8348 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8349 }
8350 else
8351#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 // else we are not connected and attempting to Join. Issue the
8353 // Join request.
8354 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308355 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8357 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8358 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8359 }
8360 if(!HAL_STATUS_SUCCESS(status))
8361 {
8362 //try something else
8363 csrRoam( pMac, pCommand );
8364 }
8365 }
8366 if( !pScanResult->Result.pvIes )
8367 {
8368 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308369 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 }
8371 }
8372 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8373 else
8374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008375 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 }
8377 }//else
8378 }//if ( WNI_CFG_SUCCESS == result )
8379 else
8380 {
8381 // In the event the configuration failed, for infra let the roam processor
8382 //attempt to join something else...
8383 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8384 {
8385 csrRoam(pMac, pCommand);
8386 }
8387 else
8388 {
8389 //We need to complete the command
8390 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8391 {
8392 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8393 }
8394 else
8395 {
8396 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8397 }
8398 }
8399 }
8400 }//we have active entry
8401}
8402
Jeff Johnson295189b2012-06-20 16:38:30 -07008403static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8404{
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008407 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008408 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8409 // join the new one...
8410 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8412 }
8413 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008414 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 /***profHandleLostLinkAfterReset(pAdapter);
8416 // In the event the authenticate fails, let the roam processor attempt to join something else...
8417 roamRoam( pAdapter );***/
8418 }
8419}
8420
Jeff Johnson295189b2012-06-20 16:38:30 -07008421static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8422{
8423 eCsrRoamCompleteResult result;
8424 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8425 tCsrRoamInfo roamInfo;
8426 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308427 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308428 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308429 tANI_U8 nilMac[6] = {0};
8430
8431 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008433 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 /* Defeaturize this part later if needed */
8436#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8437 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8438 * we need the response contents while processing the result in csrRoamProcessResults() */
8439 if (csrRoamIsHandoffInProgress(pMac))
8440 {
8441 /* Need to dig more on indicating events to SME QoS module */
8442 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8443 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308444#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8445 /* Add previous BSSID to blacklist ; this will be in blacklised for
8446 * some period and score of this AP will be reduced if black listed
8447 * to avoid ping pong */
8448 if (pMac->PERroamCandidatesCnt)
8449 {
8450 current_timestamp = jiffies_to_msecs(jiffies);
8451 for (candidateApCnt = 0; candidateApCnt <
8452 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8453 {
8454 /* Find one blank entry */
8455 if (sirCompareMacAddr(nilMac,
8456 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8457 {
8458 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8459 bssAddr,
8460 pNeighborRoamInfo->prevConnProfile.bssid,
8461 sizeof(tSirMacAddr));
8462 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8463 current_timestamp;
8464 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8465 MAC_ADDR_ARRAY(
8466 pNeighborRoamInfo->prevConnProfile.bssid),
8467 candidateApCnt);
8468 break;
8469 }
8470 /* if already in the list */
8471 if (sirCompareMacAddr(pMac->previousRoamApInfo
8472 [candidateApCnt].bssAddr,
8473 pNeighborRoamInfo->prevConnProfile.bssid) &&
8474 ((current_timestamp -
8475 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8476 pMac->PERroamTimeout))
8477 {
8478 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8479 bssAddr,
8480 pNeighborRoamInfo->prevConnProfile.bssid,
8481 sizeof(tSirMacAddr));
8482 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8483 current_timestamp;
8484 break;
8485 } else
8486 {
8487 /* find oldest BSSID entry in the blacklist */
8488 if (max_time <
8489 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8490 {
8491 max_time =
8492 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8493 oldestIndex = candidateApCnt;
8494 }
8495 }
8496 }
8497 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8498 {
8499 smsLog(pMac, LOGW,
8500 "%s: Clearing out oldest roam results bssid="
8501 MAC_ADDRESS_STR,
8502 __func__,
8503 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8504 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8505 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8506 pNeighborRoamInfo->prevConnProfile.bssid,
8507 sizeof(tSirMacAddr));
8508 }
8509 }
8510#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 }
8512 else
8513#endif
8514 {
8515 csrRoamComplete( pMac, result, NULL );
8516 }
8517 }
8518 /* Should we handle this similar to handling the join failure? Is it ok
8519 * to call csrRoamComplete() with state as CsrJoinFailure */
8520 else
8521 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008522 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308524 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8525 WLAN_LOG_INDICATOR_HOST_DRIVER,
8526 WLAN_LOG_REASON_ROAM_FAIL,
8527 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008528#ifdef WLAN_FEATURE_VOWIFI_11R
8529 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308530 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8531 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 {
8533 // Inform HDD to turn off FT flag in HDD
8534 if (pNeighborRoamInfo)
8535 {
8536 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8537 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8538 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008539 /*
8540 * Since the above callback sends a disconnect
8541 * to HDD, we should clean-up our state
8542 * machine as well to be in sync with the upper
8543 * layers. There is no need to send a disassoc
8544 * since: 1) we will never reassoc to the current
8545 * AP in LFR, and 2) there is no need to issue a
8546 * disassoc to the AP with which we were trying
8547 * to reassoc.
8548 */
8549 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8550 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 }
8552 }
8553#endif
8554 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8555 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8556 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8557 //The disassoc rsp message will remove the command from active list
8558 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8559 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8560 {
8561 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8562 }
8563 }
8564}
8565
Jeff Johnson295189b2012-06-20 16:38:30 -07008566static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8567{
Jeff Johnson295189b2012-06-20 16:38:30 -07008568#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8569 {
8570 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8572 if(pIbssLog)
8573 {
8574 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8575 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8576 {
8577 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8578 }
8579 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8580 }
8581 }
8582#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8584 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8585 {
8586 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8587 }
8588 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8589 {
8590 csrRoamReissueRoamCommand(pMac);
8591 }
8592}
8593
Jeff Johnson295189b2012-06-20 16:38:30 -07008594void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8595{
8596 tSirResultCodes statusCode;
8597#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8598 tScanResultHandle hBSSList;
8599 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8600 eHalStatus status;
8601 tCsrRoamInfo roamInfo;
8602 tCsrScanResultFilter *pScanFilter = NULL;
8603 tANI_U32 roamId = 0;
8604 tCsrRoamProfile *pCurRoamProfile = NULL;
8605 tListElem *pEntry = NULL;
8606 tSmeCmd *pCommand = NULL;
8607#endif
8608 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308609 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008610
Jeff Johnson295189b2012-06-20 16:38:30 -07008611 tSirSmeDisassocRsp SmeDisassocRsp;
8612
8613 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8614 sessionId = SmeDisassocRsp.sessionId;
8615 statusCode = SmeDisassocRsp.statusCode;
8616
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008617 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008618
8619 if ( csrIsConnStateInfra( pMac, sessionId ) )
8620 {
8621 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008624
8625 if(!pSession)
8626 {
8627 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8628 return;
8629 }
8630
Jeff Johnson295189b2012-06-20 16:38:30 -07008631 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8632 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308633 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8635 }
8636 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8637 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8638 {
8639 if ( eSIR_SME_SUCCESS == statusCode )
8640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008641 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008642 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8643 }
8644 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8647 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308648 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8649 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008650#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008651 /*
8652 * First ensure if the roam profile is in the scan cache.
8653 * If not, post a reassoc failure and disconnect.
8654 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308655 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8656 if ( NULL == pScanFilter )
8657 status = eHAL_STATUS_FAILURE;
8658 else
8659 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008660 if(HAL_STATUS_SUCCESS(status))
8661 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308662 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008663 status = csrRoamPrepareFilterFromProfile(pMac,
8664 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8665 if(!HAL_STATUS_SUCCESS(status))
8666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008667 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008668 __func__, status);
8669 goto POST_ROAM_FAILURE;
8670 }
8671 else
8672 {
8673 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8674 if (!HAL_STATUS_SUCCESS(status))
8675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008676 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008677 __func__, status);
8678 goto POST_ROAM_FAILURE;
8679 }
8680 }
8681 }
8682 else
8683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008684 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008685 __func__, status);
8686 goto POST_ROAM_FAILURE;
8687 }
8688
8689 /*
8690 * After ensuring that the roam profile is in the scan result list,
8691 * dequeue the command from the active list.
8692 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8694 if ( pEntry )
8695 {
8696 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008697 /* If the head of the queue is Active and it is a ROAM command, remove
8698 * and put this on the Free queue.
8699 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 if ( eSmeCommandRoam == pCommand->command )
8701 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008702
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008703 /*
8704 * we need to process the result first before removing it from active list
8705 * because state changes still happening insides roamQProcessRoamResults so
8706 * no other roam command should be issued.
8707 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8709 if(pCommand->u.roamCmd.fReleaseProfile)
8710 {
8711 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8712 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 else
8717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008718 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008719 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 }
8721 }
8722 else
8723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008724 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 }
8726 }
8727 else
8728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008729 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008731
8732 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8734
Kiet Lam64c1b492013-07-12 13:56:44 +05308735 vos_mem_copy(roamInfo.bssid,
8736 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8737 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008738
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008739 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8740 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008741
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008742 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308743 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8744 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308746 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008747 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8748 //make sure to put it at the head of the cmd queue
8749 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8750 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8751 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8752
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 if(!HAL_STATUS_SUCCESS(status))
8754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008755 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008756 __func__, status);
8757 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 }
8759
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008760 /* Notify sub-modules like QoS etc. that handoff happening */
8761 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308762 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008763 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308764 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308766 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008767 return;
8768 }
8769
8770POST_ROAM_FAILURE:
8771 if (pScanFilter)
8772 {
8773 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308774 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008775 }
8776 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308777 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008778
8779 /* Inform the upper layers that the reassoc failed */
8780 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8781 csrRoamCallCallback(pMac, sessionId,
8782 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8783
8784 /*
8785 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8786 * Upon success, we would re-enter this routine after receiving the disassoc
8787 * response and will fall into the reassoc fail sub-state. And, eventually
8788 * call csrRoamComplete which would remove the roam command from SME active
8789 * queue.
8790 */
8791 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8792 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008794 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008795 __func__, status);
8796 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008798#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008799
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8801 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8802 {
8803 // Disassoc due to Reassoc failure falls into this codepath....
8804 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8805 }
8806 else
8807 {
8808 if ( eSIR_SME_SUCCESS == statusCode )
8809 {
8810 // Successfully disassociated from the 'old' Bss...
8811 //
8812 // We get Disassociate response in three conditions.
8813 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8814 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8815 // Infrastructure network.
8816 // - Third is where we are doing an Infra to Infra roam between networks with different
8817 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8818
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008819 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 }
8821 else
8822 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008823 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 }
8825 //We are not done yet. Get the data and continue roaming
8826 csrRoamReissueRoamCommand(pMac);
8827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008828}
8829
Jeff Johnson295189b2012-06-20 16:38:30 -07008830static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8831{
8832 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008834 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008835 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8836 {
8837 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8838 }
8839 else
8840 {
8841 if ( eSIR_SME_SUCCESS == statusCode )
8842 {
8843 // Successfully deauth from the 'old' Bss...
8844 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008845 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 }
8847 else
8848 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008849 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 }
8851 //We are not done yet. Get the data and continue roaming
8852 csrRoamReissueRoamCommand(pMac);
8853 }
8854}
8855
Jeff Johnson295189b2012-06-20 16:38:30 -07008856static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8857{
8858 eCsrRoamCompleteResult result;
8859
8860 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008862 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 result = eCsrStartBssSuccess;
8864 }
8865 else
8866 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008867 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 //Let csrRoamComplete decide what to do
8869 result = eCsrStartBssFailure;
8870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008872}
8873
Jeff Johnson295189b2012-06-20 16:38:30 -07008874/*
8875 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8876 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8877 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8878 For the messages where sender allocates memory for specific structures, then it can be
8879 cast accordingly.
8880*/
8881void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8882{
8883 tSirSmeRsp *pSmeRsp;
8884 tSmeIbssPeerInd *pIbssPeerInd;
8885 tCsrRoamInfo roamInfo;
8886 // TODO Session Id need to be acquired in this function
8887 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308889 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8890 pSmeRsp->messageType, pSmeRsp->messageType,
8891 macTraceGetcsrRoamSubState(
8892 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 pSmeRsp->messageType = (pSmeRsp->messageType);
8894 pSmeRsp->length = (pSmeRsp->length);
8895 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 switch (pSmeRsp->messageType)
8897 {
8898
8899 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8900 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8901 {
8902 //We sent a JOIN_REQ
8903 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8904 }
8905 break;
8906
8907 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8908 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8909 {
8910 //We sent a AUTH_REQ
8911 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8912 }
8913 break;
8914
8915 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8916 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8917 {
8918 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8919 }
8920 break;
8921
8922 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8923 {
8924 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8925 }
8926 break;
8927
8928 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8929 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8930 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8931 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8932 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8933 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8934//HO
8935 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8936 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308937 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8938 macTraceGetcsrRoamSubState(
8939 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308941 if (pMac->roam.configParam.roamDelayStatsEnabled)
8942 {
8943 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 }
8946 break;
8947
8948 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8949 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8950 {
8951 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8952 }
8953 break;
8954
8955 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8956 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8957 {
8958 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8959 }
8960 break;
8961
8962 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8963 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8964 {
8965 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008968 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8969 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8970 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008971 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308972 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8973 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8975 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308976 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8977 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8979 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8980 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8981 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05308982 case eWNI_SME_LOST_LINK_PARAMS_IND:
8983 {
8984 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
8985 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8986 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8987 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8988 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
8989 pRoamInfo = &roamInfo;
8990 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
8991 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
8992 break;
8993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308995 smsLog(pMac, LOG1,
8996 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8997 pSmeRsp->messageType, pSmeRsp->messageType,
8998 macTraceGetcsrRoamSubState(
8999 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009000
9001 //If we are connected, check the link status change
9002 if(!csrIsConnStateDisconnected(pMac, sessionId))
9003 {
9004 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
9005 }
9006 break;
9007 }
9008}
9009
Jeff Johnson295189b2012-06-20 16:38:30 -07009010void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
9011{
9012 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 switch (pSirMsg->messageType)
9014 {
9015 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009016 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 csrRoamStatsRspProcessor( pMac, pSirMsg );
9018 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9020 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309021 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9023 tCsrRoamInfo roamInfo;
9024 tCsrRoamInfo *pRoamInfo = NULL;
9025 tANI_U32 sessionId;
9026 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009027 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05309028 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
9031 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9032 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009033
9034 if(!pSession)
9035 {
9036 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9037 return;
9038 }
9039
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9041 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9043 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9044 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9046 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309047 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9048 sizeof(tSirMacAddr));
9049 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9050 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309052#ifdef WLAN_FEATURE_AP_HT40_24G
9053 pRoamInfo->HT40MHzIntoEnabledSta =
9054 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9055 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9056 pRoamInfo->HT40MHzIntoEnabledSta);
9057#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309058 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309059 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9060 pRoamInfo->chan_info = pUpperLayerAssocCnf->chan_info;
9061 if (pUpperLayerAssocCnf->HTCaps.present)
9062 pRoamInfo->ht_caps = pUpperLayerAssocCnf->HTCaps;
9063 if (pUpperLayerAssocCnf->VHTCaps.present)
9064 pRoamInfo->vht_caps = pUpperLayerAssocCnf->VHTCaps;
9065
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9067 {
9068 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9069 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9070 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9071 }
9072 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9073 {
9074 vos_sleep( 100 );
9075 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9076 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9077 }
9078
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 }
9080 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 default:
9082 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9083 break;
9084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009085}
9086
Jeff Johnson295189b2012-06-20 16:38:30 -07009087eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9088 tSirBssDescription *pBssDescription,
9089 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9090 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9091 tANI_U8 keyId, tANI_U16 keyLength,
9092 tANI_U8 *pKey, tANI_U8 paeRole )
9093{
9094 eHalStatus status = eHAL_STATUS_SUCCESS;
9095 tAniEdType edType;
9096
9097 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9098 {
9099 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9100 }
9101
9102 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9103
9104 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9105 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9106 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9107 addKey )
9108 {
9109 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 setKey.encType = EncryptType;
9111 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309112 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 setKey.paeRole = paeRole; //0 for supplicant
9114 setKey.keyId = keyId; // Kye index
9115 setKey.keyLength = keyLength;
9116 if( keyLength )
9117 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309118 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 }
9120 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 return (status);
9123}
9124
Jeff Johnson295189b2012-06-20 16:38:30 -07009125static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9126 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9127{
9128 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9129 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009130#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009132#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009133
9134 do
9135 {
9136 pCommand = csrGetCommandBuffer(pMac);
9137 if(NULL == pCommand)
9138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009139 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 status = eHAL_STATUS_RESOURCES;
9141 break;
9142 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309143 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 pCommand->command = eSmeCommandSetKey;
9145 pCommand->sessionId = (tANI_U8)sessionId;
9146 // validate the key length, Adjust if too long...
9147 // for static WEP the keys are not set thru' SetContextReq
9148 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9149 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9150 {
9151 //KeyLength maybe 0 for static WEP
9152 if( pSetKey->keyLength )
9153 {
9154 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009156 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 break;
9158 }
9159
9160 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309161 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9162 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 }
9164 }
9165 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9166 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9167 {
9168 //KeyLength maybe 0 for static WEP
9169 if( pSetKey->keyLength )
9170 {
9171 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009173 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 break;
9175 }
9176
9177 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309178 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9179 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009180 }
9181 }
9182 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9183 {
9184 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009186 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 break;
9188 }
9189 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309190 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9191 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 }
9193 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9194 {
9195 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009197 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 break;
9199 }
9200 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309201 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9202 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 }
9204#ifdef FEATURE_WLAN_WAPI
9205 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9206 {
9207 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009209 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 break;
9211 }
9212 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309213 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9214 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 }
9216#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009217#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9219 {
9220 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009222 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 break;
9224 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009225 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309226 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009227 pSession->eseCckmInfo.reassoc_req_num=1;
9228 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 status = eHAL_STATUS_SUCCESS;
9230 break;
9231 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009232#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009233
Jeff Johnson295189b2012-06-20 16:38:30 -07009234#ifdef WLAN_FEATURE_11W
9235 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009236 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009238 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009240 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 break;
9242 }
9243 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309244 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 }
9246#endif
9247 status = eHAL_STATUS_SUCCESS;
9248 pCommand->u.setKeyCmd.roamId = roamId;
9249 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9250 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309251 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9252 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9254 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309255 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 //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
9257
9258 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9259 if( !HAL_STATUS_SUCCESS( status ) )
9260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009261 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 }
9263 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009265 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009266 if ( ( NULL != pCommand ) &&
9267 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009268#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009270#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009271 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 {
9273 csrReleaseCommandSetKey( pMac, pCommand );
9274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 return( status );
9276}
9277
Jeff Johnson295189b2012-06-20 16:38:30 -07009278eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9279 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9280{
9281 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9282 tSmeCmd *pCommand = NULL;
9283 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 do
9285 {
9286 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009288 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 status = eHAL_STATUS_CSR_WRONG_STATE;
9290 break;
9291 }
9292 pCommand = csrGetCommandBuffer(pMac);
9293 if(NULL == pCommand)
9294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009295 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 status = eHAL_STATUS_RESOURCES;
9297 break;
9298 }
9299 pCommand->command = eSmeCommandRemoveKey;
9300 pCommand->sessionId = (tANI_U8)sessionId;
9301 pCommand->u.removeKeyCmd.roamId = roamId;
9302 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309303 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9304 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9306 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9307 {
9308 //in this case, put it to the end of the Q incase there is a set key pending.
9309 fImediate = eANI_BOOLEAN_FALSE;
9310 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009311 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009313 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9315 if( !HAL_STATUS_SUCCESS( status ) )
9316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009317 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 break;
9319 }
9320 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009321 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9322 {
9323 csrReleaseCommandRemoveKey( pMac, pCommand );
9324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009325 return (status );
9326}
9327
Jeff Johnson295189b2012-06-20 16:38:30 -07009328eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9329{
9330 eHalStatus status;
9331 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9332 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9333 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9334 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009335#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9336 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9337 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309338 if(!pSession)
9339 {
9340 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9341 return eHAL_STATUS_FAILURE;
9342 }
lukez3c809222013-05-03 10:23:02 -07009343 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309345 vos_mem_set(&setKeyEvent,
9346 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9348 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309349 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9351 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9352 }
9353 else
9354 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309355 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009356 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9357 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9358 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309359 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009360 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 {
9362 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 //It has to be static WEP here
9364 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9365 {
9366 setKeyEvent.keyId = (v_U8_t)defKeyId;
9367 }
9368 }
9369 else
9370 {
9371 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9372 }
9373 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9374 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9375 }
9376#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 if( csrIsSetKeyAllowed(pMac, sessionId) )
9378 {
9379 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9380 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9381 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9382 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9383 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9384 pCommand->u.setKeyCmd.keyRsc);
9385 }
9386 else
9387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009388 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 //Set this status so the error handling take care of the case.
9390 status = eHAL_STATUS_CSR_WRONG_STATE;
9391 }
9392 if( !HAL_STATUS_SUCCESS(status) )
9393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009394 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009396#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009397 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 {
9399 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9400 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309401 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 }
9403 else
9404 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309405 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 }
9407 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9408 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9409 }
9410#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 return ( status );
9413}
9414
Jeff Johnson295189b2012-06-20 16:38:30 -07009415eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9416{
9417 eHalStatus status;
9418 tpSirSmeRemoveKeyReq pMsg = NULL;
9419 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9420 tANI_U8 *p;
9421 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009422#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9423 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9424 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309425 if(!pSession)
9426 {
9427 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9428 return eHAL_STATUS_FAILURE;
9429 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309430 vos_mem_set(&removeKeyEvent,
9431 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9433 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9434 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309435 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9437 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9438 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9439#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 if( csrIsSetKeyAllowed(pMac, sessionId) )
9441 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309442 pMsg = vos_mem_malloc(wMsgLen);
9443 if ( NULL == pMsg )
9444 status = eHAL_STATUS_FAILURE;
9445 else
9446 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 }
9448 else
9449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009450 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 //Set the error status so error handling kicks in below
9452 status = eHAL_STATUS_CSR_WRONG_STATE;
9453 }
9454 if( HAL_STATUS_SUCCESS( status ) )
9455 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309456 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9458 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 pMsg->sessionId = (tANI_U8)sessionId;
9460 pMsg->transactionId = 0;
9461 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9462 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9463 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309464 vos_mem_copy(p,
9465 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9466 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 p += sizeof(tSirMacAddr);
9468 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309469 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009470 p += sizeof(tSirMacAddr);
9471 // edType
9472 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9473 p++;
9474 // weptype
9475 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9476 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9477 {
9478 *p = (tANI_U8)eSIR_WEP_STATIC;
9479 }
9480 else
9481 {
9482 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9483 }
9484 p++;
9485 //keyid
9486 *p = pCommand->u.removeKeyCmd.keyId;
9487 p++;
9488 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 status = palSendMBMessage(pMac->hHdd, pMsg);
9490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 if( !HAL_STATUS_SUCCESS( status ) )
9492 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009493 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009494#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9495 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009496 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9498#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 return ( status );
9502}
9503
Jeff Johnson295189b2012-06-20 16:38:30 -07009504eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9505{
9506 eHalStatus status;
9507
9508 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9509 {
9510 status = eHAL_STATUS_CSR_WRONG_STATE;
9511 }
9512 else
9513 {
9514 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 return ( status );
9517}
9518
Jeff Johnson295189b2012-06-20 16:38:30 -07009519/*
9520 Prepare a filter base on a profile for parsing the scan results.
9521 Upon successful return, caller MUST call csrFreeScanFilter on
9522 pScanFilter when it is done with the filter.
9523*/
9524eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9525 tCsrScanResultFilter *pScanFilter)
9526{
9527 eHalStatus status = eHAL_STATUS_SUCCESS;
9528 tANI_U32 size = 0;
9529 tANI_U8 index = 0;
9530
9531 do
9532 {
9533 if(pProfile->BSSIDs.numOfBSSIDs)
9534 {
9535 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309536 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9537 if ( NULL == pScanFilter->BSSIDs.bssid )
9538 status = eHAL_STATUS_FAILURE;
9539 else
9540 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 if(!HAL_STATUS_SUCCESS(status))
9542 {
9543 break;
9544 }
9545 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309546 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 }
9548 if(pProfile->SSIDs.numOfSSIDs)
9549 {
9550 if( !CSR_IS_WDS_STA( pProfile ) )
9551 {
9552 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9553 }
9554 else
9555 {
9556 //For WDS station
9557 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9558 pScanFilter->SSIDs.numOfSSIDs = 1;
9559 }
9560 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309561 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9562 if ( NULL == pScanFilter->SSIDs.SSIDList )
9563 status = eHAL_STATUS_FAILURE;
9564 else
9565 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 if(!HAL_STATUS_SUCCESS(status))
9567 {
9568 break;
9569 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309570 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9571 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 }
9573 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9574 {
9575 pScanFilter->ChannelInfo.numOfChannels = 0;
9576 pScanFilter->ChannelInfo.ChannelList = NULL;
9577 }
9578 else if(pProfile->ChannelInfo.numOfChannels)
9579 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309580 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9581 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9582 pProfile->ChannelInfo.numOfChannels);
9583 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9584 status = eHAL_STATUS_FAILURE;
9585 else
9586 status = eHAL_STATUS_SUCCESS;
9587
Jeff Johnson295189b2012-06-20 16:38:30 -07009588 pScanFilter->ChannelInfo.numOfChannels = 0;
9589 if(HAL_STATUS_SUCCESS(status))
9590 {
9591 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9592 {
9593 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9594 {
9595 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9596 = pProfile->ChannelInfo.ChannelList[index];
9597 pScanFilter->ChannelInfo.numOfChannels++;
9598 }
9599 else
9600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009601 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 }
9604 }
9605 else
9606 {
9607 break;
9608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 }
9610 else
9611 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309612 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 status = eHAL_STATUS_FAILURE;
9614 break;
9615 }
9616 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9617 pScanFilter->authType = pProfile->AuthType;
9618 pScanFilter->EncryptionType = pProfile->EncryptionType;
9619 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9620 pScanFilter->BSSType = pProfile->BSSType;
9621 pScanFilter->phyMode = pProfile->phyMode;
9622#ifdef FEATURE_WLAN_WAPI
9623 //check if user asked for WAPI with 11n or auto mode, in that case modify
9624 //the phymode to 11g
9625 if(csrIsProfileWapi(pProfile))
9626 {
9627 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9628 {
9629 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9630 }
9631 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9632 {
9633 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9634 }
9635 if(!pScanFilter->phyMode)
9636 {
9637 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9638 }
9639 }
9640#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 /*Save the WPS info*/
9642 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009643 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 if( pProfile->countryCode[0] )
9645 {
9646 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309647 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9648 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 }
9650#ifdef WLAN_FEATURE_VOWIFI_11R
9651 if (pProfile->MDID.mdiePresent)
9652 {
9653 pScanFilter->MDID.mdiePresent = 1;
9654 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9655 }
9656#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309657 vos_mem_copy(pScanFilter->bssid_hint,
9658 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309659
9660#ifdef WLAN_FEATURE_11W
9661 // Management Frame Protection
9662 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9663 pScanFilter->MFPRequired = pProfile->MFPRequired;
9664 pScanFilter->MFPCapable = pProfile->MFPCapable;
9665#endif
9666
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }while(0);
9668
9669 if(!HAL_STATUS_SUCCESS(status))
9670 {
9671 csrFreeScanFilter(pMac, pScanFilter);
9672 }
9673
9674 return(status);
9675}
9676
Jeff Johnson295189b2012-06-20 16:38:30 -07009677tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9678 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9679{
9680 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9681 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 do
9683 {
9684 // Validate the type is ok...
9685 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9686 pCommand = csrGetCommandBuffer( pMac );
9687 if ( !pCommand )
9688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009689 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 break;
9691 }
9692 //Change the substate in case it is waiting for key
9693 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9694 {
9695 csrRoamStopWaitForKeyTimer( pMac );
9696 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9697 }
9698 pCommand->command = eSmeCommandWmStatusChange;
9699 pCommand->sessionId = (tANI_U8)sessionId;
9700 pCommand->u.wmStatusChangeCmd.Type = Type;
9701 if ( eCsrDisassociated == Type )
9702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309703 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9704 pSmeRsp,
9705 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 }
9707 else
9708 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309709 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9710 pSmeRsp,
9711 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 }
9713 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9714 {
9715 fCommandQueued = eANI_BOOLEAN_TRUE;
9716 }
9717 else
9718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009719 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 csrReleaseCommandWmStatusChange( pMac, pCommand );
9721 }
9722
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9724 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 return( fCommandQueued );
9727}
9728
Jeff Johnson295189b2012-06-20 16:38:30 -07009729static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9730{
9731 v_S7_t rssi = 0;
9732 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9733 if(pGetRssiReq)
9734 {
9735 if(NULL != pGetRssiReq->pVosContext)
9736 {
9737 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9738 }
9739 else
9740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009741 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 return;
9743 }
9744
9745 if(NULL != pGetRssiReq->rssiCallback)
9746 {
9747 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9748 }
9749 else
9750 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009751 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 return;
9753 }
9754 }
9755 else
9756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009757 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 }
9759 return;
9760}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309761
9762static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9763{
9764 tANI_S8 snr = 0;
9765 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9766
9767 if (pGetSnrReq)
9768 {
9769 if (VOS_STATUS_SUCCESS !=
9770 WDA_GetSnr(pGetSnrReq->staId, &snr))
9771 {
9772 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9773 return;
9774 }
9775
9776 if (pGetSnrReq->snrCallback)
9777 {
9778 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9779 pGetSnrReq->pDevContext);
9780 }
9781 else
9782 {
9783 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9784 return;
9785 }
9786 }
9787 else
9788 {
9789 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9790 }
9791 return;
9792}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009793#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009794void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9795{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009796 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9797
Jeff Johnson36d483b2013-04-08 11:08:53 -07009798 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009799 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009800 /* Get roam Rssi request is backed up and passed back to the response,
9801 Extract the request message to fetch callback */
9802 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9803 v_S7_t rssi = pRoamRssiRsp->rssi;
9804
9805 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009806 {
9807 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9808 reqBkp->rssiCallback = NULL;
9809 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009810 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009811 }
9812 else
9813 {
9814 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9815 if (NULL != reqBkp)
9816 {
9817 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009818 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009819 }
9820 }
9821 }
9822 else
9823 {
9824 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9825 }
9826 return;
9827}
9828#endif
9829
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009830
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009831#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009832void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9833{
9834 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9835
9836 if (NULL != pTsmStatsRsp)
9837 {
9838 /* Get roam Rssi request is backed up and passed back to the response,
9839 Extract the request message to fetch callback */
9840 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9841
9842 if (NULL != reqBkp)
9843 {
9844 if (NULL != reqBkp->tsmStatsCallback)
9845 {
9846 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9847 pTsmStatsRsp->staId, reqBkp->pDevContext);
9848 reqBkp->tsmStatsCallback = NULL;
9849 }
9850 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009851 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009852 }
9853 else
9854 {
9855 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9856 if (NULL != reqBkp)
9857 {
9858 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009859 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009860 }
9861 }
9862 }
9863 else
9864 {
9865 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9866 }
9867 return;
9868}
9869
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009870void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009871{
9872 tANI_U32 roamTS2 = 0;
9873 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009874 tpPESession pSessionEntry = NULL;
9875 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009876
9877 if (NULL == pSession)
9878 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009879 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009880 return;
9881 }
9882
9883 roamTS2 = vos_timer_get_system_time();
9884 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009885 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9886 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009887 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009888
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009889 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9890 if (NULL == pSessionEntry)
9891 {
9892 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9893 return;
9894 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009895 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009896 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009897 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009898}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009899#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009900
Jeff Johnsone7245742012-09-05 17:12:55 -07009901static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9902{
9903 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9904 if(pTlRssiInd)
9905 {
9906 if(NULL != pTlRssiInd->tlCallback)
9907 {
9908 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009909 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009910 }
9911 else
9912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009913 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009914 }
9915 }
9916 else
9917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009918 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009919 }
9920 return;
9921}
Jeff Johnson295189b2012-06-20 16:38:30 -07009922
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309923eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9924{
9925 tpSirResetAPCapsChange pMsg;
9926 tANI_U16 len;
9927 eHalStatus status = eHAL_STATUS_SUCCESS;
9928
9929 /* Create the message and send to lim */
9930 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309931 pMsg = vos_mem_malloc(len);
9932 if ( NULL == pMsg )
9933 status = eHAL_STATUS_FAILURE;
9934 else
9935 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309936 if (HAL_STATUS_SUCCESS(status))
9937 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309938 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309939 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9940 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309941 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009942 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9943 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309944 status = palSendMBMessage(pMac->hHdd, pMsg);
9945 }
9946 else
9947 {
9948 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9949 }
9950 return status;
9951}
9952
Jeff Johnson295189b2012-06-20 16:38:30 -07009953void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9954{
9955 tSirSmeAssocInd *pAssocInd;
9956 tSirSmeDisassocInd *pDisassocInd;
9957 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +05309958 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9960 tSirSmeNewBssInfo *pNewBss;
9961 tSmeIbssPeerInd *pIbssPeerInd;
9962 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9963 tSirSmeApNewCaps *pApNewCaps;
9964 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9965 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9966 tCsrRoamInfo *pRoamInfo = NULL;
9967 tCsrRoamInfo roamInfo;
9968 eHalStatus status;
9969 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9970 tCsrRoamSession *pSession = NULL;
9971 tpSirSmeSwitchChannelInd pSwitchChnInd;
9972 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309973 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009974
9975
9976 if (NULL == pSirMsg)
9977 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9978 return;
9979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 switch( pSirMsg->messageType )
9981 {
9982 case eWNI_SME_ASSOC_IND:
9983 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309984 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05309985 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009986 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9987 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9988 if( HAL_STATUS_SUCCESS( status ) )
9989 {
9990 pSession = CSR_GET_SESSION(pMac, sessionId);
9991
Jeff Johnson32d95a32012-09-10 13:15:23 -07009992 if(!pSession)
9993 {
9994 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9995 return;
9996 }
9997
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 pRoamInfo = &roamInfo;
9999
10000 // Required for indicating the frames to upper layer
10001 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
10002 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
10003
10004 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
10005 pRoamInfo->beaconLength = pAssocInd->beaconLength;
10006 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
10007 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10008
10009 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
10010 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
10011 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10012
10013 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
10014 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +053010015 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
10016 sizeof(tSirMacAddr));
10017 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
10018 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +053010020 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053010021#ifdef WLAN_FEATURE_AP_HT40_24G
10022 pRoamInfo->HT40MHzIntoEnabledSta =
10023 pAssocInd->HT40MHzIntoEnabledSta;
10024 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
10025 pRoamInfo->HT40MHzIntoEnabledSta);
10026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
10030 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010031#ifdef SAP_AUTH_OFFLOAD
10032 if (pMac->sap_auth_offload)
10033 {
10034 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
10035 pRoamInfo->fAuthRequired = FALSE;
10036 }
10037 else
10038 {
10039#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10041 {
10042 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10043 pSession->pConnectBssDesc,
10044 &(pRoamInfo->peerMac),
10045 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10046 pRoamInfo->fAuthRequired = FALSE;
10047 }
10048 else
10049 {
10050 pRoamInfo->fAuthRequired = TRUE;
10051 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010052#ifdef SAP_AUTH_OFFLOAD
10053 }
10054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10056 if (!HAL_STATUS_SUCCESS(status))
10057 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 /* Send Association completion message to PE */
10060 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10061
10062 /* send a message to CSR itself just to avoid the EAPOL frames going
10063 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10065 {
10066 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10069 {
10070 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10071 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10072 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 }
10075 }
10076 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010079 // Check if AP dis-associated us because of MIC failure. If so,
10080 // then we need to take action immediately and not wait till the
10081 // the WmStatusChange requests is pushed and processed
10082 tSmeCmd *pCommand;
10083
10084 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10085 status = csrRoamGetSessionIdFromBSSID( pMac,
10086 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10087 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010089 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10090 " for session %d "), sessionId);
10091 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10092 MAC_ADDRESS_STR " "
10093 " reason = %d status = %d "),
10094 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10095 pDisassocInd->reasonCode,
10096 pDisassocInd->statusCode);
10097 // If we are in neighbor preauth done state then on receiving
10098 // disassoc or deauth we dont roam instead we just disassoc
10099 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010100 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010101#ifdef WLAN_FEATURE_VOWIFI_11R
10102 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10103 {
10104 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010106#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010107#ifdef FEATURE_WLAN_ESE
10108 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010109 {
10110 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010112#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010113#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010114 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10115 {
10116 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10117 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010118#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010119#ifdef WLAN_FEATURE_LFR_MBB
10120 csr_stop_preauth_reassoc_mbb_timer(pMac);
10121#endif
10122
Agarwal Ashish4f616132013-12-30 23:32:50 +053010123 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010124
Agarwal Ashish4f616132013-12-30 23:32:50 +053010125 if (!pSession)
10126 {
10127 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10128 return;
10129 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010130
Agarwal Ashish4f616132013-12-30 23:32:50 +053010131 if ( csrIsConnStateInfra( pMac, sessionId ) )
10132 {
10133 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010135#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010136 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010137#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010138 csrRoamLinkDown(pMac, sessionId);
10139 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10140 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10141 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010142 /*
10143 * STA/P2P client got disassociated so remove any pending deauth
10144 * commands in sme pending list
10145 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010146 pCommand = csrGetCommandBuffer(pMac);
10147 if (NULL == pCommand)
10148 {
10149 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10150 status = eHAL_STATUS_RESOURCES;
10151 return;
10152 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010153 pCommand->command = eSmeCommandRoam;
10154 pCommand->sessionId = (tANI_U8)sessionId;
10155 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10156 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10157 pDisassocInd->peerMacAddr,
10158 sizeof(tSirMacAddr));
10159 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10160 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010161
Agarwal Ashish4f616132013-12-30 23:32:50 +053010162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010164 else
10165 {
10166 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10167 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10168 }
Kiet Lam82004c62013-11-11 13:24:28 +053010169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010170 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010172 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10174 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10175 if( HAL_STATUS_SUCCESS( status ) )
10176 {
10177 // If we are in neighbor preauth done state then on receiving
10178 // disassoc or deauth we dont roam instead we just disassoc
10179 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010180 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010181#ifdef WLAN_FEATURE_VOWIFI_11R
10182 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10183 {
10184 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10185 }
10186#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010187#ifdef FEATURE_WLAN_ESE
10188 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010189 {
10190 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10191 }
10192#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010193#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010194 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010195 {
10196 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10197 }
10198#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010199#ifdef WLAN_FEATURE_LFR_MBB
10200 csr_stop_preauth_reassoc_mbb_timer(pMac);
10201#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 pSession = CSR_GET_SESSION( pMac, sessionId );
10203
Jeff Johnson32d95a32012-09-10 13:15:23 -070010204 if(!pSession)
10205 {
10206 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10207 return;
10208 }
10209
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 if ( csrIsConnStateInfra( pMac, sessionId ) )
10211 {
10212 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010214#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10215 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10216#endif
10217 csrRoamLinkDown(pMac, sessionId);
10218 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 }
10220 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010221
10222 case eWNI_SME_DISCONNECT_DONE_IND:
10223 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10224 smsLog( pMac, LOG1,
10225 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10226 pDisConDoneInd->reasonCode);
10227 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10228 {
10229 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10230 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10231 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10232 sizeof(tSirMacAddr));
10233 status = csrRoamCallCallback(pMac,
10234 pDisConDoneInd->sessionId,
10235 &roamInfo, 0,
10236 eCSR_ROAM_LOSTLINK,
10237 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010238 pSession = CSR_GET_SESSION(pMac,
10239 pDisConDoneInd->sessionId);
10240 if (pSession &&
10241 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10242 csrRoamStateChange(pMac,
10243 eCSR_ROAMING_STATE_IDLE,
10244 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010245 }
10246 else
10247 {
10248 smsLog(pMac, LOGE, FL("Inactive session %d"),
10249 pDisConDoneInd->sessionId);
10250 }
10251 break;
10252
Jeff Johnson295189b2012-06-20 16:38:30 -070010253 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 -080010254 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10256 //Update with the new channel id.
10257 //The channel id is hidden in the statusCode.
10258 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10259 if( HAL_STATUS_SUCCESS( status ) )
10260 {
10261 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010262 if(!pSession)
10263 {
10264 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10265 return;
10266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10268 if(pSession->pConnectBssDesc)
10269 {
10270 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10271 }
10272 }
10273 break;
10274
10275 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010276 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010277 {
10278 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10279 sessionId = pDeauthRsp->sessionId;
10280 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10281 {
10282 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10284 {
10285 pRoamInfo = &roamInfo;
10286 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010287 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10288 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10290 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10291 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10292 }
10293 }
10294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 break;
10296
10297 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010298 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010299 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 {
10301 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10302 sessionId = pDisassocRsp->sessionId;
10303 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10304 {
10305 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010306 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10307 {
10308 pRoamInfo = &roamInfo;
10309 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010310 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10311 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10313 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10314 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10315 }
10316 }
10317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010319 case eWNI_SME_LOST_LINK_PARAMS_IND:
10320 {
10321 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10322 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10323 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10324 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10325 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10326 pRoamInfo = &roamInfo;
10327 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10328 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10329 break;
10330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 case eWNI_SME_MIC_FAILURE_IND:
10332 {
10333 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10334 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10335 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010336
10337 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10338 if( HAL_STATUS_SUCCESS( status ) )
10339 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010340 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010341 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10342 pRoamInfo = &roamInfo;
10343 if(pMicInd->info.multicast)
10344 {
10345 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10346 }
10347 else
10348 {
10349 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10350 }
10351 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10352 }
10353
Jeff Johnson295189b2012-06-20 16:38:30 -070010354#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10355 {
lukez3c809222013-05-03 10:23:02 -070010356 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010358 if(!pSession)
10359 {
10360 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10361 return;
10362 }
lukez3c809222013-05-03 10:23:02 -070010363
Kiet Lam64c1b492013-07-12 13:56:44 +053010364 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10366 secEvent.encryptionModeMulticast =
10367 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10368 secEvent.encryptionModeUnicast =
10369 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10370 secEvent.authMode =
10371 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010372 vos_mem_copy(secEvent.bssid,
10373 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10375 }
10376#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 }
10378 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10380 {
10381 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10382 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010383 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010384
10385 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10386 if( HAL_STATUS_SUCCESS( status ) )
10387 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010388 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10390 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10391 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10392 }
10393 }
10394 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010395
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10397 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10398 switch( pStatusChangeMsg->statusChangeCode )
10399 {
10400 case eSIR_SME_IBSS_ACTIVE:
10401 sessionId = csrFindIbssSession( pMac );
10402 if( CSR_SESSION_ID_INVALID != sessionId )
10403 {
10404 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010405 if(!pSession)
10406 {
10407 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10408 return;
10409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10411 if(pSession->pConnectBssDesc)
10412 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010413 vos_mem_copy(&roamInfo.bssid,
10414 pSession->pConnectBssDesc->bssId,
10415 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10417 pRoamInfo = &roamInfo;
10418 }
10419 else
10420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010421 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010422 }
10423 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10424 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10425 }
10426 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 case eSIR_SME_IBSS_INACTIVE:
10428 sessionId = csrFindIbssSession( pMac );
10429 if( CSR_SESSION_ID_INVALID != sessionId )
10430 {
10431 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010432 if(!pSession)
10433 {
10434 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10435 return;
10436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10438 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10439 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10440 }
10441 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10443 sessionId = csrFindIbssSession( pMac );
10444 if( CSR_SESSION_ID_INVALID != sessionId )
10445 {
10446 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010447 if(!pSession)
10448 {
10449 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10450 return;
10451 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 // update the connection state information
10453 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010454#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10455 {
10456 vos_log_ibss_pkt_type *pIbssLog;
10457 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10459 if(pIbssLog)
10460 {
10461 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10462 if(pNewBss)
10463 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010464 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 if(pNewBss->ssId.length)
10466 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010467 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
10468 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 }
10470 pIbssLog->operatingChannel = pNewBss->channelNumber;
10471 }
10472 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10473 {
10474 //***U8 is not enough for beacon interval
10475 pIbssLog->beaconInterval = (v_U8_t)bi;
10476 }
10477 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10478 }
10479 }
10480#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010482
10483 if ((eCSR_ENCRYPT_TYPE_NONE ==
10484 pSession->connectedProfile.EncryptionType ))
10485 {
10486 csrRoamIssueSetContextReq( pMac, sessionId,
10487 pSession->connectedProfile.EncryptionType,
10488 pSession->pConnectBssDesc,
10489 &Broadcastaddr,
10490 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010492 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10493 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010494 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10495 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 pRoamInfo = &roamInfo;
10497 //This BSSID is th ereal BSSID, let's save it
10498 if(pSession->pConnectBssDesc)
10499 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010500 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10501 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010503 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010504 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010506 // detection by LIM that the capabilities of the associated AP have changed.
10507 case eSIR_SME_AP_CAPS_CHANGED:
10508 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010509 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10511 if( HAL_STATUS_SUCCESS( status ) )
10512 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010513 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10514 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010515 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010516 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10517 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10518 )
10519 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010520 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10521 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010522 }
10523 else
10524 {
10525 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010526 FL("Skipping csrScanForCapabilityChange as "
10527 "CSR is in state %s and sub-state %s"),
10528 macTraceGetcsrRoamState(
10529 pMac->roam.curState[sessionId]),
10530 macTraceGetcsrRoamSubState(
10531 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010532 /* We ignore the caps change event if CSR is not in full connected state.
10533 * Send one event to PE to reset limSentCapsChangeNtf
10534 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10535 * otherwise lim cannot send any CAPS change events to SME */
10536 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 }
10539 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010540
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 default:
10542 roamStatus = eCSR_ROAM_FAILED;
10543 result = eCSR_ROAM_RESULT_NONE;
10544 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010545 } // end switch on statusChangeCode
10546 if(eCSR_ROAM_RESULT_NONE != result)
10547 {
10548 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10549 }
10550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 case eWNI_SME_IBSS_NEW_PEER_IND:
10552 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010553#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10554 {
10555 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10557 if(pIbssLog)
10558 {
10559 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010560 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10562 }
10563 }
10564#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 sessionId = csrFindIbssSession( pMac );
10566 if( CSR_SESSION_ID_INVALID != sessionId )
10567 {
10568 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010569
10570 if(!pSession)
10571 {
10572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10573 return;
10574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10576 if(pSession->pConnectBssDesc)
10577 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010578 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10579 sizeof(tCsrBssid));
10580 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10581 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10583 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010584 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10585 - sizeof(tSmeIbssPeerInd)));
10586 if ( NULL == roamInfo.pbFrames )
10587 status = eHAL_STATUS_FAILURE;
10588 else
10589 status = eHAL_STATUS_SUCCESS;
10590 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 {
10592 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010593 vos_mem_copy(roamInfo.pbFrames,
10594 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10595 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 }
10597 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10598 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10599 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010600 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10601 if ( NULL == roamInfo.pBssDesc )
10602 status = eHAL_STATUS_FAILURE;
10603 else
10604 status = eHAL_STATUS_SUCCESS;
10605 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010607 vos_mem_copy(roamInfo.pBssDesc,
10608 pSession->pConnectBssDesc,
10609 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 }
10611 if(HAL_STATUS_SUCCESS(status))
10612 {
10613 pRoamInfo = &roamInfo;
10614 }
10615 else
10616 {
10617 if(roamInfo.pbFrames)
10618 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010619 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 }
10621 if(roamInfo.pBssDesc)
10622 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010623 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 }
10625 }
10626 }
10627 else
10628 {
10629 pRoamInfo = &roamInfo;
10630 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010631 if ((eCSR_ENCRYPT_TYPE_NONE ==
10632 pSession->connectedProfile.EncryptionType ))
10633 {
10634 csrRoamIssueSetContextReq( pMac, sessionId,
10635 pSession->connectedProfile.EncryptionType,
10636 pSession->pConnectBssDesc,
10637 &(pIbssPeerInd->peerAddr),
10638 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 }
10641 else
10642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010643 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 }
10645 //send up the sec type for the new peer
10646 if (pRoamInfo)
10647 {
10648 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10649 }
10650 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10651 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10652 if(pRoamInfo)
10653 {
10654 if(roamInfo.pbFrames)
10655 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010656 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010657 }
10658 if(roamInfo.pBssDesc)
10659 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010660 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 }
10662 }
10663 }
10664 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10666 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10667 sessionId = csrFindIbssSession( pMac );
10668 if( CSR_SESSION_ID_INVALID != sessionId )
10669 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010670#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10671 {
10672 vos_log_ibss_pkt_type *pIbssLog;
10673
10674 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10675 if(pIbssLog)
10676 {
10677 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10678 if(pIbssPeerInd)
10679 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010680 vos_mem_copy(pIbssLog->peerMacAddr,
10681 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 }
10683 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10684 }
10685 }
10686#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010687 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10689 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10690 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010691 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10692 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10694 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10695 }
10696 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 case eWNI_SME_SETCONTEXT_RSP:
10698 {
10699 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10700 tListElem *pEntry;
10701 tSmeCmd *pCommand;
10702
10703 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10704 if ( pEntry )
10705 {
10706 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10707 if ( eSmeCommandSetKey == pCommand->command )
10708 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010709 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010711
10712 if(!pSession)
10713 {
10714 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10715 return;
10716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010717
10718#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10719 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10720 {
10721 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010722 vos_mem_set(&setKeyEvent,
10723 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010724 if( pRsp->peerMacAddr[0] & 0x01 )
10725 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010726 setKeyEvent.eventId =
10727 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010728 }
10729 else
10730 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010731 setKeyEvent.eventId =
10732 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010734 if( pRsp->peerMacAddr[0] & 0x01 )
10735 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010736 pMac->pmc.full_power_till_set_key = false;
10737 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010739 setKeyEvent.encryptionModeMulticast =
10740 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10741 setKeyEvent.encryptionModeUnicast =
10742 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010743 vos_mem_copy(setKeyEvent.bssid,
10744 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 setKeyEvent.authMode =
10746 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010747 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 {
10749 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10750 }
10751 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10752 }
10753#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10754 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10755 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010756 csrRoamStopWaitForKeyTimer( pMac );
10757
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 //We are done with authentication, whethere succeed or not
10759 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 //We do it here because this linkup function is not called after association
10761 //when a key needs to be set.
10762 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10763 {
10764 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10765 }
10766 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010767 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010768 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010769 vos_mem_copy(&roamInfo.peerMac,
10770 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010771 //Make sure we install the GTK before indicating to HDD as authenticated
10772 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010773 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10774 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010775 {
Yathish9f22e662012-12-10 14:21:35 -080010776#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10777 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10778 {
10779 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010780 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010781 if (NULL == pMsg)
10782 {
10783 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10784 return;
10785 }
10786
Yathish9f22e662012-12-10 14:21:35 -080010787 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010788 pMsg->length = pal_cpu_to_be16(sizeof(
10789 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010790 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010791 vos_mem_copy(pMsg->bssid,
10792 pSession->connectedProfile.bssid,
10793 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010794 status = palSendMBMessage(pMac->hHdd, pMsg );
10795 }
10796#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010797 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010798 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010799 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010800 && (pSession->connectState ==
10801 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10802 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010803 && (VOS_P2P_GO_MODE !=
10804 pSession->pCurRoamProfile->csrPersona
10805 && VOS_STA_SAP_MODE !=
10806 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010807 {
10808 tpSirSmeHT40OBSSScanInd pMsg;
10809 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010810 if (NULL == pMsg)
10811 {
10812 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10813 return;
10814 }
10815
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010816 pMsg->messageType =
10817 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10818 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010819 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10820 vos_mem_copy(pMsg->peerMacAddr,
10821 pSession->connectedProfile.bssid,
10822 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010823 status = palSendMBMessage(pMac->hHdd,
10824 pMsg );
10825 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010826 else
10827 {
10828 smsLog( pMac, LOG1,FL("OBSS SCAN"
10829 "Indication not sent to FW"
10830 "channel %d OBSS_SCAN: %d"),
10831 pSession->connectedProfile.
10832 operationChannel,
10833 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10834 smsLog( pMac, LOG1,FL("connectState %d"
Jeff Johnson89477502017-09-19 08:35:23 -070010835 "pCurRoamProfile %pK"),
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010836 pSession->connectState,
10837 pSession->pCurRoamProfile);
10838 }
10839
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010840 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010841 }
10842 else
10843 {
10844 result = eCSR_ROAM_RESULT_NONE;
10845 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010846 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 }
10848 else
10849 {
10850 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010851 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10852 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10853 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010855 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10857 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10859 // can go ahead and initiate the TSPEC if any are pending
10860 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010861#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 //Send Adjacent AP repot to new AP.
10863 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10864 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010865 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010867#ifdef FEATURE_WLAN_ESE_UPLOAD
10868 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010869#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010870 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010871#endif
10872 pSession->isPrevApInfoValid = FALSE;
10873 }
10874#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10876 {
10877 csrReleaseCommandSetKey( pMac, pCommand );
10878 }
10879 }
10880 else
10881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010882 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 }
10884 }
10885 else
10886 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010887 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 smeProcessPendingQueue( pMac );
10890 }
10891 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 case eWNI_SME_REMOVEKEY_RSP:
10893 {
10894 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10895 tListElem *pEntry;
10896 tSmeCmd *pCommand;
10897
10898 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10899 if ( pEntry )
10900 {
10901 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10902 if ( eSmeCommandRemoveKey == pCommand->command )
10903 {
10904 sessionId = pCommand->sessionId;
10905 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010906
10907 if(!pSession)
10908 {
10909 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10910 return;
10911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010912#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10913 {
10914 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010915 vos_mem_set(&removeKeyEvent,
10916 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10918 removeKeyEvent.encryptionModeMulticast =
10919 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10920 removeKeyEvent.encryptionModeUnicast =
10921 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010922 vos_mem_copy( removeKeyEvent.bssid,
10923 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 removeKeyEvent.authMode =
10925 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010926 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 {
10928 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10929 }
10930 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10931 }
10932#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010933 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010935 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10936 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 result = eCSR_ROAM_RESULT_NONE;
10938 pRoamInfo = &roamInfo;
10939 }
10940 else
10941 {
10942 result = eCSR_ROAM_RESULT_FAILURE;
10943 }
10944 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10945 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10946 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10947 {
10948 csrReleaseCommandRemoveKey( pMac, pCommand );
10949 }
10950 }
10951 else
10952 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010953 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 }
10955 }
10956 else
10957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010958 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 smeProcessPendingQueue( pMac );
10961 }
10962 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010963 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010964 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010965 csrRoamStatsRspProcessor( pMac, pSirMsg );
10966 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010967#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010968 case eWNI_SME_GET_ROAM_RSSI_RSP:
10969 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10970 csrRoamRssiRspProcessor( pMac, pSirMsg );
10971 break;
10972#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010973#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010974 case eWNI_SME_GET_TSM_STATS_RSP:
10975 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10976 csrTsmStatsRspProcessor( pMac, pSirMsg );
10977 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010978#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010980 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 csrUpdateRssi( pMac, pSirMsg );
10982 break;
10983
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010984 case eWNI_SME_GET_SNR_REQ:
10985 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10986 csrUpdateSnr(pMac, pSirMsg);
10987 break;
10988
Jeff Johnson295189b2012-06-20 16:38:30 -070010989#ifdef WLAN_FEATURE_VOWIFI_11R
10990 case eWNI_SME_FT_PRE_AUTH_RSP:
10991 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10992 break;
10993#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010994#ifdef WLAN_FEATURE_LFR_MBB
10995 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
10996 csr_roam_preauth_rsp_mbb_processor(pMac,
10997 (tpSirFTPreAuthRsp)pSirMsg);
10998 break;
10999#endif
11000
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11002 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011003 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 -070011004 sessionId = pSmeMaxAssocInd->sessionId;
11005 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011006 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
11007 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11009 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11010 break;
11011
11012 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011013 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 btampEstablishLogLinkHdlr( pSirMsg );
11015 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070011016 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011017 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011018 csrRoamRssiIndHdlr( pMac, pSirMsg );
11019 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011020#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11021 case eWNI_SME_CANDIDATE_FOUND_IND:
11022 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
11023 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
11024 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070011025 case eWNI_SME_HANDOFF_REQ:
11026 smsLog( pMac, LOG2, FL("Handoff Req from self"));
11027 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
11028 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011030
11031 default:
11032 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070011034}
11035
Jeff Johnson295189b2012-06-20 16:38:30 -070011036void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
11037 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
11038{
11039 if(pSession)
11040 {
11041 if(pSession->bRefAssocStartCnt)
11042 {
11043 pSession->bRefAssocStartCnt--;
11044 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11045 //Need to call association_completion because there is an assoc_start pending.
11046 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11047 eCSR_ROAM_ASSOCIATION_COMPLETION,
11048 eCSR_ROAM_RESULT_FAILURE);
11049 }
11050 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11051 }
11052 else
11053 {
11054 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11055 }
11056}
11057
11058
11059eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11060{
11061 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11063 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11064 {
11065 status = csrScanRequestLostLink1( pMac, sessionId );
11066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011067 return(status);
11068}
11069
Jeff Johnson295189b2012-06-20 16:38:30 -070011070//return a boolean to indicate whether roaming completed or continue.
11071tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11072 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11073{
11074 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11075 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11076 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11077 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011078 if(!pSession)
11079 {
11080 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11081 return eANI_BOOLEAN_FALSE;
11082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 //Check whether time is up
11084 if(pSession->fCancelRoaming || fForce ||
11085 ((curTime - pSession->roamingStartTime) > roamTime) ||
11086 eCsrReassocRoaming == pSession->roamingReason ||
11087 eCsrDynamicRoaming == pSession->roamingReason)
11088 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011089 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011090 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11091 {
11092 //roaming is cancelled, tell HDD to indicate disconnect
11093 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11094 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11095 //to be eSIR_BEACON_MISSED
11096 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11097 {
11098 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11099 }
11100 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11101 {
11102 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11103 }
11104 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11105 {
11106 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11107 }
11108 else
11109 {
11110 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11111 }
11112 }
11113 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11114 pSession->roamingReason = eCsrNotRoaming;
11115 }
11116 else
11117 {
11118 pSession->roamResult = roamResult;
11119 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11120 {
11121 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11122 pSession->roamingReason = eCsrNotRoaming;
11123 }
11124 else
11125 {
11126 fCompleted = eANI_BOOLEAN_FALSE;
11127 }
11128 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 return(fCompleted);
11130}
11131
Jeff Johnson295189b2012-06-20 16:38:30 -070011132void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11133{
11134 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011135
11136 if(!pSession)
11137 {
11138 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11139 return;
11140 }
11141
Jeff Johnson295189b2012-06-20 16:38:30 -070011142 if(CSR_IS_ROAMING(pSession))
11143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011144 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011145 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11146 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11147 {
11148 //No need to do anything in here because the handler takes care of it
11149 }
11150 else
11151 {
11152 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11153 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11154 //Roaming is stopped after here
11155 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11156 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011157 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 csrRoamStopRoamingTimer(pMac, sessionId);
11159 }
11160 }
11161}
11162
Jeff Johnson295189b2012-06-20 16:38:30 -070011163void csrRoamRoamingTimerHandler(void *pv)
11164{
11165 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11166 tpAniSirGlobal pMac = pInfo->pMac;
11167 tANI_U32 sessionId = pInfo->sessionId;
11168 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011169
11170 if(!pSession)
11171 {
11172 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11173 return;
11174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011175
11176 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11177 {
11178 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11179 {
11180 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11181 pSession->roamingReason = eCsrNotRoaming;
11182 }
11183 }
11184}
11185
Jeff Johnson295189b2012-06-20 16:38:30 -070011186eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11187{
11188 eHalStatus status;
11189 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011190
11191 if(!pSession)
11192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011193 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011194 return eHAL_STATUS_FAILURE;
11195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011196
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011197 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011198 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011199 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011200
11201 return (status);
11202}
11203
Jeff Johnson295189b2012-06-20 16:38:30 -070011204eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11205{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011206 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011207}
11208
Jeff Johnson295189b2012-06-20 16:38:30 -070011209void csrRoamWaitForKeyTimeOutHandler(void *pv)
11210{
11211 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11212 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011214 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011215
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011216 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011217 macTraceGetNeighbourRoamState(
11218 pMac->roam.neighborRoamInfo.neighborRoamState),
11219 macTraceGetcsrRoamSubState(
11220 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011221
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011222 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011223 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011224 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011225 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11226 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011227 //Change the substate so command queue is unblocked.
11228 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11229 pMac->roam.curSubState[pInfo->sessionId] =
11230 eCSR_ROAM_SUBSTATE_NONE;
11231 vos_spin_lock_release(&pMac->roam.roam_state_lock);
11232
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011233#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011234 if (csrNeighborRoamIsHandoffInProgress(pMac))
11235 {
11236 /*
11237 * Enable heartbeat timer when hand-off is in progress
11238 * and Key Wait timer expired.
11239 */
11240 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11241 " (nHBCount=%d)",
11242 pMac->roam.configParam.HeartbeatThresh24);
11243 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11244 pMac->roam.configParam.HeartbeatThresh24,
11245 NULL, eANI_BOOLEAN_FALSE);
11246 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011247#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011248
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011249 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011250
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011251 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011252 {
11253 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11254 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011255 status = sme_AcquireGlobalLock(&pMac->sme);
11256 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011257 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011258 csrRoamDisconnect(pMac, pInfo->sessionId,
11259 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11260 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011261 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011262 }
11263 else
11264 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011265 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11266 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011267 }
11268 }
11269 else
11270 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011271 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011272 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 }
11275
11276}
11277
Jeff Johnson295189b2012-06-20 16:38:30 -070011278eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11279{
11280 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011281#ifdef FEATURE_WLAN_LFR
11282 if (csrNeighborRoamIsHandoffInProgress(pMac))
11283 {
11284 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011285 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11286 macTraceGetNeighbourRoamState(
11287 pMac->roam.neighborRoamInfo.neighborRoamState),
11288 macTraceGetcsrRoamSubState(
11289 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11290 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011291 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11292 }
11293#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011294 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011295 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011296
11297 return (status);
11298}
11299
Jeff Johnson295189b2012-06-20 16:38:30 -070011300eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11301{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011302 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11303 macTraceGetNeighbourRoamState(
11304 pMac->roam.neighborRoamInfo.neighborRoamState),
11305 macTraceGetcsrRoamSubState(
11306 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011307#ifdef FEATURE_WLAN_LFR
11308 if (csrNeighborRoamIsHandoffInProgress(pMac))
11309 {
11310 /*
11311 * Enable heartbeat timer when hand-off is in progress
11312 * and Key Wait timer got stopped for some reason
11313 */
11314 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011315 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011316 pMac->roam.configParam.HeartbeatThresh24);
11317 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11318 pMac->roam.configParam.HeartbeatThresh24,
11319 NULL, eANI_BOOLEAN_FALSE);
11320 }
11321#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011322 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011323}
11324
Jeff Johnson295189b2012-06-20 16:38:30 -070011325void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11326 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11327{
11328 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11329 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011330 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11331 /* To silence the KW tool Null chaeck is added */
11332 if(!pSession)
11333 {
11334 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11335 return;
11336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011337
11338 if(pCommand)
11339 {
11340 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11344 {
11345 //if success, force roaming completion
11346 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11347 }
11348 else
11349 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011350 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011351 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011352 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11353 }
11354}
11355
Jeff Johnson295189b2012-06-20 16:38:30 -070011356eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11357{
11358 eHalStatus status = eHAL_STATUS_SUCCESS;
11359 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11360 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11361 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011363 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011365 /* To silence the KW tool Null chaeck is added */
11366 if(!pSession)
11367 {
11368 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11369 return eHAL_STATUS_FAILURE;
11370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011372 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011374 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011375 if ( eWNI_SME_DISASSOC_IND == type )
11376 {
11377 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11378 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11379 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011380 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011381 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11382 sizeof(tSirMacAddr));
11383 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 }
11385 else if ( eWNI_SME_DEAUTH_IND == type )
11386 {
11387 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11388 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11389 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011390 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011391 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11392 sizeof(tSirMacAddr));
11393 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 }
11395 else
11396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011397 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011399 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011401 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11402 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11403 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
11404
11405 if (type == eWNI_SME_DEAUTH_IND || type == eWNI_SME_DISASSOC_IND) {
11406 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11407 eCSR_ROAM_LOSTLINK_DETECTED, result);
11408 } else if(!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11409 csrRoamCallCallback(pMac, sessionId, NULL, 0,
11410 eCSR_ROAM_LOSTLINK_DETECTED, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 }
11412
11413 if ( eWNI_SME_DISASSOC_IND == type )
11414 {
11415 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11416 }
11417 else if ( eWNI_SME_DEAUTH_IND == type )
11418 {
11419 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 if(!HAL_STATUS_SUCCESS(status))
11422 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011423 //If fail to send confirmation to PE, not to trigger roaming
11424 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 }
11426
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011427
11428 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11429 that we are roaming. But if we cannot possibly roam, or if we are unable to
11430 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 if(fToRoam)
11432 {
11433 //Only remove the connected BSS in infrastructure mode
11434 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11435 //Not to do anying for lostlink with WDS
11436 if( pMac->roam.configParam.nRoamingTime )
11437 {
11438 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
11439 ( eWNI_SME_DEAUTH_IND == type ) ?
11440 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
11441 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011442 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011443 //For IBSS, we need to give some more info to HDD
11444 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
11445 {
11446 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
11447 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11448 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11449 }
11450 else
11451 {
11452 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
11453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
11455 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
11456 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011457 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 }
11459 else
11460 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011461 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 fToRoam = eANI_BOOLEAN_FALSE;
11463 }
11464 }
11465 else
11466 {
11467 //We are told not to roam, indicate lostlink
11468 fToRoam = eANI_BOOLEAN_FALSE;
11469 }
11470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 if(!fToRoam)
11472 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011473 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 Still enable idle scan for polling in case concurrent sessions are running */
11475 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11476 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011477 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 }
11479 }
11480
11481 return (status);
11482}
11483
Jeff Johnson295189b2012-06-20 16:38:30 -070011484eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11485{
11486 eHalStatus status = eHAL_STATUS_SUCCESS;
11487 tListElem *pEntry = NULL;
11488 tSmeCmd *pCommand = NULL;
11489 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011490
11491 if(!pSession)
11492 {
11493 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11494 return eHAL_STATUS_FAILURE;
11495 }
11496
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 //Only remove the connected BSS in infrastructure mode
11499 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11500 if(pMac->roam.configParam.nRoamingTime)
11501 {
11502 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11503 {
11504 //before starting the lost link logic release the roam command for handoff
11505 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11506 if(pEntry)
11507 {
11508 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11509 }
11510 if(pCommand)
11511 {
11512 if (( eSmeCommandRoam == pCommand->command ) &&
11513 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11514 {
11515 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11516 {
11517 csrReleaseCommandRoam( pMac, pCommand );
11518 }
11519 }
11520 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011521 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 }
11523 }
11524 else
11525 {
11526 //We are told not to roam, indicate lostlink
11527 status = eHAL_STATUS_FAILURE;
11528 }
11529
11530 return (status);
11531}
Jeff Johnson295189b2012-06-20 16:38:30 -070011532void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11533{
11534 tListElem *pEntry;
11535 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11537 if ( pEntry )
11538 {
11539 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11540 if ( eSmeCommandWmStatusChange == pCommand->command )
11541 {
11542 // Nothing to process in a Lost Link completion.... It just kicks off a
11543 // roaming sequence.
11544 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11545 {
11546 csrReleaseCommandWmStatusChange( pMac, pCommand );
11547 }
11548 else
11549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011550 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 }
11552
11553 }
11554 else
11555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011556 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 }
11558 }
11559 else
11560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011561 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011563 smeProcessPendingQueue( pMac );
11564}
11565
Jeff Johnson295189b2012-06-20 16:38:30 -070011566void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11567{
11568 eHalStatus status = eHAL_STATUS_FAILURE;
11569 tSirSmeRsp *pSirSmeMsg;
11570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011571
11572 if(!pSession)
11573 {
11574 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11575 return;
11576 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011577 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11578 pCommand->sessionId,
11579 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 switch ( pCommand->u.wmStatusChangeCmd.Type )
11581 {
11582 case eCsrDisassociated:
11583 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11584 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011586 case eCsrDeauthenticated:
11587 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11588 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011591 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 break;
11593 }
11594 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11595 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11596 {
11597 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11598 {
11599 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011600 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 }
11602 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11604 // command here since there is nothing else to do.
11605 csrRoamWmStatusChangeComplete( pMac );
11606}
11607
Jeff Johnson295189b2012-06-20 16:38:30 -070011608//This function returns band and mode information.
11609//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11610//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011611static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11612 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011613{
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11615 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11616 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011617 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011618
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 //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 -070011620 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11621 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11622 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11623 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 {
11625 switch( pMac->roam.configParam.uCfgDot11Mode )
11626 {
11627 case eCSR_CFG_DOT11_MODE_11A:
11628 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11629 eBand = eCSR_BAND_5G;
11630 break;
11631 case eCSR_CFG_DOT11_MODE_11B:
11632 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11633 eBand = eCSR_BAND_24;
11634 break;
11635 case eCSR_CFG_DOT11_MODE_11G:
11636 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11637 eBand = eCSR_BAND_24;
11638 break;
11639 case eCSR_CFG_DOT11_MODE_11N:
11640 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011641 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11642 break;
11643#ifdef WLAN_FEATURE_11AC
11644 case eCSR_CFG_DOT11_MODE_11AC:
11645 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11646 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011647 /* If the operating channel is in 2.4 GHz band, check for
11648 * INI item to disable VHT operation in 2.4 GHz band
11649 */
11650 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11651 !pMac->roam.configParam.enableVhtFor24GHz)
11652 {
11653 /* Disable 11AC operation */
11654 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11655 }
11656 else
11657 {
11658 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11659 }
11660 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011661 }
11662 else
11663 {
11664 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11665 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11666 }
11667 break;
11668 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11669 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11670 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011671 /* If the operating channel is in 2.4 GHz band, check for
11672 * INI item to disable VHT operation in 2.4 GHz band
11673 */
11674 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11675 !pMac->roam.configParam.enableVhtFor24GHz)
11676 {
11677 /* Disable 11AC operation */
11678 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11679 }
11680 else
11681 {
11682 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11683 }
11684 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011685 }
11686 else
11687 {
11688 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11689 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11690 }
11691 break;
11692#endif
11693 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011694#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011695 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11696 {
11697 /* If the operating channel is in 2.4 GHz band, check for
11698 * INI item to disable VHT operation in 2.4 GHz band
11699 */
11700 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11701 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011702 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011703 /* Disable 11AC operation */
11704 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011705 }
11706 else
11707 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011708 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11709 }
11710 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11711 }
11712 else
11713 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011714 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11715 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011716 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011717#else
11718 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11719 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11720#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011721 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 default:
11723 // Global dot11 Mode setting is 11a/b/g.
11724 // use the channel number to determine the Mode setting.
11725 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11726 {
11727 eBand = pMac->roam.configParam.eBand;
11728 if(eCSR_BAND_24 == eBand)
11729 {
11730 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11731 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11732 }
11733 else
11734 {
11735 //prefer 5GHz
11736 eBand = eCSR_BAND_5G;
11737 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11738 }
11739 }
11740 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11741 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011742 // WiFi tests require IBSS networks to start in 11b mode
11743 // without any change to the default parameter settings
11744 // on the adapter. We use ACU to start an IBSS through
11745 // creation of a startIBSS profile. This startIBSS profile
11746 // has Auto MACProtocol and the adapter property setting
11747 // for dot11Mode is also AUTO. So in this case, let's
11748 // start the IBSS network in 11b mode instead of 11g mode.
11749 // So this is for Auto=profile->MacProtocol && Auto=Global.
11750 // dot11Mode && profile->channel is < 14, then start the IBSS
11751 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011753 // Note: we used to have this start as an 11g IBSS for best
11754 // performance... now to specify that the user will have to
11755 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11757 eBand = eCSR_BAND_24;
11758 }
11759 else
11760 {
11761 // else, it's a 5.0GHz channel. Set mode to 11a.
11762 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11763 eBand = eCSR_BAND_5G;
11764 }
11765 break;
11766 }//switch
11767 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11768 else
11769 {
11770 //dot11 mode is set, lets pick the band
11771 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11772 {
11773 // channel is Auto also.
11774 eBand = pMac->roam.configParam.eBand;
11775 if(eCSR_BAND_ALL == eBand)
11776 {
11777 //prefer 5GHz
11778 eBand = eCSR_BAND_5G;
11779 }
11780 }
11781 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11782 {
11783 eBand = eCSR_BAND_24;
11784 }
11785 else
11786 {
11787 eBand = eCSR_BAND_5G;
11788 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 if(pBand)
11791 {
11792 *pBand = eBand;
11793 }
11794
11795 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011796 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11798 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011799
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011800 /* 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 +053011801 if (
11802#ifdef SAP_AUTH_OFFLOAD
11803 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11804#endif
11805 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11806 ((pProfile->privacy == 1) &&
11807 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011808 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011809#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011810 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011811#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011812 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11813 {
11814 //We cannot do 11n here
11815 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11816 {
11817 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11818 }
11819 else
11820 {
11821 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11822 }
11823 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 return( cfgDot11Mode );
11825}
11826
Jeff Johnson295189b2012-06-20 16:38:30 -070011827eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11828{
11829 eHalStatus status;
11830 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011831
11832 if(!pSession)
11833 {
11834 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11835 return eHAL_STATUS_FAILURE;
11836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011837
11838#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11839 {
11840 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11842 if(pIbssLog)
11843 {
11844 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11845 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11846 }
11847 }
11848#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 // Set the roaming substate to 'stop Bss request'...
11850 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11851
11852 // attempt to stop the Bss (reason code is ignored...)
11853 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011854 if(!HAL_STATUS_SUCCESS(status))
11855 {
11856 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11857 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 return (status);
11859}
11860
Jeff Johnson295189b2012-06-20 16:38:30 -070011861//pNumChan is a caller allocated space with the sizeof pChannels
11862eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11863{
11864
11865 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11866 (tANI_U8 *)pChannels,
11867 pNumChan));
11868}
11869
Kiran4a17ebe2013-01-31 10:43:43 -080011870tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11871{
11872 tANI_U32 cfgLength = 0;
11873 tANI_U16 cfgId = 0;
11874 tPowerdBm maxTxPwr = 0;
11875 tANI_U8 *pCountryInfo = NULL;
11876 eHalStatus status;
11877 tANI_U8 count = 0;
11878 tANI_U8 firstChannel;
11879 tANI_U8 maxChannels;
11880
11881 if (CSR_IS_CHANNEL_5GHZ(channel))
11882 {
11883 cfgId = WNI_CFG_MAX_TX_POWER_5;
11884 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11885 }
11886 else if (CSR_IS_CHANNEL_24GHZ(channel))
11887 {
11888 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11889 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11890 }
11891 else
11892 return maxTxPwr;
11893
Kiet Lam64c1b492013-07-12 13:56:44 +053011894 pCountryInfo = vos_mem_malloc(cfgLength);
11895 if ( NULL == pCountryInfo )
11896 status = eHAL_STATUS_FAILURE;
11897 else
11898 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011899 if (status != eHAL_STATUS_SUCCESS)
11900 {
11901 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011902 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011903 __FUNCTION__, status);
11904 goto error;
11905 }
11906 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11907 if (status != eHAL_STATUS_SUCCESS)
11908 {
11909 goto error;
11910 }
11911 /* Identify the channel and maxtxpower */
11912 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11913 {
11914 firstChannel = pCountryInfo[count++];
11915 maxChannels = pCountryInfo[count++];
11916 maxTxPwr = pCountryInfo[count++];
11917
11918 if ((channel >= firstChannel) &&
11919 (channel < (firstChannel + maxChannels)))
11920 {
11921 break;
11922 }
11923 }
11924
11925error:
11926 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011927 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011928
11929 return maxTxPwr;
11930}
11931
11932
Jeff Johnson295189b2012-06-20 16:38:30 -070011933tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11934{
11935 tANI_BOOLEAN fValid = FALSE;
11936 tANI_U32 idxValidChannels;
11937 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11938
11939 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11940 {
11941 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11942 {
11943 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11944 {
11945 fValid = TRUE;
11946 break;
11947 }
11948 }
11949 }
11950 pMac->roam.numValidChannels = len;
11951 return fValid;
11952}
11953
Jeff Johnson295189b2012-06-20 16:38:30 -070011954tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11955{
11956 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11957 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11959 {
11960 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11961 {
11962 fValid = eANI_BOOLEAN_TRUE;
11963 break;
11964 }
11965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 return (fValid);
11967}
11968
Jeff Johnson295189b2012-06-20 16:38:30 -070011969//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011970 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011971{
Jeff Johnsone7245742012-09-05 17:12:55 -070011972 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011973 tANI_U8 centerChn;
11974 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011975
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11977 {
11978 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11979 }
11980 else
11981 {
11982 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11983 }
11984 //Figure what the other side's CB mode
11985 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11986 {
11987 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11988 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011989 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11990 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11991 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11992 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011993 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11994 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011995 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011996 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011997
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011998 {
11999 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
12000 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12001 }
12002
12003 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012005 /* This is called during INFRA STA/CLIENT and should use the merged value of
12006 * supported channel width and recommended tx width as per standard
12007 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012008 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070012009 pIes->HTCaps.supportedChannelWidthSet,
12010 pIes->HTInfo.recommendedTxWidthSet,
12011 pIes->HTInfo.secondaryChannelOffset);
12012
12013 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12014 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 else
Jeff Johnsone7245742012-09-05 17:12:55 -070012016 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12017 switch (eRet) {
12018 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12019 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12020 break;
12021 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12022 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12023 break;
12024 case PHY_SINGLE_CHANNEL_CENTERED:
12025 default:
12026 centerChn = primaryChn;
12027 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012029 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012031 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012032 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012034 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12035 {
12036 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12037 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 }
12040 }
12041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 return eRet;
12043}
Jeff Johnson295189b2012-06-20 16:38:30 -070012044tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12045{
12046 tANI_BOOLEAN fFound = FALSE;
12047 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012048 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12049 {
12050 if( pCipherList->encryptionType[idx] == encryptionType )
12051 {
12052 fFound = TRUE;
12053 break;
12054 }
12055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 return fFound;
12057}
Jeff Johnson295189b2012-06-20 16:38:30 -070012058tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12059{
12060 tANI_BOOLEAN fFound = FALSE;
12061 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12063 {
12064 if( pAuthList->authType[idx] == authType )
12065 {
12066 fFound = TRUE;
12067 break;
12068 }
12069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 return fFound;
12071}
Jeff Johnson295189b2012-06-20 16:38:30 -070012072tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12073{
12074 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12075 tCsrScanResultFilter *pScanFilter = NULL;
12076 eHalStatus status = eHAL_STATUS_SUCCESS;
12077
12078 if(pProfile1 && pProfile2)
12079 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012080 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12081 if ( NULL == pScanFilter )
12082 status = eHAL_STATUS_FAILURE;
12083 else
12084 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 if(HAL_STATUS_SUCCESS(status))
12086 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012087 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12089 if(HAL_STATUS_SUCCESS(status))
12090 {
12091 fCheck = eANI_BOOLEAN_FALSE;
12092 do
12093 {
12094 tANI_U32 i;
12095 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12096 {
12097 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12098 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12099 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12100 if ( fCheck ) break;
12101 }
12102 if(!fCheck)
12103 {
12104 break;
12105 }
12106 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12107 || pProfile2->BSSType != pProfile1->BSSType
12108 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12109 )
12110 {
12111 fCheck = eANI_BOOLEAN_FALSE;
12112 break;
12113 }
12114#ifdef WLAN_FEATURE_VOWIFI_11R
12115 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12116 {
12117 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12118 {
12119 fCheck = eANI_BOOLEAN_FALSE;
12120 break;
12121 }
12122 }
12123#endif
12124 //Match found
12125 fCheck = eANI_BOOLEAN_TRUE;
12126 }while(0);
12127 csrFreeScanFilter(pMac, pScanFilter);
12128 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012129 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 }
12131 }
12132
12133 return (fCheck);
12134}
12135
Jeff Johnson295189b2012-06-20 16:38:30 -070012136tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12137{
12138 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12139 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 do
12141 {
12142 //Only check for static WEP
12143 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12144 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12145 {
12146 fCheck = eANI_BOOLEAN_TRUE;
12147 break;
12148 }
12149 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12150 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12151 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12152 {
12153 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012154 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12155 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 {
12157 break;
12158 }
12159 }
12160 if( i == CSR_MAX_NUM_KEY)
12161 {
12162 fCheck = eANI_BOOLEAN_TRUE;
12163 }
12164 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 return (fCheck);
12166}
12167
Jeff Johnson295189b2012-06-20 16:38:30 -070012168//IBSS
12169
Jeff Johnson295189b2012-06-20 16:38:30 -070012170tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12171{
12172 tANI_U8 channel = 0;
12173 tANI_U32 idx;
12174 tANI_U32 idxValidChannels;
12175 tANI_BOOLEAN fFound = FALSE;
12176 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12177
12178 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12179 {
12180 channel = pMac->roam.configParam.AdHocChannel5G;
12181 if(!csrRoamIsChannelValid(pMac, channel))
12182 {
12183 channel = 0;
12184 }
12185 }
12186 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12187 {
12188 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12189 {
12190 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12191 {
12192 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12193 {
12194 fFound = TRUE;
12195 channel = csrStartIbssChannels50[ idx ];
12196 }
12197 }
12198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12200 if (!fFound)
12201 {
12202 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12203 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012204 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012205 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012206 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 break;
12208 }
12209 }
12210 }
12211 }//if
12212
12213 return( channel );
12214}
12215
Jeff Johnson295189b2012-06-20 16:38:30 -070012216tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12217{
12218 tANI_U8 channel = 1;
12219 tANI_U32 idx;
12220 tANI_U32 idxValidChannels;
12221 tANI_BOOLEAN fFound = FALSE;
12222 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12223
12224 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12225 {
12226 channel = pMac->roam.configParam.AdHocChannel24;
12227 if(!csrRoamIsChannelValid(pMac, channel))
12228 {
12229 channel = 0;
12230 }
12231 }
12232
12233 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12234 {
12235 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12236 {
12237 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12238 {
12239 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12240 {
12241 fFound = TRUE;
12242 channel = csrStartIbssChannels24[ idx ];
12243 }
12244 }
12245 }
12246 }
12247
12248 return( channel );
12249}
12250
Jeff Johnson295189b2012-06-20 16:38:30 -070012251static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12252 tCsrRoamStartBssParams *pParam )
12253{
12254 eCsrCfgDot11Mode cfgDot11Mode;
12255 eCsrBand eBand;
12256 tANI_U8 channel = 0;
12257 tSirNwType nwType;
12258 tANI_U8 operationChannel = 0;
12259
12260 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12261 {
12262 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12263 }
12264
Jeff Johnson295189b2012-06-20 16:38:30 -070012265 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012266
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12268 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12269 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12270 )
12271 {
12272 /* This should never happen */
12273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012274 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 pProfile->csrPersona);
12276 VOS_ASSERT(0);
12277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012278 switch( cfgDot11Mode )
12279 {
12280 case eCSR_CFG_DOT11_MODE_11G:
12281 nwType = eSIR_11G_NW_TYPE;
12282 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 case eCSR_CFG_DOT11_MODE_11B:
12284 nwType = eSIR_11B_NW_TYPE;
12285 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012286 case eCSR_CFG_DOT11_MODE_11A:
12287 nwType = eSIR_11A_NW_TYPE;
12288 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 default:
12290 case eCSR_CFG_DOT11_MODE_11N:
12291 case eCSR_CFG_DOT11_MODE_TAURUS:
12292 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12293 if(eCSR_BAND_24 == eBand)
12294 {
12295 nwType = eSIR_11G_NW_TYPE;
12296 }
12297 else
12298 {
12299 nwType = eSIR_11A_NW_TYPE;
12300 }
12301 break;
12302 }
12303
12304 pParam->extendedRateSet.numRates = 0;
12305
12306 switch ( nwType )
12307 {
12308 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012309 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 case eSIR_11A_NW_TYPE:
12311
12312 pParam->operationalRateSet.numRates = 8;
12313
12314 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12315 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12316 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12317 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12318 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12319 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12320 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12321 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12322
12323 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12324 {
12325 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12326 if( 0 == channel &&
12327 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12328 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12329 )
12330 {
12331 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12332 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12333 nwType = eSIR_11B_NW_TYPE;
12334 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12335 pParam->operationalRateSet.numRates = 4;
12336 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12337 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12338 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12339 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12340 }
12341 }
12342 else
12343 {
12344 channel = operationChannel;
12345 }
12346 break;
12347
12348 case eSIR_11B_NW_TYPE:
12349 pParam->operationalRateSet.numRates = 4;
12350 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12351 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12352 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12353 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12355 {
12356 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12357 }
12358 else
12359 {
12360 channel = operationChannel;
12361 }
12362
12363 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 /* For P2P Client and P2P GO, disable 11b rates */
12366 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12367 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12368 )
12369 {
12370 pParam->operationalRateSet.numRates = 8;
12371
12372 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12373 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12374 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12375 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12376 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12377 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12378 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12379 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12380 }
12381 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 {
12383 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12385 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12386 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12387 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12388
12389 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12391 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12392 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12393 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12394 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12395 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12396 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12397 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12398 }
12399
12400 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12401 {
12402 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12403 }
12404 else
12405 {
12406 channel = operationChannel;
12407 }
12408
12409 break;
12410 }
12411 pParam->operationChn = channel;
12412 pParam->sirNwType = nwType;
12413}
12414
Jeff Johnson295189b2012-06-20 16:38:30 -070012415static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12416 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12417{
12418
12419 if( pParam )
12420 {
12421 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012422 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012424 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012425
12426 if( pIes )
12427 {
12428 if(pIes->SuppRates.present)
12429 {
12430 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12431 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012433 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 -070012434 pIes->SuppRates.num_rates);
12435 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12436 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012437 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12438 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012440 if (pIes->ExtSuppRates.present)
12441 {
12442 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012443 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012444 {
12445 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12446 SIR_MAC_RATESET_EID_MAX, resetting to \
12447 SIR_MAC_RATESET_EID_MAX"),
12448 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012449 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012450 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012451 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012452 pIes->ExtSuppRates.rates,
12453 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 if( pIes->SSID.present )
12456 {
12457 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012458 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12459 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 }
12461 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 }
12463 else
12464 {
12465 pParam->ssId.length = 0;
12466 pParam->operationalRateSet.numRates = 0;
12467 }
12468 }
12469}
12470
Jeff Johnson295189b2012-06-20 16:38:30 -070012471static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12472{
12473 tANI_U8 MaxRate = 0;
12474 tANI_U32 i;
12475 tANI_U8 *pRate;
12476
12477 pRate = pSirRateSet->rate;
12478 for ( i = 0; i < pSirRateSet->numRates; i++ )
12479 {
12480 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12481 }
12482
12483 // Save the max rate in the connected state information...
12484
12485 // modify LastRates variable as well
12486
12487 return;
12488}
12489
Jeff Johnson295189b2012-06-20 16:38:30 -070012490eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12491 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12492{
12493 eHalStatus status = eHAL_STATUS_SUCCESS;
12494 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012495 // Set the roaming substate to 'Start BSS attempt'...
12496 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012497#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12498 //Need to figure out whether we need to log WDS???
12499 if( CSR_IS_IBSS( pProfile ) )
12500 {
12501 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012502 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12503 if(pIbssLog)
12504 {
12505 if(pBssDesc)
12506 {
12507 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012508 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012509 }
12510 else
12511 {
12512 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12513 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012514 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 if(pProfile->ChannelInfo.numOfChannels == 0)
12516 {
12517 pIbssLog->channelSetting = AUTO_PICK;
12518 }
12519 else
12520 {
12521 pIbssLog->channelSetting = SPECIFIED;
12522 }
12523 pIbssLog->operatingChannel = pParam->operationChn;
12524 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12525 }
12526 }
12527#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12528 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012529 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12530 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012531
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 pParam->privacy = pProfile->privacy;
12533 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12534 pParam->authType = pProfile->csr80211AuthType;
12535 pParam->beaconInterval = pProfile->beaconInterval;
12536 pParam->dtimPeriod = pProfile->dtimPeriod;
12537 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12538 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12539 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12540 {
12541 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12542 {
12543 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12544 }
12545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 pParam->protEnabled = pProfile->protEnabled;
12547 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12548 pParam->ht_protection = pProfile->cfg_protection;
12549 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012550
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12552 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012554
12555#ifdef WLAN_FEATURE_11W
12556 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12557 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12558#endif
12559
Jeff Johnson295189b2012-06-20 16:38:30 -070012560 // When starting an IBSS, start on the channel from the Profile.
12561 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 return (status);
12563}
12564
Jeff Johnson295189b2012-06-20 16:38:30 -070012565static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012566 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012567{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012568 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012569 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012571
12572 if(!pSession)
12573 {
12574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12575 return;
12576 }
12577
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 if( pBssDesc )
12579 {
12580 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12581 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12582 //The following code has to be do after that.
12583 //For WDS station, use selfMac as the self BSSID
12584 if( CSR_IS_WDS_STA( pProfile ) )
12585 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012586 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12587 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 }
12589 }
12590 else
12591 {
12592 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 //Use the first SSID
12594 if(pProfile->SSIDs.numOfSSIDs)
12595 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012596 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12597 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 }
12599 //For WDS station, use selfMac as the self BSSID
12600 if( CSR_IS_WDS_STA( pProfile ) )
12601 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012602 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12603 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 }
12605 //Use the first BSSID
12606 else if( pProfile->BSSIDs.numOfBSSIDs )
12607 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012608 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12609 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 }
12611 else
12612 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012613 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 }
12615 }
12616 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 //Set operating channel in pProfile which will be used
12618 //in csrRoamSetBssConfigCfg() to determine channel bonding
12619 //mode and will be configured in CFG later
12620 pProfile->operationChannel = Channel;
12621
12622 if(Channel == 0)
12623 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012624 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 }
12626 else
12627 {
12628
12629 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012630 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012631 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012632 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012633 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012634#ifdef WLAN_FEATURE_AP_HT40_24G
12635 if (CSR_IS_INFRA_AP(pProfile))
12636 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12637 else
12638 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12639#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012640 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012641#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012642 }
12643 else
12644 {
12645 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12646 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012647 pBssConfig->cbMode = cbMode;
12648 pSession->bssParams.cbMode = cbMode;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012649 if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
12650 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
12651 else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
12652 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
12653 else
12654 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
12655 smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
12656 pSession->bssParams.orig_ch_width);
Jeff Johnsone7245742012-09-05 17:12:55 -070012657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 }
12659}
12660
Jeff Johnson295189b2012-06-20 16:38:30 -070012661static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12662 tANI_BOOLEAN *pfSameIbss )
12663{
12664 eHalStatus status = eHAL_STATUS_SUCCESS;
12665 tANI_BOOLEAN fSameIbss = FALSE;
12666
12667 if ( csrIsConnStateIbss( pMac, sessionId ) )
12668 {
12669 // Check if any profile parameter has changed ? If any profile parameter
12670 // has changed then stop old BSS and start a new one with new parameters
12671 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12672 {
12673 fSameIbss = TRUE;
12674 }
12675 else
12676 {
12677 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12678 }
12679 }
12680 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12681 {
12682 // Disassociate from the connected Infrastructure network...
12683 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12684 }
12685 else
12686 {
12687 tBssConfigParam *pBssConfig;
12688
Kiet Lam64c1b492013-07-12 13:56:44 +053012689 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12690 if ( NULL == pBssConfig )
12691 status = eHAL_STATUS_FAILURE;
12692 else
12693 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 if(HAL_STATUS_SUCCESS(status))
12695 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012696 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 // there is no Bss description before we start an IBSS so we need to adopt
12698 // all Bss configuration parameters from the Profile.
12699 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12700 if(HAL_STATUS_SUCCESS(status))
12701 {
12702 //save dotMode
12703 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12704 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012705 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012706 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12707 NULL, pBssConfig,
12708 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012709 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012710
12711 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 }//Allocate memory
12713 }
12714
12715 if(pfSameIbss)
12716 {
12717 *pfSameIbss = fSameIbss;
12718 }
12719 return( status );
12720}
12721
Jeff Johnson295189b2012-06-20 16:38:30 -070012722static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12723 tSirSmeNewBssInfo *pNewBss )
12724{
12725 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012726
12727 if(!pSession)
12728 {
12729 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12730 return;
12731 }
12732
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 if( pNewBss )
12734 {
12735 // Set the operating channel.
12736 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12737 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012738 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12739 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 return;
12742}
12743
Jeff Johnson295189b2012-06-20 16:38:30 -070012744#ifdef FEATURE_WLAN_WAPI
12745eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12746 tANI_U32 numItems )
12747{
12748 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012749 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012752 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 return status;
12754 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012755 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 pSession = CSR_GET_SESSION( pMac, sessionId );
12757 if(numItems <= CSR_MAX_BKID_ALLOWED)
12758 {
12759 status = eHAL_STATUS_SUCCESS;
12760 //numItems may be 0 to clear the cache
12761 pSession->NumBkidCache = (tANI_U16)numItems;
12762 if(numItems && pBKIDCache)
12763 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012764 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12765 sizeof(tBkidCacheInfo) * numItems);
12766 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 }
12768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 return (status);
12770}
Jeff Johnson295189b2012-06-20 16:38:30 -070012771eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12772 tBkidCacheInfo *pBkidCache)
12773{
12774 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012775 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012778 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 return status;
12780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 pSession = CSR_GET_SESSION( pMac, sessionId );
12782 if(pNum && pBkidCache)
12783 {
12784 if(pSession->NumBkidCache == 0)
12785 {
12786 *pNum = 0;
12787 status = eHAL_STATUS_SUCCESS;
12788 }
12789 else if(*pNum >= pSession->NumBkidCache)
12790 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012791 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012792 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012793 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 -070012794 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012795 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012797 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12798 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 *pNum = pSession->NumBkidCache;
12800 status = eHAL_STATUS_SUCCESS;
12801 }
12802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012804}
Jeff Johnson295189b2012-06-20 16:38:30 -070012805tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12806{
12807 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012808}
12809#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012810eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012811 tPmkidCacheInfo *pPMKIDCache,
12812 tANI_U32 numItems,
12813 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012814{
12815 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012817
12818 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012819 {
12820 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12821 return eHAL_STATUS_FAILURE;
12822 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012823
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012824 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012825
12826 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 {
12828#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12829 {
12830 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012831 vos_mem_set(&secEvent,
12832 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12834 secEvent.encryptionModeMulticast =
12835 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12836 secEvent.encryptionModeUnicast =
12837 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012838 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 secEvent.authMode =
12840 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12841 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12842 }
12843#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012845 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012846 if (numItems && pPMKIDCache)
12847 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012848 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012849 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12850 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012851 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012852 }
12853 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012854 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012855 tPmkidCacheInfo *pmksa;
12856
12857 for (i = 0; i < numItems; i++) {
12858 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012859
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012860 /* Delete the entry if present */
12861 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12862
12863 /* Add entry to the cache */
12864 vos_mem_copy(
12865 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12866 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12867 vos_mem_copy(
12868 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12869 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12870
12871 /* Increment the CSR local cache index */
12872 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12873 pSession->CurCacheIndex++;
12874 else
12875 pSession->CurCacheIndex = 0;
12876
12877 pSession->NumPmkidCache++;
12878 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12879 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012880 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 }
12882 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012883 return (status);
12884}
12885
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012886eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012887#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12888 const tANI_U8 *pBSSId,
12889#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012890 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012891#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012892 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012893{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012894 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12895 tANI_BOOLEAN fMatchFound = FALSE;
12896 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012897 tANI_U32 CurIndex;
12898 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012899
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012900 if(!pSession)
12901 {
12902 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12903 return eHAL_STATUS_FAILURE;
12904 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012905
12906 /* Check if there are no entries to delete */
12907 if (0 == pSession->NumPmkidCache) {
12908 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12909 return eHAL_STATUS_SUCCESS;
12910 }
12911
12912 if (!flush_cache) {
12913 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12914 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12915 pBSSId, VOS_MAC_ADDR_SIZE)) {
12916 fMatchFound = 1;
12917
12918 /* Clear this - the matched entry */
12919 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12920 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012921 break;
12922 }
12923 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012924
12925 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12926 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12927 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012928 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012929 else {
12930 /* Match Found */
12931 CurIndex = pSession->CurCacheIndex;
12932 if(Index < CurIndex) {
12933 for(i = Index; i < (CurIndex-1); i++) {
12934 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12935 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12936 }
12937 pSession->CurCacheIndex--;
12938 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12939 sizeof(tPmkidCacheInfo));
12940 } else if(Index > CurIndex) {
12941 for(i = Index; i > (CurIndex); i--) {
12942 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12943 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12944 }
12945 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12946 sizeof(tPmkidCacheInfo));
12947 }
12948 pSession->NumPmkidCache--;
12949 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012950 } else {
12951 /* Flush the entire cache */
12952 vos_mem_zero(pSession->PmkidCacheInfo,
12953 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12954 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012955 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012956 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012957
12958 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012959}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012960
Jeff Johnson295189b2012-06-20 16:38:30 -070012961tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12962{
12963 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12964}
12965
Jeff Johnson295189b2012-06-20 16:38:30 -070012966eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12967{
12968 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12969 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012970 tPmkidCacheInfo *pmksa;
12971 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012972
12973 if(!pSession)
12974 {
12975 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12976 return eHAL_STATUS_FAILURE;
12977 }
12978
Jeff Johnson295189b2012-06-20 16:38:30 -070012979 if(pNum && pPmkidCache)
12980 {
12981 if(pSession->NumPmkidCache == 0)
12982 {
12983 *pNum = 0;
12984 status = eHAL_STATUS_SUCCESS;
12985 }
12986 else if(*pNum >= pSession->NumPmkidCache)
12987 {
12988 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012990 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 -070012991 pSession->NumPmkidCache);
12992 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12993 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012994
12995 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12996 pmksa = &pSession->PmkidCacheInfo[i];
12997 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12998 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
12999 pPmkidCache++;
13000 j++;
13001 }
13002 }
13003
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 *pNum = pSession->NumPmkidCache;
13005 status = eHAL_STATUS_SUCCESS;
13006 }
13007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 return (status);
13009}
13010
Jeff Johnson295189b2012-06-20 16:38:30 -070013011eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13012{
13013 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13014 tANI_U32 len;
13015 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013016
13017 if(!pSession)
13018 {
13019 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13020 return eHAL_STATUS_FAILURE;
13021 }
13022
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 if(pLen)
13024 {
13025 len = *pLen;
13026 *pLen = pSession->nWpaRsnReqIeLength;
13027 if(pBuf)
13028 {
13029 if(len >= pSession->nWpaRsnReqIeLength)
13030 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013031 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13032 pSession->nWpaRsnReqIeLength);
13033 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 }
13035 }
13036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 return (status);
13038}
13039
Jeff Johnson295189b2012-06-20 16:38:30 -070013040eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13041{
13042 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13043 tANI_U32 len;
13044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013045
13046 if(!pSession)
13047 {
13048 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13049 return eHAL_STATUS_FAILURE;
13050 }
13051
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 if(pLen)
13053 {
13054 len = *pLen;
13055 *pLen = pSession->nWpaRsnRspIeLength;
13056 if(pBuf)
13057 {
13058 if(len >= pSession->nWpaRsnRspIeLength)
13059 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013060 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13061 pSession->nWpaRsnRspIeLength);
13062 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 }
13064 }
13065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 return (status);
13067}
Jeff Johnson295189b2012-06-20 16:38:30 -070013068#ifdef FEATURE_WLAN_WAPI
13069eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13070{
13071 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13072 tANI_U32 len;
13073 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013074
13075 if(!pSession)
13076 {
13077 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13078 return eHAL_STATUS_FAILURE;
13079 }
13080
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 if(pLen)
13082 {
13083 len = *pLen;
13084 *pLen = pSession->nWapiReqIeLength;
13085 if(pBuf)
13086 {
13087 if(len >= pSession->nWapiReqIeLength)
13088 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013089 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13090 pSession->nWapiReqIeLength);
13091 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 }
13093 }
13094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013095 return (status);
13096}
Jeff Johnson295189b2012-06-20 16:38:30 -070013097eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13098{
13099 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13100 tANI_U32 len;
13101 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013102
13103 if(!pSession)
13104 {
13105 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13106 return eHAL_STATUS_FAILURE;
13107 }
13108
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 if(pLen)
13110 {
13111 len = *pLen;
13112 *pLen = pSession->nWapiRspIeLength;
13113 if(pBuf)
13114 {
13115 if(len >= pSession->nWapiRspIeLength)
13116 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013117 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13118 pSession->nWapiRspIeLength);
13119 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 }
13121 }
13122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 return (status);
13124}
13125#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013126eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13127{
13128 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013130
13131 if(!pSession)
13132 {
13133 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13134 return (retStatus);
13135 }
13136
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 if(CSR_IS_ROAMING(pSession))
13138 {
13139 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13140 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 return (retStatus);
13143}
13144
Jeff Johnson295189b2012-06-20 16:38:30 -070013145//This function remove the connected BSS from te cached scan result
13146eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13147 tCsrRoamConnectedProfile *pConnProfile)
13148{
13149 eHalStatus status = eHAL_STATUS_FAILURE;
13150 tCsrScanResultFilter *pScanFilter = NULL;
13151 tListElem *pEntry;
13152 tCsrScanResult *pResult;
13153 tDot11fBeaconIEs *pIes;
13154 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13156 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13157 {
13158 do
13159 {
13160 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013161 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13162 if ( NULL == pScanFilter )
13163 status = eHAL_STATUS_FAILURE;
13164 else
13165 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013167 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13168 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13169 if ( NULL == pScanFilter->BSSIDs.bssid )
13170 status = eHAL_STATUS_FAILURE;
13171 else
13172 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013174 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13175 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13177 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13178 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013179 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13180 if ( NULL == pScanFilter->SSIDs.SSIDList )
13181 status = eHAL_STATUS_FAILURE;
13182 else
13183 status = eHAL_STATUS_SUCCESS;
13184 if (!HAL_STATUS_SUCCESS(status)) break;
13185 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13186 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 }
13188 pScanFilter->authType.numEntries = 1;
13189 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13190 pScanFilter->BSSType = pConnProfile->BSSType;
13191 pScanFilter->EncryptionType.numEntries = 1;
13192 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13193 pScanFilter->mcEncryptionType.numEntries = 1;
13194 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13195 //We ignore the channel for now, BSSID should be enough
13196 pScanFilter->ChannelInfo.numOfChannels = 0;
13197 //Also ignore the following fields
13198 pScanFilter->uapsd_mask = 0;
13199 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013200 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 pScanFilter->countryCode[0] = 0;
13202 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 csrLLLock(&pMac->scan.scanResultList);
13204 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13205 while( pEntry )
13206 {
13207 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13208 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13209 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13210 pScanFilter, NULL, NULL, NULL, &pIes);
13211 //Release the IEs allocated by csrMatchBSS is needed
13212 if( !pResult->Result.pvIes )
13213 {
13214 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013215 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 }
13217 if(fMatch)
13218 {
13219 //We found the one
13220 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13221 {
13222 //Free the memory
13223 csrFreeScanResultEntry( pMac, pResult );
13224 }
13225 break;
13226 }
13227 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13228 }//while
13229 csrLLUnlock(&pMac->scan.scanResultList);
13230 }while(0);
13231 if(pScanFilter)
13232 {
13233 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013234 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 }
13236 }
13237 return (status);
13238}
13239
Jeff Johnson295189b2012-06-20 16:38:30 -070013240//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013241eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13242{
13243 eHalStatus status = eHAL_STATUS_SUCCESS;
13244 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13246 {
13247 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13248 {
13249 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13250 {
13251 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013252 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 status = eHAL_STATUS_CSR_WRONG_STATE;
13254 break;
13255 }
13256 if( csrIsConnStateInfra( pMac, sessionId ) )
13257 {
13258 if( chnId &&
13259 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013261 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13263 status = eHAL_STATUS_CSR_WRONG_STATE;
13264 break;
13265 }
13266 }
13267 }
13268 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 return ( status );
13270}
13271
Jeff Johnson295189b2012-06-20 16:38:30 -070013272static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13273{
13274 eHalStatus status = eHAL_STATUS_SUCCESS;
13275 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13276 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013277
13278 if(!pSession)
13279 {
13280 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13281 return eHAL_STATUS_FAILURE;
13282 }
13283
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 if ( csrIsConnStateIbss( pMac, sessionId ) )
13285 {
13286 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13287 }
13288 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13289 {
13290 // Disassociate from the connected Infrastructure network...
13291 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13292 }
13293 else
13294 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13296 //Otherwise we need to add code to handle the
13297 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13298 //send stop_bss to PE, before we can continue.
13299 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013300 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013302 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13303 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 // there is no Bss description before we start an WDS so we need
13305 // to adopt all Bss configuration parameters from the Profile.
13306 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13307 if(HAL_STATUS_SUCCESS(status))
13308 {
13309 //Save profile for late use
13310 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013311 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13312 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013314 vos_mem_set(pSession->pCurRoamProfile,
13315 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013319 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013320 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13321 NULL, &bssConfig,
13322 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 }
13324 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013325
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 return( status );
13327}
13328
Jeff Johnson295189b2012-06-20 16:38:30 -070013329////////////////////Mail box
13330
Jeff Johnson295189b2012-06-20 16:38:30 -070013331//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13332//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013333static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13334 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13336{
13337 tCsrChannelSet channelGroup;
13338 tSirMacCapabilityInfo *pAP_capabilityInfo;
13339 tAniBool fTmp;
13340 tANI_BOOLEAN found = FALSE;
13341 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013342 tANI_S8 pwrLimit = 0;
13343 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13345 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13346 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13347 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 // 802.11h
13349 //We can do this because it is in HOST CPU order for now.
13350 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013351 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13352 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13353 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013354 fTmp = (tAniBool)pal_cpu_to_be32(1);
13355 }
13356 else
13357 fTmp = (tAniBool)0;
13358
13359 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013360 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013362 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013363 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 // This is required for 11k test VoWiFi Ent: Test 2.
13365 // We need the power capabilities for Assoc Req.
13366 // This macro is provided by the halPhyCfg.h. We pick our
13367 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013368 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13369 if (0 != pwrLimit)
13370 {
13371 *pBuf++ = pwrLimit;
13372 }
13373 else
13374 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013375 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013376 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 size = sizeof(pMac->roam.validChannelList);
13378 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013379 {
13380 tANI_U8 *actualSize = pBuf++;
13381 *actualSize = 0;
13382
13383 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013385 /* Only add 5ghz channels*/
13386 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13387 {
13388 *actualSize +=1;
13389 *pBuf++ = pMac->roam.validChannelList[ i ];
13390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 }
13392 }
13393 else
13394 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013395 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 *pBuf++ = 0; //tSirSupChnl->numChnl
13397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 //Check whether it is ok to enter UAPSD
13399#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13400 if( btcIsReadyForUapsd(pMac) )
13401#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13402 {
13403 *pBuf++ = uapsdMask;
13404 }
13405#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13406 else
13407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013408 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 *pBuf++ = 0;
13410 }
13411#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13412
Jeff Johnson295189b2012-06-20 16:38:30 -070013413 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013414 vos_mem_copy(pBuf, pBssDescription,
13415 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13417}
13418
Jeff Johnson295189b2012-06-20 16:38:30 -070013419/*
13420 * The communication between HDD and LIM is thru mailbox (MB).
13421 * Both sides will access the data structure "tSirSmeJoinReq".
13422 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13423 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13424 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13425 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13426 */
13427eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013428 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013429{
13430 eHalStatus status = eHAL_STATUS_SUCCESS;
13431 tSirSmeJoinReq *pMsg;
13432 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013433 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013434 tANI_U16 msgLen, wTmp, ieLen;
13435 tSirMacRateSet OpRateSet;
13436 tSirMacRateSet ExRateSet;
13437 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13438 tANI_U32 dwTmp;
13439 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013440 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013441 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013442 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013443
13444 if(!pSession)
13445 {
13446 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13447 return eHAL_STATUS_FAILURE;
13448 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013449 /* To satisfy klockworks */
13450 if (NULL == pBssDescription)
13451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013452 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013453 return eHAL_STATUS_FAILURE;
13454 }
13455
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 do {
13457 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13458 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013459 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13461 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13462 // IE fields, but the length field in the bssDescription needs to be interpreted to
13463 // determine length of the IE fields.
13464 //
13465 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13466 // add in the length from the bssDescription (then add the size of the 'length' field
13467 // itself because that is NOT included in the length field).
13468 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13469 pBssDescription->length + sizeof( pBssDescription->length ) +
13470 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 +053013471 pMsg = vos_mem_malloc(msgLen);
13472 if (NULL == pMsg)
13473 status = eHAL_STATUS_FAILURE;
13474 else
13475 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013477 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013478 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 pMsg->length = pal_cpu_to_be16(msgLen);
13480 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 // sessionId
13482 *pBuf = (tANI_U8)sessionId;
13483 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 // transactionId
13485 *pBuf = 0;
13486 *( pBuf + 1 ) = 0;
13487 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 // ssId
13489 if( pIes->SSID.present && pIes->SSID.num_ssid )
13490 {
13491 // ssId len
13492 *pBuf = pIes->SSID.num_ssid;
13493 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013494 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 pBuf += pIes->SSID.num_ssid;
13496 }
13497 else
13498 {
13499 *pBuf = 0;
13500 pBuf++;
13501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013503 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13504 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 pBuf += sizeof(tSirMacAddr);
13506 // bsstype
13507 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13508 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013509 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 pBuf += sizeof(tSirBssType);
13511 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013512 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13513 if (pBssDescription->channelId <= 14 &&
13514 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13515 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13516 {
13517 //Need to disable VHT operation in 2.4 GHz band
13518 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13519 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013520 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13521 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13522
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013523 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 //Persona
13526 *pBuf = (tANI_U8)pProfile->csrPersona;
13527 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013528 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13529 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013530 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13531 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013532 //CBMode
13533 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13534 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013535 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13536 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013537
13538 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013539 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13540 pProfile->csrPersona, pSession->bssParams.cbMode,
13541 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013542
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 // uapsdPerAcBitmask
13544 *pBuf = pProfile->uapsd_mask;
13545 pBuf++;
13546
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013547
13548
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013549 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013550 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 {
13552 // OperationalRateSet
13553 if (OpRateSet.numRates) {
13554 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013555 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 pBuf += OpRateSet.numRates;
13557 } else *pBuf++ = 0;
13558 // ExtendedRateSet
13559 if (ExRateSet.numRates) {
13560 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013561 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 pBuf += ExRateSet.numRates;
13563 } else *pBuf++ = 0;
13564 }
13565 else
13566 {
13567 *pBuf++ = 0;
13568 *pBuf++ = 0;
13569 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013570
13571 //rateBitmap
13572 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13573 pBuf += sizeof(tANI_U16);
13574
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 // rsnIE
13576 if ( csrIsProfileWpa( pProfile ) )
13577 {
13578 // Insert the Wpa IE into the join request
13579 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13580 (tCsrWpaIe *)( wpaRsnIE ) );
13581 }
13582 else if( csrIsProfileRSN( pProfile ) )
13583 {
13584 // Insert the RSN IE into the join request
13585 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13586 (tCsrRSNIe *)( wpaRsnIE ) );
13587 }
13588#ifdef FEATURE_WLAN_WAPI
13589 else if( csrIsProfileWapi( pProfile ) )
13590 {
13591 // Insert the WAPI IE into the join request
13592 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13593 (tCsrWapiIe *)( wpaRsnIE ) );
13594 }
13595#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 else
13597 {
13598 ieLen = 0;
13599 }
13600 //remember the IE for future use
13601 if( ieLen )
13602 {
13603 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13604 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013605 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 -070013606 ieLen = DOT11F_IE_RSN_MAX_LEN;
13607 }
13608#ifdef FEATURE_WLAN_WAPI
13609 if( csrIsProfileWapi( pProfile ) )
13610 {
13611 //Check whether we need to allocate more memory
13612 if(ieLen > pSession->nWapiReqIeLength)
13613 {
13614 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13615 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013616 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013618 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13619 if (NULL == pSession->pWapiReqIE)
13620 status = eHAL_STATUS_FAILURE;
13621 else
13622 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 if(!HAL_STATUS_SUCCESS(status)) break;
13624 }
13625 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013626 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013628 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013630 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 pBuf += ieLen;
13632 }
13633 else//should be WPA/WPA2 otherwise
13634#endif /* FEATURE_WLAN_WAPI */
13635 {
13636 //Check whether we need to allocate more memory
13637 if(ieLen > pSession->nWpaRsnReqIeLength)
13638 {
13639 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13640 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013641 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013643 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13644 if (NULL == pSession->pWpaRsnReqIE)
13645 status = eHAL_STATUS_FAILURE;
13646 else
13647 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 if(!HAL_STATUS_SUCCESS(status)) break;
13649 }
13650 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013651 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013653 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013655 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 pBuf += ieLen;
13657 }
13658 }
13659 else
13660 {
13661 //free whatever old info
13662 pSession->nWpaRsnReqIeLength = 0;
13663 if(pSession->pWpaRsnReqIE)
13664 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013665 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 pSession->pWpaRsnReqIE = NULL;
13667 }
13668#ifdef FEATURE_WLAN_WAPI
13669 pSession->nWapiReqIeLength = 0;
13670 if(pSession->pWapiReqIE)
13671 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013672 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 pSession->pWapiReqIE = NULL;
13674 }
13675#endif /* FEATURE_WLAN_WAPI */
13676 //length is two bytes
13677 *pBuf = 0;
13678 *(pBuf + 1) = 0;
13679 pBuf += 2;
13680 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013681#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013682 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013684 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 //length is two bytes
13686 *pBuf = 0;
13687 *(pBuf + 1) = 0;
13688 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013689 }
13690 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013692 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013693 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013694 {
13695 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013696#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013697 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013698 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013699 pSession->suppCckmIeInfo.cckmIe, ieLen);
13700#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013701 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013702 pSession,
13703 pProfile,
13704 pBssDescription,
13705 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 pSession->nWpaRsnReqIeLength,
13707 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013708#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013709 }
13710 else
13711 {
13712 ieLen = 0;
13713 }
13714 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13715 if( ieLen )
13716 {
13717 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13718 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013720 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013721 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013722 pBuf += ieLen;
13723 }
13724 else
13725 {
13726 //Indicate you have no CCKM IE
13727 //length is two bytes
13728 *pBuf = 0;
13729 *(pBuf + 1) = 0;
13730 pBuf += 2;
13731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013733#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013735 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 {
13737 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013738 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013740 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013742 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013744 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 pBuf += ieLen;
13746 }
13747 else
13748 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013749 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 *pBuf = 0;
13752 *(pBuf + 1) = 0;
13753 pBuf += 2;
13754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 // addIEAssoc
13756 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13757 {
13758 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 if(ieLen > pSession->nAddIEAssocLength)
13760 {
13761 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013762 {
13763 vos_mem_free(pSession->pAddIEAssoc);
13764 }
13765 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13766 if (NULL == pSession->pAddIEAssoc)
13767 status = eHAL_STATUS_FAILURE;
13768 else
13769 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013773 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013775 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013777 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 pBuf += ieLen;
13779 }
13780 else
13781 {
13782 pSession->nAddIEAssocLength = 0;
13783 if(pSession->pAddIEAssoc)
13784 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013785 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 pSession->pAddIEAssoc = NULL;
13787 }
13788 *pBuf = 0;
13789 *(pBuf + 1) = 0;
13790 pBuf += 2;
13791 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013792
13793 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013795 //Unmask any AC in reassoc that is ACM-set
13796 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13797 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013799 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13800 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013801#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013802 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013803#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013804 }
13805 else
13806 {
13807 uapsd_mask = 0;
13808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 }
13810 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013811
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013813 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013814 pBuf += sizeof(tANI_U32);
13815
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013817 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013818 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013819#ifdef WLAN_FEATURE_11W
13820 //MgmtEncryption
13821 if (pProfile->MFPEnabled)
13822 {
13823 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13824 }
13825 else
13826 {
13827 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13828 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013829 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013830 pBuf += sizeof(tANI_U32);
13831#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013832#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013833 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013834 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013835#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013836 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013837 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013838#endif
13839 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013840 {
13841 // is11Rconnection;
13842 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013843 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013844 pBuf += sizeof(tAniBool);
13845 }
13846 else
13847 {
13848 // is11Rconnection;
13849 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013850 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013851 pBuf += sizeof(tAniBool);
13852 }
13853#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013854#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013855
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013856 // isESEFeatureIniEnabled
13857 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013858 {
13859 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013861 pBuf += sizeof(tAniBool);
13862 }
13863 else
13864 {
13865 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013866 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013867 pBuf += sizeof(tAniBool);
13868 }
13869
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013870 /* A profile can not be both ESE and 11R. But an 802.11R AP
13871 * may be advertising support for ESE as well. So if we are
13872 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013873 * If we are associating explictly 11R only then we will get
13874 * 11R.
13875 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013876 if ((csrIsProfileESE(pProfile) ||
13877 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013878 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13879 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13880 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13881 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13882#ifdef WLAN_FEATURE_11W
13883 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013884 || (pProfile->negotiatedAuthType ==
13885 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013886#endif
13887 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013888 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013889 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013890 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013891 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013892 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013893 pBuf += sizeof(tAniBool);
13894 }
13895 else
13896 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013897 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013898 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013899 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013900 pBuf += sizeof(tAniBool);
13901 }
13902
13903 if (eWNI_SME_JOIN_REQ == messageType)
13904 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013905 tESETspecInfo eseTspec;
13906 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013907 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013908 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13909 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13910 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013911 }
13912 else if (eWNI_SME_REASSOC_REQ == messageType)
13913 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013914 if ((csrIsProfileESE(pProfile) ||
13915 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013916 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13917 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13918 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13919 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13920#ifdef WLAN_FEATURE_11W
13921 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013922 || (pProfile->negotiatedAuthType ==
13923 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013924#endif
13925 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013926 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013928 tESETspecInfo eseTspec;
13929 // ESE Tspec information
13930 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13931 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13932 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013935 if (eseTspec.numTspecs) {
13936 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13937 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013939 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013941 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013943 tESETspecInfo eseTspec;
13944 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013946 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13947 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13948 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 }
13950 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013951#endif // FEATURE_WLAN_ESE
13952#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013954 if (pMac->roam.configParam.isFastTransitionEnabled
13955#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013956 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013957#endif
13958 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013960 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013961 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013962 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 }
13964 else
13965 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013966 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013967 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013968 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 }
13970#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013971#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013972 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013973 {
13974 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013975 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013976 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013977 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013978 }
13979 else
13980 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013981 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013982 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013983 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013984 }
13985#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013986
13987 // txLdpcIniFeatureEnabled
13988 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13989 pBuf++;
13990
Kiran4a17ebe2013-01-31 10:43:43 -080013991 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13992 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13993 {
13994 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13995 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13996 csrApplyPower2Current(pMac);
13997 }
13998
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013999#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014000 // txBFIniFeatureEnabled
14001 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14002 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014003
14004 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014005 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014006 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014007 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14008 if (pIes->VHTCaps.numSoundingDim)
14009 txBFCsnValue = CSR_ROAM_MIN
14010 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014011 }
14012 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014013 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014014
14015 /* Only enable MuBf if no other MuBF session exist
14016 * and FW and HOST is MuBF capable.
14017 */
14018 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14019 {
14020 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14021 pBuf++;
14022 }
14023 else
14024 {
14025 *pBuf = 0;
14026 pBuf++;
14027 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014028#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014029 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14030 pBuf++;
14031
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014032 // WME
14033 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14034 {
14035 //WME enabled
14036 dwTmp = pal_cpu_to_be32(TRUE);
14037 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14038 pBuf += sizeof(tAniBool);
14039 }
14040 else
14041 {
14042 dwTmp = pal_cpu_to_be32(FALSE);
14043 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14044 pBuf += sizeof(tAniBool);
14045 }
14046
14047 // QOS
14048 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14049 {
14050 //QOS enabled
14051 dwTmp = pal_cpu_to_be32(TRUE);
14052 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14053 pBuf += sizeof(tAniBool);
14054 }
14055 else
14056 {
14057 dwTmp = pal_cpu_to_be32(FALSE);
14058 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14059 pBuf += sizeof(tAniBool);
14060 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014061 //BssDesc
14062 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14063 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014064
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014065 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014066 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14067 pMsg = NULL;
14068
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014069 if(!HAL_STATUS_SUCCESS(status))
14070 {
14071 break;
14072 }
14073 else
14074 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014075#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014076 if (eWNI_SME_JOIN_REQ == messageType)
14077 {
14078 //Tush-QoS: notify QoS module that join happening
14079 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14080 }
14081 else if (eWNI_SME_REASSOC_REQ == messageType)
14082 {
14083 //Tush-QoS: notify QoS module that reassoc happening
14084 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014086#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014089
14090 if (pMsg != NULL)
14091 {
14092 vos_mem_free( pMsg );
14093 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014094 pMac->roam.roamSession[sessionId].connect_req_start_time =
14095 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014096
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014098}
14099
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014100#ifdef WLAN_FEATURE_LFR_MBB
14101/**
14102 * csr_prepare_reassoc_req () - Prepares reassoc request
14103 * @mac: MAC context
14104 * @session_id: session id
14105 * @pbss_description: bss description
14106 * @ies: pointer to beacon IE's
14107 * @reassoc_req: pointer to reassociation request
14108 *
14109 *Return: None
14110 */
14111eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14112 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14113 tSirSmeJoinReq **reassoc_req)
14114{
14115 eHalStatus status = eHAL_STATUS_SUCCESS;
14116 tSirSmeJoinReq *csr_join_req;
14117 tANI_U8 *buf;
14118 v_U8_t acm_mask = 0, uapsd_mask;
14119 tANI_U16 msg_len, w_tmp, ie_len;
14120 tSirMacRateSet op_rate_set;
14121 tSirMacRateSet ex_rate_set;
14122 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14123 tANI_U32 dw_tmp;
14124 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14125 tANI_U32 uc_dot11_mode = 0;
14126 tANI_U8 tx_bf_csn_value = 0;
14127 tANI_U16 rate_bitmap = 0;
14128 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014129 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014130
14131 if(!session) {
14132 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14133 return eHAL_STATUS_FAILURE;
14134 }
14135
14136 if (NULL == bss_description) {
14137 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14138 return eHAL_STATUS_FAILURE;
14139 }
14140
14141 smsLog(mac, LOG1,
14142 FL("session_id %d"), session_id);
14143
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014144 profile = vos_mem_malloc(sizeof(*profile));
14145 if (NULL == profile) {
14146 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14147 return eHAL_STATUS_RESOURCES;
14148 }
14149
14150 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014151 if(!HAL_STATUS_SUCCESS(status)) {
14152 smsLog(mac, LOGE, FL("Profile copy failed"));
14153 return eHAL_STATUS_FAILURE;
14154 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014155
14156 do {
14157 /*
14158 * There are a number of variable length fields to consider.
14159 * First, the tSirSmeJoinReq includes a single bssDescription.
14160 * bssDescription includes a single tANI_U32 for the IE fields,
14161 * but the length field in the bssDescription needs to be
14162 * interpreted to determine length of the IE fields.
14163 * So, take the size of the JoinReq, subtract the size of the
14164 * bssDescription and add in the length from the bssDescription
14165 * (then add the size of the 'length' field itself because that is
14166 * NOT included in the length field). msgLen =
14167 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14168 * pBssDescription->length + sizeof( pBssDescription->length ) +
14169 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14170 * add in the size of the WPA IE that we may build.
14171 */
14172
14173 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14174 bss_description->length + sizeof(bss_description->length) +
14175 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14176
14177 csr_join_req = vos_mem_malloc(msg_len);
14178 if (NULL == csr_join_req)
14179 status = eHAL_STATUS_FAILURE;
14180 else
14181 status = eHAL_STATUS_SUCCESS;
14182 if (!HAL_STATUS_SUCCESS(status)) break;
14183
14184 vos_mem_set(csr_join_req, msg_len, 0);
14185 *reassoc_req = csr_join_req;
14186
14187 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14188 csr_join_req->length = pal_cpu_to_be16(msg_len);
14189 buf = &csr_join_req->sessionId;
14190
14191 /* session_id */
14192 *buf = (tANI_U8)session_id;
14193 buf++;
14194
14195 /* transactionId */
14196 *buf = 0;
14197 *(buf + 1) = 0;
14198 buf += sizeof(tANI_U16);
14199
14200 /* ssId */
14201 if(ies->SSID.present && ies->SSID.num_ssid)
14202 {
14203 /* ssId len */
14204 *buf = ies->SSID.num_ssid;
14205 buf++;
14206 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14207 buf += ies->SSID.num_ssid;
14208 }
14209 else
14210 {
14211 *buf = 0;
14212 buf++;
14213 }
14214
14215 /* selfMacAddr */
14216 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14217 sizeof(tSirMacAddr));
14218 buf += sizeof(tSirMacAddr);
14219
14220 /* bsstype */
14221 dw_tmp =
14222 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14223 /* Override BssType for BTAMP */
14224 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14225 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14226 buf += sizeof(tSirBssType);
14227
14228 /* dot11mode */
14229 uc_dot11_mode =
14230 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14231 if (bss_description->channelId <= 14 &&
14232 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14233 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14234 {
14235 /* Need to disable VHT operation in 2.4 GHz band */
14236 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14237 }
14238 *buf = (tANI_U8)uc_dot11_mode;
14239 buf++;
14240
14241 /* Persona */
14242 *buf = (tANI_U8)profile->csrPersona;
14243 buf++;
14244 *buf = (tANI_U8)profile->bOSENAssociation;
14245 buf++;
14246 *buf = (tANI_U8)profile->bWPSAssociation;
14247 buf++;
14248
14249 /* CBMode */
14250 *buf = (tANI_U8)session->bssParams.cbMode;
14251 buf++;
14252
14253 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14254 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14255 session->bssParams.cbMode);
14256
14257 /* uapsdPerAcBitmask */
14258 *buf = profile->uapsd_mask;
14259 buf++;
14260
14261
14262 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14263 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14264 if (HAL_STATUS_SUCCESS(status))
14265 {
14266 /* OperationalRateSet */
14267 if (op_rate_set.numRates) {
14268 *buf++ = op_rate_set.numRates;
14269 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14270 buf += op_rate_set.numRates;
14271 } else *buf++ = 0;
14272
14273 /* ExtendedRateSet */
14274 if (ex_rate_set.numRates) {
14275 *buf++ = ex_rate_set.numRates;
14276 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14277 buf += ex_rate_set.numRates;
14278 } else *buf++ = 0;
14279 }
14280 else
14281 {
14282 *buf++ = 0;
14283 *buf++ = 0;
14284 }
14285
14286 /* rateBitmap */
14287 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14288 buf += sizeof(tANI_U16);
14289
14290 profile->negotiatedAuthType =
14291 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14292 profile->negotiatedUCEncryptionType =
14293 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14294
14295 /* rsnIE */
14296 if ( csrIsProfileWpa(profile))
14297 {
14298 /* Insert the Wpa IE into the join request */
14299 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14300 (tCsrWpaIe *)(wpa_rsn_ie));
14301 }
14302 else if( csrIsProfileRSN(profile))
14303 {
14304 /* Insert the RSN IE into the join request */
14305 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14306 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14307 }
14308#ifdef FEATURE_WLAN_WAPI
14309 else if( csrIsProfileWapi(profile))
14310 {
14311 /* Insert the WAPI IE into the join request */
14312 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14313 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14314 }
14315#endif
14316 else
14317 {
14318 ie_len = 0;
14319 }
14320 /* remember the IE for future use */
14321 if(ie_len)
14322 {
14323 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14324 {
14325 smsLog(mac, LOGE,
14326 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14327 ie_len, DOT11F_IE_RSN_MAX_LEN);
14328 ie_len = DOT11F_IE_RSN_MAX_LEN;
14329 }
14330#ifdef FEATURE_WLAN_WAPI
14331 if( csrIsProfileWapi(profile))
14332 {
14333 /* Check whether we need to allocate more memory */
14334 if(ie_len > session->nWapiReqIeLength)
14335 {
14336 if(session->pWapiReqIE && session->nWapiReqIeLength)
14337 {
14338 vos_mem_free(session->pWapiReqIE);
14339 }
14340 session->pWapiReqIE = vos_mem_malloc(ie_len);
14341 if (NULL == session->pWapiReqIE)
14342 status = eHAL_STATUS_FAILURE;
14343 else
14344 status = eHAL_STATUS_SUCCESS;
14345 if(!HAL_STATUS_SUCCESS(status)) break;
14346 }
14347 session->nWapiReqIeLength = ie_len;
14348 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14349 w_tmp = pal_cpu_to_be16(ie_len);
14350 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14351 buf += sizeof(tANI_U16);
14352 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14353 buf += ie_len;
14354 }
14355 else /* should be WPA/WPA2 otherwise */
14356#endif
14357 {
14358 /* Check whether we need to allocate more memory */
14359 if(ie_len > session->nWpaRsnReqIeLength)
14360 {
14361 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14362 {
14363 vos_mem_free(session->pWpaRsnReqIE);
14364 }
14365 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14366 if (NULL == session->pWpaRsnReqIE)
14367 status = eHAL_STATUS_FAILURE;
14368 else
14369 status = eHAL_STATUS_SUCCESS;
14370 if(!HAL_STATUS_SUCCESS(status)) break;
14371 }
14372 session->nWpaRsnReqIeLength = ie_len;
14373 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14374 w_tmp = pal_cpu_to_be16(ie_len);
14375 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14376 buf += sizeof(tANI_U16);
14377 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14378 buf += ie_len;
14379 }
14380 }
14381 else
14382 {
14383 /* free whatever old info */
14384 session->nWpaRsnReqIeLength = 0;
14385 if(session->pWpaRsnReqIE)
14386 {
14387 vos_mem_free(session->pWpaRsnReqIE);
14388 session->pWpaRsnReqIE = NULL;
14389 }
14390#ifdef FEATURE_WLAN_WAPI
14391 session->nWapiReqIeLength = 0;
14392 if(session->pWapiReqIE)
14393 {
14394 vos_mem_free(session->pWapiReqIE);
14395 session->pWapiReqIE = NULL;
14396 }
14397#endif
14398 /* length is two bytes */
14399 *buf = 0;
14400 *(buf + 1) = 0;
14401 buf += 2;
14402 }
14403#ifdef FEATURE_WLAN_ESE
14404 if(eWNI_SME_JOIN_REQ == message_type)
14405 {
14406 /*
14407 * Never include the cckmIE in an Join Request
14408 * length is two bytes
14409 */
14410 *buf = 0;
14411 *(buf + 1) = 0;
14412 buf += 2;
14413 }
14414 else if(eWNI_SME_REASSOC_REQ == message_type)
14415 {
14416 /* cckmIE */
14417 if( csrIsProfileESE(profile))
14418 {
14419 /* Insert the CCKM IE into the join request */
14420#ifdef FEATURE_WLAN_ESE_UPLOAD
14421 ie_len = session->suppCckmIeInfo.cckmIeLen;
14422 vos_mem_copy((void *) (wpa_rsn_ie),
14423 session->suppCckmIeInfo.cckmIe, ie_len);
14424#else
14425 ie_len = csrConstructEseCckmIe(mac,
14426 session,
14427 profile,
14428 bss_description,
14429 session->pWpaRsnReqIE,
14430 session->nWpaRsnReqIeLength,
14431 (void *)(wpa_rsn_ie));
14432#endif
14433 }
14434 else
14435 {
14436 ie_len = 0;
14437 }
14438 /*
14439 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14440 * message buffer
14441 */
14442 if(ie_len)
14443 {
14444 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14445 w_tmp = pal_cpu_to_be16(ie_len);
14446 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14447 buf += sizeof(tANI_U16);
14448 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14449 buf += ie_len;
14450 }
14451 else
14452 {
14453 /* Indicate you have no CCKM IE length is two bytes */
14454 *buf = 0;
14455 *(buf + 1) = 0;
14456 buf += 2;
14457 }
14458 }
14459#endif
14460 /* addIEScan */
14461 if (profile->nAddIEScanLength)
14462 {
14463 ie_len = profile->nAddIEScanLength;
14464 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14465 session->nAddIEScanLength = ie_len;
14466 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14467 w_tmp = pal_cpu_to_be16(ie_len);
14468 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14469 buf += sizeof(tANI_U16);
14470 vos_mem_copy(buf, profile->addIEScan, ie_len);
14471 buf += ie_len;
14472 }
14473 else
14474 {
14475 memset(session->addIEScan, 0, session->nAddIEScanLength);
14476 session->nAddIEScanLength = 0;
14477 *buf = 0;
14478 *(buf + 1) = 0;
14479 buf += 2;
14480 }
14481 /* addIEAssoc */
14482 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14483 {
14484 ie_len = profile->nAddIEAssocLength;
14485 if(ie_len > session->nAddIEAssocLength)
14486 {
14487 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14488 {
14489 vos_mem_free(session->pAddIEAssoc);
14490 }
14491 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14492 if (NULL == session->pAddIEAssoc)
14493 status = eHAL_STATUS_FAILURE;
14494 else
14495 status = eHAL_STATUS_SUCCESS;
14496 if(!HAL_STATUS_SUCCESS(status)) break;
14497 }
14498 session->nAddIEAssocLength = ie_len;
14499 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14500 w_tmp = pal_cpu_to_be16(ie_len);
14501 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14502 buf += sizeof(tANI_U16);
14503 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14504 buf += ie_len;
14505 }
14506 else
14507 {
14508 session->nAddIEAssocLength = 0;
14509 if(session->pAddIEAssoc)
14510 {
14511 vos_mem_free(session->pAddIEAssoc);
14512 session->pAddIEAssoc = NULL;
14513 }
14514 *buf = 0;
14515 *(buf + 1) = 0;
14516 buf += 2;
14517 }
14518
14519 if(eWNI_SME_REASSOC_REQ == message_type )
14520 {
14521 /*Unmask any AC in reassoc that is ACM-set */
14522 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14523 if( uapsd_mask && (NULL != bss_description))
14524 {
14525 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14526 {
14527#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14528 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14529#endif
14530 }
14531 else
14532 {
14533 uapsd_mask = 0;
14534 }
14535 }
14536 }
14537
14538 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14539 profile->negotiatedUCEncryptionType));
14540 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14541 buf += sizeof(tANI_U32);
14542
14543 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14544 profile->negotiatedMCEncryptionType));
14545 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14546 buf += sizeof(tANI_U32);
14547#ifdef WLAN_FEATURE_11W
14548 /* MgmtEncryption */
14549 if (profile->MFPEnabled)
14550 {
14551 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14552 }
14553 else
14554 {
14555 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14556 }
14557 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14558 buf += sizeof(tANI_U32);
14559#endif
14560#ifdef WLAN_FEATURE_VOWIFI_11R
14561 profile->MDID.mdiePresent = bss_description->mdiePresent;
14562 if (csrIsProfile11r(profile)
14563#ifdef FEATURE_WLAN_ESE
14564 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14565 (ies->ESEVersion.present) &&
14566 (mac->roam.configParam.isEseIniFeatureEnabled))
14567#endif
14568 )
14569 {
14570 /* is11Rconnection */
14571 dw_tmp = pal_cpu_to_be32(TRUE);
14572 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14573 buf += sizeof(tAniBool);
14574 }
14575 else
14576 {
14577 /* is11Rconnection */
14578 dw_tmp = pal_cpu_to_be32(FALSE);
14579 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14580 buf += sizeof(tAniBool);
14581 }
14582#endif
14583#ifdef FEATURE_WLAN_ESE
14584
14585 /* isESEFeatureIniEnabled */
14586 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14587 {
14588 dw_tmp = pal_cpu_to_be32(TRUE);
14589 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14590 buf += sizeof(tAniBool);
14591 }
14592 else
14593 {
14594 dw_tmp = pal_cpu_to_be32(FALSE);
14595 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14596 buf += sizeof(tAniBool);
14597 }
14598
14599 /* A profile can not be both ESE and 11R. But an 802.11R AP
14600 * may be advertising support for ESE as well. So if we are
14601 * associating Open or explicitly ESE then we will get ESE.
14602 * If we are associating explictly 11R only then we will get
14603 * 11R.
14604 */
14605 if ((csrIsProfileESE(profile) ||
14606 ((ies->ESEVersion.present)
14607 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14608 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14609 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14610 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14611#ifdef WLAN_FEATURE_11W
14612 || (profile->negotiatedAuthType ==
14613 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14614 || (profile->negotiatedAuthType ==
14615 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14616#endif
14617 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14618 && (mac->roam.configParam.isEseIniFeatureEnabled))
14619 {
14620 /* isESEconnection */
14621 dw_tmp = pal_cpu_to_be32(TRUE);
14622 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14623 buf += sizeof(tAniBool);
14624 }
14625 else
14626 {
14627 /* isESEconnection */
14628 dw_tmp = pal_cpu_to_be32(FALSE);
14629 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14630 buf += sizeof(tAniBool);
14631 }
14632
14633 if (eWNI_SME_JOIN_REQ == message_type)
14634 {
14635 tESETspecInfo eseTspec;
14636 /*
14637 * ESE-Tspec IEs in the ASSOC request is presently not supported
14638 * so nullify the TSPEC parameters
14639 */
14640 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14641 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14642 buf += sizeof(tESETspecInfo);
14643 }
14644 else if (eWNI_SME_REASSOC_REQ == message_type)
14645 {
14646 if ((csrIsProfileESE(profile) ||
14647 ((ies->ESEVersion.present)
14648 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14649 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14650 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14651 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14652#ifdef WLAN_FEATURE_11W
14653 || (profile->negotiatedAuthType ==
14654 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14655 || (profile->negotiatedAuthType ==
14656 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14657#endif
14658 || (profile->negotiatedAuthType ==
14659 eCSR_AUTH_TYPE_RSN_PSK))))
14660 && (mac->roam.configParam.isEseIniFeatureEnabled))
14661 {
14662 tESETspecInfo eseTspec;
14663 /* ESE Tspec information */
14664 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14665 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14666 (tTspecInfo *) &eseTspec.tspec[0]);
14667 *buf = eseTspec.numTspecs;
14668 buf += sizeof(tANI_U8);
14669 // Copy the TSPEC information only if present
14670 if (eseTspec.numTspecs) {
14671 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14672 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14673 }
14674 buf += sizeof(eseTspec.tspec);
14675 }
14676 else
14677 {
14678 tESETspecInfo eseTspec;
14679 /*
14680 * ESE-Tspec IEs in the ASSOC request is presently
14681 * not supported so nullify the TSPEC parameters
14682 */
14683 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14684 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14685 buf += sizeof(tESETspecInfo);
14686 }
14687 }
14688#endif
14689#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14690 /* Fill in isFastTransitionEnabled */
14691 if (mac->roam.configParam.isFastTransitionEnabled
14692#ifdef FEATURE_WLAN_LFR
14693 || csrRoamIsFastRoamEnabled(mac, session_id)
14694#endif
14695 )
14696 {
14697 dw_tmp = pal_cpu_to_be32(TRUE);
14698 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14699 buf += sizeof(tAniBool);
14700 }
14701 else
14702 {
14703 dw_tmp = pal_cpu_to_be32(FALSE);
14704 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14705 buf += sizeof(tAniBool);
14706 }
14707#endif
14708#ifdef FEATURE_WLAN_LFR
14709 if(csrRoamIsFastRoamEnabled(mac, session_id))
14710 {
14711 /* legacy fast roaming enabled */
14712 dw_tmp = pal_cpu_to_be32(TRUE);
14713 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14714 buf += sizeof(tAniBool);
14715 }
14716 else
14717 {
14718 dw_tmp = pal_cpu_to_be32(FALSE);
14719 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14720 buf += sizeof(tAniBool);
14721 }
14722#endif
14723
14724 /* txLdpcIniFeatureEnabled */
14725 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14726 buf++;
14727
14728 if ((csrIs11hSupported(mac)) &&
14729 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14730 (ies->Country.present) &&\
14731 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14732 {
14733 csrSaveToChannelPower2G_5G(mac,
14734 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14735 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14736 csrApplyPower2Current(mac);
14737 }
14738
14739#ifdef WLAN_FEATURE_11AC
14740 /* txBFIniFeatureEnabled */
14741 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14742 buf++;
14743
14744 /* txBFCsnValue */
14745 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14746 {
14747 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14748 if (ies->VHTCaps.numSoundingDim)
14749 tx_bf_csn_value = CSR_ROAM_MIN
14750 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14751 }
14752 *buf = tx_bf_csn_value;
14753 buf++;
14754
14755 /* Only enable MuBf if no other MuBF session exist
14756 * and FW and HOST is MuBF capable.
14757 */
14758 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14759 {
14760 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14761 buf++;
14762 }
14763 else
14764 {
14765 *buf = 0;
14766 buf++;
14767 }
14768#endif
14769 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14770 buf++;
14771
14772 /* WME */
14773 if(mac->roam.roamSession[session_id].fWMMConnection)
14774 {
14775 /* WME enabled */
14776 dw_tmp = pal_cpu_to_be32(TRUE);
14777 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14778 buf += sizeof(tAniBool);
14779 }
14780 else
14781 {
14782 dw_tmp = pal_cpu_to_be32(FALSE);
14783 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14784 buf += sizeof(tAniBool);
14785 }
14786
14787 /* QOS */
14788 if(mac->roam.roamSession[session_id].fQOSConnection)
14789 {
14790 /* QOS enabled */
14791 dw_tmp = pal_cpu_to_be32(TRUE);
14792 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14793 buf += sizeof(tAniBool);
14794 }
14795 else
14796 {
14797 dw_tmp = pal_cpu_to_be32(FALSE);
14798 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14799 buf += sizeof(tAniBool);
14800 }
14801 /* BssDesc */
14802 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14803 (tANI_U8)profile->uapsd_mask);
14804 } while( 0 );
14805
14806 smsLog(mac, LOG1, FL("status %d"), status);
14807
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014808 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014809 return status;
14810}
14811#endif
14812
Jeff Johnson295189b2012-06-20 16:38:30 -070014813//
14814eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14815{
14816 eHalStatus status = eHAL_STATUS_SUCCESS;
14817 tSirSmeDisassocReq *pMsg;
14818 tANI_U8 *pBuf;
14819 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14821 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14822 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014824 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14825 if (NULL == pMsg)
14826 status = eHAL_STATUS_FAILURE;
14827 else
14828 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014830 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14832 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 pBuf = &pMsg->sessionId;
14834 // sessionId
14835 *pBuf++ = (tANI_U8)sessionId;
14836 // transactionId
14837 *pBuf = 0;
14838 *( pBuf + 1 ) = 0;
14839 pBuf += sizeof(tANI_U16);
14840
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014841 if ( (pSession->pCurRoamProfile != NULL) &&
14842 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14843 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 {
14845 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014846 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14847 sizeof( tSirMacAddr ));
14848 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014851 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14852 //perMacAddr is passed as bssId for softAP
14853 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 pBuf = pBuf + sizeof ( tSirMacAddr );
14855 }
14856 else
14857 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014859 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14860 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053014862 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
14863 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 if(!HAL_STATUS_SUCCESS(status))
14867 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014868 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 break;
14870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 // reasonCode
14872 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014873 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
14874 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 if(!HAL_STATUS_SUCCESS(status))
14876 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014877 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 break;
14879 }
14880 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14882 Here we should not send the disassoc over the air to the AP */
14883 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14884#ifdef WLAN_FEATURE_VOWIFI_11R
14885 && csrRoamIs11rAssoc(pMac)
14886#endif
14887 )
14888 {
14889 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14890 }
14891 pBuf += sizeof(tANI_U8);
14892 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 return( status );
14895}
Jeff Johnson295189b2012-06-20 16:38:30 -070014896eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14897{
14898 eHalStatus status = eHAL_STATUS_SUCCESS;
14899 tSirSmeTkipCntrMeasReq *pMsg;
14900 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014901 do
14902 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014903 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14904 if ( NULL == pMsg )
14905 status = eHAL_STATUS_FAILURE;
14906 else
14907 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014909 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14911 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 pBuf = &pMsg->sessionId;
14913 // sessionId
14914 *pBuf++ = (tANI_U8)sessionId;
14915 // transactionId
14916 *pBuf = 0;
14917 *( pBuf + 1 ) = 0;
14918 pBuf += sizeof(tANI_U16);
14919 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014920 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14921 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 pBuf = pBuf + sizeof ( tSirMacAddr );
14923 // bEnable
14924 *pBuf = (tANI_BOOLEAN)bEnable;
14925 if(!HAL_STATUS_SUCCESS(status))
14926 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014927 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 break;
14929 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 return( status );
14933}
Jeff Johnson295189b2012-06-20 16:38:30 -070014934eHalStatus
14935csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
14936 VOS_MODULE_ID modId, tSirMacAddr bssId,
14937 void *pUsrContext, void *pfnSapEventCallback,
14938 tANI_U8 *pAssocStasBuf )
14939{
14940 eHalStatus status = eHAL_STATUS_SUCCESS;
14941 tSirSmeGetAssocSTAsReq *pMsg;
14942 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14943 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 do
14945 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014946 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
14947 if ( NULL == pMsg )
14948 status = eHAL_STATUS_FAILURE;
14949 else
14950 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014952 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 pBuf = (tANI_U8 *)&pMsg->bssId;
14955 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014957 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 // modId
14960 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014961 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014964 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
14965 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014967 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
14968 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080014970 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
14971 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 status = palSendMBMessage( pMac->hHdd, pMsg );
14974 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 return( status );
14976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014977eHalStatus
14978csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
14979 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
14980 {
14981 eHalStatus status = eHAL_STATUS_SUCCESS;
14982 tSirSmeGetWPSPBCSessionsReq *pMsg;
14983 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080014984
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 do
14986 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014987 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
14988 if ( NULL == pMsg )
14989 status = eHAL_STATUS_FAILURE;
14990 else
14991 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014993 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070014996 VOS_ASSERT(pBuf);
14997
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015000 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15001 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015003 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15004 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015006 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015009 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 return( status );
15015}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015016
15017eHalStatus
15018csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15019{
15020 tpSirChangeBIParams pMsg;
15021 tANI_U16 len = 0;
15022 eHalStatus status = eHAL_STATUS_SUCCESS;
15023 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15024
15025 if(!pSession)
15026 {
15027 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15028 return eHAL_STATUS_FAILURE;
15029 }
15030
15031 //NO need to update the Beacon Params if update beacon parameter flag is not set
15032 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15033 return eHAL_STATUS_SUCCESS;
15034
15035 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15036
15037 /* Create the message and send to lim */
15038 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015039 pMsg = vos_mem_malloc(len);
15040 if ( NULL == pMsg )
15041 status = eHAL_STATUS_FAILURE;
15042 else
15043 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015044 if(HAL_STATUS_SUCCESS(status))
15045 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015046 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015047 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15048 pMsg->length = len;
15049
15050 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015051 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15052 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015053 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15054 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015055 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015056 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015057 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15058 status = palSendMBMessage(pMac->hHdd, pMsg);
15059 }
15060 return status;
15061}
15062
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015063#ifdef WLAN_FEATURE_AP_HT40_24G
15064eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15065{
15066 tpSirSetHT2040Mode pMsg;
15067 tANI_U16 len = 0;
15068 eHalStatus status = eHAL_STATUS_SUCCESS;
15069 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15070
15071 if(!pSession)
15072 {
15073 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15074 return eHAL_STATUS_FAILURE;
15075 }
15076
15077 /* Create the message and send to lim */
15078 len = sizeof(tSirSetHT2040Mode);
15079 pMsg = vos_mem_malloc(len);
15080
15081 if ( NULL == pMsg )
15082 {
15083 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15084 status = eHAL_STATUS_FAILURE;
15085 }
15086 else
15087 status = eHAL_STATUS_SUCCESS;
15088
15089 if(HAL_STATUS_SUCCESS(status))
15090 {
15091 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15092 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15093 pMsg->length = len;
15094
15095 // bssId
15096 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15097 sizeof(tSirMacAddr));
15098
15099 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15100 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15101 MAC_ADDR_ARRAY(pMsg->bssId));
15102
15103 pMsg->sessionId = sessionId;
15104 pMsg->cbMode = cbMode;
15105
15106 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15107 sessionId, cbMode);
15108
15109 status = palSendMBMessage(pMac->hHdd, pMsg);
15110 }
15111 return status;
15112}
15113#endif
15114
Jeff Johnson295189b2012-06-20 16:38:30 -070015115eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15116{
15117 eHalStatus status = eHAL_STATUS_SUCCESS;
15118 tSirSmeDeauthReq *pMsg;
15119 tANI_U8 *pBuf;
15120 tANI_U16 wTmp;
15121 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15122 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15123 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015124 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015125 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15126 if ( NULL == pMsg )
15127 status = eHAL_STATUS_FAILURE;
15128 else
15129 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015131 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15133 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15134 //sessionId
15135 pBuf = &pMsg->sessionId;
15136 *pBuf++ = (tANI_U8)sessionId;
15137
15138 //tansactionId
15139 *pBuf = 0;
15140 *(pBuf + 1 ) = 0;
15141 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15145 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015146 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15147 sizeof( pMsg->peerMacAddr ) );
15148 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 pBuf = pBuf + sizeof(tSirMacAddr);
15150 }
15151 else
15152 {
15153 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015154 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15155 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 }
15158 if(!HAL_STATUS_SUCCESS(status))
15159 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015160 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 break;
15162 }
15163 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015164 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15165 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 pBuf = pBuf + sizeof(tSirMacAddr);
15167 if(!HAL_STATUS_SUCCESS(status))
15168 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015169 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 break;
15171 }
15172 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015173 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15174 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 if(!HAL_STATUS_SUCCESS(status))
15176 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015177 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 break;
15179 }
15180 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 return( status );
15183}
15184
Jeff Johnson295189b2012-06-20 16:38:30 -070015185eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15186{
15187 eHalStatus status = eHAL_STATUS_SUCCESS;
15188 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015189 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015190 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15191 if ( NULL == pMsg )
15192 status = eHAL_STATUS_FAILURE;
15193 else
15194 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015196 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15198 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15199 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015200 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015201 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15202 sizeof(pMsg->peerMacAddr));
15203 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 if(!HAL_STATUS_SUCCESS(status))
15205 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015206 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 break;
15208 }
15209//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015210 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15211 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015212 if(!HAL_STATUS_SUCCESS(status))
15213 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015214 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 break;
15216 }
15217//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015219 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 return( status );
15221}
15222
Jeff Johnson295189b2012-06-20 16:38:30 -070015223eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15224{
15225 eHalStatus status = eHAL_STATUS_SUCCESS;
15226 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015228 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15229 if ( NULL == pMsg )
15230 status = eHAL_STATUS_FAILURE;
15231 else
15232 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015234 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15236 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15237 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015238 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015239 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15240 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 if(!HAL_STATUS_SUCCESS(status))
15242 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015243 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 break;
15245 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015246 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15247 sizeof(pMsg->peerMacAddr));
15248 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015249 if(!HAL_STATUS_SUCCESS(status))
15250 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015251 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 break;
15253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 return( status );
15257}
Jeff Johnson295189b2012-06-20 16:38:30 -070015258eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15259{
15260 eHalStatus status = eHAL_STATUS_SUCCESS;
15261 tSirSmeAssocCnf *pMsg;
15262 tANI_U8 *pBuf;
15263 tSirResultCodes statusCode;
15264 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015265
15266 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15267 "HalStatus : %d"),
15268 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015269 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015270 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15271 if ( NULL == pMsg )
15272 status = eHAL_STATUS_FAILURE;
15273 else
15274 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015275 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015276 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15278 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015279 pBuf = (tANI_U8 *)&pMsg->statusCode;
15280 if(HAL_STATUS_SUCCESS(Halstatus))
15281 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15282 else
15283 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015284 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 pBuf += sizeof(tSirResultCodes);
15286 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015287 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15288 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015289 pBuf += sizeof (tSirMacAddr);
15290 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015291 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15292 sizeof(tSirMacAddr));
15293 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 pBuf += sizeof (tSirMacAddr);
15295 // aid
15296 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015297 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 pBuf += sizeof (tANI_U16);
15299 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015300 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15301 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 pBuf += sizeof (tSirMacAddr);
15303 // alternateChannelId
15304 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 status = palSendMBMessage( pMac->hHdd, pMsg );
15306 if(!HAL_STATUS_SUCCESS(status))
15307 {
15308 //pMsg is freed by palSendMBMessage
15309 break;
15310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 return( status );
15313}
Jeff Johnson295189b2012-06-20 16:38:30 -070015314eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15315 tpSirSmeAssocInd pAssocInd,
15316 eHalStatus Halstatus,
15317 tANI_U8 sessionId)
15318{
15319 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15321 tANI_U8 *pBuf;
15322 tSirResultCodes statusCode;
15323 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015325 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15326 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15327 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015328
Jeff Johnson295189b2012-06-20 16:38:30 -070015329 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15330 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15331
15332 pMsg->sessionId = sessionId;
15333
15334 pBuf = (tANI_U8 *)&pMsg->statusCode;
15335 if(HAL_STATUS_SUCCESS(Halstatus))
15336 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15337 else
15338 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015339 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 pBuf += sizeof(tSirResultCodes);
15341 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015342 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015343 pBuf += sizeof (tSirMacAddr);
15344 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015345 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15346 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 pBuf += sizeof (tSirMacAddr);
15348 // StaId
15349 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015350 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 pBuf += sizeof (tANI_U16);
15352 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015353 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 pBuf += sizeof (tSirMacAddr);
15355 // alternateChannelId
15356 *pBuf = 11;
15357 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015358 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 //Wmm
15360 *pBuf = pAssocInd->wmmEnabledSta;
15361 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015363 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015365 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015366 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 //reassocReq
15369 *pBuf = pAssocInd->reassocReq;
15370 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015371#ifdef WLAN_FEATURE_AP_HT40_24G
15372 // 40 MHz Intolerant
15373 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15374 pBuf += sizeof (tANI_U8);
15375#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015376 *pBuf = pAssocInd->rate_flags;
15377 pBuf += sizeof (uint32_t);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053015378
15379 pBuf = (tANI_U8 *)&pMsg->chan_info;
15380 vos_mem_copy((void *)pBuf, &pAssocInd->chan_info,
15381 sizeof(tSirSmeChanInfo));
15382
15383 pBuf = (tANI_U8 *)&pMsg->ch_width;
15384 *pBuf = pAssocInd->ch_width;
15385
15386 if (pAssocInd->HTCaps.present) {
15387 pBuf = (tANI_U8 *)&pMsg->HTCaps;
15388 vos_mem_copy(pBuf, &pAssocInd->HTCaps, sizeof(pMsg->HTCaps));
15389 }
15390
15391 if (pAssocInd->VHTCaps.present) {
15392 pBuf = (tANI_U8 *)&pMsg->VHTCaps;
15393 vos_mem_copy(pBuf, &pAssocInd->VHTCaps, sizeof(pMsg->VHTCaps));
15394 }
15395
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15397 msgQ.bodyptr = pMsg;
15398 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015401 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015402}
Jeff Johnson295189b2012-06-20 16:38:30 -070015403
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015404eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15406 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15407 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15408 tANI_U8 *pKeyRsc )
15409{
15410 tSirSmeSetContextReq *pMsg;
15411 tANI_U16 msgLen;
15412 eHalStatus status = eHAL_STATUS_FAILURE;
15413 tAniEdType tmpEdType;
15414 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015415 tANI_U8 *pBuf = NULL;
15416 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015418 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15419 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15423 // key set. Since we only support upto one key, we always allocate memory for 1 key
15424 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15425 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15426 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15427 ( sizeof( pMsg->keyMaterial.key ) );
15428
Kiet Lam64c1b492013-07-12 13:56:44 +053015429 pMsg = vos_mem_malloc(msgLen);
15430 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15431 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15433 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015434 //sessionId
15435 pBuf = &pMsg->sessionId;
15436 *pBuf = (tANI_U8)sessionId;
15437 pBuf++;
15438 // transactionId
15439 *pBuf = 0;
15440 *(pBuf + 1) = 0;
15441 pBuf += sizeof(tANI_U16);
15442 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015443 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015444
15445 pBuf += sizeof(tSirMacAddr);
15446
15447 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015448 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15449 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015450
15451 pBuf += sizeof(tSirMacAddr);
15452
15453 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15455 // in the tSirKeyMaterial keyMaterial; field).
15456 //
15457 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15458 // shorter than this max size. Is LIM interpreting this ok ?
15459 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 -070015460 // set pMsg->keyMaterial.edType
15461 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015462 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 // set the pMsg->keyMaterial.numKeys field
15465 *p = numKeys;
15466 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 // set pSirKey->keyId = keyId;
15468 *p = keyId;
15469 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 // set pSirKey->unicast = (tANI_U8)fUnicast;
15471 *p = (tANI_U8)fUnicast;
15472 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015473 // set pSirKey->keyDirection = aniKeyDirection;
15474 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015475 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 p += sizeof(tAniKeyDirection);
15477 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015478 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015479 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015480 // set pSirKey->paeRole
15481 *p = paeRole; // 0 is Supplicant
15482 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015483 // set pSirKey->keyLength = keyLength;
15484 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015486 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 return( status );
15490}
15491
Jeff Johnson295189b2012-06-20 16:38:30 -070015492eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15493 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15494{
15495 eHalStatus status;
15496 tSirSmeStartBssReq *pMsg;
15497 tANI_U8 *pBuf = NULL;
15498 tANI_U8 *wTmpBuf = NULL;
15499 tANI_U16 msgLen, wTmp;
15500 tANI_U32 dwTmp;
15501 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015502 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015504 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015505
15506 if(!pSession)
15507 {
15508 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15509 return eHAL_STATUS_FAILURE;
15510 }
15511
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 do {
15513 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15514 pSession->joinFailStatusCode.reasonCode = 0;
15515 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015516 pMsg = vos_mem_malloc(msgLen);
15517 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15518 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015519 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015520 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015521 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 //sessionId
15523 *pBuf = (tANI_U8)sessionId;
15524 pBuf++;
15525 // transactionId
15526 *pBuf = 0;
15527 *(pBuf + 1) = 0;
15528 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015529 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015530 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015531 pBuf += sizeof(tSirMacAddr);
15532 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015533 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015534 pBuf += sizeof(tSirMacAddr);
15535 // beaconInterval
15536 if( pBssDesc && pBssDesc->beaconInterval )
15537 {
15538 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 else if(pParam->beaconInterval)
15541 {
15542 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 else
15545 {
15546 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15547 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015548 if(csrIsconcurrentsessionValid (pMac, sessionId,
15549 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015550 == eHAL_STATUS_SUCCESS )
15551 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015552 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015553 pParam->bssPersona);
15554 //Update the beacon Interval
15555 pParam->beaconInterval = wTmp;
15556 }
15557 else
15558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015559 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015560 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015561 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015562 return status;
15563 }
15564
Kiet Lam64c1b492013-07-12 13:56:44 +053015565 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015566 pBuf += sizeof(tANI_U16);
15567 // dot11mode
15568 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15569 pBuf += 1;
15570 // bssType
15571 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015572 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 pBuf += sizeof(tSirBssType);
15574 // ssId
15575 if( pParam->ssId.length )
15576 {
15577 // ssId len
15578 *pBuf = pParam->ssId.length;
15579 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015580 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 pBuf += pParam->ssId.length;
15582 }
15583 else
15584 {
15585 *pBuf = 0;
15586 pBuf++;
15587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015588 // set the channel Id
15589 *pBuf = pParam->operationChn;
15590 pBuf++;
15591 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015592 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015593 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015594 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015595
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 // Set privacy
15597 *pBuf = pParam->privacy;
15598 pBuf++;
15599
15600 //Set Uapsd
15601 *pBuf = pParam->ApUapsdEnable;
15602 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 //Set SSID hidden
15604 *pBuf = pParam->ssidHidden;
15605 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15607 pBuf++;
15608
15609 //Ht protection Enable/Disable
15610 *pBuf = (tANI_U8)pParam->protEnabled;
15611 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 //Enable Beacons to Receive for OBSS protection Enable/Disable
15613 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15614 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015615 //set cfg related to protection
15616 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015617 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 // Set Auth type
15620 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015621 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015623 // Set DTIM
15624 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015625 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 // Set wps_state
15628 *pBuf = pParam->wps_state;
15629 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015630 // set isCoalesingInIBSSAllowed
15631 *pBuf = pMac->isCoalesingInIBSSAllowed;
15632 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 //Persona
15634 *pBuf = (tANI_U8)pParam->bssPersona;
15635 pBuf++;
15636
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015637 //txLdpcIniFeatureEnabled
15638 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15639 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015640
Chet Lanctot8cecea22014-02-11 19:09:36 -080015641#ifdef WLAN_FEATURE_11W
15642 // Set MFP capable/required
15643 *pBuf = (tANI_U8)pParam->mfpCapable;
15644 pBuf++;
15645 *pBuf = (tANI_U8)pParam->mfpRequired;
15646 pBuf++;
15647#endif
15648
krunal soni4f087d22013-07-29 16:32:26 -070015649 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15651 {
15652 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015653 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015654 break;
15655 }
15656 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015657 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015658 pBuf += sizeof(tANI_U16);
15659 if( wTmp )
15660 {
15661 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015662 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015663 pBuf += wTmp;
15664 }
15665 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015666 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015667 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015668 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15669 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015670 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15671 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015672 pBuf += pParam->operationalRateSet.numRates ;
15673 *pBuf++ = pParam->extendedRateSet.numRates;
15674 if(0 != pParam->extendedRateSet.numRates)
15675 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015676 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15677 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 pBuf += pParam->extendedRateSet.numRates;
15679 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015680#ifdef WLAN_FEATURE_AP_HT40_24G
15681 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15682#endif
krunal sonie9002db2013-11-25 14:24:17 -080015683
Jeff Johnson295189b2012-06-20 16:38:30 -070015684 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15685 pMsg->length = pal_cpu_to_be16(msgLen);
15686
15687 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 return( status );
15690}
15691
Jeff Johnson295189b2012-06-20 16:38:30 -070015692eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15693{
15694 eHalStatus status = eHAL_STATUS_FAILURE;
15695 tSirSmeStopBssReq *pMsg;
15696 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15697 tANI_U8 *pBuf;
15698 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015699
15700 if(!pSession)
15701 {
15702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15703 return eHAL_STATUS_FAILURE;
15704 }
15705
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015706 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15707 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15708 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15709 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15710 pBuf = &pMsg->sessionId;
15711 //sessionId
15712 *pBuf = (tANI_U8)sessionId;
15713 pBuf++;
15714 // transactionId
15715 *pBuf = 0;
15716 pBuf += sizeof(tANI_U16);
15717 //reason code
15718 *pBuf = 0;
15719 pBuf += sizeof(tSirResultCodes);
15720 // bssid
15721 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15722 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15723 {
15724 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15725 sizeof(tSirMacAddr));
15726 }
15727 else
15728 {
15729 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15730 sizeof(tSirMacAddr));
15731 }
15732 pBuf += sizeof(tSirMacAddr);
15733 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15734 pMsg->length = pal_cpu_to_be16(msgLen);
15735 status = palSendMBMessage( pMac->hHdd, pMsg );
15736
Jeff Johnson295189b2012-06-20 16:38:30 -070015737 return( status );
15738}
15739
Jeff Johnson295189b2012-06-20 16:38:30 -070015740eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15741 tCsrRoamModifyProfileFields *pModProfileFields,
15742 tANI_U32 *pRoamId, v_BOOL_t fForce)
15743{
Jeff Johnson295189b2012-06-20 16:38:30 -070015744 eHalStatus status = eHAL_STATUS_FAILURE;
15745 tANI_U32 roamId = 0;
15746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015748 (fForce || (!vos_mem_compare( &pModProfileFields,
15749 &pSession->connectedProfile.modifyProfileFields,
15750 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015751 {
15752 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15753 if(pRoamId)
15754 {
15755 *pRoamId = roamId;
15756 }
15757
Jeff Johnson295189b2012-06-20 16:38:30 -070015758 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15759 eCsrSmeIssuedReassocToSameAP, roamId,
15760 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015762 return status;
15763}
Jeff Johnson295189b2012-06-20 16:38:30 -070015764static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15765{
15766 eHalStatus status = eHAL_STATUS_SUCCESS;
15767 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015768 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015769 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15770 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15771 return (status);
15772}
Jeff Johnson295189b2012-06-20 16:38:30 -070015773eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15774{
15775 eHalStatus status = eHAL_STATUS_SUCCESS;
15776 tListElem *pEntry = NULL;
15777 tSmeCmd *pCommand = NULL;
15778 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 do
15780 {
15781 if(pMsg == NULL)
15782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015783 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 status = eHAL_STATUS_FAILURE;
15785 break;
15786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015787 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15788 if(pEntry)
15789 {
15790 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15791 if(eSmeCommandAddStaSession == pCommand->command)
15792 {
15793 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015794 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015795 if (pRsp->status == eSIR_FAILURE) {
15796 VOS_ASSERT( 0 );
15797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015798 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015800 //Remove this command out of the active list
15801 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15802 {
15803 //Now put this command back on the avilable command list
15804 csrReleaseCommand(pMac, pCommand);
15805 }
15806 smeProcessPendingQueue( pMac );
15807 }
15808 else
15809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015810 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 -070015811 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015812 status = eHAL_STATUS_FAILURE;
15813 break;
15814 }
15815 }
15816 else
15817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015818 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 -070015819 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 status = eHAL_STATUS_FAILURE;
15821 break;
15822 }
15823 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015825}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015826eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15827 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015828{
15829 tSirSmeAddStaSelfReq *pMsg;
15830 tANI_U16 msgLen;
15831 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015832 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015833 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015834 pMsg = vos_mem_malloc(msgLen);
15835 if ( NULL == pMsg ) break;
15836 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015837 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15838 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015840 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015841 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15842
15843 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
15844
Arif Hussain24bafea2013-11-15 15:10:03 -080015845 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
15846 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015847 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015848 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 return( status );
15850}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015851eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
15852 tANI_U32 sessionId,
15853 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070015854{
15855 eHalStatus status = eHAL_STATUS_SUCCESS;
15856 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 pCommand = csrGetCommandBuffer(pMac);
15858 if(NULL == pCommand)
15859 {
15860 status = eHAL_STATUS_RESOURCES;
15861 }
15862 else
15863 {
15864 pCommand->command = eSmeCommandAddStaSession;
15865 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053015866 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
15867 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015868 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
15870 if( !HAL_STATUS_SUCCESS( status ) )
15871 {
15872 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015873 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015874 }
15875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015876 return (status);
15877}
Jeff Johnson295189b2012-06-20 16:38:30 -070015878eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15879{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015880 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070015881}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015882eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
15883 csrRoamCompleteCallback callback,
15884 void *pContext, tANI_U8 *pSelfMacAddr,
15885 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070015886{
15887 eHalStatus status = eHAL_STATUS_SUCCESS;
15888 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053015889 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015890 *pbSessionId = CSR_SESSION_ID_INVALID;
15891 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15892 {
15893 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15894 {
15895 pSession = CSR_GET_SESSION( pMac, i );
15896 status = eHAL_STATUS_SUCCESS;
15897 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15898 pSession->sessionId = (tANI_U8)i;
15899 pSession->callback = callback;
15900 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015901 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015903 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15904 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015905 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015906 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015908 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 break;
15910 }
15911#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015912 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15913 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015914 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015915 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015917 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015918 break;
15919 }
15920#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015921 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 break;
15923 }
15924 }
15925 if( CSR_ROAM_SESSION_MAX == i )
15926 {
15927 //No session is available
15928 status = eHAL_STATUS_RESOURCES;
15929 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 return ( status );
15931}
Jeff Johnson295189b2012-06-20 16:38:30 -070015932eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15933{
15934 eHalStatus status = eHAL_STATUS_SUCCESS;
15935 tListElem *pEntry = NULL;
15936 tSmeCmd *pCommand = NULL;
15937 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015938 do
15939 {
15940 if(pMsg == NULL)
15941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015942 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 status = eHAL_STATUS_FAILURE;
15944 break;
15945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015946 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15947 if(pEntry)
15948 {
15949 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15950 if(eSmeCommandDelStaSession == pCommand->command)
15951 {
15952 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015953 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015954 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015955 //This session is done.
15956 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 if(pCommand->u.delStaSessionCmd.callback)
15958 {
15959
15960 status = sme_ReleaseGlobalLock( &pMac->sme );
15961 if ( HAL_STATUS_SUCCESS( status ) )
15962 {
15963 pCommand->u.delStaSessionCmd.callback(
15964 pCommand->u.delStaSessionCmd.pContext);
15965 status = sme_AcquireGlobalLock( &pMac->sme );
15966 if (! HAL_STATUS_SUCCESS( status ) )
15967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015968 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 return status;
15970 }
15971 }
15972 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015973 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 }
15975 }
15976
15977 //Remove this command out of the active list
15978 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15979 {
15980 //Now put this command back on the avilable command list
15981 csrReleaseCommand(pMac, pCommand);
15982 }
15983 smeProcessPendingQueue( pMac );
15984 }
15985 else
15986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015987 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 -070015988 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 status = eHAL_STATUS_FAILURE;
15990 break;
15991 }
15992 }
15993 else
15994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015995 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 -070015996 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 status = eHAL_STATUS_FAILURE;
15998 break;
15999 }
16000 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016002}
Jeff Johnson295189b2012-06-20 16:38:30 -070016003eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16004{
16005 tSirSmeDelStaSelfReq *pMsg;
16006 tANI_U16 msgLen;
16007 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016009 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16010 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016011 pMsg = vos_mem_malloc(msgLen);
16012 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16013 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016014 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16015 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016017 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16018 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016021 return( status );
16022}
Jeff Johnson295189b2012-06-20 16:38:30 -070016023eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016024 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016025 tSirMacAddr sessionMacAddr,
16026 csrRoamSessionCloseCallback callback,
16027 void *pContext)
16028{
16029 eHalStatus status = eHAL_STATUS_SUCCESS;
16030 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016031 pCommand = csrGetCommandBuffer(pMac);
16032 if(NULL == pCommand)
16033 {
16034 status = eHAL_STATUS_RESOURCES;
16035 }
16036 else
16037 {
16038 pCommand->command = eSmeCommandDelStaSession;
16039 pCommand->sessionId = (tANI_U8)sessionId;
16040 pCommand->u.delStaSessionCmd.callback = callback;
16041 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016042 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16043 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016044 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016045 if( !HAL_STATUS_SUCCESS( status ) )
16046 {
16047 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016048 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016049 }
16050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 return (status);
16052}
Jeff Johnson295189b2012-06-20 16:38:30 -070016053eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16054{
16055 return csrSendMBDelSelfStaReqMsg( pMac,
16056 pCommand->u.delStaSessionCmd.selfMacAddr );
16057}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016058static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16059 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016060{
16061 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16062 tListElem *pEntry, *pNext;
16063 tSmeCmd *pCommand;
16064 tDblLinkList localList;
16065
16066 vos_mem_zero(&localList, sizeof(tDblLinkList));
16067 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16068 {
16069 smsLog(pMac, LOGE, FL(" failed to open list"));
16070 return;
16071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016072 csrLLLock(pList);
16073 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16074 while(pEntry != NULL)
16075 {
16076 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16077 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016078
16079 if (!flush_all &&
16080 csr_is_disconnect_full_power_cmd(pCommand)) {
16081 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16082 pEntry = pNext;
16083 continue;
16084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016085 if(pCommand->sessionId == sessionId)
16086 {
16087 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16088 {
16089 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16090 }
16091 }
16092 pEntry = pNext;
16093 }
16094 csrLLUnlock(pList);
16095
16096 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16097 {
16098 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16099 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16100 }
16101 csrLLClose(&localList);
16102}
16103
Jeff Johnson295189b2012-06-20 16:38:30 -070016104void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16105{
16106 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16107 {
16108 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016109 csrRoamStop(pMac, sessionId);
16110 csrFreeConnectBssDesc(pMac, sessionId);
16111 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16112 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016113 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016114#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016115 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016116#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016117 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016118 csrInitSession(pMac, sessionId);
16119 }
16120}
16121
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016122void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16123 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016124{
16125 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016126 &pMac->sme.smeCmdPendingList,
16127 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016128 if (pMac->fScanOffload)
16129 {
16130 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016131 &pMac->sme.smeScanCmdPendingList,
16132 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016133 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016134 purgeCsrSessionCmdList(pMac, sessionId,
16135 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016136}
16137
Jeff Johnson295189b2012-06-20 16:38:30 -070016138eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016139 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016140 csrRoamSessionCloseCallback callback,
16141 void *pContext )
16142{
16143 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016144 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16145 {
16146 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16147 if(fSync)
16148 {
16149 csrCleanupSession(pMac, sessionId);
16150 }
16151 else
mukul sharmabab477d2015-06-11 17:14:55 +053016152 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016153 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016154 /* If bPurgeList is FALSE, it means HDD already free all the
16155 * cmd and later queue few essential cmd. Now sme should process
16156 * the cmd in pending queue order only.Hence we should
16157 * avoid DEL_SELF_STA as high priority cmd.
16158 */
16159 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016160 pSession->selfMacAddr, callback, pContext);
16161 }
16162 }
16163 else
16164 {
16165 status = eHAL_STATUS_INVALID_PARAMETER;
16166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016167 return ( status );
16168}
16169
Jeff Johnson295189b2012-06-20 16:38:30 -070016170static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16171{
16172 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016173
16174 if(!pSession)
16175 {
16176 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16177 return;
16178 }
16179
Jeff Johnson295189b2012-06-20 16:38:30 -070016180 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16181 pSession->sessionId = CSR_SESSION_ID_INVALID;
16182 pSession->callback = NULL;
16183 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016184 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16185 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16186 csrFreeRoamProfile( pMac, sessionId );
16187 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16188 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16189 csrFreeConnectBssDesc(pMac, sessionId);
16190 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016191 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16192 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016193 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016194 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016195 pSession->pWpaRsnReqIE = NULL;
16196 }
16197 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016198 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016200 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016201 pSession->pWpaRsnRspIE = NULL;
16202 }
16203 pSession->nWpaRsnRspIeLength = 0;
16204#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016205 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016206 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016207 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016208 pSession->pWapiReqIE = NULL;
16209 }
16210 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016211 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016212 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016213 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016214 pSession->pWapiRspIE = NULL;
16215 }
16216 pSession->nWapiRspIeLength = 0;
16217#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016218 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016219 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016220 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016221 }
16222 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016223
Kiet Lam64c1b492013-07-12 13:56:44 +053016224 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016225 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016226 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016229 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016230}
16231
Jeff Johnson295189b2012-06-20 16:38:30 -070016232eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16233{
16234 eHalStatus status = eHAL_STATUS_FAILURE;
16235 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016236 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16237 {
16238 if( CSR_IS_SESSION_VALID( pMac, i ) )
16239 {
16240 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16241 {
16242 //Found it
16243 status = eHAL_STATUS_SUCCESS;
16244 *pSessionId = i;
16245 break;
16246 }
16247 }
16248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016249 return( status );
16250}
16251
Jeff Johnson295189b2012-06-20 16:38:30 -070016252//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16253//session because for IBSS, the bssid changes.
16254static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16255{
16256 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16257 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016258 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16259 {
16260 if( CSR_IS_SESSION_VALID( pMac, i ) )
16261 {
16262 pSession = CSR_GET_SESSION( pMac, i );
16263 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16264 {
16265 //Found it
16266 nRet = i;
16267 break;
16268 }
16269 }
16270 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016271 return (nRet);
16272}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016273void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016274{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016275 VOS_STATUS status = VOS_STATUS_SUCCESS;
16276
16277 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016278 profile info from pmac global structure */
16279
Arif Hussain24bafea2013-11-15 15:10:03 -080016280 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16281 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016282 /* Check for user misconfig of RSSI trigger threshold */
16283 pMac->roam.configParam.vccRssiThreshold =
16284 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16285 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16286 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016287 /* Check for user misconfig of UL MAC Loss trigger threshold */
16288 pMac->roam.configParam.vccUlMacLossThreshold =
16289 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16290 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016291#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16292 {
16293 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016294 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016295 /* Indicate the neighbor roal algorithm about the connect indication */
16296 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16297 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016298
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016299 /* Making sure we are roaming force fully to 5GHz AP only once and
16300 * only when we connected to 2.4GH AP only during initial association.
16301 */
16302 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16303 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16304 SIR_BAND_2_4_GHZ)
16305 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016306 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016307 status = vos_timer_start(
16308 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16309 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016310 if ( status != VOS_STATUS_SUCCESS )
16311 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016312 smsLog(pMac, LOGE,
16313 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16314 status);
16315 //Send RSO start because in case 5G roaming
16316 //host have not enabled at initial connection
16317 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016318 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016319 else
16320 {
16321 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16322 __func__);
16323 }
16324 }
16325 /*
16326 * Making ini value to false here only so we just roam to
16327 * only once for whole driver load to unload tenure
16328 * This feature is only applicable for first connection only
16329 */
16330 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16331 {
16332 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16333 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 }
16336#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016337}
16338
Jeff Johnson295189b2012-06-20 16:38:30 -070016339static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16340{
16341 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016342
16343 if(!pSession)
16344 {
16345 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16346 return;
16347 }
16348
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 //Only to handle the case for Handover on infra link
16350 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16351 {
16352 return;
16353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16355 csrRoamDeregStatisticsReq(pMac);
16356 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16357#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16358 /* Indicate the neighbor roal algorithm about the disconnect indication */
16359 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16360#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016361
16362 //Remove this code once SLM_Sessionization is supported
16363 //BMPS_WORKAROUND_NOT_NEEDED
16364 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016365 csrIsInfraApStarted( pMac ) &&
16366 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016367 {
16368 pMac->roam.configParam.doBMPSWorkaround = 0;
16369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016370}
16371
Jeff Johnson295189b2012-06-20 16:38:30 -070016372void csrRoamTlStatsTimerHandler(void *pv)
16373{
16374 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16375 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16377
Jeff Johnsone7245742012-09-05 17:12:55 -070016378 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16379
Jeff Johnson295189b2012-06-20 16:38:30 -070016380#if 0
16381 // TODO Persession .???
16382 //req TL for stats
16383 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016385 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016386 }
16387 else
16388 {
16389 //save in SME
16390 csrRoamSaveStatsFromTl(pMac, tlStats);
16391 }
16392#endif
16393 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16394 {
16395 if(pMac->roam.tlStatsReqInfo.periodicity)
16396 {
16397 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016398 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16399 pMac->roam.tlStatsReqInfo.periodicity);
16400 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016402 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 return;
16404 }
16405 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16406 }
16407 }
16408}
Jeff Johnson295189b2012-06-20 16:38:30 -070016409void csrRoamPeStatsTimerHandler(void *pv)
16410{
16411 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16412 eHalStatus status;
16413 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16414 VOS_STATUS vosStatus;
16415 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016416 pPeStatsReqListEntry->timerRunning = FALSE;
16417 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16418 {
16419 // If we entered here, meaning the timer could not be successfully
16420 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16421
16422 /* Destroy the timer */
16423 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16424 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016426 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 }
16428
16429 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016430 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016431 pPeStatsReqListEntry = NULL;
16432 }
16433 else
16434 {
16435 if(!pPeStatsReqListEntry->rspPending)
16436 {
16437 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16438 pPeStatsReqListEntry->staId);
16439 if(!HAL_STATUS_SUCCESS(status))
16440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016441 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016442 }
16443 else
16444 {
16445 pPeStatsReqListEntry->rspPending = TRUE;
16446 }
16447 }
16448
16449 //send down a req
16450 if(pPeStatsReqListEntry->periodicity &&
16451 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16452 {
16453 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16454 if(ePMC_FULL_POWER == powerState)
16455 {
16456 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16457 {
16458 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16459 }
16460 }
16461 else
16462 {
16463 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16464 {
16465 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16466 }
16467 }
16468 //start timer
16469 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16470 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016472 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016473 return;
16474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016475 pPeStatsReqListEntry->timerRunning = TRUE;
16476
16477 }
16478
16479 }
16480}
Jeff Johnson295189b2012-06-20 16:38:30 -070016481void csrRoamStatsClientTimerHandler(void *pv)
16482{
16483 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016484 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16485 {
16486#if 0
16487 // TODO Stats fix for multisession
16488 //start the timer
16489 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16490
16491 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016493 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 }
16495#endif
16496 }
16497#if 0
16498 //send up the stats report
16499 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16500 pStaEntry->staId, pStaEntry->pContext);
16501#endif
16502}
16503
16504
16505
Jeff Johnson295189b2012-06-20 16:38:30 -070016506eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16507{
16508 tAniGetPEStatsReq *pMsg;
16509 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016510 tSirMsgQ msgQ;
16511
Kiet Lam64c1b492013-07-12 13:56:44 +053016512 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16513 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016515 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016516 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016517 }
16518 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016519 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16521 pMsg->staId = staId;
16522 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016523
16524 msgQ.type = WDA_GET_STATISTICS_REQ;
16525 msgQ.reserved = 0;
16526 msgQ.bodyptr = pMsg;
16527 msgQ.bodyval = 0;
16528 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016529 if(!HAL_STATUS_SUCCESS(status))
16530 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016531 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016532 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 return status;
16535}
Jeff Johnson295189b2012-06-20 16:38:30 -070016536void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16537{
16538 tAniGetPEStatsRsp *pSmeStatsRsp;
16539 eHalStatus status = eHAL_STATUS_FAILURE;
16540 tListElem *pEntry = NULL;
16541 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16542 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16543 tANI_U32 tempMask = 0;
16544 tANI_U8 counter = 0;
16545 tANI_U8 *pStats = NULL;
16546 tANI_U32 length = 0;
16547 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016548 v_S7_t rssi = 0, snr = 0;
16549 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016550 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016551 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016552 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16553 if(pSmeStatsRsp->rc)
16554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016555 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016556 goto post_update;
16557 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016558 tempMask = pSmeStatsRsp->statsMask;
16559 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016560 /* subtract all statistics from this length, and after processing the entire
16561 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16562 * in this 'stats' message.
16563 */
16564 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016565 //new stats info from PE, fill up the stats strucutres in PMAC
16566 while(tempMask)
16567 {
16568 if(tempMask & 1)
16569 {
16570 switch(counter)
16571 {
16572 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016573 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016574 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16575 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016576 pStats += sizeof(tCsrSummaryStatsInfo);
16577 length -= sizeof(tCsrSummaryStatsInfo);
16578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016579 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016580 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016581 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16582 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016583 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16584 length -= sizeof(tCsrGlobalClassAStatsInfo);
16585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016587 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016588 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16589 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016590 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16591 length -= sizeof(tCsrGlobalClassBStatsInfo);
16592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016593 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016594 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016595 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16596 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16598 length -= sizeof(tCsrGlobalClassCStatsInfo);
16599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016600 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016601 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016602 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16603 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016604 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016605 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16606 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016607 }
16608 else
16609 {
16610 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016611 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016612 VOS_ASSERT( 0 );
16613 }
16614 if(!HAL_STATUS_SUCCESS(status))
16615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016616 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016617 }
16618 pStats += sizeof(tCsrPerStaStatsInfo);
16619 length -= sizeof(tCsrPerStaStatsInfo);
16620 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016621 case eCsrPerPktStats:
16622 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16623 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16624 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16625 {
16626 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16627 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16628 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016629 /* for reserved bytes */
16630 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16631 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016632 }
16633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016634 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016635 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016637 }
16638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 tempMask >>=1;
16640 counter++;
16641 }
16642 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16643 if (length != 0)
16644 {
16645 pRssi = (tANI_U32*)pStats;
16646 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016647 pStats += sizeof(tANI_U32);
16648 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016649 }
16650 else
16651 {
16652 /* If riva is not sending rssi, continue to use the hack */
16653 rssi = RSSI_HACK_BMPS;
16654 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016655 /* send positive value of rssi to wifi_hal */
16656 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016657 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016659
16660 if (length != 0)
16661 {
16662 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016663 pStats += sizeof(tANI_U32);
16664 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016665 }
16666 else
16667 {
16668 linkCapacity = 0;
16669 }
16670
16671 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016672
16673 if (length != 0)
16674 {
16675 pSnr = (tANI_U32*)pStats;
16676 snr = (v_S7_t)*pSnr;
16677 }
16678 else
16679 {
16680 snr = SNR_HACK_BMPS;
16681 }
16682
16683 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016684post_update:
16685 //make sure to update the pe stats req list
16686 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16687 if(pEntry)
16688 {
16689 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16690 pPeStaEntry->rspPending = FALSE;
16691
16692 }
16693 //check the one timer cases
16694 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16695 if(pEntry)
16696 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016698 if(pTempStaEntry->timerExpired)
16699 {
16700 //send up the stats report
16701 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16702 pTempStaEntry->staId, pTempStaEntry->pContext);
16703 //also remove from the client list
16704 csrRoamRemoveStatListEntry(pMac, pEntry);
16705 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016706 }
16707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016708}
Jeff Johnson295189b2012-06-20 16:38:30 -070016709tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16710{
16711 tListElem *pEntry = NULL;
16712 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016713 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 if(!pEntry)
16715 {
16716 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016717 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 return NULL;
16719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016720 while( pEntry )
16721 {
16722 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016723 if(pTempStaEntry->statsMask == statsMask)
16724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016725 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016726 break;
16727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016728 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 return pEntry;
16731}
16732
Jeff Johnson295189b2012-06-20 16:38:30 -070016733tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16734 tANI_BOOLEAN update)
16735{
16736 tListElem *pEntry;
16737 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 if(!pEntry)
16740 {
16741 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016742 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016743 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 return NULL;
16745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 while( pEntry )
16747 {
16748 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016749 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16750 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016752 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 if(update)
16754 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016755 pTempStaEntry->periodicity = pStaEntry->periodicity;
16756 pTempStaEntry->callback = pStaEntry->callback;
16757 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 }
16759 break;
16760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016761 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 return pEntry;
16764}
Jeff Johnson295189b2012-06-20 16:38:30 -070016765tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16766{
16767 tListElem *pEntry;
16768 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 if(!pEntry)
16771 {
16772 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016773 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016774 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 return NULL;
16776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016777 while( pEntry )
16778 {
16779 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016780 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016782 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016783 break;
16784 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016785 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016787 return pEntry;
16788}
Jeff Johnson295189b2012-06-20 16:38:30 -070016789eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16790 csrRoamLinkQualityIndCallback callback,
16791 void *pContext)
16792{
16793 pMac->roam.linkQualityIndInfo.callback = callback;
16794 pMac->roam.linkQualityIndInfo.context = pContext;
16795 if( NULL == callback )
16796 {
16797 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16798 }
16799 else
16800 {
16801 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 /* do we need to invoke the callback to notify client of initial value ?? */
16803 }
16804 return eHAL_STATUS_SUCCESS;
16805}
Jeff Johnson295189b2012-06-20 16:38:30 -070016806void csrRoamVccTrigger(tpAniSirGlobal pMac)
16807{
16808 eCsrRoamLinkQualityInd newVccLinkQuality;
16809 tANI_U32 ul_mac_loss = 0;
16810 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016811 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16812 /*-------------------------------------------------------------------------
16813 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016814 Check for a change in link quality and notify client if necessary
16815 -------------------------------------------------------------------------*/
16816 ul_mac_loss_trigger_threshold =
16817 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016818 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016819 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016820 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016821 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016823 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016824 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16825 }
16826 else
16827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016828 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016829 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016831 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16832 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016835 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016836 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016838 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016839 newVccLinkQuality );
16840
16841 /* we now invoke the callback once to notify client of initial value */
16842 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16843 pMac->roam.linkQualityIndInfo.context );
16844 //event: EVENT_WLAN_VCC
16845 }
16846 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016847 pMac->roam.vccLinkQuality = newVccLinkQuality;
16848
Jeff Johnson295189b2012-06-20 16:38:30 -070016849}
Jeff Johnson295189b2012-06-20 16:38:30 -070016850VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
16851 v_U8_t rssiNotification,
16852 void * context)
16853{
16854 tpAniSirGlobal pMac = PMAC_STRUCT( context );
16855 eCsrRoamLinkQualityInd newVccLinkQuality;
16856 // TODO : Session info unavailable
16857 tANI_U32 sessionId = 0;
16858 VOS_STATUS status = VOS_STATUS_SUCCESS;
16859 /*-------------------------------------------------------------------------
16860 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016861 Check for a change in link quality and notify client if necessary
16862 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016863 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 pMac->roam.configParam.vccRssiThreshold);
16865 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
16866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016867 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070016868 return VOS_STATUS_SUCCESS;
16869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
16871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016872 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070016873 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16874 }
16875 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
16876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016877 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16879 }
16880 else
16881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016882 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 //Set to this so the code below won't do anything
16884 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 VOS_ASSERT(0);
16886 }
16887
Jeff Johnson295189b2012-06-20 16:38:30 -070016888 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016890 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016891 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016893 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 /* we now invoke the callback once to notify client of initial value */
16896 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16897 pMac->roam.linkQualityIndInfo.context );
16898 //event: EVENT_WLAN_VCC
16899 }
16900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016902 return status;
16903}
Jeff Johnson295189b2012-06-20 16:38:30 -070016904tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16905 tDblLinkList *pStaList,
16906 tCsrStatsClientReqInfo *pStaEntry)
16907{
16908 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016909 //if same entity requested for same set of stats with different periodicity &
16910 // callback update it
16911 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16912 {
16913
Kiet Lam64c1b492013-07-12 13:56:44 +053016914 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16915 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016916 {
16917 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016918 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 return NULL;
16920 }
16921
Jeff Johnson295189b2012-06-20 16:38:30 -070016922 pNewStaEntry->callback = pStaEntry->callback;
16923 pNewStaEntry->pContext = pStaEntry->pContext;
16924 pNewStaEntry->periodicity = pStaEntry->periodicity;
16925 pNewStaEntry->requesterId = pStaEntry->requesterId;
16926 pNewStaEntry->statsMask = pStaEntry->statsMask;
16927 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16928 pNewStaEntry->pMac = pStaEntry->pMac;
16929 pNewStaEntry->staId = pStaEntry->staId;
16930 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16931
16932 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
16933 }
16934 return pNewStaEntry;
16935}
16936
Jeff Johnson295189b2012-06-20 16:38:30 -070016937tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
16938 tDblLinkList *pStaList,
16939 tCsrPeStatsReqInfo *pStaEntry)
16940{
16941 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016942 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
16943 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016944 {
16945 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016946 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016947 return NULL;
16948 }
16949
Jeff Johnson295189b2012-06-20 16:38:30 -070016950 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
16951 pNewStaEntry->numClient = pStaEntry->numClient;
16952 pNewStaEntry->periodicity = pStaEntry->periodicity;
16953 pNewStaEntry->statsMask = pStaEntry->statsMask;
16954 pNewStaEntry->pMac = pStaEntry->pMac;
16955 pNewStaEntry->staId = pStaEntry->staId;
16956 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
16957 pNewStaEntry->rspPending = pStaEntry->rspPending;
16958
16959 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 return pNewStaEntry;
16961}
Jeff Johnson295189b2012-06-20 16:38:30 -070016962eHalStatus csrGetRssi(tpAniSirGlobal pMac,
16963 tCsrRssiCallback callback,
16964 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16965{
16966 eHalStatus status = eHAL_STATUS_SUCCESS;
16967 vos_msg_t msg;
16968 tANI_U32 sessionId;
16969
16970 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016971 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016972 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16973 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016975 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016976 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
16979
16980 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
16981 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
16982 pMsg->sessionId = sessionId;
16983 pMsg->staId = staId;
16984 pMsg->rssiCallback = callback;
16985 pMsg->pDevContext = pContext;
16986 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016987 msg.type = eWNI_SME_GET_RSSI_REQ;
16988 msg.bodyptr = pMsg;
16989 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016990 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016992 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016993 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016994 status = eHAL_STATUS_FAILURE;
16995 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016996 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 return status;
16998}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016999
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017000eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17001 tCsrSnrCallback callback,
17002 tANI_U8 staId, tCsrBssid bssId,
17003 void *pContext)
17004{
17005 eHalStatus status = eHAL_STATUS_SUCCESS;
17006 vos_msg_t msg;
17007 tANI_U32 sessionId;
17008
17009 tAniGetSnrReq *pMsg;
17010
17011 smsLog(pMac, LOG2, FL("called"));
17012
17013 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17014 if (NULL == pMsg )
17015 {
17016 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17017 return status;
17018 }
17019
17020 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17021
17022 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17023 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17024 pMsg->sessionId = sessionId;
17025 pMsg->staId = staId;
17026 pMsg->snrCallback = callback;
17027 pMsg->pDevContext = pContext;
17028 msg.type = eWNI_SME_GET_SNR_REQ;
17029 msg.bodyptr = pMsg;
17030 msg.reserved = 0;
17031
17032 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17033 {
17034 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17035 vos_mem_free((v_VOID_t *)pMsg);
17036 status = eHAL_STATUS_FAILURE;
17037 }
17038
17039 smsLog(pMac, LOG2, FL("returned"));
17040 return status;
17041}
17042
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017043#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017044eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17045 tCsrRssiCallback callback,
17046 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17047{
17048 eHalStatus status = eHAL_STATUS_SUCCESS;
17049 tAniGetRssiReq *pMsg;
17050
Kiet Lam64c1b492013-07-12 13:56:44 +053017051 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17052 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017053 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017054 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017055 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017056 }
17057 // need to initiate a stats request to PE
17058 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17059 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17060 pMsg->staId = staId;
17061 pMsg->rssiCallback = callback;
17062 pMsg->pDevContext = pContext;
17063 pMsg->pVosContext = pVosContext;
17064 status = palSendMBMessage(pMac->hHdd, pMsg );
17065 if(!HAL_STATUS_SUCCESS(status))
17066 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017067 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017068 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017069 status = eHAL_STATUS_FAILURE;
17070 }
17071 return status;
17072}
17073#endif
17074
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017075
17076
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017077#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017078eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17079 tCsrTsmStatsCallback callback,
17080 tANI_U8 staId,
17081 tCsrBssid bssId,
17082 void *pContext,
17083 void* pVosContext,
17084 tANI_U8 tid)
17085{
17086 eHalStatus status = eHAL_STATUS_SUCCESS;
17087 tAniGetTsmStatsReq *pMsg = NULL;
17088
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017089 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17090 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017091 {
17092 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017093 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017094 }
17095 // need to initiate a stats request to PE
17096 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17097 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17098 pMsg->staId = staId;
17099 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017100 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017101 pMsg->tsmStatsCallback = callback;
17102 pMsg->pDevContext = pContext;
17103 pMsg->pVosContext = pVosContext;
17104 status = palSendMBMessage(pMac->hHdd, pMsg );
17105 if(!HAL_STATUS_SUCCESS(status))
17106 {
17107 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17108 //pMsg is freed by palSendMBMessage
17109 status = eHAL_STATUS_FAILURE;
17110 }
17111 return status;
17112}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017113#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017114
17115
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017116/* ---------------------------------------------------------------------------
17117 \fn csrGetTLSTAState
17118 \helper function to get teh TL STA State whenever the function is called.
17119
17120 \param staId - The staID to be passed to the TL
17121 to get the relevant TL STA State
17122 \return the state as tANI_U16
17123 ---------------------------------------------------------------------------*/
17124tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17125{
17126 WLANTL_STAStateType tlSTAState;
17127 tlSTAState = WLANTL_STA_INIT;
17128
17129 //request TL for STA State
17130 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17131 {
17132 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17133 }
17134
17135 return tlSTAState;
17136}
17137
Jeff Johnson295189b2012-06-20 16:38:30 -070017138eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17139 tANI_U32 statsMask,
17140 tCsrStatsCallback callback,
17141 tANI_U32 periodicity, tANI_BOOLEAN cache,
17142 tANI_U8 staId, void *pContext)
17143{
17144 tCsrStatsClientReqInfo staEntry;
17145 tCsrStatsClientReqInfo *pStaEntry = NULL;
17146 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17147 tListElem *pEntry = NULL;
17148 tANI_BOOLEAN found = FALSE;
17149 eHalStatus status = eHAL_STATUS_SUCCESS;
17150 tANI_BOOLEAN insertInClientList = FALSE;
17151 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017152 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017153
17154 if( csrIsAllSessionDisconnected(pMac) )
17155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017156 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017157 return eHAL_STATUS_FAILURE;
17158 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017159
17160 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17161 {
17162 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17163 return eHAL_STATUS_FAILURE;
17164 }
17165
Jeff Johnson295189b2012-06-20 16:38:30 -070017166 if((!statsMask) && (!callback))
17167 {
17168 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017169 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017170 return eHAL_STATUS_FAILURE;
17171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017172 //for the search list method for deregister
17173 staEntry.requesterId = requesterId;
17174 staEntry.statsMask = statsMask;
17175 //requester wants to deregister or just an error
17176 if((statsMask) && (!callback))
17177 {
17178 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17179 if(!pEntry)
17180 {
17181 //msg
17182 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017183 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017184 return eHAL_STATUS_FAILURE;
17185 }
17186 else
17187 {
17188 //clean up & return
17189 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017190 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017191 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017192 pStaEntry->pPeStaEntry->numClient--;
17193 //check if we need to delete the entry from peStatsReqList too
17194 if(!pStaEntry->pPeStaEntry->numClient)
17195 {
17196 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017198 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017199
Jeff Johnson295189b2012-06-20 16:38:30 -070017200 //check if we need to stop the tl stats timer too
17201 pMac->roam.tlStatsReqInfo.numClient--;
17202 if(!pMac->roam.tlStatsReqInfo.numClient)
17203 {
17204 if(pMac->roam.tlStatsReqInfo.timerRunning)
17205 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017206 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17207 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017209 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017210 return eHAL_STATUS_FAILURE;
17211 }
17212 }
17213 pMac->roam.tlStatsReqInfo.periodicity = 0;
17214 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17215 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017216 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017218 vos_timer_stop(&pStaEntry->timer);
17219 // Destroy the vos timer
17220 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17221 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17222 {
17223 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017226 csrRoamRemoveStatListEntry(pMac, pEntry);
17227 pStaEntry = NULL;
17228 return eHAL_STATUS_SUCCESS;
17229 }
17230 }
17231
17232 if(cache && !periodicity)
17233 {
17234 //return the cached stats
17235 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17236 }
17237 else
17238 {
17239 //add the request in the client req list
17240 staEntry.callback = callback;
17241 staEntry.pContext = pContext;
17242 staEntry.periodicity = periodicity;
17243 staEntry.pPeStaEntry = NULL;
17244 staEntry.staId = staId;
17245 staEntry.pMac = pMac;
17246 staEntry.timerExpired = FALSE;
17247
17248
Jeff Johnson295189b2012-06-20 16:38:30 -070017249 //if periodic report requested with non cached result from PE/TL
17250 if(periodicity)
17251 {
17252
17253 //if looking for stats from PE
17254 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17255 {
17256
17257 //check if same request made already & waiting for rsp
17258 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17259 periodicity, &found, staId);
17260 if(!pPeStaEntry)
17261 {
17262 //bail out, maxed out on number of req for PE
17263 return eHAL_STATUS_FAILURE;
17264 }
17265 else
17266 {
17267 staEntry.pPeStaEntry = pPeStaEntry;
17268 }
17269
17270 }
17271 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17272 if(statsMask & (1 << eCsrGlobalClassDStats))
17273 {
17274 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017276 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017277 }
17278 else
17279 {
17280
17281 //update periodicity
17282 if(pMac->roam.tlStatsReqInfo.periodicity)
17283 {
17284 pMac->roam.tlStatsReqInfo.periodicity =
17285 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17286 }
17287 else
17288 {
17289 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17290 }
17291 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17292 {
17293 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17294 }
17295
17296 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17297 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017298 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017299 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017300 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017301 //req TL for class D stats
17302 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017304 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017305 }
17306 else
17307 {
17308 //save in SME
17309 csrRoamSaveStatsFromTl(pMac, pTlStats);
17310 }
17311 vos_mem_free(pTlStats);
17312 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017313 }
17314 else
17315 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017316 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017317 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017318
Jeff Johnson295189b2012-06-20 16:38:30 -070017319 if(pMac->roam.tlStatsReqInfo.periodicity)
17320 {
17321 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017322 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17323 pMac->roam.tlStatsReqInfo.periodicity);
17324 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017326 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017327 return eHAL_STATUS_FAILURE;
17328 }
17329 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17330 }
17331 }
17332 }
17333 pMac->roam.tlStatsReqInfo.numClient++;
17334 }
17335
17336 insertInClientList = TRUE;
17337 }
17338 //if one time report requested with non cached result from PE/TL
17339 else if(!cache && !periodicity)
17340 {
17341 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17342 {
17343 //send down a req
17344 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17345 if(!HAL_STATUS_SUCCESS(status))
17346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017347 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017348 }
17349 //so that when the stats rsp comes back from PE we respond to upper layer
17350 //right away
17351 staEntry.timerExpired = TRUE;
17352 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017353 }
17354 if(statsMask & (1 << eCsrGlobalClassDStats))
17355 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017356 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017357 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017358 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017359 //req TL for class D stats
17360 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017362 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017363 }
17364 else
17365 {
17366 //save in SME
17367 csrRoamSaveStatsFromTl(pMac, pTlStats);
17368 }
17369 vos_mem_free(pTlStats);
17370 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017371 }
17372 else
17373 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017374 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017375 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017376
17377 }
17378 //if looking for stats from TL only
17379 if(!insertInClientList)
17380 {
17381 //return the stats
17382 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017385 if(insertInClientList)
17386 {
17387 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17388 if(!pStaEntry)
17389 {
17390 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017391 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017392 return eHAL_STATUS_FAILURE;
17393 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017394 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017395 //Init & start timer if needed
17396 if(periodicity)
17397 {
17398 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17399 csrRoamStatsClientTimerHandler, pStaEntry );
17400 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017402 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017403 return eHAL_STATUS_FAILURE;
17404 }
17405 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17406 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017408 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017409 return eHAL_STATUS_FAILURE;
17410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017412 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017413 }
17414 return eHAL_STATUS_SUCCESS;
17415}
17416
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017417#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17418
17419static tSirRetStatus
17420csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17421 tANI_U8* pBD,
17422 tANI_U8 type,
17423 tANI_U8 subType,
17424 tSirMacAddr peerAddr,
17425 tSirMacAddr selfMacAddr)
17426{
17427 tSirRetStatus statusCode = eSIR_SUCCESS;
17428 tpSirMacMgmtHdr pMacHdr;
17429
17430 /* Prepare MAC management header */
17431 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17432
17433 /* Prepare FC */
17434 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17435 pMacHdr->fc.type = type;
17436 pMacHdr->fc.subType = subType;
17437
17438 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017439 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17440 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017441
17442 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17443
17444 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017445 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17446 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017447 return statusCode;
17448} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17449
17450static tSirRetStatus
17451csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17452 tANI_U8 nChannelNum,
17453 tANI_U32 dot11mode,
17454 tSirMacAddr selfMacAddr,
17455 tANI_U8 *pFrame,
17456 tANI_U16 *pusLen)
17457{
17458 tDot11fProbeRequest pr;
17459 tANI_U32 nStatus, nBytes, nPayload;
17460 tSirRetStatus nSirStatus;
17461 /*Bcast tx*/
17462 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17463 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17464
17465
Kiet Lam64c1b492013-07-12 13:56:44 +053017466 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017467
17468 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17469
17470 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17471 {
17472 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17473 }
17474
17475
17476 if (IS_DOT11_MODE_HT(dot11mode))
17477 {
17478 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17479 }
17480
17481
17482 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17483 if ( DOT11F_FAILED( nStatus ) )
17484 {
17485 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17486 "Failed to calculate the packed size f"
17487 "or a Probe Request (0x%08x).\n", nStatus );
17488
17489
17490 nPayload = sizeof( tDot11fProbeRequest );
17491 }
17492 else if ( DOT11F_WARNED( nStatus ) )
17493 {
17494 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17495 "There were warnings while calculating"
17496 "the packed size for a Probe Request ("
17497 "0x%08x).\n", nStatus );
17498 }
17499
17500 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17501
17502 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017503 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017504
17505
17506 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017507 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017508
17509 if ( eSIR_SUCCESS != nSirStatus )
17510 {
17511 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17512 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17513 nSirStatus );
17514 return nSirStatus;
17515 }
17516
17517
17518 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17519 sizeof( tSirMacMgmtHdr ),
17520 nPayload, &nPayload );
17521 if ( DOT11F_FAILED( nStatus ) )
17522 {
17523 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17524 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17525 return eSIR_FAILURE;
17526 }
17527 else if ( DOT11F_WARNED( nStatus ) )
17528 {
17529 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017530 "There were warnings while packing a Probe Request (0x%08x).\n",
17531 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017532 }
17533
17534 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17535 return eSIR_SUCCESS;
17536}
17537
Mukul Sharmad68cda62015-03-20 21:25:41 +053017538/*
17539 * Below Table describe whether RSO command can be send down to fimrware or not.
17540 * Host check it on the basis of previous RSO command sent down to firmware.
17541||===========================================================================||
17542|| New cmd | LAST SENT COMMAND ---> ||
17543||====|======================================================================||
17544|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17545|| --------------------------------------------------------------------------||
17546|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017547|| RSO_STOP | YES | NO | YES | YES ||
17548|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017549|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17550||===========================================================================||
17551*/
17552
17553#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17554#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17555#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17556#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17557
17558#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17559#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017560 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017561#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17562 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017563#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017564 RSO_START_BIT)
17565
17566tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17567{
17568 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17569 tANI_U8 desiredMask = 0;
17570 switch(command)
17571 {
17572 case ROAM_SCAN_OFFLOAD_START:
17573 desiredMask = RSO_START_ALLOW_MASK;
17574 break;
17575 case ROAM_SCAN_OFFLOAD_STOP:
17576 desiredMask = RSO_STOP_ALLOW_MASK;
17577 break;
17578 case ROAM_SCAN_OFFLOAD_RESTART:
17579 desiredMask = RSO_RESTART_ALLOW_MASK;
17580 break;
17581 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17582 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17583 break;
17584 default:
17585 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17586 FL("Wrong RSO command %d, not allowed"), command);
17587 return 0;/*Cmd Not allowed*/
17588 }
17589 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17590}
17591
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017592eCsrBand GetCurrentBand(tANI_U8 channel)
17593{
17594 tSirRFBand Rfband;
17595 eCsrBand band;
17596
17597 Rfband = GetRFBand(channel);
17598
17599 if (Rfband == SIR_BAND_5_GHZ)
17600 band = eCSR_BAND_5G;
17601 else if (Rfband == SIR_BAND_2_4_GHZ)
17602 band = eCSR_BAND_24;
17603 else if (Rfband == SIR_BAND_UNKNOWN)
17604 band = eCSR_BAND_MAX;
17605
17606 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17607 "channel %d Rfband %d band %d", channel, Rfband, band);
17608
17609 return band;
17610}
17611
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017612eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17613{
17614 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017615 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017616 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017617 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017618 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017619 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017620 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017621 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017622 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017623 eHalStatus status = eHAL_STATUS_SUCCESS;
17624 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017625 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017626 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017627 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017628 tSirBssDescription *pBssDesc = NULL;
17629 tDot11fBeaconIEs *pIes = NULL;
17630 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017631 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017632
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017633 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17634
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017635 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017636 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017637 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017638 return eHAL_STATUS_FAILURE;
17639 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017640
17641 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17642 {
17643 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17644 return eHAL_STATUS_FAILURE;
17645 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017646
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017647 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17648 * It is important to ensure that the command is passed down to the FW only
17649 * if the Infra Station is in a connected state.A connected station could also be
17650 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17651 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17652 * irrespective of whichever state we are in.*/
17653 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17654 (command != ROAM_SCAN_OFFLOAD_STOP))
17655 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017656 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17657 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17658 macTraceGetNeighbourRoamState(
17659 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017660 return eHAL_STATUS_FAILURE;
17661 }
17662
Mukul Sharmad68cda62015-03-20 21:25:41 +053017663 if (!CsrIsRSOCommandAllowed(pMac, command))
17664 {
17665 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17666 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17667 command, pNeighborRoamInfo->lastSentCmd);
17668 return eHAL_STATUS_FAILURE;
17669 }
17670
Abhishek Singh3e915632014-11-01 17:14:50 +053017671 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17672 * Also there are cases where pNeighborRoamInfo->currAPbssid
17673 * is set to 0 during disconnect and so we might return without stopping
17674 * the roam scan. So no need to find the session if command is
17675 * ROAM_SCAN_OFFLOAD_STOP.
17676 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017677 status = csrRoamGetSessionIdFromBSSID(pMac,
17678 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17679 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017680 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017681 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017682 if ( !HAL_STATUS_SUCCESS( status ) )
17683 {
17684 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17685 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17686 return eHAL_STATUS_FAILURE;
17687 }
17688 pSession = CSR_GET_SESSION( pMac, sessionId );
17689 if (NULL == pSession)
17690 {
17691 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080017692 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053017693 return eHAL_STATUS_FAILURE;
17694 }
17695 pBssDesc = pSession->pConnectBssDesc;
17696 if (pBssDesc == NULL)
17697 {
17698 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17699 "%s: pBssDesc not found for current session", __func__);
17700 return eHAL_STATUS_FAILURE;
17701 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017702
17703 operationChannel = pSession->connectedProfile.operationChannel;
17704 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17705 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017706 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017707 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17708 if (NULL == pRequestBuf)
17709 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017710 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17711 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17712 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017713 }
17714
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017715#ifdef FEATURE_WLAN_DIAG_SUPPORT
17716 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17717 eSIR_SUCCESS, eSIR_SUCCESS);
17718#endif
17719
Abhishek Singh3e915632014-11-01 17:14:50 +053017720 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17721 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17722 * host driver reloads, but Riva still up and running*/
17723 pRequestBuf->Command = command;
17724 if(command == ROAM_SCAN_OFFLOAD_STOP)
17725 {
17726 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017727 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017728 /*For a STOP Command, there is no need to
17729 * go through filling up all the below parameters
17730 * since they are not required for the STOP command*/
17731 goto send_roam_scan_offload_cmd;
17732 }
17733 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017734 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017735 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17736 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017737 sizeof(tCsrBssid));
17738 pRequestBuf->ConnectedNetwork.ssId.length =
17739 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17740 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17741 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17742 pRequestBuf->ConnectedNetwork.ssId.length);
17743 pRequestBuf->ConnectedNetwork.authentication =
17744 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17745 pRequestBuf->ConnectedNetwork.encryption =
17746 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17747 pRequestBuf->ConnectedNetwork.mcencryption =
17748 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017749 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17750 {
17751 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017752 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017753 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17754 }
17755 else
17756 {
17757 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017758
17759 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17760 {
17761 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17762 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17763 vos_mem_free(pRequestBuf);
17764 return eHAL_STATUS_FAILURE;
17765 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017766 if(NULL == pIes)
17767 {
17768 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17769 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017770 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017771 return eHAL_STATUS_FAILURE;
17772 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017773 if (pIes->SuppRates.present)
17774 {
17775 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17776 /*Check for both basic rates and extended rates.*/
17777 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17778 {
17779 /*Check if the Rate is Mandatory or Not*/
17780 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17781 && (pIes->SuppRates.rates[i] & 0x80))
17782 {
17783 /*Retrieve the actual data rate*/
17784 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17785 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17786 if (minRate == 0)
17787 minRate = dataRate;
17788 else
17789 minRate = (minRate < dataRate) ? minRate:dataRate;
17790 }
17791 }
17792
17793 if (pIes->ExtSuppRates.present)
17794 {
17795 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17796 {
17797 /*Check if the Rate is Mandatory or Not*/
17798 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17799 && (pIes->ExtSuppRates.rates[i] & 0x80))
17800 {
17801 /*Retrieve the actual data rate*/
17802 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17803 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17804 if (minRate == 0)
17805 minRate = dataRate;
17806 else
17807 minRate = (minRate < dataRate) ? minRate:dataRate;
17808 }
17809 }
17810 }
17811 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17812 }
17813 else
17814 {
17815 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17816 "%s: Supp Rates not present in pIes", __func__);
17817 vos_mem_free(pRequestBuf);
17818 return eHAL_STATUS_FAILURE;
17819 }
17820 if (NULL != pIes)
17821 {
17822 vos_mem_free(pIes);
17823 pIes = NULL;
17824 }
17825 switch (minRate)
17826 {
17827 case 1:
17828 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
17829 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
17830 break;
17831 case 2:
17832 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
17833 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
17834 break;
17835 case 5:
17836 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
17837 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
17838 break;
17839 case 6:
17840 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17841 {
17842 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
17843 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
17844 }
17845 else
17846 {
17847 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
17848 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
17849 }
17850 break;
17851 case 11:
17852 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
17853 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
17854 break;
17855 case 12:
17856 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17857 {
17858 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
17859 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
17860 }
17861 else
17862 {
17863 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
17864 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
17865 }
17866 break;
17867 case 24:
17868 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17869 {
17870 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
17871 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
17872 }
17873 else
17874 {
17875 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
17876 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
17877 }
17878 break;
17879 default:
17880 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
17881 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17882 break;
17883 }
17884 }
17885 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17886 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
17887 operationChannel, minRate,
17888 pRequestBuf->RxSensitivityThreshold,
17889 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017890 pRequestBuf->RoamRssiDiff =
17891 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017892 pRequestBuf->StartScanReason = reason;
17893 pRequestBuf->NeighborScanTimerPeriod =
17894 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
17895 pRequestBuf->NeighborRoamScanRefreshPeriod =
17896 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
17897 pRequestBuf->NeighborScanChannelMinTime =
17898 pNeighborRoamInfo->cfgParams.minChannelScanTime;
17899 pRequestBuf->NeighborScanChannelMaxTime =
17900 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
17901 pRequestBuf->EmptyRefreshScanPeriod =
17902 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080017903 /* MAWC feature */
17904 pRequestBuf->MAWCEnabled =
17905 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017906
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017907#ifdef FEATURE_WLAN_ESE
17908 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017909#endif
17910 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017911#ifdef FEATURE_WLAN_ESE
17912 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017913 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17914 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017915 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17916#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017917 currChannelListInfo->numOfChannels == 0)
17918 {
17919
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017920 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
17921 * Give Preference to INI Channels.*/
17922 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
17923 {
17924 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
17925 /*The INI channels need to be filtered with respect to the current
17926 * band that is supported.*/
17927 eBand = pMac->roam.configParam.bandCapability;
17928 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017929 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017930 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17931 "Invalid band, No operation carried out (Band %d)", eBand);
17932 vos_mem_free(pRequestBuf);
17933 return eHAL_STATUS_FAILURE;
17934 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017935
17936 if (pMac->roam.configParam.nRoamIntraBand)
17937 {
17938 eBand = GetCurrentBand(operationChannel);
17939 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17940 "Current Band %d", eBand);
17941 }
17942
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017943 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
17944 {
17945 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17946 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
17947 (eCSR_BAND_ALL == eBand))
17948 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017949 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
17950 ((pMac->roam.configParam.allowDFSChannelRoam) ||
17951 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
17952 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017953 {
17954 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
17955 }
17956 }
17957 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017958 }
17959 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17960 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017961 }
17962 else
17963 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017964 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017965
17966 if (pMac->roam.configParam.nRoamIntraBand)
17967 {
17968 Rfband = GetCurrentBand(operationChannel);
17969 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17970 "Current Band %d", Rfband);
17971 }
17972
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017973 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
17974 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017975 if(((eCSR_BAND_24 == Rfband) &&
17976 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17977 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
17978 || (eCSR_BAND_ALL == Rfband))
17979 {
17980 /* Allow DFS channels only if the DFS channel roam flag is
17981 * enabled
17982 */
17983 if(*ChannelList && ((pMac->roam.configParam.
17984 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
17985 && (num_channels < SIR_ROAM_MAX_CHANNELS))
17986 {
17987 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
17988 = *ChannelList;
17989 }
17990 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017991 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017992 }
17993 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17994 /* If the profile changes as to what it was earlier, inform the FW through
17995 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
17996 * for the earlier profile and try to learn them afresh.*/
17997 if (reason == REASON_FLUSH_CHANNEL_LIST)
17998 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
17999 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018000 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18001 (pMac->roam.configParam.nRoamIntraBand))
18002 pRequestBuf->ChannelCacheType =
18003 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018004 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018005 pRequestBuf->ChannelCacheType =
18006 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018007 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018008 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018009 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018010#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018011 else
18012 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018013 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018014 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018015 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018016 if (currChannelListInfo->numOfChannels != 0)
18017 {
18018 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018019
18020 if (pMac->roam.configParam.nRoamIntraBand)
18021 {
18022 Rfband = GetCurrentBand(operationChannel);
18023 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18024 "Current Band %d", Rfband);
18025 }
18026
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018027 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018028 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018029 if(((eCSR_BAND_24 == Rfband) &&
18030 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18031 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18032 || (eCSR_BAND_ALL == Rfband))
18033 {
18034 if(*ChannelList && ((pMac->roam.configParam.
18035 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18036 {
18037 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018038 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018039 }
18040 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018041 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018042 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018043 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018044 if (pMac->roam.configParam.nRoamIntraBand)
18045 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18046 else
18047 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018048 }
18049 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018050#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018051 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18052 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018053 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018054 if (j < sizeof(ChannelCacheStr))
18055 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018056 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18057 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018058 }
18059 else
18060 {
18061 break;
18062 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018063 }
18064 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18065 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18066 pRequestBuf->ChannelCacheType,
18067 pRequestBuf->ConnectedNetwork.ChannelCount,
18068 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018069 num_channels = 0;
18070 ChannelList = NULL;
18071
18072 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018073 host_channels = sizeof(pMac->roam.validChannelList);
18074 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018075 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018076 ChannelList = pMac->roam.validChannelList;
18077 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018078 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018079 else
18080 {
18081 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18082 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018083 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018084 return eHAL_STATUS_FAILURE;
18085 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018086
18087 if (pMac->roam.configParam.nRoamIntraBand)
18088 {
18089 Rfband = GetCurrentBand(operationChannel);
18090 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18091 Rfband);
18092 }
18093
Srinivas Girigowda56076852013-08-20 14:00:50 -070018094 for(i=0; i<pMac->roam.numValidChannels; i++)
18095 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018096 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18097 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18098 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018099 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018100 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18101 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18102 {
18103 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18104 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018105 }
18106 ChannelList++;
18107 }
18108 pRequestBuf->ValidChannelCount = num_channels;
18109
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018110 pRequestBuf->MDID.mdiePresent =
18111 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18112 pRequestBuf->MDID.mobilityDomain =
18113 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018114 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18115
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018116 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018117 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18118 * where RFS is the RF Switching time. It is twice RFS to consider the
18119 * time to go off channel and return to the home channel. */
18120 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18121 {
18122 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18123 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18124 " Hence enforcing home away time to disable (0)",
18125 __func__, pRequestBuf->HomeAwayTime,
18126 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18127 pRequestBuf->HomeAwayTime = 0;
18128 }
18129 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018130
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018131 pRequestBuf->WeakZoneRssiThresholdForRoam =
18132 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018133 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18134 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18135 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18136 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18137 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18138
18139 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18140 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018141send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018142 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018143 msg.reserved = 0;
18144 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018145 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18146 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018147 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18148 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018149 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18150 vos_mem_free(pRequestBuf);
18151 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018152 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018153 else
18154 {
18155 if (ROAM_SCAN_OFFLOAD_START == command)
18156 bRoamScanOffloadStarted = VOS_TRUE;
18157 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18158 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018159
18160 /*update the last sent cmd*/
18161 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018162 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018163
18164 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 +053018165
18166 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018167 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18168 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018169 {
18170
18171 /* PER ROAM SCAN */
18172 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18173 if (!PERRoamReqBuf)
18174 {
18175 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18176 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18177 return eHAL_STATUS_FAILURE;
18178 }
18179 /* PER Roam Config */
18180 PERRoamReqBuf->rateUpThreshold =
18181 pMac->roam.configParam.rateUpThreshold;
18182 PERRoamReqBuf->rateDownThreshold =
18183 pMac->roam.configParam.rateDownThreshold;
18184 PERRoamReqBuf->waitPeriodForNextPERScan =
18185 pMac->roam.configParam.waitPeriodForNextPERScan;
18186 PERRoamReqBuf->PERtimerThreshold =
18187 pMac->roam.configParam.PERtimerThreshold;
18188 PERRoamReqBuf->isPERRoamCCAEnabled =
18189 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018190 PERRoamReqBuf->PERRoamFullScanThreshold =
18191 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018192 PERRoamReqBuf->PERroamTriggerPercent =
18193 pMac->roam.configParam.PERroamTriggerPercent;
18194 PERRoamReqBuf->sessionId = sessionId;
18195
18196 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18197 PERroamScanConfigMsg.reserved = 0;
18198 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18199 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18200 &PERroamScanConfigMsg))) {
18201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18202 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18203 vos_mem_free(PERRoamReqBuf);
18204 return eHAL_STATUS_FAILURE;
18205 }
18206 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18207 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18208 PERRoamReqBuf->rateUpThreshold,
18209 PERRoamReqBuf->rateDownThreshold,
18210 PERRoamReqBuf->waitPeriodForNextPERScan,
18211 PERRoamReqBuf->PERtimerThreshold);
18212 }
18213
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018214 return status;
18215}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018216
18217eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18218{
18219 switch(reason)
18220 {
18221 case 0:
18222 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18223 break;
18224 case REASON_OS_REQUESTED_ROAMING_NOW:
18225 csrNeighborRoamProceedWithHandoffReq(pMac);
18226 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018227 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18228 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18229 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018230 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018231 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 -070018232 }
18233 return eHAL_STATUS_SUCCESS;
18234}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018235#endif
18236
Jeff Johnson295189b2012-06-20 16:38:30 -070018237tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18238 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18239{
18240 tANI_BOOLEAN found = FALSE;
18241 eHalStatus status = eHAL_STATUS_SUCCESS;
18242 tCsrPeStatsReqInfo staEntry;
18243 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18244 tListElem *pStaEntry = NULL;
18245 VOS_STATUS vosStatus;
18246 tPmcPowerState powerState;
18247 *pFound = FALSE;
18248
18249 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18250 if(pStaEntry)
18251 {
18252 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18253 if(pTempStaEntry->periodicity)
18254 {
18255 pTempStaEntry->periodicity =
18256 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18257 }
18258 else
18259 {
18260 pTempStaEntry->periodicity = periodicity;
18261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018262 pTempStaEntry->numClient++;
18263 found = TRUE;
18264 }
18265 else
18266 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018267 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018268 staEntry.numClient = 1;
18269 staEntry.periodicity = periodicity;
18270 staEntry.pMac = pMac;
18271 staEntry.rspPending = FALSE;
18272 staEntry.staId = staId;
18273 staEntry.statsMask = statsMask;
18274 staEntry.timerRunning = FALSE;
18275 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18276 if(!pTempStaEntry)
18277 {
18278 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018279 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018280 return NULL;
18281 }
18282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018283 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18284 if(ePMC_FULL_POWER == powerState)
18285 {
18286 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18287 {
18288 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18289 }
18290 }
18291 else
18292 {
18293 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18294 {
18295 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18296 }
18297 }
18298 if(!pTempStaEntry->timerRunning)
18299 {
18300 //send down a req in case of one time req, for periodic ones wait for timer to expire
18301 if(!pTempStaEntry->rspPending &&
18302 !pTempStaEntry->periodicity)
18303 {
18304 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18305 if(!HAL_STATUS_SUCCESS(status))
18306 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018307 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018308 }
18309 else
18310 {
18311 pTempStaEntry->rspPending = TRUE;
18312 }
18313 }
18314 if(pTempStaEntry->periodicity)
18315 {
18316 if(!found)
18317 {
18318
18319 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18320 csrRoamPeStatsTimerHandler, pTempStaEntry );
18321 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18322 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018323 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018324 return NULL;
18325 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018326 }
18327 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018328 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018329 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18330 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018332 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018333 return NULL;
18334 }
18335 pTempStaEntry->timerRunning = TRUE;
18336 }
18337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018338 *pFound = found;
18339 return pTempStaEntry;
18340}
18341
Jeff Johnson295189b2012-06-20 16:38:30 -070018342/*
18343 pStaEntry is no longer invalid upon the return of this function.
18344*/
18345static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18346{
18347 if(pEntry)
18348 {
18349 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18350 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018351 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018353 }
18354 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018355
18356void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18357{
18358 tListElem *pEntry;
18359 tCsrPeStatsReqInfo *pTempStaEntry;
18360 VOS_STATUS vosStatus;
18361 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018362 if(!pEntry)
18363 {
18364 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018365 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018366 return;
18367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018368 while( pEntry )
18369 {
18370 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018371 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18372 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018373 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018374 if(pTempStaEntry->timerRunning)
18375 {
18376 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18377 /* If we are not able to stop the timer here, just remove
18378 * the entry from the linked list. Destroy the timer object
18379 * and free the memory in the timer CB
18380 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018381 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018382 {
18383 /* the timer is successfully stopped */
18384 pTempStaEntry->timerRunning = FALSE;
18385
18386 /* Destroy the timer */
18387 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18388 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018390 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018391 }
18392 }
18393 else
18394 {
18395 // the timer could not be stopped. Hence destroy and free the
18396 // memory for the PE stat entry in the timer CB.
18397 pTempStaEntry->timerStopFailed = TRUE;
18398 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018400
18401 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18402 {
18403 // Only free the memory if we could stop the timer successfully
18404 if(!pTempStaEntry->timerStopFailed)
18405 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018406 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018407 pTempStaEntry = NULL;
18408 }
18409 break;
18410 }
18411
18412 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18413 }
18414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018415 return;
18416}
18417
18418
Jeff Johnsone7245742012-09-05 17:12:55 -070018419void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018420{
18421
Jeff Johnsone7245742012-09-05 17:12:55 -070018422 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18423 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18424 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18425 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18426 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18427 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18428 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018429 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018430 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18431 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18432 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18433 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18434 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18435 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018436 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018437 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18438 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018439
18440}
18441
Jeff Johnson295189b2012-06-20 16:38:30 -070018442void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18443 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18444{
18445 tANI_U8 stats[500];
18446 tANI_U8 *pStats = NULL;
18447 tANI_U32 tempMask = 0;
18448 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018449 if(!callback)
18450 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018451 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018452 return;
18453 }
18454 if(!statsMask)
18455 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018456 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018457 return;
18458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018459 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018460 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018461 while(tempMask)
18462 {
18463 if(tempMask & 1)
18464 {
18465 //new stats info from PE, fill up the stats strucutres in PMAC
18466 switch(counter)
18467 {
18468 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018469 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018470 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18471 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018472 pStats += sizeof(tCsrSummaryStatsInfo);
18473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018474 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018475 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018476 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18477 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018478 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018479 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018480 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018481 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018482 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18483 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018484 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018485 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018486 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018487 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018488 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18489 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018490 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018491 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018492 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018493 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018494 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18495 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018496 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018497 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018498 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018499 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018500 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18501 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018502 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018503 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018504 case eCsrPerPktStats:
18505 smsLog( pMac, LOG2, FL("PerPkt stats"));
18506 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18507 sizeof(tPerTxPacketFrmFw));
18508 pStats += sizeof(tPerTxPacketFrmFw);
18509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018510 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018511 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018513 }
18514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018515 tempMask >>=1;
18516 counter++;
18517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018518 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018519}
18520
Jeff Johnson295189b2012-06-20 16:38:30 -070018521eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18522{
18523 tListElem *pEntry = NULL;
18524 tListElem *pPrevEntry = NULL;
18525 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18526 eHalStatus status = eHAL_STATUS_SUCCESS;
18527 VOS_STATUS vosStatus;
18528 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018529 if(!pEntry)
18530 {
18531 //list empty
18532 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018533 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018534 return status;
18535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018536 while( pEntry )
18537 {
18538 if(pPrevEntry)
18539 {
18540 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18541 //send up the stats report
18542 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18543 pTempStaEntry->staId, pTempStaEntry->pContext);
18544 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018546 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018547 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18548 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018549 pTempStaEntry->pPeStaEntry->numClient--;
18550 //check if we need to delete the entry from peStatsReqList too
18551 if(!pTempStaEntry->pPeStaEntry->numClient)
18552 {
18553 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18554 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018556 //check if we need to stop the tl stats timer too
18557 pMac->roam.tlStatsReqInfo.numClient--;
18558 if(!pMac->roam.tlStatsReqInfo.numClient)
18559 {
18560 if(pMac->roam.tlStatsReqInfo.timerRunning)
18561 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018562 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18563 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018565 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018566 //we will continue
18567 }
18568 }
18569 pMac->roam.tlStatsReqInfo.periodicity = 0;
18570 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018572 if (pTempStaEntry->periodicity)
18573 {
18574 //While creating StaEntry in csrGetStatistics,
18575 //Initializing and starting timer only when periodicity is set.
18576 //So Stop and Destroy timer only when periodicity is set.
18577
Jeff Johnsone7245742012-09-05 17:12:55 -070018578 vos_timer_stop( &pTempStaEntry->timer );
18579 // Destroy the vos timer...
18580 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18581 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018583 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018585 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018586
Jeff Johnson295189b2012-06-20 16:38:30 -070018587
18588 pPrevEntry = pEntry;
18589 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18590 }
18591 //the last one
18592 if(pPrevEntry)
18593 {
18594 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18595 //send up the stats report
18596 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18597 pTempStaEntry->staId, pTempStaEntry->pContext);
18598 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018600 return status;
18601
18602}
18603
Jeff Johnson295189b2012-06-20 16:38:30 -070018604eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18605 tRequestFullPowerReason *pReason,
18606 tANI_BOOLEAN *pfNeedPower )
18607{
18608 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18609 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18610 tPmcState pmcState;
18611 eHalStatus status = eHAL_STATUS_SUCCESS;
18612 // TODO : Session info unavailable
18613 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018614 if( pfNeedPower )
18615 {
18616 *pfNeedPower = eANI_BOOLEAN_FALSE;
18617 }
18618 //We only handle CSR commands
18619 if( !(eSmeCsrCommandMask & pCommand->command) )
18620 {
18621 return eHAL_STATUS_SUCCESS;
18622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018623 //Check PMC state first
18624 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018625 switch( pmcState )
18626 {
18627 case REQUEST_IMPS:
18628 case IMPS:
18629 if( eSmeCommandScan == pCommand->command )
18630 {
18631 switch( pCommand->u.scanCmd.reason )
18632 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018633#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18634 case eCsrScanGetLfrResult:
18635#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018636 case eCsrScanGetResult:
18637 case eCsrScanBGScanAbort:
18638 case eCsrScanBGScanEnable:
18639 case eCsrScanGetScanChnInfo:
18640 //Internal process, no need for full power
18641 fNeedFullPower = eANI_BOOLEAN_FALSE;
18642 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018643 default:
18644 //Other scans are real scan, ask for power
18645 fNeedFullPower = eANI_BOOLEAN_TRUE;
18646 break;
18647 } //switch
18648 }
18649 else
18650 {
18651 //ask for power for roam and status change
18652 fNeedFullPower = eANI_BOOLEAN_TRUE;
18653 }
18654 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018655 case REQUEST_BMPS:
18656 case BMPS:
18657 case REQUEST_START_UAPSD:
18658 case UAPSD:
18659 //We treat WOWL same as BMPS
18660 case REQUEST_ENTER_WOWL:
18661 case WOWL:
18662 if( eSmeCommandRoam == pCommand->command )
18663 {
18664 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18665 tCsrScanResult *pScanResult;
18666 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018667 switch ( pCommand->u.roamCmd.roamReason )
18668 {
18669 case eCsrForcedDisassoc:
18670 case eCsrForcedDisassocMICFailure:
18671 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18672 fNeedFullPower = eANI_BOOLEAN_TRUE;
18673 break;
18674 case eCsrSmeIssuedDisassocForHandoff:
18675 case eCsrForcedDeauth:
18676 case eCsrHddIssuedReassocToSameAP:
18677 case eCsrSmeIssuedReassocToSameAP:
18678 fNeedFullPower = eANI_BOOLEAN_TRUE;
18679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018680 case eCsrCapsChange:
18681 fNeedFullPower = eANI_BOOLEAN_TRUE;
18682 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018683 case eCsrForcedDisassocSta:
18684 case eCsrForcedDeauthSta:
18685 fNeedFullPower = eANI_BOOLEAN_FALSE;
18686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018687 default:
18688 //Check whether the profile is already connected. If so, no need for full power
18689 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18690 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18691 {
18692 //Only need to check the first one
18693 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18694 if( pEntry )
18695 {
18696 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18697#if 0
18698 // TODO : Session Specific info pConnectBssDesc
18699 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18700 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18701 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18702 {
18703 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18704 // with Authenticating first. To force this, stop the current association (Disassociate) and
18705 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18706 // a new Association.
18707 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18708 {
18709 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18710 {
18711 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18712 //No need for full power
18713 //Set the flag so the code later can avoid to do the above
18714 //check again.
18715 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18716 break;
18717 }
18718 }
18719 }
18720#endif
18721 }
18722 }
18723 //If we are here, full power is needed
18724 fNeedFullPower = eANI_BOOLEAN_TRUE;
18725 break;
18726 }
18727 }
18728 else if( eSmeCommandWmStatusChange == pCommand->command )
18729 {
18730 //need full power for all
18731 fNeedFullPower = eANI_BOOLEAN_TRUE;
18732 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18733 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018734#ifdef FEATURE_WLAN_TDLS
18735 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18736 {
18737 //TDLS link is getting established. need full power
18738 fNeedFullPower = eANI_BOOLEAN_TRUE;
18739 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18740 }
18741#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018742 else if (eSmeCommandDelStaSession == pCommand->command)
18743 {
18744 //need full power for all
18745 fNeedFullPower = eANI_BOOLEAN_TRUE;
18746 }
18747
Jeff Johnson295189b2012-06-20 16:38:30 -070018748 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018749 case REQUEST_STOP_UAPSD:
18750 case REQUEST_EXIT_WOWL:
18751 if( eSmeCommandRoam == pCommand->command )
18752 {
18753 fNeedFullPower = eANI_BOOLEAN_TRUE;
18754 switch ( pCommand->u.roamCmd.roamReason )
18755 {
18756 case eCsrForcedDisassoc:
18757 case eCsrForcedDisassocMICFailure:
18758 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18759 break;
18760 default:
18761 break;
18762 }
18763 }
18764 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018765 case STOPPED:
18766 case REQUEST_STANDBY:
18767 case STANDBY:
18768 case LOW_POWER:
18769 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018770 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18771 " stopped/standby state %s (%d)" ),
18772 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018773 status = eHAL_STATUS_FAILURE;
18774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018775 case FULL_POWER:
18776 case REQUEST_FULL_POWER:
18777 default:
18778 //No need to ask for full power. This has to be FULL_POWER state
18779 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018780 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018781 if( pReason )
18782 {
18783 *pReason = reason;
18784 }
18785 if( pfNeedPower )
18786 {
18787 *pfNeedPower = fNeedFullPower;
18788 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018789 return ( status );
18790}
18791
Jeff Johnson295189b2012-06-20 16:38:30 -070018792static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18793{
18794 eHalStatus status = eHAL_STATUS_SUCCESS;
18795 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18796 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018797 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018798 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18799 {
18800 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018802 return ( status );
18803}
18804
Jeff Johnson295189b2012-06-20 16:38:30 -070018805tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18806{
18807 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018808 if( pCmd )
18809 {
18810 pMac->roam.sPendingCommands++;
18811 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018812 return ( pCmd );
18813}
18814
Jeff Johnson295189b2012-06-20 16:38:30 -070018815void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18816{
18817 if (pMac->roam.sPendingCommands > 0)
18818 {
18819 //All command allocated through csrGetCommandBuffer need to
18820 //decrement the pending count when releasing.
18821 pMac->roam.sPendingCommands--;
18822 smeReleaseCommand( pMac, pCommand );
18823 }
18824 else
18825 {
18826 smsLog(pMac, LOGE, FL( "no pending commands"));
18827 VOS_ASSERT(0);
18828 }
18829}
18830
Jeff Johnson295189b2012-06-20 16:38:30 -070018831//Return SUCCESS is the command is queued, failed
18832eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
18833{
18834 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053018835
18836 if (!SME_IS_START(pMac))
18837 {
18838 smsLog( pMac, LOGE, FL("Sme in stop state"));
18839 return eHAL_STATUS_FAILURE;
18840 }
18841
Jeff Johnson295189b2012-06-20 16:38:30 -070018842 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
18843 {
18844 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
18845 pCommand->u.scanCmd.reason);
18846 return eHAL_STATUS_CSR_WRONG_STATE;
18847 }
18848
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018849 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
18850 {
18851 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
18852 &pCommand->Link, LL_ACCESS_LOCK);
18853 // process the command queue...
18854 smeProcessPendingQueue(pMac);
18855 status = eHAL_STATUS_SUCCESS;
18856 goto end;
18857 }
18858
Jeff Johnson295189b2012-06-20 16:38:30 -070018859 //We can call request full power first before putting the command into pending Q
18860 //because we are holding SME lock at this point.
18861 status = csrRequestFullPower( pMac, pCommand );
18862 if( HAL_STATUS_SUCCESS( status ) )
18863 {
18864 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070018865 //make sure roamCmdPendingList is not empty first
18866 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
18867 if( fNoCmdPending )
18868 {
18869 smePushCommand( pMac, pCommand, fHighPriority );
18870 }
18871 else
18872 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018873 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070018874 //no list lock is needed since SME lock is held
18875 if( !fHighPriority )
18876 {
18877 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18878 }
18879 else {
18880 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18881 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018882 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018883 }
18884 else if( eHAL_STATUS_PMC_PENDING == status )
18885 {
18886 //no list lock is needed since SME lock is held
18887 if( !fHighPriority )
18888 {
18889 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18890 }
18891 else {
18892 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18893 }
18894 //Let caller know the command is queue
18895 status = eHAL_STATUS_SUCCESS;
18896 }
18897 else
18898 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018899 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070018900 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018901 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070018902 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018903end:
Jeff Johnson295189b2012-06-20 16:38:30 -070018904 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070018905}
Jeff Johnson295189b2012-06-20 16:38:30 -070018906eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
18907{
18908 eHalStatus status = eHAL_STATUS_SUCCESS;
18909 tSirUpdateAPWPSIEsReq *pMsg;
18910 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
18911
18912 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18913 if (NULL == pSession)
18914 {
18915 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18916 return eHAL_STATUS_FAILURE;
18917 }
18918
Jeff Johnson295189b2012-06-20 16:38:30 -070018919 do
18920 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018921 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
18922 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18923 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018924 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
18925
18926 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070018927 VOS_ASSERT(pBuf);
18928
Jeff Johnson295189b2012-06-20 16:38:30 -070018929 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018930 // transactionId
18931 *pBuf = 0;
18932 *( pBuf + 1 ) = 0;
18933 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070018934 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018935 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18936 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070018937 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018938 //sessionId
18939 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018940 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018941 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070018942 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070018943 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018944 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018945 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018946 return ( status );
18947}
Jeff Johnson295189b2012-06-20 16:38:30 -070018948eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
18949{
18950 eHalStatus status = eHAL_STATUS_SUCCESS;
18951 tSirUpdateAPWPARSNIEsReq *pMsg;
18952 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018953 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18954 if (NULL == pSession)
18955 {
18956 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18957 return eHAL_STATUS_FAILURE;
18958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018959 do
18960 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018961 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
18962 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18963 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018964 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070018965 pBuf = (tANI_U8 *)&pMsg->transactionId;
18966 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018967 // transactionId
18968 *pBuf = 0;
18969 *( pBuf + 1 ) = 0;
18970 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070018971 VOS_ASSERT(pBuf);
18972
Jeff Johnson295189b2012-06-20 16:38:30 -070018973 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018974 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18975 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070018976 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018977 // sessionId
18978 *pBuf++ = (tANI_U8)sessionId;
18979
18980 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018981 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070018982 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070018983 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018984 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018985 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018986 return ( status );
18987}
Jeff Johnson295189b2012-06-20 16:38:30 -070018988
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053018989tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
18990 tpSirBssDescription pBssDescription)
18991{
18992 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
18993 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18994 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
18995 eHalStatus status;
18996 tDot11fBeaconIEs *ies_local = NULL;
18997 tANI_U32 dot11mode = 0;
18998
18999 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19000
19001 /* Get IE's */
19002 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19003 if (!HAL_STATUS_SUCCESS(status)) {
19004 smsLog(pMac, LOGE,
19005 FL("csrGetParsedBssDescriptionIEs failed"));
19006 return 0;
19007 }
19008 if(ies_local == NULL) {
19009 smsLog(pMac, LOGE,
19010 FL("ies_local is NULL"));
19011 return 0;
19012 }
19013
19014 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19015 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19016 uCfgDot11Mode = cfgDot11Mode;
19017 else
19018 {
19019 smsLog(pMac, LOGE, "Can not find match phy mode");
19020 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19021 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19022 else
19023 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19024 }
19025
19026 /* dot11mode */
19027 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19028 smsLog(pMac, LOG1,
19029 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19030
19031 if (pBssDescription->channelId <= 14 &&
19032 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19033 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19034 {
19035 /* Need to disable VHT operation in 2.4 GHz band */
19036 dot11mode = WNI_CFG_DOT11_MODE_11N;
19037 }
19038 vos_mem_free(ies_local);
19039 return dot11mode;
19040}
19041
Jeff Johnson295189b2012-06-20 16:38:30 -070019042#ifdef WLAN_FEATURE_VOWIFI_11R
19043//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19044eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19045{
19046 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19047 tpSirFTPreAuthReq pftPreAuthReq;
19048 tANI_U16 auth_req_len = 0;
19049 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019050 auth_req_len = sizeof(tSirFTPreAuthReq);
19051 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019052 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019053 {
19054 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19055 return eHAL_STATUS_RESOURCES;
19056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019057 // Save the SME Session ID here. We need it while processing the preauth response
19058 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019059 vos_mem_zero(pftPreAuthReq, auth_req_len);
19060
19061 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19062 sizeof(pBssDescription->length) + pBssDescription->length);
19063
19064 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19065
19066 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019067 pftPreAuthReq->dot11mode =
19068 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19069 if (!pftPreAuthReq->dot11mode)
19070 {
19071 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19072 vos_mem_free(pftPreAuthReq);
19073 return eHAL_STATUS_FAILURE;
19074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019075
Kiet Lam64c1b492013-07-12 13:56:44 +053019076 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19077 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19078 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19079 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019080
Jeff Johnson295189b2012-06-20 16:38:30 -070019081#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019082 if (csrRoamIs11rAssoc(pMac) &&
19083 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019084 {
19085 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019086 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19087 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019088 }
19089 else
19090#endif
19091 {
19092 pftPreAuthReq->ft_ies_length = 0;
19093 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019094 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19095 sizeof(pBssDescription->length) + pBssDescription->length);
19096 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019097 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19098}
Jeff Johnson295189b2012-06-20 16:38:30 -070019099/*--------------------------------------------------------------------------
19100 * This will receive and process the FT Pre Auth Rsp from the current
19101 * associated ap.
19102 *
19103 * This will invoke the hdd call back. This is so that hdd can now
19104 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19105 ------------------------------------------------------------------------*/
19106void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19107{
19108 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19109 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019110#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019111 tCsrRoamInfo roamInfo;
19112#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019113 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019114
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019115#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019116 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019117 if (status != eHAL_STATUS_SUCCESS) {
19118 /*
19119 * Bail out if pre-auth was not even processed.
19120 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019121 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19122 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019123 return;
19124 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019125#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019126 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19127 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19128 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019129 // Implies a success
19130 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019131 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19132 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019133 /* No need to notify qos module if this is a non 11r & ESE roam*/
19134 if (csrRoamIs11rAssoc(pMac)
19135#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19136 || csrRoamIsESEAssoc(pMac)
19137#endif
19138 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019139 {
19140 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19141 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019142 if (pMac->roam.configParam.roamDelayStatsEnabled)
19143 {
19144 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019146 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19147 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019148 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19149 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019150 if (pMac->roam.configParam.roamDelayStatsEnabled)
19151 {
19152 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019154 if (eHAL_STATUS_SUCCESS != status)
19155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019156 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019157 return;
19158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019159 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019160 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19161 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019162 if (csrRoamIs11rAssoc(pMac))
19163 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19164 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19165
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019166#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19167 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019168 {
19169 /* read TSF */
19170 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19171
19172 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019173 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019174 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19175 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019176#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019177#ifdef FEATURE_WLAN_LFR
19178 // If Legacy Fast Roaming is enabled, signal the supplicant
19179 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019180 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019181 {
19182 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019183 vos_mem_copy((void *)&roamInfo.bssid,
19184 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019185 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19186 }
19187
19188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019189
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019190 // If its an Open Auth, FT IEs are not provided by supplicant
19191 // Hence populate them here
19192 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19193 pMac->ft.ftSmeContext.addMDIE = FALSE;
19194 if( csrRoamIs11rAssoc(pMac) &&
19195 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19196 {
19197 tANI_U16 ft_ies_length;
19198 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19199
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019200 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19201 connectedProfile.MDID.mdiePresent)
19202 pMac->ft.ftSmeContext.addMDIE = TRUE;
19203
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019204 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19205 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19206 {
19207 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19208 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19209 }
19210
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019211 if (!ft_ies_length)
19212 {
19213 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19214 return;
19215 }
19216
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019217 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19218 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19219 {
19220 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19221 }
19222 else
19223 {
19224 // Copy the RIC IEs to reassoc IEs
19225 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19226 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19227 pFTPreAuthRsp->ric_ies_length);
19228 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19229 pMac->ft.ftSmeContext.addMDIE = TRUE;
19230 }
19231 }
19232
Jeff Johnson295189b2012-06-20 16:38:30 -070019233 // Done with it, init it.
19234 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19235}
19236#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019237
Jeff Johnson295189b2012-06-20 16:38:30 -070019238#ifdef FEATURE_WLAN_BTAMP_UT_RF
19239void csrRoamJoinRetryTimerHandler(void *pv)
19240{
19241 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19242 tpAniSirGlobal pMac = pInfo->pMac;
19243 tANI_U32 sessionId = pInfo->sessionId;
19244 tCsrRoamSession *pSession;
19245
19246 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19247 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019248 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019249 pSession = CSR_GET_SESSION( pMac, sessionId );
19250 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19251 {
19252 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019254 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019255 }
19256 }
19257 }
19258}
Jeff Johnson295189b2012-06-20 16:38:30 -070019259eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19260{
19261 eHalStatus status = eHAL_STATUS_FAILURE;
19262 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19263
19264 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019266 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019267 pSession->maxRetryCount--;
19268 pSession->joinRetryTimerInfo.pMac = pMac;
19269 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019270 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19271 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019273 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019274 }
19275 }
19276 else
19277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019278 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019279 pSession->maxRetryCount);
19280 }
19281
19282 return (status);
19283}
Jeff Johnson295189b2012-06-20 16:38:30 -070019284eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19285{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019286 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019287 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19288 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019289 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019290 }
19291
19292 return eHAL_STATUS_SUCCESS;
19293}
19294#endif
19295
19296
19297/*
19298 pBuf points to the beginning of the message
19299 LIM packs disassoc rsp as below,
19300 messageType - 2 bytes
19301 messageLength - 2 bytes
19302 sessionId - 1 byte
19303 transactionId - 2 bytes (tANI_U16)
19304 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19305 peerMacAddr - 6 bytes
19306 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19307*/
19308static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19309{
19310 if(pBuf && pRsp)
19311 {
19312 pBuf += 4; //skip type and length
19313 pRsp->sessionId = *pBuf++;
19314 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19315 pBuf += 2;
19316 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19317 pBuf += 4;
19318 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19319 }
19320}
19321
Jeff Johnsond13512a2012-07-17 11:42:19 -070019322eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19323{
19324 static uNvTables nvTables;
19325 eHalStatus status = eHAL_STATUS_SUCCESS;
19326 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19327
19328 /* read the country code from NV and use it */
19329 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19330 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019331 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19332 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019333 return status;
19334 }
19335 else
19336 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019337 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019338 status = eHAL_STATUS_FAILURE;
19339 return status;
19340 }
19341}
19342
19343eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19344{
Kiet Lam64c1b492013-07-12 13:56:44 +053019345 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019346 return eHAL_STATUS_SUCCESS;
19347}
schang86c22c42013-03-13 18:41:24 -070019348
19349eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19350{
19351 tSirSetTxPowerReq *pMsg = NULL;
19352 eHalStatus status = eHAL_STATUS_SUCCESS;
19353 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19354
19355 if (!pSession)
19356 {
19357 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19358 return eHAL_STATUS_FAILURE;
19359 }
19360
Kiet Lam64c1b492013-07-12 13:56:44 +053019361 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19362 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19363 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19364 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19365 pMsg->length = sizeof(tSirSetTxPowerReq);
19366 pMsg->mwPower = mW;
19367 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19368 sizeof(tSirMacAddr));
19369 status = palSendMBMessage(pMac->hHdd, pMsg);
19370 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019371 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019372 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19373 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019374 }
19375 return status;
19376}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019377
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019378eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19379{
19380 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19381 eHalStatus status = eHAL_STATUS_SUCCESS;
19382 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19383
19384 if (!pSession)
19385 {
19386 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19387 return eHAL_STATUS_FAILURE;
19388 }
19389 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19390 {
19391 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019392
19393 if( NULL == pMsg )
19394 {
19395 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19396 return eHAL_STATUS_FAILURE;
19397 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019398 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19399 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019400 pMsg->length =
19401 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019402 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019403 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19404 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019405 status = palSendMBMessage(pMac->hHdd, pMsg);
19406 if (!HAL_STATUS_SUCCESS(status))
19407 {
19408 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19409 //pMsg is freed by palSendMBMessage
19410 }
19411 }
19412 else
19413 {
19414 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19415 status = eHAL_STATUS_FAILURE;
19416 }
19417 return status;
19418}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019419/* Returns whether a session is in VOS_STA_MODE...or not */
19420tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19421{
19422 tCsrRoamSession *pSession = NULL;
19423 pSession = CSR_GET_SESSION ( pMac, sessionId );
19424 if(!pSession)
19425 {
19426 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19427 return eANI_BOOLEAN_FALSE;
19428 }
19429 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19430 {
19431 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19432 return eANI_BOOLEAN_FALSE;
19433 }
19434 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19435 {
19436 return eANI_BOOLEAN_FALSE;
19437 }
19438 /* There is a possibility that the above check may fail,because
19439 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19440 * when it is connected.So,we may sneak through the above check even
19441 * if we are not a STA mode INFRA station. So, if we sneak through
19442 * the above condition, we can use the following check if we are
19443 * really in STA Mode.*/
19444
19445 if ( NULL != pSession->pCurRoamProfile )
19446 {
19447 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19448 {
19449 return eANI_BOOLEAN_TRUE;
19450 } else {
19451 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19452 return eANI_BOOLEAN_FALSE;
19453 }
19454 }
19455
19456 return eANI_BOOLEAN_FALSE;
19457}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019458
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019459/**
19460 * csr_set_src_handoff_request() - Set handoff source to
19461 * SME handoff request
19462 * @pHandoffInfo: Pointer to Handoff info
19463 * @pMsg: Pointer to SME handoff request message
19464 *
19465 * Return: None
19466 */
19467#ifndef QCA_WIFI_ISOC
19468static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19469 tCsrHandoffRequest *pHandoffInfo)
19470{
19471 pMsg->handoff_src = pHandoffInfo->src;
19472}
19473#else
19474static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19475 tCsrHandoffRequest *pHandoffInfo)
19476{
19477}
19478#endif
19479
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019480#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19481eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19482 tCsrHandoffRequest *pHandoffInfo)
19483{
19484 eHalStatus status = eHAL_STATUS_SUCCESS;
19485 vos_msg_t msg;
19486
19487 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019488 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19489 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019490 {
19491 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019492 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019493 }
19494 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19495 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19496 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19497 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019498 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019499 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019500 pHandoffInfo->bssid,
19501 6);
19502 msg.type = eWNI_SME_HANDOFF_REQ;
19503 msg.bodyptr = pMsg;
19504 msg.reserved = 0;
19505 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19506 {
19507 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019508 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019509 status = eHAL_STATUS_FAILURE;
19510 }
19511 return status;
19512}
19513#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019514
Abhishek Singh00b71972016-01-07 10:51:04 +053019515#ifdef WLAN_FEATURE_RMC
19516eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19517{
19518 tSirSetRMCReq *pMsg = NULL;
19519 eHalStatus status = eHAL_STATUS_SUCCESS;
19520 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19521
19522 if (!pSession)
19523 {
19524 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19525 return eHAL_STATUS_FAILURE;
19526 }
19527
19528 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19529 if (NULL != pMsg)
19530 {
19531 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19532 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19533 pMsg->msgLen = sizeof(tSirSetRMCReq);
19534 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19535 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19536
19537 status = palSendMBMessage(pMac->hHdd, pMsg);
19538 if (!HAL_STATUS_SUCCESS(status))
19539 {
19540 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19541 //pMsg is freed by palSendMBMessage
19542 }
19543 }
19544 else
19545 {
19546 return eHAL_STATUS_FAILURE;
19547 }
19548 return status;
19549}
19550
19551eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19552{
19553 tSirSetRMCReq *pMsg = NULL;
19554 eHalStatus status = eHAL_STATUS_SUCCESS;
19555 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19556
19557 if (!pSession)
19558 {
19559 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19560 return eHAL_STATUS_FAILURE;
19561 }
19562
19563 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19564 if (NULL != pMsg)
19565 {
19566 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19567 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19568 pMsg->msgLen = sizeof(tSirSetRMCReq);
19569 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19570 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19571
19572 status = palSendMBMessage(pMac->hHdd, pMsg);
19573 if (!HAL_STATUS_SUCCESS(status))
19574 {
19575 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19576 //pMsg is freed by palSendMBMessage
19577 }
19578 }
19579 else
19580 {
19581 return eHAL_STATUS_FAILURE;
19582 }
19583 return status;
19584}
19585
19586#endif /* WLAN_FEATURE_RMC */
19587
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019588
19589#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019590/* ---------------------------------------------------------------------------
19591 \fn csrSetCCKMIe
19592 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19593 data structure and this IE will be packed inside reassociation request
19594 \param pMac - pMac global structure
19595 \param sessionId - Current session id
19596 \param pCckmIe - pointer to CCKM IE data
19597 \param ccKmIeLen - length of the CCKM IE
19598 \- return Success or failure
19599 -------------------------------------------------------------------------*/
19600VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19601 const tANI_U8 *pCckmIe,
19602 const tANI_U8 ccKmIeLen)
19603{
19604 eHalStatus status = eHAL_STATUS_SUCCESS;
19605 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19606
19607 if (!pSession)
19608 {
19609 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19610 return eHAL_STATUS_FAILURE;
19611 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019612 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019613 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19614 return status;
19615}
19616
19617/* ---------------------------------------------------------------------------
19618 \fn csrRoamReadTSF
19619 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19620 probe response reception from the hand off AP to arrive at the latest TSF value.
19621 \param pMac - pMac global structure
19622 \param pTimestamp - output TSF timestamp
19623 \- return Success or failure
19624 -------------------------------------------------------------------------*/
19625VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19626{
19627 eHalStatus status = eHAL_STATUS_SUCCESS;
19628 tCsrNeighborRoamBSSInfo handoffNode;
19629 tANI_U32 timer_diff = 0;
19630 tANI_U32 timeStamp[2];
19631 tpSirBssDescription pBssDescription = NULL;
19632
19633 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19634 pBssDescription = handoffNode.pBssDescription;
19635
19636 // Get the time diff in milli seconds
19637 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19638 // Convert msec to micro sec timer
19639 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19640
19641 timeStamp[0] = pBssDescription->timeStamp[0];
19642 timeStamp[1] = pBssDescription->timeStamp[1];
19643
19644 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19645
Kiet Lamf2f201e2013-11-16 21:24:16 +053019646 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019647 sizeof (tANI_U32) * 2);
19648 return status;
19649}
19650
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019651#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019652
Agarwal Ashish738843c2014-09-25 12:27:56 +053019653/* ---------------------------------------------------------------------------
19654 \fn csrDisableDfsChannel
19655 \brief This function will call csrApplyChannelPowerCountryInfo to
19656 \ to trim the list on basis of NO_DFS flag.
19657 \param pMac - pMac global structure
19658 \- return void
19659 -------------------------------------------------------------------------*/
19660void csrDisableDfsChannel(tpAniSirGlobal pMac)
19661{
19662 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19663 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19664}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019665
19666/* ---------------------------------------------------------------------------
19667 \fn csrGetStaticUapsdMask
19668 \brief This function will get the static uapsd settings for an existing
19669 \ Infra session.
19670 \param pMac - pMac global structure
19671 \- return void
19672 -------------------------------------------------------------------------*/
19673void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19674{
19675 tANI_S8 sessionId;
19676 tCsrRoamSession *pSession = NULL;
19677
19678 *staticUapsdMask = 0;
19679 sessionId = csrGetInfraSessionId(pMac);
19680 if(sessionId == -1)
19681 smsLog(pMac, LOGE, FL("Valid session not present."));
19682 else
19683 pSession = CSR_GET_SESSION(pMac, sessionId);
19684
19685 if(!pSession || !pSession->pCurRoamProfile)
19686 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019687 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019688 else
19689 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19690}
19691
Abhishek Singh02605092017-10-25 14:06:12 +053019692VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19693 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19694{
19695 VOS_STATUS status = VOS_STATUS_SUCCESS;
19696 struct sir_ecsa_ie_req *msg;
19697
19698 msg = vos_mem_malloc(sizeof(*msg));
19699 if (!msg) {
19700 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19701 return VOS_STATUS_E_NOMEM;
19702 }
19703
19704 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19705 msg->len = sizeof(*msg);
19706
19707 msg->new_chan = new_chan;
19708 msg->cb_mode = cb_mode;
19709 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19710
19711 status = palSendMBMessage(mac_ctx->hHdd, msg);
19712 if (!VOS_IS_STATUS_SUCCESS(status))
19713 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019714 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019715 return status;
19716}
19717
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019718VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19719 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19720{
19721 VOS_STATUS status = VOS_STATUS_SUCCESS;
19722 struct sir_channel_chanege_req *msg;
19723 tCsrRoamStartBssParams param;
19724
19725 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19726
19727 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19728
19729 msg = vos_mem_malloc(sizeof(*msg));
19730 if (!msg) {
19731 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19732 return VOS_STATUS_E_NOMEM;
19733 }
19734
19735 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19736 msg->len = sizeof(*msg);
19737
19738 msg->new_chan = new_chan;
19739 msg->cb_mode = cb_mode;
19740 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19741 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19742 mac_ctx->roam.configParam.uCfgDot11Mode);
19743 if (IS_24G_CH(msg->new_chan) &&
19744 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19745 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19746 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19747 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19748
19749 vos_mem_copy(&msg->operational_rateset,
19750 &param.operationalRateSet, sizeof(msg->operational_rateset));
19751 vos_mem_copy(&msg->extended_rateset,
19752 &param.extendedRateSet, sizeof(msg->extended_rateset));
19753
19754 status = palSendMBMessage(mac_ctx->hHdd, msg);
19755 if (!VOS_IS_STATUS_SUCCESS(status))
19756 smsLog(mac_ctx, LOGE,
19757 FL(" channel switch req fauiled status %d "), status);
19758 return status;
19759}