blob: a4edc0b35109c13e16e80f3265e585ebd7a88ce8 [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;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301290 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_FALSE;
1291 pMac->roam.configParam.num_ba_buff_btc_sco = DEFAULT_NUM_BUFF_BTC_SCO;
1292 pMac->roam.configParam.num_ba_buff = WNI_CFG_NUM_BUFF_ADVERT_STADEF;
Mohit Khanna349bc392012-09-11 17:24:52 -07001293
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001294 //Remove this code once SLM_Sessionization is supported
1295 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001296 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001297
Jeff Johnsone7245742012-09-05 17:12:55 -07001298}
Jeff Johnson295189b2012-06-20 16:38:30 -07001299eCsrBand csrGetCurrentBand(tHalHandle hHal)
1300{
1301 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1302 return pMac->roam.configParam.bandCapability;
1303}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001304
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001305
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001306#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001307/*
1308 This function flushes the roam scan cache
1309*/
1310eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1311{
1312 eHalStatus status = eHAL_STATUS_SUCCESS;
1313 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1314
1315 /* Free up the memory first (if required) */
1316 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1317 {
1318 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1319 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1320 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1321 }
1322 return status;
1323}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001324#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001325
1326
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001327#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001328/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001329 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001330*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001331eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001332{
1333 eHalStatus status = eHAL_STATUS_SUCCESS;
1334 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1335
1336 /* Free up the memory first (if required) */
1337 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1338 {
1339 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1340 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001341 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001342 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001343 return status;
1344}
1345
1346
1347
1348/*
1349 This function flushes the roam scan cache and creates fresh cache
1350 based on the input channel list
1351*/
1352eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1353 const tANI_U8 *pChannelList,
1354 const tANI_U8 numChannels)
1355{
1356 eHalStatus status = eHAL_STATUS_SUCCESS;
1357 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1358
Srinivas Girigowdade697412013-02-14 16:31:48 -08001359 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1360
1361 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1362 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1363
1364 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1365 {
1366 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1367 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1368 return eHAL_STATUS_RESOURCES;
1369 }
1370
1371 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301372 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1373 pChannelList,
1374 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001375 return status;
1376}
1377
1378/* This function modifies the bgscan channel list set via config ini or
1379 runtime, whenever the band changes.
1380 if the band is auto, then no operation is performed on the channel list
1381 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1382 if the band is 5G, then make sure channel list contains only 5G valid channels
1383*/
1384eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1385 eCsrBand eBand)
1386{
1387 eHalStatus status = eHAL_STATUS_SUCCESS;
1388 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1389 tANI_U8 outNumChannels = 0;
1390 tANI_U8 inNumChannels = 0;
1391 tANI_U8 *inPtr = NULL;
1392 tANI_U8 i = 0;
1393 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1394
1395 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1396
1397 {
1398 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1399 "No update required for channel list "
1400 "either cfg.ini channel list is not set up or "
1401 "auto band (Band %d)", eBand);
1402 return status;
1403 }
1404
1405 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1406 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1407 if (eCSR_BAND_24 == eBand)
1408 {
1409 for (i = 0; i < inNumChannels; i++)
1410 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001411 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001412 {
1413 ChannelList[outNumChannels++] = inPtr[i];
1414 }
1415 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001416 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001417 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001418 }
1419 else if (eCSR_BAND_5G == eBand)
1420 {
1421 for (i = 0; i < inNumChannels; i++)
1422 {
1423 /* Add 5G Non-DFS channel */
1424 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001425 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001426 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1427 {
1428 ChannelList[outNumChannels++] = inPtr[i];
1429 }
1430 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001431 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001432 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001433 }
1434 else if (eCSR_BAND_ALL == eBand)
1435 {
1436 for (i = 0; i < inNumChannels; i++)
1437 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001438 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001439 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1440 {
1441 ChannelList[outNumChannels++] = inPtr[i];
1442 }
1443 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001444 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001445 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001446 }
1447 else
1448 {
1449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1450 "Invalid band, No operation carried out (Band %d)", eBand);
1451 status = eHAL_STATUS_INVALID_PARAMETER;
1452 }
1453
1454 return status;
1455}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001456#endif
1457
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001458#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001459/* This function modifies the roam scan channel list as per AP neighbor
1460 report; AP neighbor report may be empty or may include only other AP
1461 channels; in any case, we merge the channel list with the learned occupied
1462 channels list.
1463 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1464 if the band is 5G, then make sure channel list contains only 5G valid channels
1465*/
1466eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1467 tANI_U8 *pChannelList,
1468 tANI_U8 numChannels,
1469 const eCsrBand eBand)
1470{
1471 eHalStatus status = eHAL_STATUS_SUCCESS;
1472 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1473 tANI_U8 outNumChannels = 0;
1474 tANI_U8 inNumChannels = numChannels;
1475 tANI_U8 *inPtr = pChannelList;
1476 tANI_U8 i = 0;
1477 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1478 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1479 tANI_U8 mergedOutputNumOfChannels = 0;
1480 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1481
1482 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1483 * report Channels. This increases the chances of the DUT to get a candidate AP while
1484 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1485 if (pMac->scan.occupiedChannels.numChannels)
1486 {
1487 csrNeighborRoamMergeChannelLists(pMac,
1488 &pMac->scan.occupiedChannels.channelList[0],
1489 pMac->scan.occupiedChannels.numChannels,
1490 inPtr,
1491 inNumChannels,
1492 &mergedOutputNumOfChannels);
1493 inNumChannels = mergedOutputNumOfChannels;
1494 }
1495
1496 if (eCSR_BAND_24 == eBand)
1497 {
1498 for (i = 0; i < inNumChannels; i++)
1499 {
1500 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1501 {
1502 ChannelList[outNumChannels++] = inPtr[i];
1503 }
1504 }
1505 }
1506 else if (eCSR_BAND_5G == eBand)
1507 {
1508 for (i = 0; i < inNumChannels; i++)
1509 {
1510 /* Add 5G Non-DFS channel */
1511 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1512 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1513 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1514 {
1515 ChannelList[outNumChannels++] = inPtr[i];
1516 }
1517 }
1518 }
1519 else if (eCSR_BAND_ALL == eBand)
1520 {
1521 for (i = 0; i < inNumChannels; i++)
1522 {
1523 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1524 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1525 {
1526 ChannelList[outNumChannels++] = inPtr[i];
1527 }
1528 }
1529 }
1530 else
1531 {
1532 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1533 "Invalid band, No operation carried out (Band %d)", eBand);
1534 return eHAL_STATUS_INVALID_PARAMETER;
1535 }
1536
1537 /* if roaming within band is enabled, then select only the
1538 in band channels .
1539 This is required only if the band capability is set to ALL,
1540 E.g., if band capability is only 2.4G then all the channels in the
1541 list are already filtered for 2.4G channels, hence ignore this check*/
1542
1543 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1544 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301545 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001546 pMac,
1547 ChannelList,
1548 outNumChannels,
1549 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301550 &outNumChannels,
1551 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301552 vos_mem_copy(ChannelList,
1553 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001554 }
1555
1556 /* Prepare final roam scan channel list */
1557 if(outNumChannels)
1558 {
1559 /* Clear the channel list first */
1560 if (NULL != currChannelListInfo->ChannelList)
1561 {
1562 vos_mem_free(currChannelListInfo->ChannelList);
1563 currChannelListInfo->ChannelList = NULL;
1564 currChannelListInfo->numOfChannels = 0;
1565 }
1566
1567 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1568 if (NULL == currChannelListInfo->ChannelList)
1569 {
1570 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1571 "Failed to allocate memory for roam scan channel list");
1572 currChannelListInfo->numOfChannels = 0;
1573 return VOS_STATUS_E_RESOURCES;
1574 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301575 vos_mem_copy(currChannelListInfo->ChannelList,
1576 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001577 }
1578 return status;
1579}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001580#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001581
Jeff Johnson295189b2012-06-20 16:38:30 -07001582eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1583{
1584 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1585 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1587 (eBand == eCSR_BAND_24))
1588 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001589 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001591 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001592 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 pMac->roam.configParam.uCfgDot11Mode, eBand);
1594 return eHAL_STATUS_INVALID_PARAMETER;
1595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1597 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1598 (eBand == eCSR_BAND_5G))
1599 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001600 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001602 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001603 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 pMac->roam.configParam.uCfgDot11Mode, eBand);
1605 return eHAL_STATUS_INVALID_PARAMETER;
1606 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001607 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001608 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001609 pMac->roam.configParam.eBand = eBand;
1610 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001612#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001613 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1614 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 status = csrInitGetChannels( pMac );
1617 if (eHAL_STATUS_SUCCESS == status)
1618 csrInitChannelList( hHal );
1619 return status;
1620}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001621
1622
Jeff Johnsone7245742012-09-05 17:12:55 -07001623/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1624 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1625 * Ideally we should have kept the ini value and enum value same and representing the same
1626 * cb values as in 11n standard i.e.
1627 * Set to 1 (SCA) if the secondary channel is above the primary channel
1628 * Set to 3 (SCB) if the secondary channel is below the primary channel
1629 * Set to 0 (SCN) if no secondary channel is present
1630 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1631 * 0 - secondary none
1632 * 1 - secondary LOW
1633 * 2 - secondary HIGH
1634 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1635 * The enum values are as follows:
1636 * PHY_SINGLE_CHANNEL_CENTERED = 0
1637 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1638 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1639 */
1640ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1641{
1642
1643 ePhyChanBondState phyCbState;
1644 switch (cbIniValue) {
1645 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301646 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1648 break;
1649 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301650 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001651 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1652 break;
1653 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301654 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001655 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1656 break;
1657#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301658 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1659 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001660 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301661 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001662 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1663 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301664 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1665 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1666 break;
1667 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001668 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1669 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301670 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301672 break;
1673 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001674 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1675 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301676 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001677 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301678 break;
1679#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001680 default:
1681 // If an invalid value is passed, disable CHANNEL BONDING
1682 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1683 break;
1684 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301685
Jeff Johnsone7245742012-09-05 17:12:55 -07001686 return phyCbState;
1687}
1688
1689v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1690{
1691
1692 v_U32_t cbIniValue;
1693 switch (phyCbState) {
1694 // secondary none
1695 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301696 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001697 break;
1698 // secondary LOW
1699 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301700 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001701 break;
1702 // secondary HIGH
1703 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301704 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001705 break;
1706#ifdef WLAN_FEATURE_11AC
1707 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301708 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001709 break;
1710 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301711 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001712 break;
1713 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301714 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001715 break;
1716 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301717 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001718 break;
1719 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301720 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001721 break;
1722 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301723 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001724 break;
1725 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301726 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001727 break;
1728#endif
1729 default:
1730 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301731 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001732 break;
1733 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301734
Jeff Johnsone7245742012-09-05 17:12:55 -07001735 return cbIniValue;
1736}
Jeff Johnson295189b2012-06-20 16:38:30 -07001737
1738eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1739{
1740 eHalStatus status = eHAL_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301741 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742
1743 if(pParam)
1744 {
1745 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1746 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1747 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1748 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1749 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1750 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1751
1752 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001753 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1754
Jeff Johnsone7245742012-09-05 17:12:55 -07001755 /* channelBondingMode5GHz plays a dual role right now
1756 * 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
1757 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1758 */
1759 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001761 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001762 }
1763 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1764 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001766 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001767 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301768#ifdef WLAN_FEATURE_AP_HT40_24G
1769 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1770#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001771 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1773 pMac->roam.configParam.phyMode = pParam->phyMode;
1774 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1775 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1776 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1777 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1778 pMac->roam.configParam.TxRate = pParam->TxRate;
1779 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1780 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1781 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1782 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1783 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001784 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 //if HDD passed down non zero values then only update,
1786 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301787 if (pParam->nInitialDwellTime)
1788 {
1789 pMac->roam.configParam.nInitialDwellTime =
1790 pParam->nInitialDwellTime;
1791 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001792 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 {
1794 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301795 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1796 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001798 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 {
1800 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301801 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1802 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001804 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 {
1806 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301807 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1808 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001810 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 {
1812 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301813 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1814 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301816 if (pParam->nOBSSScanWidthTriggerInterval)
1817 {
1818 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1819 pParam->nOBSSScanWidthTriggerInterval;
1820 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1821 pParam->nOBSSScanWidthTriggerInterval);
1822 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301823 if (pParam->max_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001824 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301825 pMac->roam.configParam.max_chntime_btc_esco =
1826 pParam->max_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001827 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301828 if (pParam->min_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001829 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301830 pMac->roam.configParam.min_chntime_btc_esco =
1831 pParam->min_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001832 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301833 if (pParam->min_chntime_btc_sco)
1834 pMac->roam.configParam.min_chntime_btc_sco =
1835 pParam->min_chntime_btc_sco;
1836 if (pParam->max_chntime_btc_sco)
1837 pMac->roam.configParam.max_chntime_btc_sco =
1838 pParam->max_chntime_btc_sco;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001839#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001840 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001841 {
1842 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1843 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001844 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001845 {
1846 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1847 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001848 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001849 {
1850 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1851 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001852 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001853 {
1854 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1855 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001856 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001857 {
1858 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1859 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001860 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001861 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001862 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1863 }
1864 if (pParam->nNumP2PChanCombinedConc)
1865 {
1866 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001867 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001868#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001870 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 {
1872 //Change the unit from second to microsecond
1873 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1875 {
1876 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1877 }
1878 else
1879 {
1880 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1881 }
1882 }
1883 else
1884 {
1885 pMac->roam.configParam.impsSleepTime = 0;
1886 }
1887 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1889 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 //if HDD passed down non zero values for age params, then only update,
1891 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001892 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 {
1894 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 if(pParam->scanAgeTimeNCNPS)
1897 {
1898 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 if(pParam->scanAgeTimeNCPS)
1901 {
1902 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 if(pParam->scanAgeTimeCNPS)
1905 {
1906 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1907 }
1908 if(pParam->scanAgeTimeCPS)
1909 {
1910 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1911 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301912 if (pParam->initialScanSkipDFSCh)
1913 {
1914 pMac->roam.configParam.initialScanSkipDFSCh =
1915 pParam->initialScanSkipDFSCh;
1916 }
1917
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001918 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1920 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1921 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1922 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1923 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1925 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1927 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1928 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1929 //Assign this before calling CsrInit11dInfo
1930 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 if( csrIs11dSupported( pMac ) )
1932 {
1933 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1934 }
1935 else
1936 {
1937 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1938 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001939
1940 /* Initialize the power + channel information if 11h is enabled.
1941 If 11d is enabled this information has already been initialized */
1942 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1943 {
1944 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1945 }
1946
1947
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301948#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301949 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1950 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001951 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001952#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001953#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001955 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001956 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001957 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001958 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001959 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001960 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001961 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001962 pMac->roam.configParam.nProbes = pParam->nProbes;
1963 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001965#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301966 pMac->roam.configParam.isRoamOffloadScanEnabled =
1967 pParam->isRoamOffloadScanEnabled;
1968 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1969 pParam->bFastRoamInConIniFeatureEnabled;
1970 pMac->roam.configParam.isPERRoamEnabled =
1971 pParam->isPERRoamEnabled;
1972 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
1973 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
1974 pMac->roam.configParam.waitPeriodForNextPERScan =
1975 pParam->waitPeriodForNextPERScan;
1976 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
1977 pMac->roam.configParam.isPERRoamCCAEnabled =
1978 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05301979 pMac->roam.configParam.PERRoamFullScanThreshold =
1980 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05301981 pMac->roam.configParam.PERroamTriggerPercent =
1982 pParam->PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05301983 pMac->roam.configParam.PERMinRssiThresholdForRoam =
1984 pParam->PERMinRssiThresholdForRoam;
1985 pMac->PERroamTimeout = pParam->waitPeriodForNextPERScan;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001986#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301987
1988#ifdef WLAN_FEATURE_LFR_MBB
1989 pMac->roam.configParam.enable_lfr_mbb = pParam->enable_lfr_mbb;
1990#endif
1991
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001992#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001993 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001994 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001995#endif
1996
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001997#ifdef FEATURE_WLAN_ESE
1998 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001999#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002000#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302001 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
2002 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002003 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
2004 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
2005 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
2006 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
2007 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
2008 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
2009 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
2010 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302011 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05302012 smsLog( pMac, LOG1, "nWeakZoneRssiThresholdForRoam = %d", pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam);
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 {
2014 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002015 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 -07002016 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2017 {
2018 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 }
2021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
2023 pMac->scan.fValidateList = pParam->fValidateList;
2024 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2025 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302026 pMac->scan.disable_scan_during_sco = pParam->disable_scan_during_sco;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08002027 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002029 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05302030 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07002031 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2032 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2033 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2034 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2035 * single session
2036 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002037 //Remove this code once SLM_Sessionization is supported
2038 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002039 pMac->roam.configParam.doBMPSWorkaround = 0;
2040
Jeff Johnsone7245742012-09-05 17:12:55 -07002041#ifdef WLAN_FEATURE_11AC
2042 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002043 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002044 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002045 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302046 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2047 if ( pParam->enableTxBF )
2048 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2049 else
2050 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002051#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002052 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002053
2054 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002055 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302056 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302057 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302058 pMac->roam.configParam.disableP2PMacSpoofing =
2059 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302060 pMac->roam.configParam.enableFatalEvent =
2061 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002062 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2063 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302064 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302065 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302066#ifdef WLAN_FEATURE_AP_HT40_24G
2067 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2068#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302069 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302070 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2071 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302072
2073 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2074 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2075 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2076 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2077 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2078
2079 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2080 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2081 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2082 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2083
2084 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2085 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2086 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2087 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302088 pMac->sta_sap_scc_on_dfs_chan = pParam->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302089 for (i = 0; i < 3; i++) {
2090 pMac->roam.configParam.agg_btc_sco_oui[i] =
2091 pParam->agg_btc_sco_oui[i];
2092 }
2093 pMac->roam.configParam.num_ba_buff_btc_sco =
2094 pParam->num_ba_buff_btc_sco;
2095 pMac->roam.configParam.num_ba_buff = pParam->num_ba_buff;
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 }
2097
2098 return status;
2099}
2100
Jeff Johnson295189b2012-06-20 16:38:30 -07002101eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2102{
2103 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302104 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 if(pParam)
2106 {
2107 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2108 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2109 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2110 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2111 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2112 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002113 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302114#ifdef WLAN_FEATURE_AP_HT40_24G
2115 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2116#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002117 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2119 pParam->phyMode = pMac->roam.configParam.phyMode;
2120 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2121 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2122 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2123 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2124 pParam->TxRate = pMac->roam.configParam.TxRate;
2125 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2126 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2127 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2128 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2129 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2131 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2132 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2133 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05302134 pParam->max_chntime_btc_esco =
2135 pMac->roam.configParam.max_chntime_btc_esco;
2136 pParam->min_chntime_btc_esco =
2137 pMac->roam.configParam.min_chntime_btc_esco;
2138 pParam->min_chntime_btc_sco =
2139 pMac->roam.configParam.min_chntime_btc_sco;
2140 pParam->max_chntime_btc_sco =
2141 pMac->roam.configParam.max_chntime_btc_sco;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002142 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002143#ifdef WLAN_AP_STA_CONCURRENCY
2144 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2145 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2146 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2147 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2148 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002149 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2150 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002151#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 //Change the unit from microsecond to second
2153 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2154 pParam->eBand = pMac->roam.configParam.eBand;
2155 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2156 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2157 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2158 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2159 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2160 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2161 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2162 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2163 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2164 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2165 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2166 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2167 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2169 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2170 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2171 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2173 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2174 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2175 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302176 pParam->disable_scan_during_sco = pMac->scan.disable_scan_during_sco;
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002178 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002179 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002180 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002181 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302182 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002183#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302184 vos_mem_copy(&pParam->neighborRoamConfig,
2185 &pMac->roam.configParam.neighborRoamConfig,
2186 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002187#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002188#ifdef WLAN_FEATURE_11AC
2189 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002190 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002191 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002192 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302193 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2194 if ( pParam->enableTxBF )
2195 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2196 else
2197 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002198#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002199#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302200 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2201 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002202#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002203#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002204 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2205 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2206 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2207 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2208 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002209 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002210 pParam->nProbes = pMac->roam.configParam.nProbes;
2211 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002212#endif
2213#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2214 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2215 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302216 pParam->isPERRoamEnabled =
2217 pMac->roam.configParam.isPERRoamEnabled;
2218 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2219 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2220 pParam->waitPeriodForNextPERScan =
2221 pMac->roam.configParam.waitPeriodForNextPERScan;
2222 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2223 pParam->isPERRoamCCAEnabled =
2224 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302225 pParam->PERRoamFullScanThreshold =
2226 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302227 pParam->PERroamTriggerPercent =
2228 pMac->roam.configParam.PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302229 pParam->PERMinRssiThresholdForRoam =
2230 pMac->roam.configParam.PERMinRssiThresholdForRoam;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002231#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302232
2233#ifdef WLAN_FEATURE_LFR_MBB
2234 pParam->enable_lfr_mbb = pMac->roam.configParam.enable_lfr_mbb;
2235#endif
2236
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002237#ifdef FEATURE_WLAN_LFR
2238 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2239#endif
2240
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002241#ifdef FEATURE_WLAN_ESE
2242 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002243#endif
2244#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302245 vos_mem_copy(&pParam->neighborRoamConfig,
2246 &pMac->roam.configParam.neighborRoamConfig,
2247 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002248 {
2249 int i;
2250 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2251 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2252 {
2253 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2254 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002255 }
2256#endif
2257
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002258 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002259
krunal soni5afa96c2013-09-06 22:19:02 -07002260 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002261 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302262 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302263 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302264 pParam->disableP2PMacSpoofing =
2265 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302266 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002267
krunal sonie9002db2013-11-25 14:24:17 -08002268 pParam->isCoalesingInIBSSAllowed =
2269 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302270 pParam->allowDFSChannelRoam =
2271 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302272 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302274#ifdef WLAN_FEATURE_AP_HT40_24G
2275 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2276#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302277 pParam->max_chan_for_dwell_time_cfg =
2278 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002279
Abhishek Singh48cd3402016-03-30 15:20:19 +05302280 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2281 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2282 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2283 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2284 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2285
2286 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2287 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2288 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2289 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2290
2291 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2292 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2293 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2294 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302295 pParam->sta_sap_scc_on_dfs_chan = pMac->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302296 for (i = 0; i < 3; i++) {
2297 pParam->agg_btc_sco_oui[i] =
2298 pMac->roam.configParam.agg_btc_sco_oui[i];
2299 }
2300 pParam->num_ba_buff_btc_sco =
2301 pMac->roam.configParam.num_ba_buff_btc_sco;
2302 pParam->num_ba_buff = pMac->roam.configParam.num_ba_buff;
2303
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 status = eHAL_STATUS_SUCCESS;
2305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 return (status);
2307}
2308
Jeff Johnson295189b2012-06-20 16:38:30 -07002309eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2310{
2311 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2312 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2313 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2314 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 do
2316 {
2317 if(eCSR_BAND_24 == eBand)
2318 {
2319 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2320 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2321 }
2322 if(eCSR_BAND_5G == eBand)
2323 {
2324 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2325 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2326 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2327 )
2328 {
2329 break;
2330 }
2331 }
2332 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2333 {
2334 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2335 }
2336 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2337 {
2338 newPhyMode = eCSR_DOT11_MODE_AUTO;
2339 }
2340 else
2341 {
2342 //Check for dual band and higher capability first
2343 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2344 {
2345 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2346 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2347 }
2348 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2349 {
2350 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2351 if(eCSR_BAND_24 == eBand) break;
2352 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2353 eBand = eCSR_BAND_5G;
2354 }
2355 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2356 {
2357 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2358 if(eCSR_BAND_5G == eBand) break;
2359 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2360 eBand = eCSR_BAND_24;
2361 }
2362 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2363 {
2364 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2365 if(eCSR_BAND_5G == eBand) break;
2366 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2367 eBand = eCSR_BAND_24;
2368 }
2369 else if(eCSR_DOT11_MODE_11n & phyMode)
2370 {
2371 newPhyMode = eCSR_DOT11_MODE_11n;
2372 }
2373 else if(eCSR_DOT11_MODE_abg & phyMode)
2374 {
2375 newPhyMode = eCSR_DOT11_MODE_abg;
2376 }
2377 else if(eCSR_DOT11_MODE_11a & phyMode)
2378 {
2379 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2380 {
2381 if(eCSR_BAND_ALL == eBand)
2382 {
2383 newPhyMode = eCSR_DOT11_MODE_abg;
2384 }
2385 else
2386 {
2387 //bad setting
2388 break;
2389 }
2390 }
2391 else
2392 {
2393 newPhyMode = eCSR_DOT11_MODE_11a;
2394 eBand = eCSR_BAND_5G;
2395 }
2396 }
2397 else if(eCSR_DOT11_MODE_11g & phyMode)
2398 {
2399 newPhyMode = eCSR_DOT11_MODE_11g;
2400 eBand = eCSR_BAND_24;
2401 }
2402 else if(eCSR_DOT11_MODE_11b & phyMode)
2403 {
2404 newPhyMode = eCSR_DOT11_MODE_11b;
2405 eBand = eCSR_BAND_24;
2406 }
2407 else
2408 {
2409 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002410 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 newPhyMode = eCSR_DOT11_MODE_AUTO;
2412 }
2413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 //Done validating
2415 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 //Now we need to check whether a restart is needed.
2417 if(eBand != pMac->roam.configParam.eBand)
2418 {
2419 fRestartNeeded = eANI_BOOLEAN_TRUE;
2420 break;
2421 }
2422 if(newPhyMode != pMac->roam.configParam.phyMode)
2423 {
2424 fRestartNeeded = eANI_BOOLEAN_TRUE;
2425 break;
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 if(HAL_STATUS_SUCCESS(status))
2429 {
2430 pMac->roam.configParam.eBand = eBand;
2431 pMac->roam.configParam.phyMode = newPhyMode;
2432 if(pfRestartNeeded)
2433 {
2434 *pfRestartNeeded = fRestartNeeded;
2435 }
2436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 return (status);
2438}
2439
Jeff Johnson295189b2012-06-20 16:38:30 -07002440void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2441{
2442 tANI_U8 Index;
2443 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 // for dual band NICs, don't need to trim the channel list....
2445 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2446 {
2447 // 2.4 GHz band operation requires the channel list to be trimmed to
2448 // the 2.4 GHz channels only...
2449 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2450 {
2451 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2452 Index++ )
2453 {
2454 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2455 {
2456 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2457 cChannels++;
2458 }
2459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2461 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2462 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2463 // only if we need to.
2464 //
2465 // The amount of memory to clear is the number of channesl that we trimmed
2466 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2467
2468 if ( pChannelList->numChannels > cChannels )
2469 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302470 vos_mem_set(&pChannelList->channelList[ cChannels ],
2471 sizeof( pChannelList->channelList[ 0 ] ) *
2472 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 }
2474
2475 pChannelList->numChannels = cChannels;
2476 }
2477 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2478 {
2479 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2480 {
2481 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2482 {
2483 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2484 cChannels++;
2485 }
2486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2488 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2489 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2490 // only if we need to.
2491 //
2492 // The amount of memory to clear is the number of channesl that we trimmed
2493 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2494 if ( pChannelList->numChannels > cChannels )
2495 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302496 vos_mem_set(&pChannelList->channelList[ cChannels ],
2497 sizeof( pChannelList->channelList[ 0 ] ) *
2498 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 }
2500
2501 pChannelList->numChannels = cChannels;
2502 }
2503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002504}
Jeff Johnson295189b2012-06-20 16:38:30 -07002505#define INFRA_AP_DEFAULT_CHANNEL 6
2506eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2507{
2508 tANI_U8 index= 0;
2509 eHalStatus status = eHAL_STATUS_FAILURE;
2510 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2511 {
2512 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2513 status = eHAL_STATUS_SUCCESS;
2514 break;
2515 }
2516 }
2517 return status;
2518}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002519
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002520
Jeff Johnson295189b2012-06-20 16:38:30 -07002521eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2522{
2523 eHalStatus status = eHAL_STATUS_SUCCESS;
2524 tANI_U8 num20MHzChannelsFound = 0;
2525 VOS_STATUS vosStatus;
2526 tANI_U8 Index = 0;
2527 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002528
Jeff Johnson295189b2012-06-20 16:38:30 -07002529
2530 //TODO: this interface changed to include the 40MHz channel list
2531 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2532 // Read the scan channel list (including the power limit) from EEPROM
2533 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2534 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2535 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002537 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 status = eHAL_STATUS_FAILURE;
2539 }
2540 else
2541 {
2542 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2543 {
2544 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2545 }
2546 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2547 // Move the channel list to the global data
2548 // structure -- this will be used as the scan list
2549 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2550 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 }
2553 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2554 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2555 {
2556 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2557 }
2558 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2559 {
2560 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2561 }
2562 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 return (status);
2565}
Jeff Johnson295189b2012-06-20 16:38:30 -07002566eHalStatus csrInitChannelList( tHalHandle hHal )
2567{
2568 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2569 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2571 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002572 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2573 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002575 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302576 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 return (status);
2578}
Jeff Johnson295189b2012-06-20 16:38:30 -07002579eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2580 tCsrUpdateConfigParam *pUpdateConfigParam)
2581{
2582 eHalStatus status = eHAL_STATUS_FAILURE;
2583 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2585 status = CsrInit11dInfo(pMac, ps11dinfo);
2586 return status;
2587}
2588
Jeff Johnson295189b2012-06-20 16:38:30 -07002589static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2590{
2591 eHalStatus status = eHAL_STATUS_FAILURE;
2592 tANI_U8 index;
2593 tANI_U32 count=0;
2594 tSirMacChanInfo *pChanInfo;
2595 tSirMacChanInfo *pChanInfoStart;
2596 tANI_BOOLEAN applyConfig = TRUE;
2597
Mihir Shetebc866f62014-02-13 16:08:53 +05302598 pMac->scan.currentCountryRSSI = -128;
2599
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 if(!ps11dinfo)
2601 {
2602 return (status);
2603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2605 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302606 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2607 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2608 ps11dinfo->Channels.channelList,
2609 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
2611 else
2612 {
2613 //No change
2614 return (eHAL_STATUS_SUCCESS);
2615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302617
2618 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2619 WNI_CFG_COUNTRY_CODE_LEN);
2620
2621
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 //Tush: at csropen get this initialized with default, during csr reset if this
2623 // already set with some value no need initilaize with default again
2624 if(0 == pMac->scan.countryCodeCurrent[0])
2625 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302626 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2627 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302630 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2631 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302633 vos_mem_set(pChanInfo,
2634 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2635 0);
2636
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002638 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2639 {
2640 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2641 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2642 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2643 pChanInfo++;
2644 count++;
2645 }
2646 if(count)
2647 {
2648 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2649 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302650 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002651 }
2652 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2653 if( HAL_STATUS_SUCCESS(status) )
2654 {
2655 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2656 {
2657 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2658 {
2659 applyConfig = FALSE;
2660 }
2661 }
2662
2663 if(TRUE == applyConfig)
2664 {
2665 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002666 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002667 }
2668
2669 }
2670 return (status);
2671}
2672/* Initialize the Channel + Power List in the local cache and in the CFG */
2673eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2674{
2675 tANI_U8 index;
2676 tANI_U32 count=0;
2677 tSirMacChanInfo *pChanInfo;
2678 tSirMacChanInfo *pChanInfoStart;
2679
2680 if(!ps11dinfo || !pMac)
2681 {
2682 return eHAL_STATUS_FAILURE;
2683 }
2684
Kiet Lam64c1b492013-07-12 13:56:44 +05302685 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2686 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002687 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302688 vos_mem_set(pChanInfo,
2689 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2690 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002691 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002692
2693 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2694 {
2695 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2696 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2697 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2698 pChanInfo++;
2699 count++;
2700 }
2701 if(count)
2702 {
2703 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2704 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302705 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 }
2707
Jeff Johnsone7245742012-09-05 17:12:55 -07002708 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002709}
2710
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302711/**
2712 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2713 * list
2714 *
2715 * @pMac: pointer to global mac
2716 * @sessionId: session id for the cmd
2717 * @pList: pending list from which cmd needs to be removed
2718 * @pCommand: cmd to be removed, can be NULL
2719 * @eRoamReason: cmd with reason to be removed
2720 *
2721 * Remove duplicate command from the pending list.
2722 *
2723 * Return: void
2724 */
2725void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2726 tANI_U32 sessionId, tDblLinkList *pList,
2727 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002728{
2729 tListElem *pEntry, *pNextEntry;
2730 tSmeCmd *pDupCommand;
2731 tDblLinkList localList;
2732
2733 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302734 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302736 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 return;
2738 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302739 csrLLLock(pList);
2740 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2741 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302743 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2744 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2745 /*
2746 * Remove the previous command if..
2747 * - the new roam command is for the same RoamReason...
2748 * - the new roam command is a NewProfileList.
2749 * - the new roam command is a Forced Dissoc
2750 * - the new roam command is from an 802.11 OID
2751 * (OID_SSID or OID_BSSID).
2752 */
2753 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2754 ((pCommand->command == pDupCommand->command) &&
2755 /*
2756 * This peermac check is requried for Softap/GO scenarios
2757 * For STA scenario below OR check will suffice as pCommand
2758 * will always be NULL for STA scenarios
2759 */
2760 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2761 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2762 ((pCommand->u.roamCmd.roamReason ==
2763 pDupCommand->u.roamCmd.roamReason) ||
2764 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2765 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2766 /* OR if pCommand is NULL */
2767 ((sessionId == pDupCommand->sessionId) &&
2768 (eSmeCommandRoam == pDupCommand->command) &&
2769 ((eCsrForcedDisassoc == eRoamReason) ||
2770 (eCsrHddIssued == eRoamReason))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302772 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2773 pDupCommand->u.roamCmd.roamReason);
2774 /* Remove the 'stale' roam command from the pending list */
2775 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 }
2778 pEntry = pNextEntry;
2779 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302780 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002781
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302782 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 {
2784 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302785 /* Tell caller that the command is cancelled */
2786 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2787 pDupCommand->u.roamCmd.roamId,
2788 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 csrReleaseCommandRoam(pMac, pDupCommand);
2790 }
2791 csrLLClose(&localList);
2792}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302793
2794/**
2795 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2796 * from pending lists.
2797 *
2798 * @pMac: pointer to global mac
2799 * @sessionId: session id for the cmd
2800 * @pCommand: cmd to be removed, can be null
2801 * @eRoamReason: cmd with reason to be removed
2802 *
2803 * Remove duplicate command from the sme and roam pending list.
2804 *
2805 * Return: void
2806 */
2807void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2808 tANI_U32 sessionId, tSmeCmd *pCommand,
2809 eCsrRoamReason eRoamReason)
2810{
2811 /* Always lock active list before locking pending lists */
2812 csrLLLock(&pMac->sme.smeCmdActiveList);
2813 csr_roam_remove_duplicate_cmd_from_list(pMac,
2814 sessionId, &pMac->sme.smeCmdPendingList,
2815 pCommand, eRoamReason);
2816 csr_roam_remove_duplicate_cmd_from_list(pMac,
2817 sessionId, &pMac->roam.roamCmdPendingList,
2818 pCommand, eRoamReason);
2819 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2820}
2821
Jeff Johnson295189b2012-06-20 16:38:30 -07002822eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2823 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2824{
2825 eHalStatus status = eHAL_STATUS_SUCCESS;
2826#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2827 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2828#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302829 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2831 {
2832 pSession = CSR_GET_SESSION( pMac, sessionId );
2833 }
2834 else
2835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002836 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 VOS_ASSERT(0);
2838 return eHAL_STATUS_FAILURE;
2839 }
krunal soni587bf012014-02-04 12:35:11 -08002840
2841 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2842 {
2843 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2844 return eHAL_STATUS_FAILURE;
2845 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002846
krunal soni587bf012014-02-04 12:35:11 -08002847 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2848
krunal soni7f7d2c92014-02-06 15:08:43 -08002849 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002851 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002853 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2854 /*
2855 * Decrement bRefAssocStartCnt for FT reassoc failure.
2856 * Reason: For FT reassoc failures, we first call
2857 * csrRoamCallCallback before notifying a failed roam
2858 * completion through csrRoamComplete. The latter in
2859 * turn calls csrRoamProcessResults which tries to
2860 * once again call csrRoamCallCallback if bRefAssocStartCnt
2861 * is non-zero. Since this is redundant for FT reassoc
2862 * failure, decrement bRefAssocStartCnt.
2863 */
2864 pSession->bRefAssocStartCnt--;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302865 } else if (u1 == eCSR_ROAM_ECSA_CHAN_CHANGE_RSP && u2 ==
2866 eCSR_ROAM_RESULT_NONE)
2867 pSession->connectedProfile.operationChannel =
2868 pRoamInfo->ap_chan_change_rsp->new_channel;
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002869
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05302870 if (eCSR_ROAM_RESULT_LOSTLINK == u2 ||
2871 eCSR_ROAM_LOSTLINK_DETECTED == u1)
2872 smsLog(pMac, LOG1, "eCSR_ROAM_RESULT_LOSTLINK ");
2873
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 if(NULL != pSession->callback)
2875 {
2876 if( pRoamInfo )
2877 {
2878 pRoamInfo->sessionId = (tANI_U8)sessionId;
2879 }
2880
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302881 /* avoid holding the global lock when making the roaming callback, original change came
2882 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2883 is possible on other OS ports where the callback may need to take locks to protect
2884 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2886 that may actually depend on the lock being held */
2887 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2888 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2889 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2890 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302891 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2892 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002893#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302894 vos_mem_set(&connectionStatus,
2895 sizeof(vos_event_wlan_status_payload_type), 0);
2896
krunal soni7f7d2c92014-02-06 15:08:43 -08002897 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 {
2899 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2900 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2901 if(NULL != pRoamInfo->pBssDesc)
2902 {
2903 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2904 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2907 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2908 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302909 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302910 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2911 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302914 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2917 {
2918 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2919 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302920 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 if(eCSR_ROAM_RESULT_FORCED == u2)
2923 {
2924 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2925 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302926 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2929 {
2930 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2931 connectionStatus.reason = eCSR_REASON_DISASSOC;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302932 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2935 {
2936 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2937 connectionStatus.reason = eCSR_REASON_DEAUTH;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302938 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002940#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2941
2942 return (status);
2943}
Jeff Johnson295189b2012-06-20 16:38:30 -07002944// Returns whether handoff is currently in progress or not
2945tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2946{
2947#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2948 return csrNeighborRoamIsHandoffInProgress(pMac);
2949#else
2950 return eANI_BOOLEAN_FALSE;
2951#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002952}
Jeff Johnson295189b2012-06-20 16:38:30 -07002953eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2954 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2955{
2956 eHalStatus status = eHAL_STATUS_SUCCESS;
2957 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2958 tANI_U16 reasonCode;
2959 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002960
2961 if(!pSession)
2962 {
2963 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2964 return eHAL_STATUS_FAILURE;
2965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002966
2967 //Restore AC weight in case we change it
2968 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2969 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002970 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 -07002971 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2972 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2973 }
2974
2975 if ( fMICFailure )
2976 {
2977 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2978 }
2979 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2980 {
2981 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002982 }
2983 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 {
2985 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002987#ifdef WLAN_FEATURE_VOWIFI_11R
2988 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2989 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2990 {
2991 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302992 vos_mem_copy(&bssId,
2993 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2994 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002995 }
2996 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002997#endif
2998 if(pSession->pConnectBssDesc)
2999 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303000 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003002
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303004 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
3005 " subState = %s reason=%d"),
3006 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
3007 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08003008
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3010
3011 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
3012
3013 if(HAL_STATUS_SUCCESS(status))
3014 {
3015 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003016#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3017 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
3018 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
3019 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003020 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
3022 }
3023#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003024 }
3025 else
3026 {
3027 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
3028 }
3029
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 return (status);
3031}
Jeff Johnson295189b2012-06-20 16:38:30 -07003032
Jeff Johnson295189b2012-06-20 16:38:30 -07003033/* ---------------------------------------------------------------------------
3034 \fn csrRoamIssueDisassociateStaCmd
3035 \brief csr function that HDD calls to disassociate a associated station
3036 \param sessionId - session Id for Soft AP
3037 \param pPeerMacAddr - MAC of associated station to delete
3038 \param reason - reason code, be one of the tSirMacReasonCodes
3039 \return eHalStatus
3040 ---------------------------------------------------------------------------*/
3041eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303042 tANI_U32 sessionId,
3043#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3044 const tANI_U8 *pPeerMacAddr,
3045#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 tANI_U32 reason)
3049{
3050 eHalStatus status = eHAL_STATUS_SUCCESS;
3051 tSmeCmd *pCommand;
3052
3053 do
3054 {
3055 pCommand = csrGetCommandBuffer( pMac );
3056 if ( !pCommand )
3057 {
3058 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3059 status = eHAL_STATUS_RESOURCES;
3060 break;
3061 }
3062 pCommand->command = eSmeCommandRoam;
3063 pCommand->sessionId = (tANI_U8)sessionId;
3064 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
3065 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
3066 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
3067 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3068 if( !HAL_STATUS_SUCCESS( status ) )
3069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003070 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 csrReleaseCommandRoam( pMac, pCommand );
3072 }
3073 }while(0);
3074
3075 return status;
3076}
3077
3078
Jeff Johnson295189b2012-06-20 16:38:30 -07003079/* ---------------------------------------------------------------------------
3080 \fn csrRoamIssueDeauthSta
3081 \brief csr function that HDD calls to delete a associated station
3082 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303083 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 \return eHalStatus
3085 ---------------------------------------------------------------------------*/
3086eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303087 tANI_U32 sessionId,
3088 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003089{
3090 eHalStatus status = eHAL_STATUS_SUCCESS;
3091 tSmeCmd *pCommand;
3092
3093 do
3094 {
3095 pCommand = csrGetCommandBuffer( pMac );
3096 if ( !pCommand )
3097 {
3098 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3099 status = eHAL_STATUS_RESOURCES;
3100 break;
3101 }
3102 pCommand->command = eSmeCommandRoam;
3103 pCommand->sessionId = (tANI_U8)sessionId;
3104 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303105 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3106 sizeof(tSirMacAddr));
3107 pCommand->u.roamCmd.reason =
3108 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3110 if( !HAL_STATUS_SUCCESS( status ) )
3111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003112 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 csrReleaseCommandRoam( pMac, pCommand );
3114 }
3115 }while(0);
3116
3117 return status;
3118}
Jeff Johnson295189b2012-06-20 16:38:30 -07003119eHalStatus
3120csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3121 tANI_BOOLEAN bEnable )
3122{
3123 eHalStatus status = eHAL_STATUS_FAILURE;
3124 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 if (!pSession)
3127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003128 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 return (status);
3130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 if (pSession->pConnectBssDesc)
3132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303133 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 }
3135 else
3136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003137 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 return (status);
3139 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003140 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3141 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3143 return (status);
3144}
Jeff Johnson295189b2012-06-20 16:38:30 -07003145eHalStatus
3146csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3147 VOS_MODULE_ID modId, void *pUsrContext,
3148 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3149{
3150 eHalStatus status = eHAL_STATUS_SUCCESS;
3151 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3152 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 if (!pSession)
3154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003155 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 return (status);
3157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 if(pSession->pConnectBssDesc)
3159 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303160 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 }
3162 else
3163 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003164 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 return (status);
3166 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003167 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3168 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3170 return (status);
3171}
Jeff Johnson295189b2012-06-20 16:38:30 -07003172eHalStatus
3173csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3174 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3175{
3176 eHalStatus status = eHAL_STATUS_SUCCESS;
3177 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3178 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3179
3180 if (!pSession)
3181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003182 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 return (status);
3184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 if(pSession->pConnectBssDesc)
3186 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303187 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 }
3189 else
3190 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003191 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 return (status);
3193 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003194 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3195 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003196
3197 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3198
3199 return (status);
3200}
Jeff Johnson295189b2012-06-20 16:38:30 -07003201eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3202{
3203 eHalStatus status = eHAL_STATUS_SUCCESS;
3204 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003206
3207 if (!pSession)
3208 {
3209 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3210 return eHAL_STATUS_FAILURE;
3211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003212
3213 if(pSession->pConnectBssDesc)
3214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303215 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003217 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3218 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3220
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303221 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303222 if(HAL_STATUS_SUCCESS(status))
3223 {
3224 csrRoamLinkDown(pMac, sessionId);
3225 }
3226 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003227 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303228 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3229 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003230 }
3231
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 return (status);
3233}
3234
Jeff Johnson295189b2012-06-20 16:38:30 -07003235eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3236{
3237 eHalStatus status = eHAL_STATUS_SUCCESS;
3238 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3239 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003240
3241 if(!pSession)
3242 {
3243 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3244 return eHAL_STATUS_FAILURE;
3245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003246
3247 // If no BSS description was found in this connection (happens with start IBSS), then
3248 // nix the BSS description that we keep around for the connected BSS) and get out...
3249 if(NULL == pBssDesc)
3250 {
3251 csrFreeConnectBssDesc(pMac, sessionId);
3252 }
3253 else
3254 {
3255 size = pBssDesc->length + sizeof( pBssDesc->length );
3256 if(NULL != pSession->pConnectBssDesc)
3257 {
3258 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3259 {
3260 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3261 csrFreeConnectBssDesc(pMac, sessionId);
3262 }
3263 }
3264 if(NULL == pSession->pConnectBssDesc)
3265 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303266 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303268 if (NULL == pSession->pConnectBssDesc)
3269 status = eHAL_STATUS_FAILURE;
3270 else
3271 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 return (status);
3274}
3275
Jeff Johnson295189b2012-06-20 16:38:30 -07003276eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3277 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3278 tDot11fBeaconIEs *pIes)
3279{
3280 eHalStatus status = eHAL_STATUS_SUCCESS;
3281 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303283 if (pIes == NULL)
3284 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003285
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 do
3287 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303288 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3289 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 //get qos
3291 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3292 //get SSID
3293 if(pIes->SSID.present)
3294 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303295 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3297 }
3298 else
3299 pBssConfig->SSID.length = 0;
3300 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003302 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 //Return failed if profile doesn't have an SSID either.
3304 if(pProfile->SSIDs.numOfSSIDs == 0)
3305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003306 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 status = eHAL_STATUS_FAILURE;
3308 break;
3309 }
3310 }
3311 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3312 {
3313 pBssConfig->eBand = eCSR_BAND_5G;
3314 }
3315 else
3316 {
3317 pBssConfig->eBand = eCSR_BAND_24;
3318 }
3319 //phymode
3320 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3321 {
3322 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3323 }
3324 else
3325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003326 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 //force it
3328 if(eCSR_BAND_24 == pBssConfig->eBand)
3329 {
3330 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3331 }
3332 else
3333 {
3334 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3335 }
3336 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +05303337 smsLog(pMac, LOG1, FL("phyMode %d uCfgDot11Mode %d"),
3338 pProfile->phyMode, pBssConfig->uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 //Qos
3340 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3341 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3342 {
3343 //Joining BSS is not 11n capable and WMM is disabled on client.
3344 //Disable QoS and WMM
3345 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3346 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303347
3348 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303349 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303350 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3351 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3352 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3353 {
3354 //Joining BSS is 11n capable and WMM is disabled on AP.
3355 //Assume all HT AP's are QOS AP's and enable WMM
3356 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3357 }
3358
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 //auth type
3360 switch( pProfile->negotiatedAuthType )
3361 {
3362 default:
3363 case eCSR_AUTH_TYPE_WPA:
3364 case eCSR_AUTH_TYPE_WPA_PSK:
3365 case eCSR_AUTH_TYPE_WPA_NONE:
3366 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3367 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 case eCSR_AUTH_TYPE_SHARED_KEY:
3370 pBssConfig->authType = eSIR_SHARED_KEY;
3371 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 case eCSR_AUTH_TYPE_AUTOSWITCH:
3373 pBssConfig->authType = eSIR_AUTO_SWITCH;
3374 break;
3375 }
3376 //short slot time
3377 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3378 {
3379 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3380 }
3381 else
3382 {
3383 pBssConfig->uShortSlotTime = 0;
3384 }
3385 if(pBssConfig->BssCap.ibss)
3386 {
3387 //We don't support 11h on IBSS
3388 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3389 }
3390 else
3391 {
3392 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3393 }
3394 //power constraint
3395 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3396 //heartbeat
3397 if ( CSR_IS_11A_BSS( pBssDesc ) )
3398 {
3399 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3400 }
3401 else
3402 {
3403 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3404 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303405 /*
3406 * Join timeout, if we find a BeaconInterval in the BssDescription,
3407 * then set the Join Timeout to be 3 BeaconInterval.
3408 */
3409 if (pBssDesc->beaconInterval)
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 {
3411 //Make sure it is bigger than the minimal
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303412 pBssConfig->uJoinTimeOut =
3413 CSR_ROAM_MAX(3 * pBssDesc->beaconInterval,
3414 CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303416 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 {
3418 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3419 }
3420 //validate CB
3421 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Abhishek Singhe3beee22017-07-31 15:35:40 +05303422 if (CSR_IS_CHANNEL_24GHZ(pBssDesc->channelId) &&
3423 pProfile->force_24ghz_in_ht20) {
3424 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
3425 smsLog(pMac, LOG1,
3426 FL("force_24ghz_in_ht20 is set so set cbmode to 0"));
3427 }
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303428 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3429 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 return (status);
3432}
3433
Jeff Johnson295189b2012-06-20 16:38:30 -07003434static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3435 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3436{
3437 eHalStatus status = eHAL_STATUS_SUCCESS;
3438 tANI_U8 operationChannel = 0;
3439 tANI_U8 qAPisEnabled = FALSE;
3440 //SSID
3441 pBssConfig->SSID.length = 0;
3442 if(pProfile->SSIDs.numOfSSIDs)
3443 {
3444 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303445 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3446 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 }
3448 else
3449 {
3450 //SSID must present
3451 return eHAL_STATUS_FAILURE;
3452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 //Settomg up the capabilities
3454 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3455 {
3456 pBssConfig->BssCap.ibss = 1;
3457 }
3458 else
3459 {
3460 pBssConfig->BssCap.ess = 1;
3461 }
3462 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3463 {
3464 pBssConfig->BssCap.privacy = 1;
3465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 pBssConfig->eBand = pMac->roam.configParam.eBand;
3467 //phymode
3468 if(pProfile->ChannelInfo.ChannelList)
3469 {
3470 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3473 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 //QOS
3475 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 if ( pBssConfig->BssCap.ess == 1 )
3477 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 /*For Softap case enable WMM*/
3479 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3480 qAPisEnabled = TRUE;
3481 }
3482 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3484 qAPisEnabled = TRUE;
3485 } else {
3486 qAPisEnabled = FALSE;
3487 }
3488 } else {
3489 qAPisEnabled = TRUE;
3490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3492 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3493 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3494 )
3495 {
3496 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3497 } else {
3498 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3499 }
3500
3501 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003502 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 {
3504 default:
3505 case eCSR_AUTH_TYPE_WPA:
3506 case eCSR_AUTH_TYPE_WPA_PSK:
3507 case eCSR_AUTH_TYPE_WPA_NONE:
3508 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3509 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3510 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 case eCSR_AUTH_TYPE_SHARED_KEY:
3512 pBssConfig->authType = eSIR_SHARED_KEY;
3513 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 case eCSR_AUTH_TYPE_AUTOSWITCH:
3515 pBssConfig->authType = eSIR_AUTO_SWITCH;
3516 break;
3517 }
3518 //short slot time
3519 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3520 {
3521 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3522 }
3523 else
3524 {
3525 pBssConfig->uShortSlotTime = 0;
3526 }
3527 //power constraint. We don't support 11h on IBSS
3528 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3529 pBssConfig->uPowerLimit = 0;
3530 //heartbeat
3531 if ( eCSR_BAND_5G == pBssConfig->eBand )
3532 {
3533 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3534 }
3535 else
3536 {
3537 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3538 }
3539 //Join timeout
3540 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003541
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 return (status);
3543}
Jeff Johnson295189b2012-06-20 16:38:30 -07003544static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3545{
3546 eHalStatus status = eHAL_STATUS_FAILURE;
3547 tDot11fBeaconIEs *pIes = NULL;
3548
3549 do
3550 {
3551 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3552 {
3553 //err msg
3554 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003555 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 break;
3557 }
3558 //check if the AP is QAP & it supports APSD
3559 if( CSR_IS_QOS_BSS(pIes) )
3560 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303561 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 }
3563 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303564
3565 if (NULL != pIes)
3566 {
3567 vos_mem_free(pIes);
3568 }
3569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 return status;
3571}
3572
Jeff Johnson295189b2012-06-20 16:38:30 -07003573void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3574{
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3576 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3577 // See !!Note: below in this function...
3578 tANI_U32 PrivacyEnabled = 0;
3579 tANI_U32 RsnEnabled = 0;
3580 tANI_U32 WepDefaultKeyId = 0;
3581 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3582 tANI_U32 Key0Length = 0;
3583 tANI_U32 Key1Length = 0;
3584 tANI_U32 Key2Length = 0;
3585 tANI_U32 Key3Length = 0;
3586
3587 // Reserve for the biggest key
3588 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3589 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3590 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3591 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3592
3593 switch ( pProfile->negotiatedUCEncryptionType )
3594 {
3595 case eCSR_ENCRYPT_TYPE_NONE:
3596
3597 // for NO encryption, turn off Privacy and Rsn.
3598 PrivacyEnabled = 0;
3599 RsnEnabled = 0;
3600
3601 // WEP key length and Wep Default Key ID don't matter in this case....
3602
3603 // clear out the WEP keys that may be hanging around.
3604 Key0Length = 0;
3605 Key1Length = 0;
3606 Key2Length = 0;
3607 Key3Length = 0;
3608
3609 break;
3610
3611 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303612 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003613
3614 // Privacy is ON. NO RSN for Wep40 static key.
3615 PrivacyEnabled = 1;
3616 RsnEnabled = 0;
3617
3618 // Set the Wep default key ID.
3619 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 // Wep key size if 5 bytes (40 bits).
3621 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3622
3623 // set encryption keys in the CFG database or clear those that are not present in this profile.
3624 if ( pProfile->Keys.KeyLength[0] )
3625 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303626 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3627 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3629 }
3630 else
3631 {
3632 Key0Length = 0;
3633 }
3634
3635 if ( pProfile->Keys.KeyLength[1] )
3636 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303637 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3638 WNI_CFG_WEP_KEY_LENGTH_5);
3639 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 }
3641 else
3642 {
3643 Key1Length = 0;
3644 }
3645
3646 if ( pProfile->Keys.KeyLength[2] )
3647 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303648 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3649 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3651 }
3652 else
3653 {
3654 Key2Length = 0;
3655 }
3656
3657 if ( pProfile->Keys.KeyLength[3] )
3658 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303659 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3660 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3662 }
3663 else
3664 {
3665 Key3Length = 0;
3666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 break;
3668
3669 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303670 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
3672 // Privacy is ON. NO RSN for Wep40 static key.
3673 PrivacyEnabled = 1;
3674 RsnEnabled = 0;
3675
3676 // Set the Wep default key ID.
3677 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3678
3679 // Wep key size if 13 bytes (104 bits).
3680 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3681
3682 // set encryption keys in the CFG database or clear those that are not present in this profile.
3683 if ( pProfile->Keys.KeyLength[0] )
3684 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303685 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3686 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3688 }
3689 else
3690 {
3691 Key0Length = 0;
3692 }
3693
3694 if ( pProfile->Keys.KeyLength[1] )
3695 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303696 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3697 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3699 }
3700 else
3701 {
3702 Key1Length = 0;
3703 }
3704
3705 if ( pProfile->Keys.KeyLength[2] )
3706 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303707 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3708 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3710 }
3711 else
3712 {
3713 Key2Length = 0;
3714 }
3715
3716 if ( pProfile->Keys.KeyLength[3] )
3717 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303718 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3719 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3721 }
3722 else
3723 {
3724 Key3Length = 0;
3725 }
3726
3727 break;
3728
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 case eCSR_ENCRYPT_TYPE_TKIP:
3730 case eCSR_ENCRYPT_TYPE_AES:
3731#ifdef FEATURE_WLAN_WAPI
3732 case eCSR_ENCRYPT_TYPE_WPI:
3733#endif /* FEATURE_WLAN_WAPI */
3734 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3735 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3736 PrivacyEnabled = (0 != fPrivacy);
3737
3738 // turn on RSN enabled for WPA associations
3739 RsnEnabled = 1;
3740
3741 // WEP key length and Wep Default Key ID don't matter in this case....
3742
3743 // clear out the static WEP keys that may be hanging around.
3744 Key0Length = 0;
3745 Key1Length = 0;
3746 Key2Length = 0;
3747 Key3Length = 0;
3748
3749 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 default:
3751 PrivacyEnabled = 0;
3752 RsnEnabled = 0;
3753 break;
3754 }
3755
3756 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3757 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3758 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3759 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3760 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3761 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3762 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3763 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3764}
3765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3767{
3768 tANI_U32 len = 0;
3769 if(pSSID->length <= WNI_CFG_SSID_LEN)
3770 {
3771 len = pSSID->length;
3772 }
3773 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3774}
3775
Jeff Johnson295189b2012-06-20 16:38:30 -07003776eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3777{
3778 eHalStatus status = eHAL_STATUS_SUCCESS;
3779 tANI_U32 QoSEnabled;
3780 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 // set the CFG enable/disable variables based on the qosType being configured...
3782 switch( qosType )
3783 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3785 QoSEnabled = FALSE;
3786 WmeEnabled = TRUE;
3787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3789 QoSEnabled = FALSE;
3790 WmeEnabled = TRUE;
3791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3793 QoSEnabled = FALSE;
3794 WmeEnabled = TRUE;
3795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3797 QoSEnabled = TRUE;
3798 WmeEnabled = FALSE;
3799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 case eCSR_MEDIUM_ACCESS_11e_HCF:
3801 QoSEnabled = TRUE;
3802 WmeEnabled = FALSE;
3803 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 default:
3805 case eCSR_MEDIUM_ACCESS_DCF:
3806 QoSEnabled = FALSE;
3807 WmeEnabled = FALSE;
3808 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 }
3810 //save the WMM setting for later use
3811 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303812 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 return (status);
3814}
Jeff Johnson295189b2012-06-20 16:38:30 -07003815static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303816 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003817{
3818 eHalStatus status = eHAL_STATUS_FAILURE;
3819 int i;
3820 eCsrCfgDot11Mode cfgDot11Mode;
3821 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303822 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303823 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3824 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003826
3827 if( NULL != pIes )
3828 {
3829 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 // Originally, we thought that for 11a networks, the 11a rates are always
3831 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3832 // appear in the Operational Rate set. Consequently, in either case, we
3833 // would blindly put the rates we support into our Operational Rate set
3834 // (including the basic rates, which we have already verified are
3835 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 // However, it turns out that this is not always the case. Some AP's
3837 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3838 // too. Now, we're a little more careful:
3839 pDstRate = pOpRateSet->rate;
3840 if(pIes->SuppRates.present)
3841 {
3842 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3843 {
3844 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3845 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003846 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3847 {
3848 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3849 *pDstRate++ = pIes->SuppRates.rates[ i ];
3850 pOpRateSet->numRates++;
3851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 }
3853 }
3854 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303855 /* If there are Extended Rates in the beacon, we will reflect those
3856 * extended rates that we support in out Extended Operational Rate
3857 * set*/
3858 pDstRate = pExRateSet->rate;
3859 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303861 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303863 if (csrRatesIsDot11RateSupported(pMac,
3864 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303866 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3867 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303869 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3870 &rateBitmap);
3871 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3872 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 }
3874 }
3875 }
3876 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303877 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 }//Parsing BSSDesc
3879 else
3880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003881 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 }
3883 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3884 return status;
3885}
3886
3887static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3888 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3889{
3890 int i;
3891 tANI_U8 *pDstRate;
3892 eCsrCfgDot11Mode cfgDot11Mode;
3893 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3894 tANI_U32 OperationalRatesLength = 0;
3895 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3896 tANI_U32 ExtendedOperationalRatesLength = 0;
3897 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3898 tANI_U32 ProprietaryOperationalRatesLength = 0;
3899 tANI_U32 PropRatesEnable = 0;
3900 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3901 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 if( NULL != pIes )
3904 {
3905 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 // Originally, we thought that for 11a networks, the 11a rates are always
3907 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3908 // appear in the Operational Rate set. Consequently, in either case, we
3909 // would blindly put the rates we support into our Operational Rate set
3910 // (including the basic rates, which we have already verified are
3911 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 // However, it turns out that this is not always the case. Some AP's
3913 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3914 // too. Now, we're a little more careful:
3915 pDstRate = OperationalRates;
3916 if(pIes->SuppRates.present)
3917 {
3918 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3919 {
3920 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3921 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3922 {
3923 *pDstRate++ = pIes->SuppRates.rates[ i ];
3924 OperationalRatesLength++;
3925 }
3926 }
3927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3929 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3930 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3931 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3932 {
3933 // If there are Extended Rates in the beacon, we will reflect those
3934 // extended rates that we support in out Extended Operational Rate
3935 // set:
3936 pDstRate = ExtendedOperationalRates;
3937 if(pIes->ExtSuppRates.present)
3938 {
3939 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3940 {
3941 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3942 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3943 {
3944 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3945 ExtendedOperationalRatesLength++;
3946 }
3947 }
3948 }
3949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 // Enable proprietary MAC features if peer node is Airgo node and STA
3951 // user wants to use them
3952 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3953 {
3954 PropRatesEnable = 1;
3955 }
3956 else
3957 {
3958 PropRatesEnable = 0;
3959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 // For ANI network companions, we need to populate the proprietary rate
3961 // set with any proprietary rates we found in the beacon, only if user
3962 // allows them...
3963 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3964 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3965 {
3966 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3967 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3968 {
3969 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3970 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303971 vos_mem_copy(ProprietaryOperationalRates,
3972 pIes->Airgo.PropSuppRates.rates,
3973 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 }
3975 else {
3976 // No proprietary modes...
3977 ProprietaryOperationalRatesLength = 0;
3978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 /* Get MCS Rate */
3980 pDstRate = MCSRateIdxSet;
3981 if ( pIes->HTCaps.present )
3982 {
3983 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3984 {
3985 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3986 {
3987 MCSRateLength++;
3988 *pDstRate++ = i;
3989 }
3990 }
3991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 // Set the operational rate set CFG variables...
3993 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3994 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3995 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3996 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3997 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3998 ProprietaryOperationalRates,
3999 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4000 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
4001 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
4002 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
4003 }//Parsing BSSDesc
4004 else
4005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004006 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 }
4008}
4009
Jeff Johnson295189b2012-06-20 16:38:30 -07004010static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
4011 tCsrRoamProfile *pProfile )
4012{
4013 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4014 { 8,
4015 { SIR_MAC_RATE_6,
4016 SIR_MAC_RATE_9,
4017 SIR_MAC_RATE_12,
4018 SIR_MAC_RATE_18,
4019 SIR_MAC_RATE_24,
4020 SIR_MAC_RATE_36,
4021 SIR_MAC_RATE_48,
4022 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4024 { 4,
4025 { SIR_MAC_RATE_1,
4026 SIR_MAC_RATE_2,
4027 SIR_MAC_RATE_5_5,
4028 SIR_MAC_RATE_11 } } };
4029
4030
4031 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4032 { SIR_MAC_RATE_72,
4033 SIR_MAC_RATE_96,
4034 SIR_MAC_RATE_108 } };
4035 eCsrCfgDot11Mode cfgDot11Mode;
4036 eCsrBand eBand;
4037 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4038 tANI_U32 OperationalRatesLength = 0;
4039 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4040 tANI_U32 ExtendedOperationalRatesLength = 0;
4041 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
4042 tANI_U32 ProprietaryOperationalRatesLength = 0;
4043 tANI_U32 PropRatesEnable = 0;
4044 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 if(pProfile->ChannelInfo.ChannelList)
4046 {
4047 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4051 // networks, the 11b rates appear in the Operational Rate set. In either case,
4052 // we can blindly put the rates we support into our Operational Rate set
4053 // (including the basic rates, which we have already verified are supported
4054 // earlier in the roaming decision).
4055 if ( eCSR_BAND_5G == eBand )
4056 {
4057 // 11a rates into the Operational Rate Set.
4058 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4059 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304060 vos_mem_copy(OperationalRates,
4061 DefaultSupportedRates11a.supportedRateSet.rate,
4062 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004063
4064 // Nothing in the Extended rate set.
4065 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 // populate proprietary rates if user allows them
4067 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4068 {
4069 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4070 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304071 vos_mem_copy(ProprietaryOperationalRates,
4072 DefaultSupportedPropRates.propRate,
4073 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 }
4075 else
4076 {
4077 // No proprietary modes
4078 ProprietaryOperationalRatesLength = 0;
4079 }
4080 }
4081 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4082 {
4083 // 11b rates into the Operational Rate Set.
4084 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4085 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304086 vos_mem_copy(OperationalRates,
4087 DefaultSupportedRates11b.supportedRateSet.rate,
4088 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 // Nothing in the Extended rate set.
4090 ExtendedOperationalRatesLength = 0;
4091 // No proprietary modes
4092 ProprietaryOperationalRatesLength = 0;
4093 }
4094 else
4095 {
4096 // 11G
4097
4098 // 11b rates into the Operational Rate Set.
4099 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4100 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304101 vos_mem_copy(OperationalRates,
4102 DefaultSupportedRates11b.supportedRateSet.rate,
4103 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 // 11a rates go in the Extended rate set.
4106 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4107 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304108 vos_mem_copy(ExtendedOperationalRates,
4109 DefaultSupportedRates11a.supportedRateSet.rate,
4110 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004111
4112 // populate proprietary rates if user allows them
4113 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4114 {
4115 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4116 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304117 vos_mem_copy(ProprietaryOperationalRates,
4118 DefaultSupportedPropRates.propRate,
4119 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121 else
4122 {
4123 // No proprietary modes
4124 ProprietaryOperationalRatesLength = 0;
4125 }
4126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4128 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4129 {
4130 PropRatesEnable = 1;
4131 }
4132 else
4133 {
4134 PropRatesEnable = 0;
4135 }
4136
4137 // Set the operational rate set CFG variables...
4138 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4139 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4140 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4141 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4142 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4143 ProprietaryOperationalRates,
4144 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4145 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004146}
Jeff Johnson295189b2012-06-20 16:38:30 -07004147void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4148{
4149 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004150
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4152 tANI_U32 sessionId;
4153 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 if(NULL == pEntry)
4155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004156 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 return;
4158 }
4159 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4160 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304161 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4162 " current state : %d sub state : %d "),
4163 result, pMac->roam.curState[sessionId],
4164 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4166 {
4167 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4168 }
4169}
4170
Jeff Johnson295189b2012-06-20 16:38:30 -07004171//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4172tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4173{
4174 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4175 {
4176 return (WNI_CFG_PHY_MODE_11B);
4177 }
4178 else
4179 {
4180 if(eCSR_BAND_24 == band)
4181 return (WNI_CFG_PHY_MODE_11G);
4182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 return (WNI_CFG_PHY_MODE_11A);
4184}
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
Jeff Johnsone7245742012-09-05 17:12:55 -07004186
4187#ifdef WLAN_FEATURE_11AC
4188ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4189{
4190 switch ( aniCBMode )
4191 {
4192 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4193 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4194 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4195 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4196 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4197 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4198 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4199 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4200 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004201 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004202 return PHY_SINGLE_CHANNEL_CENTERED;
4203 }
4204}
4205#endif
4206
Jeff Johnson295189b2012-06-20 16:38:30 -07004207//pIes may be NULL
4208eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4209 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304210 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004211{
4212 eHalStatus status = eHAL_STATUS_SUCCESS;
4213 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4214 tANI_U8 channel = 0;
4215 //Make sure we have the domain info for the BSS we try to connect to.
4216 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304217 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304219 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 {
4221 //Make sure the 11d info from this BSSDesc can be applied
4222 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304223 if (VOS_TRUE == resetCountry)
4224 {
4225 csrApplyCountryInformation(pMac, FALSE);
4226 }
4227 else
4228 {
4229 csrApplyCountryInformation(pMac, TRUE);
4230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 }
Kiran4a17ebe2013-01-31 10:43:43 -08004232 if ((csrIs11dSupported (pMac)) && pIes)
4233 {
4234 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004235 {
Kiran4a17ebe2013-01-31 10:43:43 -08004236 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004237 }
4238 else
4239 {
4240 //Let's also update the below to make sure we don't update CC while
4241 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304242 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004243 pBssDesc->bssId, sizeof(tSirMacAddr));
4244 }
Kiran4a17ebe2013-01-31 10:43:43 -08004245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 //Qos
4248 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4249 //SSID
4250 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4251 //fragment threshold
4252 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4253 //RTS threshold
4254 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4255
4256 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 //Auth type
4258 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4259 //encryption type
4260 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4261 //short slot time
4262 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 //11d
4264 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4265 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4266 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 /*//11h
4268 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4269 */
4270 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4271 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004272
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004273 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 {
4275 channel = pProfile->operationChannel;
4276 }
4277 else
4278 {
4279 if(pBssDesc)
4280 {
4281 channel = pBssDesc->channelId;
4282 }
4283 }
4284 if(0 != channel)
4285 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304286 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4287 !pMac->roam.configParam.channelBondingMode24GHz &&
4288 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4289 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304291 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4292 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4293 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 }
4295 else
4296 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004297 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 }
4299 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004300#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004301 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4302 // in function csrConvertCBIniValueToPhyCBState()
4303 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4304 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004305 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004306 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004307 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004308 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304309 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004310 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004311 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004312 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004313 }
4314 else
4315#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4317 //Rate
4318 //Fixed Rate
4319 if(pBssDesc)
4320 {
4321 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4322 }
4323 else
4324 {
4325 csrSetCfgRateSetFromProfile(pMac, pProfile);
4326 }
4327 //Make this the last CFG to set. The callback will trigger a join_req
4328 //Join time out
4329 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4330
4331 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 return (status);
4333}
4334
Jeff Johnson295189b2012-06-20 16:38:30 -07004335eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4336 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4337{
4338 eHalStatus status;
4339 tBssConfigParam *pBssConfig;
4340 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004341
4342 if(!pSession)
4343 {
4344 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4345 return eHAL_STATUS_FAILURE;
4346 }
4347
Kiet Lam64c1b492013-07-12 13:56:44 +05304348 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4349 if ( NULL == pBssConfig )
4350 status = eHAL_STATUS_FAILURE;
4351 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304353 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4355 if(HAL_STATUS_SUCCESS(status))
4356 {
4357 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004358 /* This will allow to pass cbMode during join req */
4359 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 //For IBSS, we need to prepare some more information
4361 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 )
4364 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004365 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 }
4367 // If we are in an IBSS, then stop the IBSS...
4368 ////Not worry about WDS connection for now
4369 if ( csrIsConnStateIbss( pMac, sessionId ) )
4370 {
4371 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4372 }
4373 else
4374 {
4375 // if we are in an Infrastructure association....
4376 if ( csrIsConnStateInfra( pMac, sessionId ) )
4377 {
4378 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4379 // across SSIDs (roaming to a new SSID)... //
4380 //Not worry about WDS connection for now
4381 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304382 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 {
4384 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304385 status = csrRoamIssueDisassociate( pMac, sessionId,
4386 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304388 else
4389 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4391 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304392 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304394 // Set parameters for this Bss.
4395 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4396 pBssDesc, pBssConfig,
4397 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304401 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 {
4403 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4404 // Nothing to stop.
4405 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304407 )
4408 {
4409 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4410 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4411 // Set parameters for this Bss.
4412 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4413 pBssDesc, pBssConfig,
4414 pIes, is11rRoamingFlag);
4415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 }
4417 }
4418 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304419 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 return (status);
4422}
4423
Jeff Johnson295189b2012-06-20 16:38:30 -07004424eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4425 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4426{
4427 eCsrJoinState eRoamState = eCsrContinueRoaming;
4428 eHalStatus status;
4429 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4430 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004432
4433 if(!pSession)
4434 {
4435 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4436 return (eCsrStopRoaming);
4437 }
4438
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 if( CSR_IS_WDS_STA( pProfile ) )
4440 {
4441 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4442 if( !HAL_STATUS_SUCCESS( status ) )
4443 {
4444 eRoamState = eCsrStopRoaming;
4445 }
4446 }
4447 else
4448 {
4449 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4450 {
4451 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4452 return (eCsrStopRoaming);
4453 }
4454 if ( csrIsInfraBssDesc( pBssDesc ) )
4455 {
4456 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4457 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4458 // have changed and handle the changes (without disturbing the current association).
4459
4460 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4461 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4462 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4463 )
4464 {
4465 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4466 // with Authenticating first. To force this, stop the current association (Disassociate) and
4467 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4468 // a new Association.
4469 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4470 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004471 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4473 {
4474 eRoamState = eCsrReassocToSelfNoCapChange;
4475 }
4476 else
4477 {
4478 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304480 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4482 if(HAL_STATUS_SUCCESS(status))
4483 {
4484 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004485 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304487 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4488 pBssDesc, &bssConfig,
4489 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 if(!HAL_STATUS_SUCCESS(status))
4491 {
4492 eRoamState = eCsrStopRoaming;
4493 }
4494 }
4495 else
4496 {
4497 eRoamState = eCsrStopRoaming;
4498 }
4499 }//same profile
4500 }
4501 else
4502 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304503 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4505 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304506 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4507 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304511 }
4512 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 {
4514 // 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 -07004515 // stop the existing network before attempting to join the new network...
4516 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4517 {
4518 eRoamState = eCsrStopRoaming;
4519 }
4520 }
4521 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304522 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 {
4524 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4525 {
4526 eRoamState = eCsrStopRoaming;
4527 }
4528 }
4529 if( pIesLocal && !pScanResult->pvIes )
4530 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304531 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 }
4533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 return( eRoamState );
4535}
4536
Jeff Johnson295189b2012-06-20 16:38:30 -07004537eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4538 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4539{
4540 eHalStatus status = eHAL_STATUS_SUCCESS;
4541 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304542 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 roamInfo.pBssDesc = pBssDesc;
4544 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4545 return (status);
4546}
Jeff Johnson295189b2012-06-20 16:38:30 -07004547//In case no matching BSS is found, use whatever default we can find
4548static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4549{
4550 //Need to get all negotiated types in place first
4551 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004552 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 {
4554 default:
4555 case eCSR_AUTH_TYPE_WPA:
4556 case eCSR_AUTH_TYPE_WPA_PSK:
4557 case eCSR_AUTH_TYPE_WPA_NONE:
4558 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4559 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4560 break;
4561
4562 case eCSR_AUTH_TYPE_SHARED_KEY:
4563 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4564 break;
4565
4566 case eCSR_AUTH_TYPE_AUTOSWITCH:
4567 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4568 break;
4569 }
4570 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4571 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4572 //In this case, the multicast encryption needs to follow the uncast ones.
4573 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4574 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4575}
4576
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004577
4578static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4579{
4580 switch(pCommand->u.roamCmd.roamReason)
4581 {
4582 case eCsrLostLink1:
4583 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4584 break;
4585 case eCsrLostLink2:
4586 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4587 break;
4588 case eCsrLostLink3:
4589 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4590 break;
4591 default:
4592 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4593 pCommand->u.roamCmd.roamReason);
4594 break;
4595 }
4596}
4597
Jeff Johnson295189b2012-06-20 16:38:30 -07004598static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4599{
4600 eHalStatus status;
4601 tCsrScanResult *pScanResult = NULL;
4602 eCsrJoinState eRoamState = eCsrStopRoaming;
4603 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4604 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4605 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4606#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4607 v_U8_t acm_mask = 0;
4608#endif
4609 tANI_U32 sessionId = pCommand->sessionId;
4610 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4611 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4612 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004613
4614 if(!pSession)
4615 {
4616 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4617 return (eCsrStopRoaming);
4618 }
4619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 do
4621 {
4622 // Check for Cardbus eject condition, before trying to Roam to any BSS
4623 //***if( !balIsCardPresent(pAdapter) ) break;
4624
Kiet Lam64c1b492013-07-12 13:56:44 +05304625 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304626 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 if(NULL != pBSSList)
4628 {
4629 // When handling AP's capability change, continue to associate to
4630 // same BSS and make sure pRoamBssEntry is not Null.
4631 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4632 {
4633 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4634 {
4635 //Try the first BSS
4636 pCommand->u.roamCmd.pLastRoamBss = NULL;
4637 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4638 }
4639 else
4640 {
4641 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4642 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4643 {
4644 //Done with all the BSSs
4645 //In this case, will tell HDD the completion
4646 break;
4647 }
4648 else
4649 {
4650 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304651 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4653 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4654 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4655 pRoamInfo = &roamInfo;
4656 }
4657 }
4658 while(pCommand->u.roamCmd.pRoamBssEntry)
4659 {
4660 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 /*If concurrency enabled take the concurrent connected channel first. */
4662 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304663 if (vos_concurrent_open_sessions_running() &&
4664 !csrIsValidMcConcurrentSession(pMac, sessionId,
4665 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 {
4667 concurrentChannel =
4668 csrGetConcurrentOperationChannel(pMac);
4669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004670 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 if ((concurrentChannel) &&
4672 (concurrentChannel ==
4673 pScanResult->Result.BssDescriptor.channelId))
4674 {
4675 //make this 0 because we do not want the
4676 //below check to pass as we don't want to
4677 //connect on other channel
4678 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4679 FL("Concurrent channel match =%d"),
4680 concurrentChannel);
4681 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 }
4683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004684
4685 if (!concurrentChannel)
4686 {
4687
4688 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4689 sessionId, &pScanResult->Result.BssDescriptor,
4690 pCommand->u.roamCmd.roamId)))
4691 {
4692 //Ok to roam this
4693 break;
4694 }
4695 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004696 else
4697 {
4698 eRoamState = eCsrStopRoamingDueToConcurrency;
4699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4701 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4702 {
4703 //Done with all the BSSs
4704 fDone = eANI_BOOLEAN_TRUE;
4705 break;
4706 }
4707 }
4708 if(fDone)
4709 {
4710 break;
4711 }
4712 }
4713 }
4714 //We have something to roam, tell HDD when it is infra.
4715 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4716 //For WDS, the indication is eCSR_ROAM_WDS_IND
4717 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4718 {
4719 if(pRoamInfo)
4720 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004721 if(pSession->bRefAssocStartCnt)
4722 {
4723 pSession->bRefAssocStartCnt--;
4724 //Complete the last association attemp because a new one is about to be tried
4725 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4726 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004728 }
4729 }
4730 /* If the roaming has stopped, not to continue the roaming command*/
4731 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4732 {
4733 //No need to complete roaming here as it already completes
4734 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4735 pCommand->u.roamCmd.roamReason);
4736 eRoamState = eCsrStopRoaming;
4737 csrSetAbortRoamingCommand(pMac, pCommand);
4738 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304740 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 if(pScanResult)
4742 {
4743 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004746 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 fDone = eANI_BOOLEAN_TRUE;
4748 eRoamState = eCsrStopRoaming;
4749 break;
4750 }
4751 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4752 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4753 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4754 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4755 CSR_IS_QOS_BSS(pIesLocal) &&
4756 CSR_IS_UAPSD_BSS(pIesLocal) )
4757 {
4758#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4760 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004761#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 }
4763 else
4764 {
4765 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4766 }
4767 if( pIesLocal && !pScanResult->Result.pvIes)
4768 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304769 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 }
4771 }
4772 else
4773 {
4774 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4775 }
4776 roamInfo.pProfile = pProfile;
4777 pSession->bRefAssocStartCnt++;
4778 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4779 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4782 {
4783 // If this is a start IBSS profile, then we need to start the IBSS.
4784 if ( CSR_IS_START_IBSS(pProfile) )
4785 {
4786 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 // Attempt to start this IBSS...
4788 csrRoamAssignDefaultParam( pMac, pCommand );
4789 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4790 if(HAL_STATUS_SUCCESS(status))
4791 {
4792 if ( fSameIbss )
4793 {
4794 eRoamState = eCsrStartIbssSameIbss;
4795 }
4796 else
4797 {
4798 eRoamState = eCsrContinueRoaming;
4799 }
4800 }
4801 else
4802 {
4803 //it somehow fail need to stop
4804 eRoamState = eCsrStopRoaming;
4805 }
4806 break;
4807 }
4808 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 )
4811 {
4812 // Attempt to start this WDS...
4813 csrRoamAssignDefaultParam( pMac, pCommand );
4814 /* For AP WDS, we dont have any BSSDescription */
4815 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4816 if(HAL_STATUS_SUCCESS(status))
4817 {
4818 eRoamState = eCsrContinueRoaming;
4819 }
4820 else
4821 {
4822 //it somehow fail need to stop
4823 eRoamState = eCsrStopRoaming;
4824 }
4825 }
4826 else
4827 {
4828 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004829 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 eRoamState = eCsrStopRoaming;
4831 break;
4832 }
4833 }
4834 else //We have BSS
4835 {
4836 //Need to assign these value because they are used in csrIsSameProfile
4837 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004838 /* The OSEN IE doesn't provide the cipher suite.
4839 * Therefore set to constant value of AES */
4840 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4841 {
4842 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4843 eCSR_ENCRYPT_TYPE_AES;
4844 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4845 eCSR_ENCRYPT_TYPE_AES;
4846 }
4847 else
4848 {
4849 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4850 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4851 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4852 pScanResult->mcEncryptionType;
4853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4855 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4856 {
4857 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4858 {
4859 eRoamState = eCsrStartIbssSameIbss;
4860 break;
4861 }
4862 }
4863 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4864 {
4865 //trying to connect to the one already connected
4866 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4867 eRoamState = eCsrReassocToSelfNoCapChange;
4868 break;
4869 }
4870 // Attempt to Join this Bss...
4871 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4872 break;
4873 }
4874
4875 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4877 {
4878 //Need to indicate association_completion if association_start has been done
4879 if(pSession->bRefAssocStartCnt > 0)
4880 {
4881 pSession->bRefAssocStartCnt--;
4882 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004883 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4885 eCSR_ROAM_ASSOCIATION_COMPLETION,
4886 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4887 }
4888 }
4889
4890 return( eRoamState );
4891}
4892
Jeff Johnson295189b2012-06-20 16:38:30 -07004893static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4894{
4895 eHalStatus status = eHAL_STATUS_SUCCESS;
4896 eCsrJoinState RoamState;
4897 tANI_U32 sessionId = pCommand->sessionId;
4898
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 //***if( hddIsRadioStateOn( pAdapter ) )
4900 {
4901 // Attept to join a Bss...
4902 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004903
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004905 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 {
4907 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 // and if connected in Infrastructure mode...
4909 if ( csrIsConnStateInfra(pMac, sessionId) )
4910 {
4911 //... then we need to issue a disassociation
4912 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4913 if(!HAL_STATUS_SUCCESS(status))
4914 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004915 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 //roam command is completed by caller in the failed case
4917 fComplete = eANI_BOOLEAN_TRUE;
4918 }
4919 }
4920 else if( csrIsConnStateIbss(pMac, sessionId) )
4921 {
4922 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4923 if(!HAL_STATUS_SUCCESS(status))
4924 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004925 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 //roam command is completed by caller in the failed case
4927 fComplete = eANI_BOOLEAN_TRUE;
4928 }
4929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4931 {
4932 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4933 if(!HAL_STATUS_SUCCESS(status))
4934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004935 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 //roam command is completed by caller in the failed case
4937 fComplete = eANI_BOOLEAN_TRUE;
4938 }
4939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 else
4941 {
4942 fComplete = eANI_BOOLEAN_TRUE;
4943 }
4944 if(fComplete)
4945 {
4946 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004947 if(eCsrStopRoamingDueToConcurrency == RoamState)
4948 {
4949 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4950 }
4951 else
4952 {
4953 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 }
4956 }
4957 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4958 {
4959 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4960 }
4961 else if ( eCsrStartIbssSameIbss == RoamState )
4962 {
4963 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4964 }
4965 }//hddIsRadioStateOn
4966
4967 return status;
4968}
Jeff Johnson295189b2012-06-20 16:38:30 -07004969eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4970{
4971 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05304972 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 tCsrScanResult *pScanResult = NULL;
4974 tSirBssDescription *pBssDesc = NULL;
4975 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 sessionId = pCommand->sessionId;
4977 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004978
4979 if(!pSession)
4980 {
4981 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4982 return eHAL_STATUS_FAILURE;
4983 }
4984
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4986 {
4987 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004988 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4990 return eHAL_STATUS_FAILURE;
4991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 if (pCommand->u.roamCmd.pRoamBssEntry)
4993 {
4994 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4995 pBssDesc = &pScanResult->Result.BssDescriptor;
4996 }
4997 else
4998 {
4999 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005000 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
5002 return eHAL_STATUS_FAILURE;
5003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
5005 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
5006 return status;
5007}
5008
Jeff Johnson295189b2012-06-20 16:38:30 -07005009eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5010{
5011 eHalStatus status = eHAL_STATUS_SUCCESS;
5012 tCsrRoamInfo roamInfo;
5013 tANI_U32 sessionId = pCommand->sessionId;
5014 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005015
5016 if(!pSession)
5017 {
5018 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5019 return eHAL_STATUS_FAILURE;
5020 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05305021 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5022 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 switch ( pCommand->u.roamCmd.roamReason )
5024 {
5025 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005027 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 case eCsrSmeIssuedDisassocForHandoff:
5030 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
5031#if 0 // TODO : Confirm this change
5032 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
5033#else
5034 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
5035#endif
5036
5037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005040 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005044 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 case eCsrHddIssuedReassocToSameAP:
5047 case eCsrSmeIssuedReassocToSameAP:
5048 {
5049 tDot11fBeaconIEs *pIes = NULL;
5050
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 if( pSession->pConnectBssDesc )
5052 {
5053 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5054 if(!HAL_STATUS_SUCCESS(status) )
5055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005056 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 }
5058 else
5059 {
5060 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5061 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5062 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5064 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5065 pSession->bRefAssocStartCnt++;
5066 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5067 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5068
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005069 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005070 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5071 &pCommand->u.roamCmd.roamProfile );
5072 if(!HAL_STATUS_SUCCESS(status))
5073 {
5074 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005075 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005076 }
5077
Kiet Lam64c1b492013-07-12 13:56:44 +05305078 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 pIes = NULL;
5080 }
5081 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305082 else
5083 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 break;
5085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005087 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5089 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5090 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005092 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5094 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005095
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 case eCsrStopBss:
5097 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5098 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5099 break;
5100
5101 case eCsrForcedDisassocSta:
5102 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5103 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5104 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5105 pCommand->u.roamCmd.reason);
5106 break;
5107
5108 case eCsrForcedDeauthSta:
5109 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5110 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5111 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5112 pCommand->u.roamCmd.reason);
5113 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005114
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005115 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005116 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005117 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5118 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005119 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005120
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305121#ifdef WLAN_FEATURE_LFR_MBB
5122 case ecsr_mbb_perform_preauth_reassoc:
5123 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5124 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5125 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305126 if (eHAL_STATUS_SUCCESS != status)
5127 {
5128 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5129 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5130 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5131 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305132 break;
5133#endif
5134
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 default:
5136 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5137
5138 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5139 {
5140 //Remember the roaming profile
5141 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305142 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5143 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305145 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5147 }
5148 }
5149
5150 //At this point, original uapsd_mask is saved in pCurRoamProfile
5151 //uapsd_mask in the pCommand may change from this point on.
5152
5153 // Attempt to roam with the new scan results (if we need to..)
5154 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005155 if(!HAL_STATUS_SUCCESS(status))
5156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005157 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 break;
5160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 return (status);
5162}
5163
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005164void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5165{
5166 pCommand->u.roamCmd.pLastRoamBss = NULL;
5167 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5168 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305169 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005170}
5171
Jeff Johnson295189b2012-06-20 16:38:30 -07005172void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5173{
5174 if(pCommand->u.roamCmd.fReleaseBssList)
5175 {
5176 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5177 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5178 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5179 }
5180 if(pCommand->u.roamCmd.fReleaseProfile)
5181 {
5182 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5183 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5184 }
5185 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5186 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305187 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005188}
5189
Jeff Johnson295189b2012-06-20 16:38:30 -07005190void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5191{
Kiet Lam64c1b492013-07-12 13:56:44 +05305192 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005193}
Jeff Johnson295189b2012-06-20 16:38:30 -07005194void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5195{
5196 tListElem *pEntry;
5197 tSmeCmd *pCommand;
5198 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005199 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5201 if ( pEntry )
5202 {
5203 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 // If the head of the queue is Active and it is a ROAM command, remove
5205 // and put this on the Free queue.
5206 if ( eSmeCommandRoam == pCommand->command )
5207 {
5208 //we need to process the result first before removing it from active list because state changes
5209 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5210 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5211 if( fReleaseCommand )
5212 {
5213 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5214 {
5215 csrReleaseCommandRoam( pMac, pCommand );
5216 }
5217 else
5218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005219 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005220 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 }
5222 }
5223 else
5224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005225 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005226 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 }
5228 }
5229 else
5230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005231 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 }
5233 }
5234 else
5235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005236 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 if( fReleaseCommand )
5239 {
5240 smeProcessPendingQueue( pMac );
5241 }
5242}
5243
Jeff Johnson295189b2012-06-20 16:38:30 -07005244void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5245{
5246 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005247 if(!pSession)
5248 {
5249 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5250 return;
5251 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305252 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5253 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 pSession->NumPmkidCandidate = 0;
5255}
Jeff Johnson295189b2012-06-20 16:38:30 -07005256#ifdef FEATURE_WLAN_WAPI
5257void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5258{
5259 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005260 if(!pSession)
5261 {
5262 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5263 return;
5264 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305265 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5266 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 pSession->NumBkidCandidate = 0;
5268}
5269#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005270extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5271
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305272eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5273 tANI_U32 sessionId, eCsrAuthType authType,
5274 tSirBssDescription *pSirBssDesc,
5275 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005276{
5277 eHalStatus status = eHAL_STATUS_SUCCESS;
5278 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5279 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005280
5281 if(!pSession)
5282 {
5283 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5284 return eHAL_STATUS_FAILURE;
5285 }
5286
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 if((eCSR_AUTH_TYPE_WPA == authType) ||
5288 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5289 (eCSR_AUTH_TYPE_RSN == authType) ||
5290 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5291#if defined WLAN_FEATURE_VOWIFI_11R
5292 ||
5293 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5294 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5295#endif /* FEATURE_WLAN_WAPI */
5296#ifdef FEATURE_WLAN_WAPI
5297 ||
5298 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5299 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5300#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005301#ifdef WLAN_FEATURE_11W
5302 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305303 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5304 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005305#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 )
5307 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005310 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 }
5312 if( pIesLocal )
5313 {
5314 tANI_U32 nIeLen;
5315 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 if((eCSR_AUTH_TYPE_RSN == authType) ||
5317#if defined WLAN_FEATURE_VOWIFI_11R
5318 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5319 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5320#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005321#if defined WLAN_FEATURE_11W
5322 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305323 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5326 {
5327 if(pIesLocal->RSN.present)
5328 {
5329 //Calculate the actual length
5330 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5331 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5332 + 2 //akm_suite_count
5333 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5334 + 2; //reserved
5335 if( pIesLocal->RSN.pmkid_count )
5336 {
5337 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5338 }
5339 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305340 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5341 if (NULL == pSession->pWpaRsnRspIE)
5342 status = eHAL_STATUS_FAILURE;
5343 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305345 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5347 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5348 //copy upto akm_suites
5349 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305350 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5351 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005352 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305353 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5354 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005355 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305356 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5357 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005358 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 if( pIesLocal->RSN.pwise_cipher_suite_count )
5360 {
5361 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305362 vos_mem_copy(pIeBuf,
5363 pIesLocal->RSN.pwise_cipher_suites,
5364 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5366 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305367 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 pIeBuf += 2;
5369 if( pIesLocal->RSN.akm_suite_count )
5370 {
5371 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305372 vos_mem_copy(pIeBuf,
5373 pIesLocal->RSN.akm_suites,
5374 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5376 }
5377 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305378 vos_mem_copy(pIeBuf,
5379 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5380 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5382 }
5383 }
5384 }
5385 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5386 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5387 {
5388 if(pIesLocal->WPA.present)
5389 {
5390 //Calculate the actual length
5391 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5392 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5393 + 2 //auth_suite_count
5394 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5395 // The WPA capabilities follows the Auth Suite (two octects)--
5396 // this field is optional, and we always "send" zero, so just
5397 // remove it. This is consistent with our assumptions in the
5398 // frames compiler; c.f. bug 15234:
5399 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305400
5401 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5402 if ( NULL == pSession->pWpaRsnRspIE )
5403 status = eHAL_STATUS_FAILURE;
5404 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 {
5406 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5407 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5408 pIeBuf = pSession->pWpaRsnRspIE + 2;
5409 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305410 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305412 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5413 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305415 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5416 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5418 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5419 }
5420 }
5421 }
5422#ifdef FEATURE_WLAN_WAPI
5423 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5424 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5425 {
5426 if(pIesLocal->WAPI.present)
5427 {
5428 //Calculate the actual length
5429 nIeLen = 4 //version + akm_suite_count
5430 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5431 + 2 //pwise_cipher_suite_count
5432 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5433 + 6; //gp_cipher_suite + preauth + reserved
5434 if( pIesLocal->WAPI.bkid_count )
5435 {
5436 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5437 }
5438
5439 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305440 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5441 if ( NULL == pSession->pWapiRspIE )
5442 status = eHAL_STATUS_FAILURE;
5443 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 {
5445 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5446 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5447 pIeBuf = pSession->pWapiRspIE + 2;
5448 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305449 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 pIeBuf += 4;
5451 if( pIesLocal->WAPI.akm_suite_count )
5452 {
5453 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305454 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5455 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305457 }
5458 vos_mem_copy(pIeBuf,
5459 &pIesLocal->WAPI.unicast_cipher_suite_count,
5460 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5463 {
5464 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305465 vos_mem_copy( pIeBuf,
5466 pIesLocal->WAPI.unicast_cipher_suites,
5467 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5469 }
lukez3c809222013-05-03 10:23:02 -07005470 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305471 vos_mem_copy(pIeBuf,
5472 pIesLocal->WAPI.multicast_cipher_suite,
5473 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005474 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305475 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305476 vos_mem_copy(pIeBuf,
5477 pIesLocal->WAPI.multicast_cipher_suite + 4,
5478 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005479 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305480 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305482 //bkid_count
5483 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5484 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305486 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5487 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5489 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305490 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 }
5493 }
5494#endif /* FEATURE_WLAN_WAPI */
5495 if( !pIes )
5496 {
5497 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305498 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 }
5500 }
5501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 return (status);
5503}
5504
Jeff Johnson295189b2012-06-20 16:38:30 -07005505static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5506{
5507 v_U8_t bACWeights[WLANTL_MAX_AC];
5508 v_U8_t paramBk, paramBe, paramVi, paramVo;
5509 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5511 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5512 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5513 //This doesn't address the case where the lower AC needs a real higher weight
5514 if( pIEs->WMMParams.present )
5515 {
5516 //no change to the lowest ones
5517 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5518 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5519 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5520 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5521 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5522 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5523 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5524 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5525 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5526 {
5527 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5528 fWeightChange = VOS_TRUE;
5529 }
5530 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5531 {
5532 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5533 fWeightChange = VOS_TRUE;
5534 }
5535 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5536 {
5537 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5538 fWeightChange = VOS_TRUE;
5539 }
5540 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5541 {
5542 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5543 fWeightChange = VOS_TRUE;
5544 }
5545 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5546 {
5547 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5548 fWeightChange = VOS_TRUE;
5549 }
5550 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5551 {
5552 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5553 fWeightChange = VOS_TRUE;
5554 }
5555 if(fWeightChange)
5556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005557 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 bACWeights[2], bACWeights[3]);
5559 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5560 }
5561 }
5562}
Jeff Johnson295189b2012-06-20 16:38:30 -07005563#ifdef WLAN_FEATURE_VOWIFI_11R
5564//Returns whether the current association is a 11r assoc or not
5565tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5566{
5567#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5568 return csrNeighborRoamIs11rAssoc(pMac);
5569#else
5570 return eANI_BOOLEAN_FALSE;
5571#endif
5572}
5573#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005574#ifdef FEATURE_WLAN_ESE
5575//Returns whether the current association is a ESE assoc or not
5576tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005577{
5578#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005579 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005580#else
5581 return eANI_BOOLEAN_FALSE;
5582#endif
5583}
5584#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005585#ifdef FEATURE_WLAN_LFR
5586//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305587tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005588{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305589 tCsrRoamSession *pSession = NULL;
5590
5591 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5592 {
5593 pSession = CSR_GET_SESSION( pMac, sessionId );
5594 if (NULL != pSession->pCurRoamProfile)
5595 {
5596 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5597 {
5598 return eANI_BOOLEAN_FALSE;
5599 }
5600 }
5601 }
5602
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005603#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5604 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5605 {
5606 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5607 }
5608 else
5609#endif
5610 {
5611 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005612 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005613 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005614}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005615
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005616#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005617/* ---------------------------------------------------------------------------
5618
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005619 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005620
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005621 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005622
5623 \param pMac - The handle returned by macOpen.
5624
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005625 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005626
5627---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005628tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005629{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005630 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005631}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005632#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005633
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005634#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5635//Returns whether "FW based BG scan" is currently enabled...or not
5636tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5637{
5638 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5639}
5640#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005641#endif
5642
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005643#if defined(FEATURE_WLAN_ESE)
5644tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005645{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005646 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005647}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005648#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650//Return true means the command can be release, else not
5651static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5652 eCsrRoamCompleteResult Result, void *Context )
5653{
5654 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5655 tSirBssDescription *pSirBssDesc = NULL;
5656 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5657 tCsrScanResult *pScanResult = NULL;
5658 tCsrRoamInfo roamInfo;
5659 sme_QosAssocInfo assocInfo;
5660 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5661 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5662 tDot11fBeaconIEs *pIes = NULL;
5663 tANI_U32 sessionId = pCommand->sessionId;
5664 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5665 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5666 eRoamCmdStatus roamStatus;
5667 eCsrRoamResult roamResult;
5668 eHalStatus status;
5669 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005671
Jeff Johnson32d95a32012-09-10 13:15:23 -07005672 if(!pSession)
5673 {
5674 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5675 return eANI_BOOLEAN_FALSE;
5676 }
5677
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005678 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 switch( Result )
5680 {
5681 case eCsrJoinSuccess:
5682 // reset the IDLE timer
5683 // !!
5684 // !! fall through to the next CASE statement here is intentional !!
5685 // !!
5686 case eCsrReassocSuccess:
5687 if(eCsrReassocSuccess == Result)
5688 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305689 roamInfo.reassoc = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5691 }
5692 else
5693 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305694 roamInfo.reassoc = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5696 }
5697 // Success Join Response from LIM. Tell NDIS we are connected and save the
5698 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005699 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305700 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 //always free the memory here
5702 if(pSession->pWpaRsnRspIE)
5703 {
5704 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305705 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 pSession->pWpaRsnRspIE = NULL;
5707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005708#ifdef FEATURE_WLAN_WAPI
5709 if(pSession->pWapiRspIE)
5710 {
5711 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305712 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 pSession->pWapiRspIE = NULL;
5714 }
5715#endif /* FEATURE_WLAN_WAPI */
5716#ifdef FEATURE_WLAN_BTAMP_UT_RF
5717 //Reset counter so no join retry is needed.
5718 pSession->maxRetryCount = 0;
5719 csrRoamStopJoinRetryTimer(pMac, sessionId);
5720#endif
5721 /* This creates problem since we have not saved the connected profile.
5722 So moving this after saving the profile
5723 */
5724 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305725
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305726 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305727 * by last failed secured connection.
5728 * It should be set only for secured connection.
5729 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305730 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5732 {
5733 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5734 }
5735 else
5736 {
5737 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 //Use the last connected bssdesc for reassoc-ing to the same AP.
5740 //NOTE: What to do when reassoc to a different AP???
5741 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5742 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5743 {
5744 pSirBssDesc = pSession->pConnectBssDesc;
5745 if(pSirBssDesc)
5746 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305747 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5748 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 }
5750 }
5751 else
5752 {
5753
5754 if(pCommand->u.roamCmd.pRoamBssEntry)
5755 {
5756 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5757 if(pScanResult != NULL)
5758 {
5759 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5760 //this can be NULL
5761 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305762 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5763 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 }
5765 }
5766 }
5767 if( pSirBssDesc )
5768 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5771 //Save WPA/RSN IE
5772 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005773#ifdef FEATURE_WLAN_ESE
5774 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005775#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305776#ifdef WLAN_FEATURE_VOWIFI_11R
5777 if (pSirBssDesc->mdiePresent)
5778 {
5779 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5780#ifdef FEATURE_WLAN_ESE
5781 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5782 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5783#endif
5784 )
5785 {
5786 // is11Rconnection;
5787 roamInfo.is11rAssoc = VOS_TRUE;
5788 }
5789 else
5790 {
5791 // is11Rconnection;
5792 roamInfo.is11rAssoc = VOS_FALSE;
5793 }
5794 }
5795#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5797 // substate change.
5798 // Moving even save profile above so that below mentioned conditon is also met.
5799 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5800 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5802 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5803 // will be dropped for the security context may not be set properly.
5804 //
5805 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5806 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5807 //
5808 // this reordering was done on titan_prod_usb branch and is being replicated here.
5809 //
5810
5811 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5812 !pProfile->bWPSAssociation)
5813 {
5814 // Issue the set Context request to LIM to establish the Unicast STA context
5815 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5816 pProfile->negotiatedUCEncryptionType,
5817 pSirBssDesc, &(pSirBssDesc->bssId),
5818 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5819 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005820 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5822 }
5823 // Issue the set Context request to LIM to establish the Broadcast STA context
5824 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5825 pSirBssDesc, &BroadcastMac,
5826 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5827 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305828 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 {
5830 //Need to wait for supplicant authtication
5831 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 //Set the subestate to WaitForKey in case authentiation is needed
5833 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5834
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 if(pProfile->bWPSAssociation)
5836 {
5837 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5838 }
5839 else
5840 {
5841 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5842 }
5843
5844 //Save sessionId in case of timeout
5845 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5846 //This time should be long enough for the rest of the process plus setting key
5847 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5848 {
5849 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005850 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5852 }
5853 }
5854
5855 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5856 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 if(Context)
5858 {
5859 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5860 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5862 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5863#ifdef WLAN_FEATURE_VOWIFI_11R
5864 len += pJoinRsp->parsedRicRspLen;
5865#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005866#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 len += pJoinRsp->tspecIeLen;
5868#endif
5869 if(len)
5870 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305871 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5872 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305874 vos_mem_copy(pSession->connectedInfo.pbFrames,
5875 pJoinRsp->frames, len);
5876 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5877 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5878 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305880 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005881#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005882#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305883 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005884#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305885 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5886 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5887 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5888 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 }
5890 }
5891 if(pCommand->u.roamCmd.fReassoc)
5892 {
5893 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5894 }
5895 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5896 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5897 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5898 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305899 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305900 roamInfo.vht_caps = pJoinRsp->vht_caps;
5901 roamInfo.ht_caps = pJoinRsp->ht_caps;
5902 roamInfo.hs20vendor_ie = pJoinRsp->hs20vendor_ie;
5903 roamInfo.ht_operation = pJoinRsp->ht_operation;
5904 roamInfo.vht_operation = pJoinRsp->vht_operation;
5905
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 }
5907 else
5908 {
5909 if(pCommand->u.roamCmd.fReassoc)
5910 {
5911 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5912 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5913 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5914 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5915 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5916 }
5917 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305918 /* Update the staId from the previous connected profile info
5919 as the reassociation is triggred at SME/HDD */
5920 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5921 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5922 {
5923 roamInfo.staId = pSession->connectedInfo.staId;
5924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005925#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5926 // Indicate SME-QOS with reassoc success event, only after
5927 // copying the frames
5928 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5929#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 roamInfo.pBssDesc = pSirBssDesc;
5931 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5932 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5933#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5934 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5935#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5936 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5938 //It may be better to let QoS do this????
5939 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005941 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5943 pmcStartUapsd( pMac, NULL, NULL );
5944 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305945 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5947 if( pSession->bRefAssocStartCnt > 0 )
5948 {
5949 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005950 //Remove this code once SLM_Sessionization is supported
5951 //BMPS_WORKAROUND_NOT_NEEDED
5952 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005953 {
5954 pMac->roam.configParam.doBMPSWorkaround = 1;
5955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5957 }
5958
5959 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 // reset the PMKID candidate list
5961 csrResetPMKIDCandidateList( pMac, sessionId );
5962 //Update TL's AC weight base on the current EDCA parameters
5963 //These parameters may change in the course of the connection, that sictuation
5964 //is not taken care here. This change is mainly to address a WIFI WMM test where
5965 //BE has a equal or higher TX priority than VI.
5966 //We only do this for infra link
5967 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5968 {
5969 csrCheckAndUpdateACWeight(pMac, pIes);
5970 }
5971#ifdef FEATURE_WLAN_WAPI
5972 // reset the BKID candidate list
5973 csrResetBKIDCandidateList( pMac, sessionId );
5974#endif /* FEATURE_WLAN_WAPI */
5975 }
5976 else
5977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005978 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 csrScanCancelIdleScan(pMac);
5981 //Not to signal link up because keys are yet to be set.
5982 //The linkup function will overwrite the sub-state that we need to keep at this point.
5983 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5984 {
5985 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5988 //enough to let security and DHCP handshake succeed before entry into BMPS
5989 if (pmcShouldBmpsTimerRun(pMac))
5990 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305991 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05305992 * until keys are set before going into BMPS.
5993 */
5994 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5995 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305996 pMac->pmc.full_power_till_set_key = true;
5997 smsLog(pMac, LOG1,
5998 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 +05305999 }
6000
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
6002 != eHAL_STATUS_SUCCESS)
6003 {
6004 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
6005 }
6006 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
6007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 break;
6009
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 case eCsrStartBssSuccess:
6011 // on the StartBss Response, LIM is returning the Bss Description that we
6012 // are beaconing. Add this Bss Description to our scan results and
6013 // chain the Profile to this Bss Description. On a Start BSS, there was no
6014 // detected Bss description (no partner) so we issued the Start Bss to
6015 // start the Ibss without any Bss description. Lim was kind enough to return
6016 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006017 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05306020 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 if( CSR_IS_IBSS( pProfile ) )
6022 {
6023 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 else if (CSR_IS_INFRA_AP(pProfile))
6026 {
6027 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 else
6030 {
6031 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6032 }
6033 if( !CSR_IS_WDS_STA( pProfile ) )
6034 {
6035 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
6038 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306039 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 roamInfo.pBssDesc = pSirBssDesc;
6041 //We need to associate_complete it first, becasue Associate_start already indicated.
6042 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6043 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
6044 break;
6045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07006048 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 }
6050 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6051 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6052 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6053 if(pSirBssDesc)
6054 {
6055 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306056 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6057 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 }
6059 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306060 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006061#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6062 {
6063 vos_log_ibss_pkt_type *pIbssLog;
6064 tANI_U32 bi;
6065
6066 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6067 if(pIbssLog)
6068 {
6069 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6070 {
6071 //We start the IBSS (didn't find any matched IBSS out there)
6072 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6073 }
6074 else
6075 {
6076 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6077 }
6078 if(pSirBssDesc)
6079 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6082 }
6083 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6084 {
6085 //***U8 is not enough for beacon interval
6086 pIbssLog->beaconInterval = (v_U8_t)bi;
6087 }
6088 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6089 }
6090 }
6091#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6092 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6093 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6095 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6097 csrRoamIssueSetContextReq( pMac, sessionId,
6098 pProfile->negotiatedMCEncryptionType,
6099 pSirBssDesc, &BroadcastMac,
6100 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6101 }
6102 }
6103 else
6104 {
6105 //Keep the state to eCSR_ROAMING_STATE_JOINING
6106 //Need to send join_req.
6107 if(pCommand->u.roamCmd.pRoamBssEntry)
6108 {
6109 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6110 {
6111 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6112 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6113 // Set the roaming substate to 'join attempt'...
6114 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006115 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 }
6117 }
6118 else
6119 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006120 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 VOS_ASSERT( 0 );
6122 }
6123 }
6124 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6125 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6126 //trigger the connection start indication in Vista
6127 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6128 {
6129 roamStatus = eCSR_ROAM_IBSS_IND;
6130 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6131 if( CSR_IS_WDS( pProfile ) )
6132 {
6133 roamStatus = eCSR_ROAM_WDS_IND;
6134 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 if( CSR_IS_INFRA_AP( pProfile ) )
6137 {
6138 roamStatus = eCSR_ROAM_INFRA_IND;
6139 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006141
6142 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6143 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6144 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306145 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6147 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006148 //We start the IBSS (didn't find any matched IBSS out there)
6149 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306151 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6152 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006153 //Remove this code once SLM_Sessionization is supported
6154 //BMPS_WORKAROUND_NOT_NEEDED
6155 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006156 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006157 {
6158 pMac->roam.configParam.doBMPSWorkaround = 1;
6159 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006160
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6162 }
6163
6164 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006165
6166 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 {
6168 //need to send stop BSS because we fail to send join_req
6169 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6170 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6171 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 case eCsrStartBssFailure:
6175#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6176 {
6177 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6179 if(pIbssLog)
6180 {
6181 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6182 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6183 }
6184 }
6185#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 roamStatus = eCSR_ROAM_IBSS_IND;
6187 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6188 if( CSR_IS_WDS( pProfile ) )
6189 {
6190 roamStatus = eCSR_ROAM_WDS_IND;
6191 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 if( CSR_IS_INFRA_AP( pProfile ) )
6194 {
6195 roamStatus = eCSR_ROAM_INFRA_IND;
6196 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 if(Context)
6199 {
6200 pSirBssDesc = (tSirBssDescription *)Context;
6201 }
6202 else
6203 {
6204 pSirBssDesc = NULL;
6205 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306206 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 roamInfo.pBssDesc = pSirBssDesc;
6208 //We need to associate_complete it first, becasue Associate_start already indicated.
6209 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6210 csrSetDefaultDot11Mode( pMac );
6211 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 case eCsrSilentlyStopRoaming:
6213 // We are here because we try to start the same IBSS
6214 //No message to PE
6215 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006216 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6218 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306219 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6221 if( roamInfo.pBssDesc )
6222 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306223 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6224 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 }
6226 //Since there is no change in the current state, simply pass back no result otherwise
6227 //HDD may be mistakenly mark to disconnected state.
6228 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6229 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 case eCsrSilentlyStopRoamingSaveState:
6232 //We are here because we try to connect to the same AP
6233 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006234 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306235 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236
6237 //to aviod resetting the substate to NONE
6238 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6239 //No need to change substate to wai_for_key because there is no state change
6240 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6241 if( roamInfo.pBssDesc )
6242 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306243 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6244 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6247 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6248 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6249 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6250 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6251 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6252 roamInfo.staId = pSession->connectedInfo.staId;
6253 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 pSession->bRefAssocStartCnt--;
6256 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6257 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6258 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6259 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 case eCsrReassocFailure:
6261#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6262 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6263#endif
6264 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006265 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 csrFreeConnectBssDesc(pMac, sessionId);
6267 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6268 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306269 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6271 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6272 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6273 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6274 eCSR_ROAM_WDS_IND,
6275 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6276 //Need to issue stop_bss
6277 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 case eCsrJoinFailure:
6279 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006280 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 default:
6282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006283 smsLog(pMac, LOGW, FL("receives no association indication"));
6284 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006285 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6287 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6288 {
6289 //do not free for the other profiles as we need to send down stop BSS later
6290 csrFreeConnectBssDesc(pMac, sessionId);
6291 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6292 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6293 csrSetDefaultDot11Mode( pMac );
6294 }
6295
6296 switch( pCommand->u.roamCmd.roamReason )
6297 {
6298 // If this transition is because of an 802.11 OID, then we transition
6299 // back to INIT state so we sit waiting for more OIDs to be issued and
6300 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006301 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 case eCsrSmeIssuedAssocToSimilarAP:
6303 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006304 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306306 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6308 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6309 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306310 vos_mem_copy(&roamInfo.bssid,
6311 &pSession->joinFailStatusCode.bssId,
6312 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006313
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 /* Defeaturize this later if needed */
6315#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6316 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6317 if (csrRoamIsHandoffInProgress(pMac))
6318 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 /* Should indicate neighbor roam algorithm about the connect failure here */
6320 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006322#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 if(pSession->bRefAssocStartCnt > 0)
6324 {
6325 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006326 if(eCsrJoinFailureDueToConcurrency == Result)
6327 {
6328 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6329 eCSR_ROAM_ASSOCIATION_COMPLETION,
6330 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6331 }
6332 else
6333 {
6334 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 eCSR_ROAM_ASSOCIATION_COMPLETION,
6336 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006339 else
6340 {
6341 /* bRefAssocStartCnt is not incremented when
6342 * eRoamState == eCsrStopRoamingDueToConcurrency
6343 * in csrRoamJoinNextBss API. so handle this in
6344 * else case by sending assoc failure
6345 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006346 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006347 pCommand->u.scanCmd.roamId,
6348 eCSR_ROAM_ASSOCIATION_FAILURE,
6349 eCSR_ROAM_RESULT_FAILURE);
6350 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006351 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306353 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6355#endif
6356 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6357 csrScanStartIdleScan(pMac);
6358#ifdef FEATURE_WLAN_BTAMP_UT_RF
6359 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6360 //BT activity and not able to recevie WLAN traffic. Retry the join
6361 if( CSR_IS_WDS_STA(pProfile) )
6362 {
6363 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6364 }
6365#endif
6366 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 case eCsrHddIssuedReassocToSameAP:
6368 case eCsrSmeIssuedReassocToSameAP:
6369 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6370
6371 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6372#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6373 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6374#endif
6375 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6376 csrScanStartIdleScan(pMac);
6377 break;
6378 case eCsrForcedDisassoc:
6379 case eCsrForcedDeauth:
6380 case eCsrSmeIssuedIbssJoinFailure:
6381 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6382
6383 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6384 {
6385 // Notify HDD that IBSS join failed
6386 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6387 }
6388 else
6389 {
6390 csrRoamCallCallback(pMac, sessionId, NULL,
6391 pCommand->u.roamCmd.roamId,
6392 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6393 }
6394#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6395 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6396#endif
6397 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006398 /*
6399 *DelSta not done FW still in conneced state so dont
6400 *issue IMPS req
6401 */
6402 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6403 {
6404 smsLog(pMac, LOGW, FL("FW still in connected state "));
6405 break;
6406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 csrScanStartIdleScan(pMac);
6408 break;
6409 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306410 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 csrRoamCallCallback(pMac, sessionId, NULL,
6412 pCommand->u.roamCmd.roamId,
6413 eCSR_ROAM_IBSS_LEAVE,
6414 eCSR_ROAM_RESULT_IBSS_STOP);
6415 break;
6416 case eCsrForcedDisassocMICFailure:
6417 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6418
6419 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6420#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6421 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6422#endif
6423 csrScanStartIdleScan(pMac);
6424 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 case eCsrStopBss:
6426 csrRoamCallCallback(pMac, sessionId, NULL,
6427 pCommand->u.roamCmd.roamId,
6428 eCSR_ROAM_INFRA_IND,
6429 eCSR_ROAM_RESULT_INFRA_STOPPED);
6430 break;
6431 case eCsrForcedDisassocSta:
6432 case eCsrForcedDeauthSta:
6433 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306434 pSession = CSR_GET_SESSION(pMac, sessionId);
6435 if (pSession)
6436 {
6437 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306439 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6440 {
6441 roamInfo.u.pConnectedProfile =
6442 &pSession->connectedProfile;
6443 vos_mem_copy(roamInfo.peerMac,
6444 pCommand->u.roamCmd.peerMac,
6445 sizeof(tSirMacAddr));
6446 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6447 roamInfo.statusCode = eSIR_SME_SUCCESS;
6448 status = csrRoamCallCallback(pMac, sessionId,
6449 &roamInfo, pCommand->u.roamCmd.roamId,
6450 eCSR_ROAM_LOSTLINK,
6451 eCSR_ROAM_RESULT_FORCED);
6452 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306453 }
6454 else
6455 {
6456 smsLog(pMac, LOGE, FL("Inactive session %d"),
6457 sessionId);
6458 return eHAL_STATUS_FAILURE;
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306461 else
6462 {
6463 smsLog(pMac, LOGE, FL("Invalid session"));
6464 return eHAL_STATUS_FAILURE;
6465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 case eCsrLostLink1:
6468 // if lost link roam1 failed, then issue lost link Scan2 ...
6469 csrScanRequestLostLink2(pMac, sessionId);
6470 break;
6471 case eCsrLostLink2:
6472 // if lost link roam2 failed, then issue lost link scan3 ...
6473 csrScanRequestLostLink3(pMac, sessionId);
6474 break;
6475 case eCsrLostLink3:
6476 default:
6477 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6478
6479 //We are done with one round of lostlink roaming here
6480 csrScanHandleFailedLostlink3(pMac, sessionId);
6481 break;
6482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 break;
6484 }
6485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 return ( fReleaseCommand );
6487}
6488
Jeff Johnson295189b2012-06-20 16:38:30 -07006489eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6490{
6491 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 return (status);
6493}
6494
Jeff Johnson295189b2012-06-20 16:38:30 -07006495eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6496{
6497 eHalStatus status = eHAL_STATUS_SUCCESS;
6498 tANI_U32 size = 0;
6499
6500 do
6501 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306502 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6504 {
6505 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306506 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6507 if ( NULL == pDstProfile->BSSIDs.bssid )
6508 status = eHAL_STATUS_FAILURE;
6509 else
6510 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 if(!HAL_STATUS_SUCCESS(status))
6512 {
6513 break;
6514 }
6515 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306516 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6517 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
6519 if(pSrcProfile->SSIDs.numOfSSIDs)
6520 {
6521 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306522 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6523 if ( NULL == pDstProfile->SSIDs.SSIDList )
6524 status = eHAL_STATUS_FAILURE;
6525 else
6526 status = eHAL_STATUS_SUCCESS;
6527 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 {
6529 break;
6530 }
6531 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306532 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6533 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 }
6535 if(pSrcProfile->nWPAReqIELength)
6536 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306537 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6538 if ( NULL == pDstProfile->pWPAReqIE )
6539 status = eHAL_STATUS_FAILURE;
6540 else
6541 status = eHAL_STATUS_SUCCESS;
6542
6543 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 {
6545 break;
6546 }
6547 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306548 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6549 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 }
6551 if(pSrcProfile->nRSNReqIELength)
6552 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306553 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6554 if ( NULL == pDstProfile->pRSNReqIE )
6555 status = eHAL_STATUS_FAILURE;
6556 else
6557 status = eHAL_STATUS_SUCCESS;
6558
6559 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 {
6561 break;
6562 }
6563 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306564 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6565 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 }
6567#ifdef FEATURE_WLAN_WAPI
6568 if(pSrcProfile->nWAPIReqIELength)
6569 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306570 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6571 if ( NULL == pDstProfile->pWAPIReqIE )
6572 status = eHAL_STATUS_FAILURE;
6573 else
6574 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 if(!HAL_STATUS_SUCCESS(status))
6576 {
6577 break;
6578 }
6579 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306580 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6581 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 }
6583#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 if(pSrcProfile->nAddIEScanLength)
6585 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306586 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6587 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306589 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306590 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306591 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6592 }
6593 else
6594 {
6595 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6596 FL(" AddIEScanLength is not valid %u"),
6597 pSrcProfile->nAddIEScanLength);
6598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 if(pSrcProfile->nAddIEAssocLength)
6601 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306602 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6603 if ( NULL == pDstProfile->pAddIEAssoc )
6604 status = eHAL_STATUS_FAILURE;
6605 else
6606 status = eHAL_STATUS_SUCCESS;
6607
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 if(!HAL_STATUS_SUCCESS(status))
6609 {
6610 break;
6611 }
6612 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306613 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6614 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 if(pSrcProfile->ChannelInfo.ChannelList)
6617 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306618 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6619 pSrcProfile->ChannelInfo.numOfChannels);
6620 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6621 status = eHAL_STATUS_FAILURE;
6622 else
6623 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 if(!HAL_STATUS_SUCCESS(status))
6625 {
6626 break;
6627 }
6628 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306629 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6630 pSrcProfile->ChannelInfo.ChannelList,
6631 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 pDstProfile->AuthType = pSrcProfile->AuthType;
6634 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6635 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6636 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6637 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6638 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006639#ifdef WLAN_FEATURE_11W
6640 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6641 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6642 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6643#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 pDstProfile->BSSType = pSrcProfile->BSSType;
6645 pDstProfile->phyMode = pSrcProfile->phyMode;
6646 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6647
6648#ifdef FEATURE_WLAN_WAPI
6649 if(csrIsProfileWapi(pSrcProfile))
6650 {
6651 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6652 {
6653 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6654 }
6655 }
6656#endif /* FEATURE_WLAN_WAPI */
6657 pDstProfile->CBMode = pSrcProfile->CBMode;
6658 /*Save the WPS info*/
6659 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006660 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 pDstProfile->privacy = pSrcProfile->privacy;
6664 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6665 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6666 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6667 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6668 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6669 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6670 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6671 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6672 pDstProfile->wps_state = pSrcProfile->wps_state;
6673 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Abhishek Singhe3beee22017-07-31 15:35:40 +05306674 pDstProfile->force_24ghz_in_ht20 =
6675 pSrcProfile->force_24ghz_in_ht20;
Kiet Lam64c1b492013-07-12 13:56:44 +05306676 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6677 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006678#ifdef WLAN_FEATURE_VOWIFI_11R
6679 if (pSrcProfile->MDID.mdiePresent)
6680 {
6681 pDstProfile->MDID.mdiePresent = 1;
6682 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6683 }
6684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 }while(0);
6686
6687 if(!HAL_STATUS_SUCCESS(status))
6688 {
6689 csrReleaseProfile(pMac, pDstProfile);
6690 pDstProfile = NULL;
6691 }
6692
6693 return (status);
6694}
Jeff Johnson295189b2012-06-20 16:38:30 -07006695eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6696{
6697 eHalStatus status = eHAL_STATUS_SUCCESS;
6698 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6699 do
6700 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306701 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 if(pSrcProfile->bssid)
6703 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306704 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6705 if ( NULL == pDstProfile->BSSIDs.bssid )
6706 status = eHAL_STATUS_FAILURE;
6707 else
6708 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 if(!HAL_STATUS_SUCCESS(status))
6710 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306711 smsLog( pMac, LOGE,
6712 FL("failed to allocate memory for BSSID"
6713 "%02x:%02x:%02x:%02x:%02x:%02x"),
6714 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6715 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 break;
6717 }
6718 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306719 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6720 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 }
6722 if(pSrcProfile->SSID.ssId)
6723 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306724 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6725 if ( NULL == pDstProfile->SSIDs.SSIDList )
6726 status = eHAL_STATUS_FAILURE;
6727 else
6728 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 if(!HAL_STATUS_SUCCESS(status))
6730 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306731 smsLog( pMac, LOGE,
6732 FL("failed to allocate memory for SSIDList"
6733 "%02x:%02x:%02x:%02x:%02x:%02x"),
6734 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6735 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 break;
6737 }
6738 pDstProfile->SSIDs.numOfSSIDs = 1;
6739 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6740 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306741 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6742 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006744 if(pSrcProfile->nAddIEAssocLength)
6745 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306746 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6747 if ( NULL == pDstProfile->pAddIEAssoc)
6748 status = eHAL_STATUS_FAILURE;
6749 else
6750 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006751 if(!HAL_STATUS_SUCCESS(status))
6752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006753 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006754 break;
6755 }
6756 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306757 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6758 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006759 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306760 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6761 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6762 status = eHAL_STATUS_FAILURE;
6763 else
6764 status = eHAL_STATUS_SUCCESS;
6765
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 if(!HAL_STATUS_SUCCESS(status))
6767 {
6768 break;
6769 }
6770 pDstProfile->ChannelInfo.numOfChannels = 1;
6771 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 pDstProfile->AuthType.numEntries = 1;
6773 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6774 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6775 pDstProfile->EncryptionType.numEntries = 1;
6776 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6777 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6778 pDstProfile->mcEncryptionType.numEntries = 1;
6779 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6780 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6781 pDstProfile->BSSType = pSrcProfile->BSSType;
6782 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306783 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6784 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306785#ifdef WLAN_FEATURE_11W
6786 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6787 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6788 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6789#endif
6790
Jeff Johnson295189b2012-06-20 16:38:30 -07006791#ifdef WLAN_FEATURE_VOWIFI_11R
6792 if (pSrcProfile->MDID.mdiePresent)
6793 {
6794 pDstProfile->MDID.mdiePresent = 1;
6795 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6796 }
6797#endif
6798
6799 }while(0);
6800
6801 if(!HAL_STATUS_SUCCESS(status))
6802 {
6803 csrReleaseProfile(pMac, pDstProfile);
6804 pDstProfile = NULL;
6805 }
6806
6807 return (status);
6808}
6809
Jeff Johnson295189b2012-06-20 16:38:30 -07006810eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6811 tScanResultHandle hBSSList,
6812 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6813 tANI_BOOLEAN fClearScan)
6814{
6815 eHalStatus status = eHAL_STATUS_SUCCESS;
6816 tSmeCmd *pCommand;
6817
6818 pCommand = csrGetCommandBuffer(pMac);
6819 if(NULL == pCommand)
6820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006821 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 status = eHAL_STATUS_RESOURCES;
6823 }
6824 else
6825 {
6826 if( fClearScan )
6827 {
6828 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306829 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 }
6831 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6832 if(NULL == pProfile)
6833 {
6834 //We can roam now
6835 //Since pProfile is NULL, we need to build our own profile, set everything to default
6836 //We can only support open and no encryption
6837 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6838 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6839 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6840 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6841 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6842 }
6843 else
6844 {
6845 //make a copy of the profile
6846 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6847 if(HAL_STATUS_SUCCESS(status))
6848 {
6849 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6850 }
6851 }
6852 pCommand->command = eSmeCommandRoam;
6853 pCommand->sessionId = (tANI_U8)sessionId;
6854 pCommand->u.roamCmd.hBSSList = hBSSList;
6855 pCommand->u.roamCmd.roamId = roamId;
6856 pCommand->u.roamCmd.roamReason = reason;
6857 //We need to free the BssList when the command is done
6858 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6859 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6861 FL("CSR PERSONA=%d"),
6862 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6864 if( !HAL_STATUS_SUCCESS( status ) )
6865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006866 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 csrReleaseCommandRoam( pMac, pCommand );
6868 }
6869 }
6870
6871 return (status);
6872}
Jeff Johnson295189b2012-06-20 16:38:30 -07006873eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6874 tCsrRoamModifyProfileFields *pMmodProfileFields,
6875 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6876{
6877 eHalStatus status = eHAL_STATUS_SUCCESS;
6878 tSmeCmd *pCommand;
6879
6880 pCommand = csrGetCommandBuffer(pMac);
6881 if(NULL == pCommand)
6882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006883 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 status = eHAL_STATUS_RESOURCES;
6885 }
6886 else
6887 {
6888 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306889 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 if(pProfile)
6891 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006892 //This is likely trying to reassoc to different profile
6893 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6894 //make a copy of the profile
6895 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6896 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 }
6898 else
6899 {
6900 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6901 //how to update WPA/WPA2 info in roamProfile??
6902 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 if(HAL_STATUS_SUCCESS(status))
6905 {
6906 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6907 }
6908 pCommand->command = eSmeCommandRoam;
6909 pCommand->sessionId = (tANI_U8)sessionId;
6910 pCommand->u.roamCmd.roamId = roamId;
6911 pCommand->u.roamCmd.roamReason = reason;
6912 //We need to free the BssList when the command is done
6913 //For reassoc there is no BSS list, so the boolean set to false
6914 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6915 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6916 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6918 if( !HAL_STATUS_SUCCESS( status ) )
6919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006920 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6922 csrReleaseCommandRoam( pMac, pCommand );
6923 }
6924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 return (status);
6926}
6927
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006928eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6929 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306930// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006931{
6932 eHalStatus status = eHAL_STATUS_SUCCESS;
6933 tSmeCmd *pCommand;
6934
6935 pCommand = csrGetCommandBuffer(pMac);
6936 if(NULL == pCommand)
6937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006938 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006939 status = eHAL_STATUS_RESOURCES;
6940 }
6941 else
6942 {
6943 if(pBssDescription)
6944 {
6945 //copy over the parameters we need later
6946 pCommand->command = eSmeCommandRoam;
6947 pCommand->sessionId = (tANI_U8)sessionId;
6948 pCommand->u.roamCmd.roamReason = reason;
6949 //this is the important parameter
6950 //in this case we are using this field for the "next" BSS
6951 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6952 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6953 if( !HAL_STATUS_SUCCESS( status ) )
6954 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006955 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006956 csrReleaseCommandPreauth( pMac, pCommand );
6957 }
6958 }
6959 else
6960 {
6961 //Return failure
6962 status = eHAL_STATUS_RESOURCES;
6963 }
6964 }
6965 return (status);
6966}
6967
6968eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6969{
6970 tListElem *pEntry;
6971 tSmeCmd *pCommand;
6972 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6973 if ( pEntry )
6974 {
6975 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6976 if ( (eSmeCommandRoam == pCommand->command) &&
6977 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6978 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006979 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006980 pCommand->command, pCommand->u.roamCmd.roamReason);
6981 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6982 csrReleaseCommandPreauth( pMac, pCommand );
6983 }
6984 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006985 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006986 pCommand->command, pCommand->u.roamCmd.roamReason);
6987 }
6988 }
6989 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006990 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006991 }
6992 smeProcessPendingQueue( pMac );
6993 return eHAL_STATUS_SUCCESS;
6994}
6995
Jeff Johnson295189b2012-06-20 16:38:30 -07006996eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6997 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6998{
6999 eHalStatus status = eHAL_STATUS_FAILURE;
7000 tScanResultHandle hBSSList;
7001 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
7003 if(HAL_STATUS_SUCCESS(status))
7004 {
7005 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7006 if(pRoamId)
7007 {
7008 *pRoamId = roamId;
7009 }
7010 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7011 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7012 if(!HAL_STATUS_SUCCESS(status))
7013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007014 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 csrScanResultPurge(pMac, hBSSList);
7016 }
7017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 return (status);
7019}
7020
Jeff Johnson295189b2012-06-20 16:38:30 -07007021eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7022 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7023{
7024 eHalStatus status = eHAL_STATUS_SUCCESS;
7025 tScanResultHandle hBSSList;
7026 tCsrScanResultFilter *pScanFilter;
7027 tANI_U32 roamId = 0;
7028 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
7029 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 if (NULL == pProfile)
7031 {
7032 smsLog(pMac, LOGP, FL("No profile specified"));
7033 return eHAL_STATUS_FAILURE;
7034 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307035 if(!pSession)
7036 {
7037 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7038 return eHAL_STATUS_FAILURE;
7039 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307040 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7041 "encryType = %d"),
7042 lim_BssTypetoString(pProfile->BSSType),
7043 pProfile->BSSType,
7044 pProfile->AuthType.authType[0],
7045 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 if( CSR_IS_WDS( pProfile ) &&
7047 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
7048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007049 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007050 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 return status;
7052 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307053 /* Reset abortConnection for the fresh connection */
7054 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 csrRoamCancelRoaming(pMac, sessionId);
7056 csrScanRemoveFreshScanCommand(pMac, sessionId);
7057 csrScanCancelIdleScan(pMac);
7058 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307059 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307060
7061 if (!vos_concurrent_open_sessions_running() &&
7062 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307064 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 csrScanDisable(pMac);
7066 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307067
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7069 //Check whether ssid changes
7070 if(csrIsConnStateConnected(pMac, sessionId))
7071 {
7072 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7073 {
7074 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7075 }
7076 }
7077#ifdef FEATURE_WLAN_BTAMP_UT_RF
7078 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7079#endif
Abhishek Singh5de9efd2017-06-15 10:22:39 +05307080
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007083 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7085 if(pRoamId)
7086 {
7087 roamId = *pRoamId;
7088 }
7089 if(!HAL_STATUS_SUCCESS(status))
7090 {
7091 fCallCallback = eANI_BOOLEAN_TRUE;
7092 }
7093 }
7094 else
7095 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307096 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7097 if ( NULL == pScanFilter )
7098 status = eHAL_STATUS_FAILURE;
7099 else
7100 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007101 if(HAL_STATUS_SUCCESS(status))
7102 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307103 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 //Try to connect to any BSS
7105 if(NULL == pProfile)
7106 {
7107 //No encryption
7108 pScanFilter->EncryptionType.numEntries = 1;
7109 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7110 }//we don't have a profile
7111 else
7112 {
7113 //Here is the profile we need to connect to
7114 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7115 }//We have a profile
7116 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7117 if(pRoamId)
7118 {
7119 *pRoamId = roamId;
7120 }
7121
7122 if(HAL_STATUS_SUCCESS(status))
7123 {
7124 /*Save the WPS info*/
7125 if(NULL != pProfile)
7126 {
7127 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007128 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 }
7130 else
7131 {
7132 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007133 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 do
7136 {
7137 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 )
7140 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007141 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7143 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7144 if(!HAL_STATUS_SUCCESS(status))
7145 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007146 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 fCallCallback = eANI_BOOLEAN_TRUE;
7148 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007149 else
7150 {
7151 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 break;
7154 }
7155 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007156 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 if(HAL_STATUS_SUCCESS(status))
7158 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7160 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7161 if(!HAL_STATUS_SUCCESS(status))
7162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007163 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 csrScanResultPurge(pMac, hBSSList);
7165 fCallCallback = eANI_BOOLEAN_TRUE;
7166 }
7167 }//Have scan result
7168 else if(NULL != pProfile)
7169 {
7170 //Check whether it is for start ibss
7171 if(CSR_IS_START_IBSS(pProfile))
7172 {
7173 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7174 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7175 if(!HAL_STATUS_SUCCESS(status))
7176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007177 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 fCallCallback = eANI_BOOLEAN_TRUE;
7179 }
7180 }
7181 else
7182 {
7183 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007184 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 if(!HAL_STATUS_SUCCESS(status))
7186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007187 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 fCallCallback = eANI_BOOLEAN_TRUE;
7189 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007190 else
7191 {
7192 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 }
7195 }
7196 else
7197 {
7198 fCallCallback = eANI_BOOLEAN_TRUE;
7199 }
7200 } while (0);
7201 if(NULL != pProfile)
7202 {
7203 //we need to free memory for filter if profile exists
7204 csrFreeScanFilter(pMac, pScanFilter);
7205 }
7206 }//Got the scan filter from profile
7207
Kiet Lam64c1b492013-07-12 13:56:44 +05307208 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 }//allocated memory for pScanFilter
7210 }//No Bsslist coming in
7211 //tell the caller if we fail to trigger a join request
7212 if( fCallCallback )
7213 {
7214 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7215 }
7216
7217 return (status);
7218}
Jeff Johnson295189b2012-06-20 16:38:30 -07007219eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7220 tCsrRoamModifyProfileFields modProfileFields,
7221 tANI_U32 *pRoamId)
7222{
7223 eHalStatus status = eHAL_STATUS_SUCCESS;
7224 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7225 tANI_U32 roamId = 0;
7226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 if (NULL == pProfile)
7228 {
7229 smsLog(pMac, LOGP, FL("No profile specified"));
7230 return eHAL_STATUS_FAILURE;
7231 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307232 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7233 "encryType = %d"),
7234 lim_BssTypetoString(pProfile->BSSType),
7235 pProfile->BSSType,
7236 pProfile->AuthType.authType[0],
7237 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 csrRoamCancelRoaming(pMac, sessionId);
7239 csrScanRemoveFreshScanCommand(pMac, sessionId);
7240 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307241 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007242 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 if(csrIsConnStateConnected(pMac, sessionId))
7244 {
7245 if(pProfile)
7246 {
7247 if(pProfile->SSIDs.numOfSSIDs &&
7248 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7249 {
7250 fCallCallback = eANI_BOOLEAN_FALSE;
7251 }
7252 else
7253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007254 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 }
7256 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307257 else if (!vos_mem_compare(&modProfileFields,
7258 &pSession->connectedProfile.modifyProfileFields,
7259 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 {
7261 fCallCallback = eANI_BOOLEAN_FALSE;
7262 }
7263 else
7264 {
7265 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007266 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 }
7268 }
7269 else
7270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007271 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 if(!fCallCallback)
7274 {
7275 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7276 if(pRoamId)
7277 {
7278 *pRoamId = roamId;
7279 }
7280
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7282 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 }
7284 else
7285 {
7286 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7287 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 return status;
7290}
Jeff Johnson295189b2012-06-20 16:38:30 -07007291eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7292{
7293 eHalStatus status = eHAL_STATUS_FAILURE;
7294 tScanResultHandle hBSSList = NULL;
7295 tCsrScanResultFilter *pScanFilter = NULL;
7296 tANI_U32 roamId;
7297 tCsrRoamProfile *pProfile = NULL;
7298 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007299
7300 if(!pSession)
7301 {
7302 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7303 return eHAL_STATUS_FAILURE;
7304 }
7305
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 do
7307 {
7308 if(pSession->pCurRoamProfile)
7309 {
7310 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307311 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307313 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7314 if ( NULL == pProfile )
7315 status = eHAL_STATUS_FAILURE;
7316 else
7317 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 if(!HAL_STATUS_SUCCESS(status))
7319 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307320 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307322 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307324 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7325 if ( NULL == pScanFilter )
7326 status = eHAL_STATUS_FAILURE;
7327 else
7328 status = eHAL_STATUS_SUCCESS;
7329
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 if(!HAL_STATUS_SUCCESS(status))
7331 {
7332 break;
7333 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307334 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7336 if(!HAL_STATUS_SUCCESS(status))
7337 {
7338 break;
7339 }
7340 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7341 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7342 if(HAL_STATUS_SUCCESS(status))
7343 {
7344 //we want to put the last connected BSS to the very beginning, if possible
7345 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7346 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7347 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7348 if(!HAL_STATUS_SUCCESS(status))
7349 {
7350 csrScanResultPurge(pMac, hBSSList);
7351 break;
7352 }
7353 }
7354 else
7355 {
7356 //Do a scan on this profile
7357 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007358 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 if(!HAL_STATUS_SUCCESS(status))
7360 {
7361 break;
7362 }
7363 }
7364 }//We have a profile
7365 else
7366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007367 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 break;
7369 }
7370 }while(0);
7371 if(pScanFilter)
7372 {
7373 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307374 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 }
7376 if(NULL != pProfile)
7377 {
7378 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307379 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 return (status);
7382}
Jeff Johnson295189b2012-06-20 16:38:30 -07007383eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7384{
7385 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 if(csrIsConnStateConnected(pMac, sessionId))
7387 {
7388 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7389 if(HAL_STATUS_SUCCESS(status))
7390 {
7391 status = csrRoamJoinLastProfile(pMac, sessionId);
7392 }
7393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 return (status);
7395}
7396
Jeff Johnson295189b2012-06-20 16:38:30 -07007397eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7398{
7399 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007400 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 csrRoamCancelRoaming(pMac, sessionId);
7402 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7403 if(csrIsConnStateDisconnected(pMac, sessionId))
7404 {
7405 status = csrRoamJoinLastProfile(pMac, sessionId);
7406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 return (status);
7408}
7409
Jeff Johnson295189b2012-06-20 16:38:30 -07007410eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7411{
7412 eHalStatus status = eHAL_STATUS_SUCCESS;
7413 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7414 eCsrRoamSubState NewSubstate;
7415 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307416
7417 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7418 {
7419 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7420 " eCSR_ROAM_SUBSTATE_NONE"));
7421 csrRoamStopWaitForKeyTimer( pMac );
7422 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 // change state to 'Roaming'...
7425 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7426
7427 if ( csrIsConnStateIbss( pMac, sessionId ) )
7428 {
7429 // If we are in an IBSS, then stop the IBSS...
7430 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7431 fComplete = (!HAL_STATUS_SUCCESS(status));
7432 }
7433 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007435 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 -07007436 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7437 //Restore AC weight in case we change it
7438 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7439 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7440 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7441 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7442 {
7443 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7444 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307445 else
7446 {
7447 // If we are in neighbor preauth done state then on receiving
7448 // disassoc or deauth we dont roam instead we just disassoc
7449 // from current ap and then go to disconnected state
7450 // This happens for ESE and 11r FT connections ONLY.
7451#ifdef WLAN_FEATURE_VOWIFI_11R
7452 if (csrRoamIs11rAssoc(pMac) &&
7453 (csrNeighborRoamStatePreauthDone(pMac)))
7454 {
7455 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7456 }
7457#endif
7458#ifdef FEATURE_WLAN_ESE
7459 if (csrRoamIsESEAssoc(pMac) &&
7460 (csrNeighborRoamStatePreauthDone(pMac)))
7461 {
7462 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7463 }
7464#endif
7465#ifdef FEATURE_WLAN_LFR
7466 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7467 (csrNeighborRoamStatePreauthDone(pMac)))
7468 {
7469 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7470 }
7471#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307472#ifdef WLAN_FEATURE_LFR_MBB
7473 csr_stop_preauth_reassoc_mbb_timer(pMac);
7474#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307475 }
7476
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 if( fDisassoc )
7478 {
7479 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307480 if (pMac->roam.configParam.roamDelayStatsEnabled)
7481 {
7482 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 }
7485 else
7486 {
7487 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7488 }
7489 fComplete = (!HAL_STATUS_SUCCESS(status));
7490 }
7491 else if ( csrIsConnStateWds( pMac, sessionId ) )
7492 {
7493 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7494 {
7495 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7496 fComplete = (!HAL_STATUS_SUCCESS(status));
7497 }
7498 //This has to be WDS station
7499 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7500 {
7501
7502 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7503 if( fDisassoc )
7504 {
7505 status = csrRoamIssueDisassociate( pMac, sessionId,
7506 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7507 fComplete = (!HAL_STATUS_SUCCESS(status));
7508 }
7509 }
7510 } else {
7511 // we got a dis-assoc request while not connected to any peer
7512 // just complete the command
7513 fComplete = eANI_BOOLEAN_TRUE;
7514 status = eHAL_STATUS_FAILURE;
7515 }
7516 if(fComplete)
7517 {
7518 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7519 }
7520
7521 if(HAL_STATUS_SUCCESS(status))
7522 {
7523 if ( csrIsConnStateInfra( pMac, sessionId ) )
7524 {
7525 //Set the state to disconnect here
7526 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307527#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7528 //we don't need to run this timer any more
7529 if (VOS_TIMER_STATE_RUNNING ==
7530 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7531 {
7532 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7533 if (status != eHAL_STATUS_SUCCESS)
7534 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7535 }
7536#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 }
7538 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007539 else
7540 {
7541 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 return (status);
7544}
7545
Jeff Johnson295189b2012-06-20 16:38:30 -07007546/* This is been removed from latest code base */
7547/*
7548static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7549{
7550 eHalStatus status;
7551 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007552 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7553 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 return ( status );
7555}
7556*/
7557
Jeff Johnson295189b2012-06-20 16:38:30 -07007558eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7559{
7560 eHalStatus status = eHAL_STATUS_SUCCESS;
7561 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307562
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 do
7564 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 pCommand = csrGetCommandBuffer( pMac );
7566 if ( !pCommand )
7567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007568 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 status = eHAL_STATUS_RESOURCES;
7570 break;
7571 }
7572 //Change the substate in case it is wait-for-key
7573 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7574 {
7575 csrRoamStopWaitForKeyTimer( pMac );
7576 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7577 }
7578 pCommand->command = eSmeCommandRoam;
7579 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307580 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7581 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 switch ( reason )
7583 {
7584 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7585 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 case eCSR_DISCONNECT_REASON_DEAUTH:
7588 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7594 case eCSR_DISCONNECT_REASON_DISASSOC:
7595 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7598 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7601 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7602 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 default:
7604 break;
7605 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307606 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 if( !HAL_STATUS_SUCCESS( status ) )
7608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007609 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 csrReleaseCommandRoam( pMac, pCommand );
7611 }
7612 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 return( status );
7614}
7615
Jeff Johnson295189b2012-06-20 16:38:30 -07007616eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7617{
7618 eHalStatus status = eHAL_STATUS_SUCCESS;
7619 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 pCommand = csrGetCommandBuffer( pMac );
7621 if ( NULL != pCommand )
7622 {
7623 //Change the substate in case it is wait-for-key
7624 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7625 {
7626 csrRoamStopWaitForKeyTimer( pMac );
7627 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7628 }
7629 pCommand->command = eSmeCommandRoam;
7630 pCommand->sessionId = (tANI_U8)sessionId;
7631 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7632 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7633 if( !HAL_STATUS_SUCCESS( status ) )
7634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007635 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 csrReleaseCommandRoam( pMac, pCommand );
7637 }
7638 }
7639 else
7640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007641 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 status = eHAL_STATUS_RESOURCES;
7643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 return ( status );
7645}
7646
Jeff Johnson295189b2012-06-20 16:38:30 -07007647eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7648{
7649 eHalStatus status = eHAL_STATUS_SUCCESS;
7650 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007651
7652 if(!pSession)
7653 {
7654 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7655 return eHAL_STATUS_FAILURE;
7656 }
7657
Jeff Johnson295189b2012-06-20 16:38:30 -07007658#ifdef FEATURE_WLAN_BTAMP_UT_RF
7659 //Stop te retry
7660 pSession->maxRetryCount = 0;
7661 csrRoamStopJoinRetryTimer(pMac, sessionId);
7662#endif
7663 //Not to call cancel roaming here
7664 //Only issue disconnect when necessary
7665 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7666 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7667 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7668
7669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007670 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7672 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307673 else
7674 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307675 csrScanAbortScanForSSID(pMac, sessionId);
Mukul Sharma11841b42017-07-05 13:10:09 +05307676 csrScanStartIdleScan(pMac);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307677 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307678 smsLog(pMac, LOGE,
7679 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 return (status);
7682}
7683
Jeff Johnson295189b2012-06-20 16:38:30 -07007684eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7685{
7686 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007687
7688 if(!pSession)
7689 {
7690 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7691 return eHAL_STATUS_FAILURE;
7692 }
7693
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7696
7697 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7698}
7699
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307700void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7701{
7702 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7703 if(!pSession)
7704 {
7705 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7706 return;
7707 }
7708 pSession->abortConnection = TRUE;
7709 return;
7710}
7711
Jeff Johnson295189b2012-06-20 16:38:30 -07007712eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7713 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7714{
7715 eHalStatus status = eHAL_STATUS_SUCCESS;
7716 tDot11fBeaconIEs *pIesTemp = pIes;
7717 tANI_U8 index;
7718 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7719 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007720
7721 if(!pSession)
7722 {
7723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7724 return eHAL_STATUS_FAILURE;
7725 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007726 if(pConnectProfile->pAddIEAssoc)
7727 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307728 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007729 pConnectProfile->pAddIEAssoc = NULL;
7730 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307731 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007732 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7733 pConnectProfile->AuthInfo = pProfile->AuthType;
7734 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7735 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7736 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7737 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7738 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7739 pConnectProfile->BSSType = pProfile->BSSType;
7740 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7741 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007742 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307743 if (!pConnectProfile->beaconInterval)
7744 {
7745 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7746 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307747 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007748 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7749 if(pProfile->nAddIEAssocLength)
7750 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307751 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7752 if ( NULL == pConnectProfile->pAddIEAssoc )
7753 status = eHAL_STATUS_FAILURE;
7754 else
7755 status = eHAL_STATUS_SUCCESS;
7756 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007757 {
7758 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7759 return eHAL_STATUS_FAILURE;
7760 }
7761 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307762 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7763 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007764 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307765
7766#ifdef WLAN_FEATURE_11W
7767 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7768 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7769 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7770#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007771
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 //Save bssid
7773 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7774#ifdef WLAN_FEATURE_VOWIFI_11R
7775 if (pSirBssDesc->mdiePresent)
7776 {
7777 pConnectProfile->MDID.mdiePresent = 1;
7778 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7779 }
7780#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007781 if( NULL == pIesTemp )
7782 {
7783 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7784 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007785#ifdef FEATURE_WLAN_ESE
7786 if ((csrIsProfileESE(pProfile) ||
7787 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307788 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7789 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7790 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7791 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7792#ifdef WLAN_FEATURE_11W
7793 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307794 || (pProfile->negotiatedAuthType ==
7795 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307796#endif
7797 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007798 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007800 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 }
7802#endif
7803 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 if(HAL_STATUS_SUCCESS(status))
7805 {
7806 if(pIesTemp->SSID.present)
7807 {
7808 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307809 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7810 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 }
7812
7813 //Save the bss desc
7814 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307815
7816 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307818 //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 -07007819 pConnectProfile->qap = TRUE;
7820 }
7821 else
7822 {
7823 pConnectProfile->qap = FALSE;
7824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 if ( NULL == pIes )
7826 {
7827 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307828 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 }
7830 }
7831 //Save Qos connection
7832 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7833
7834 if(!HAL_STATUS_SUCCESS(status))
7835 {
7836 csrFreeConnectBssDesc(pMac, sessionId);
7837 }
7838 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7839 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307840 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7841 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7842 pConnectProfile->SSID.ssId,
7843 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 {
7845 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7846 break;
7847 }
7848 pConnectProfile->handoffPermitted = FALSE;
7849 }
7850
7851 return (status);
7852}
7853
Jeff Johnson295189b2012-06-20 16:38:30 -07007854static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7855{
7856 tListElem *pEntry = NULL;
7857 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307858 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 //The head of the active list is the request we sent
7860 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7861 if(pEntry)
7862 {
7863 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7864 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307865 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7867 {
7868 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7869 {
7870#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7871 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7872#endif
7873 }
7874 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307875 if(!pSession)
7876 {
7877 smsLog(pMac, LOGE, FL(" session %d not found "),
7878 pSmeJoinRsp->sessionId);
7879 return;
7880 }
7881 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 }
7883 else
7884 {
7885 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007886 if(!pSession)
7887 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307888 smsLog(pMac, LOGE, FL(" session %d not found "),
7889 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007890 return;
7891 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307892 if (pSession->abortConnection)
7893 {
7894 smsLog(pMac, LOG1, FL("Disconnection in progess"
7895 "abort Join request"));
7896 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7897 pSession->abortConnection = FALSE;
7898 return;
7899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 //The head of the active list is the request we sent
7901 //Try to get back the same profile and roam again
7902 if(pCommand)
7903 {
7904 roamId = pCommand->u.roamCmd.roamId;
7905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7907 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007908 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007909#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7910 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7911 if (csrRoamIsHandoffInProgress(pMac))
7912 {
7913 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7914 /* Should indicate neighbor roam algorithm about the connect failure here */
7915 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7916 }
7917#endif
7918 if (pCommand)
7919 {
7920 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7921 {
7922 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7923 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7924 csrRoamReissueRoamCommand(pMac);
7925 }
7926 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7927 {
7928 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7929 }
7930 else
7931 {
7932 csrRoam(pMac, pCommand);
7933 }
7934 }
7935 else
7936 {
7937 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7938 }
7939 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7940}
7941
Jeff Johnson295189b2012-06-20 16:38:30 -07007942eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7943 tDot11fBeaconIEs *pIes,
7944 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7945{
7946 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007947 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7948 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007949
7950 // Set the roaming substate to 'join attempt'...
7951 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007953 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 return (status);
7955}
7956
Jeff Johnson295189b2012-06-20 16:38:30 -07007957static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7958 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7959{
7960 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 // Set the roaming substate to 'join attempt'...
7962 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7963
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307964 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7965 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307966 if (pMac->roam.configParam.roamDelayStatsEnabled)
7967 {
7968 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7969 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007972 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007973}
7974
Jeff Johnson295189b2012-06-20 16:38:30 -07007975void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7976{
7977 tListElem *pEntry;
7978 tSmeCmd *pCommand;
7979 tCsrRoamInfo roamInfo;
7980 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307981 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007982
7983 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7984 if(pEntry)
7985 {
7986 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7987 if ( eSmeCommandRoam == pCommand->command )
7988 {
7989 sessionId = pCommand->sessionId;
7990 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007991
7992 if(!pSession)
7993 {
7994 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7995 return;
7996 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307997 /* While switching between two AP, csr will reissue roam command again
7998 to the nextbss if it was interrupted by the dissconnect req for the
7999 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
8000 so reset the bRefAssocStartCnt.
8001 */
8002 if(pSession->bRefAssocStartCnt > 0)
8003 {
8004 pSession->bRefAssocStartCnt--;
8005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 if( pCommand->u.roamCmd.fStopWds )
8007 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308008 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8010 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8011 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
8014 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8015 eCSR_ROAM_WDS_IND,
8016 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
8018 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8019 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8020 eCSR_ROAM_INFRA_IND,
8021 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
8022 }
8023
Jeff Johnson295189b2012-06-20 16:38:30 -07008024
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
8026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008027 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8029 }
8030 }
8031 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
8032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008033 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8035 }
8036 }
8037 else
8038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008039 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 }
8041 }
8042 else
8043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008044 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 }
8046}
8047
Jeff Johnson295189b2012-06-20 16:38:30 -07008048tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
8049{
8050 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8051 tListElem *pEntry;
8052 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 //alwasy lock active list before locking pending list
8054 csrLLLock( &pMac->sme.smeCmdActiveList );
8055 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8056 if(pEntry)
8057 {
8058 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8059 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8060 {
8061 fRet = eANI_BOOLEAN_TRUE;
8062 }
8063 }
8064 if(eANI_BOOLEAN_FALSE == fRet)
8065 {
8066 csrLLLock(&pMac->sme.smeCmdPendingList);
8067 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8068 while(pEntry)
8069 {
8070 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8071 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8072 {
8073 fRet = eANI_BOOLEAN_TRUE;
8074 break;
8075 }
8076 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8077 }
8078 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8079 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308080 if (eANI_BOOLEAN_FALSE == fRet)
8081 {
8082 csrLLLock(&pMac->roam.roamCmdPendingList);
8083 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8084 while (pEntry)
8085 {
8086 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8087 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8088 {
8089 fRet = eANI_BOOLEAN_TRUE;
8090 break;
8091 }
8092 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8093 }
8094 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008096 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 return (fRet);
8098}
8099
Jeff Johnson295189b2012-06-20 16:38:30 -07008100tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8101{
8102 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8103 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8105 {
8106 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8107 {
8108 break;
8109 }
8110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 return ( fRet );
8112}
8113
Jeff Johnson295189b2012-06-20 16:38:30 -07008114tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8115{
8116 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 //alwasy lock active list before locking pending list
8118 csrLLLock( &pMac->sme.smeCmdActiveList );
8119 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8120 if(eANI_BOOLEAN_FALSE == fRet)
8121 {
8122 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8123 }
8124 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 return (fRet);
8126}
8127
Jeff Johnson295189b2012-06-20 16:38:30 -07008128tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8129{
8130 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8131 tListElem *pEntry;
8132 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 //alwasy lock active list before locking pending list
8134 csrLLLock( &pMac->sme.smeCmdActiveList );
8135 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8136 if( pEntry )
8137 {
8138 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8139 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8140 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8141 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8142 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8143 {
8144 fRet = eANI_BOOLEAN_TRUE;
8145 }
8146 }
8147 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 return (fRet);
8149}
Jeff Johnson295189b2012-06-20 16:38:30 -07008150eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8151{
8152 eHalStatus status = eHAL_STATUS_SUCCESS;
8153 tSmeCmd *pCommand = NULL;
8154 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8155 tANI_BOOLEAN fRemoveCmd = FALSE;
8156 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 // Delete the old assoc command. All is setup for reassoc to be serialized
8158 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8159 if ( pEntry )
8160 {
8161 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8162 if ( !pCommand )
8163 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008164 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 return eHAL_STATUS_RESOURCES;
8166 }
8167 if ( eSmeCommandRoam == pCommand->command )
8168 {
8169 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8170 {
8171 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8172 }
8173 else
8174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008175 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 }
8177 if (fRemoveCmd == FALSE)
8178 {
8179 // Implies we did not get the serialized assoc command we
8180 // were expecting
8181 pCommand = NULL;
8182 }
8183 }
8184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 if(NULL == pCommand)
8186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008187 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 return eHAL_STATUS_RESOURCES;
8189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 do
8191 {
8192 //Change the substate in case it is wait-for-key
8193 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8194 {
8195 csrRoamStopWaitForKeyTimer( pMac );
8196 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8197 }
8198 pCommand->command = eSmeCommandRoam;
8199 pCommand->sessionId = (tANI_U8)sessionId;
8200 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8202 if( !HAL_STATUS_SUCCESS( status ) )
8203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008204 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 csrReleaseCommandRoam( pMac, pCommand );
8206 }
8207 } while( 0 );
8208
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 return( status );
8210}
8211static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8212{
8213 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8214 tCsrScanResult *pScanResult = NULL;
8215 tSirBssDescription *pBssDesc = NULL;
8216 tSmeCmd *pCommand = NULL;
8217 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308218 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 if(NULL == pEntry)
8220 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308221 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 return;
8223 }
8224 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8225 sessionId = pCommand->sessionId;
8226 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008227
8228 if(!pSession)
8229 {
8230 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8231 return;
8232 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308233 smsLog(pMac, LOG1, FL("CFG return value is %d "
8234 " current state is : %d substate is : %d "),
8235 result, pMac->roam.curState[sessionId],
8236 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8238 {
8239 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008240 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8242 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008243 /* If the roaming has stopped, not to continue the roaming command*/
8244 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8245 {
8246 //No need to complete roaming here as it already completes
8247 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8248 pCommand->u.roamCmd.roamReason);
8249 csrSetAbortRoamingCommand( pMac, pCommand );
8250 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 else
8253 {
8254 if ( CCM_IS_RESULT_SUCCESS(result) )
8255 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308256 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 // Successfully set the configuration parameters for the new Bss. Attempt to
8258 // join the roaming Bss.
8259 if(pCommand->u.roamCmd.pRoamBssEntry)
8260 {
8261 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308262 if (!pScanResult)
8263 {
8264 smsLog(pMac, LOGE,
8265 FL("Failed to get base address for pScanResult"));
8266 return;
8267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 pBssDesc = &pScanResult->Result.BssDescriptor;
8269 }
8270 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8271 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 )
8274 {
8275 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8276 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8277 pBssDesc, pCommand->u.roamCmd.roamId )))
8278 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308279 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 //We need to complete the command
8281 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8282 }
8283 }
8284 else
8285 {
8286 if (!pCommand->u.roamCmd.pRoamBssEntry)
8287 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308288 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 //We need to complete the command
8290 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8291 return;
8292 }
8293 // If we are roaming TO an Infrastructure BSS...
8294 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308295 if( !pScanResult->Result.pvIes )
8296 {
8297 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8298 return;
8299 }
8300
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 if ( csrIsInfraBssDesc( pBssDesc ) )
8302 {
8303 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308304 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8306 {
8307 // ..and currently in an Infrastructure connection....
8308 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8309 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308310 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 // ...and the SSIDs are equal, then we Reassoc.
8312 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8313 pIesLocal ) )
8314 // ..and currently in an infrastructure connection
8315 {
8316 // then issue a Reassoc.
8317 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8318 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8319 &pCommand->u.roamCmd.roamProfile );
8320 }
8321 else
8322 {
8323
8324 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8325 // previously associated AP.
8326 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8327 pIesLocal,
8328 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8329 {
8330 //try something else
8331 csrRoam( pMac, pCommand );
8332 }
8333 }
8334 }
8335 else
8336 {
8337 eHalStatus status = eHAL_STATUS_SUCCESS;
8338
8339 /* We need to come with other way to figure out that this is because of HO in BMP
8340 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008341 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 * use join request */
8343#ifdef WLAN_FEATURE_VOWIFI_11R
8344 if (csrRoamIsHandoffInProgress(pMac) &&
8345 csrRoamIs11rAssoc(pMac))
8346 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308347 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8349 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8350 }
8351 else
8352#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008353#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008355 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308357 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 // Now serialize the reassoc command.
8359 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8360 }
8361 else
8362#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008363#ifdef FEATURE_WLAN_LFR
8364 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308365 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008366 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308367 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008368 // Now serialize the reassoc command.
8369 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8370 }
8371 else
8372#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 // else we are not connected and attempting to Join. Issue the
8374 // Join request.
8375 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308376 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8378 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8379 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8380 }
8381 if(!HAL_STATUS_SUCCESS(status))
8382 {
8383 //try something else
8384 csrRoam( pMac, pCommand );
8385 }
8386 }
8387 if( !pScanResult->Result.pvIes )
8388 {
8389 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308390 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 }
8392 }
8393 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8394 else
8395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008396 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 }
8398 }//else
8399 }//if ( WNI_CFG_SUCCESS == result )
8400 else
8401 {
8402 // In the event the configuration failed, for infra let the roam processor
8403 //attempt to join something else...
8404 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8405 {
8406 csrRoam(pMac, pCommand);
8407 }
8408 else
8409 {
8410 //We need to complete the command
8411 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8412 {
8413 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8414 }
8415 else
8416 {
8417 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8418 }
8419 }
8420 }
8421 }//we have active entry
8422}
8423
Jeff Johnson295189b2012-06-20 16:38:30 -07008424static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8425{
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008428 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8430 // join the new one...
8431 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8433 }
8434 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008435 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 /***profHandleLostLinkAfterReset(pAdapter);
8437 // In the event the authenticate fails, let the roam processor attempt to join something else...
8438 roamRoam( pAdapter );***/
8439 }
8440}
8441
Jeff Johnson295189b2012-06-20 16:38:30 -07008442static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8443{
8444 eCsrRoamCompleteResult result;
8445 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8446 tCsrRoamInfo roamInfo;
8447 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308448 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308449 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308450 tANI_U8 nilMac[6] = {0};
8451
8452 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008454 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 /* Defeaturize this part later if needed */
8457#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8458 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8459 * we need the response contents while processing the result in csrRoamProcessResults() */
8460 if (csrRoamIsHandoffInProgress(pMac))
8461 {
8462 /* Need to dig more on indicating events to SME QoS module */
8463 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8464 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308465#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8466 /* Add previous BSSID to blacklist ; this will be in blacklised for
8467 * some period and score of this AP will be reduced if black listed
8468 * to avoid ping pong */
8469 if (pMac->PERroamCandidatesCnt)
8470 {
8471 current_timestamp = jiffies_to_msecs(jiffies);
8472 for (candidateApCnt = 0; candidateApCnt <
8473 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8474 {
8475 /* Find one blank entry */
8476 if (sirCompareMacAddr(nilMac,
8477 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8478 {
8479 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8480 bssAddr,
8481 pNeighborRoamInfo->prevConnProfile.bssid,
8482 sizeof(tSirMacAddr));
8483 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8484 current_timestamp;
8485 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8486 MAC_ADDR_ARRAY(
8487 pNeighborRoamInfo->prevConnProfile.bssid),
8488 candidateApCnt);
8489 break;
8490 }
8491 /* if already in the list */
8492 if (sirCompareMacAddr(pMac->previousRoamApInfo
8493 [candidateApCnt].bssAddr,
8494 pNeighborRoamInfo->prevConnProfile.bssid) &&
8495 ((current_timestamp -
8496 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8497 pMac->PERroamTimeout))
8498 {
8499 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8500 bssAddr,
8501 pNeighborRoamInfo->prevConnProfile.bssid,
8502 sizeof(tSirMacAddr));
8503 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8504 current_timestamp;
8505 break;
8506 } else
8507 {
8508 /* find oldest BSSID entry in the blacklist */
8509 if (max_time <
8510 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8511 {
8512 max_time =
8513 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8514 oldestIndex = candidateApCnt;
8515 }
8516 }
8517 }
8518 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8519 {
8520 smsLog(pMac, LOGW,
8521 "%s: Clearing out oldest roam results bssid="
8522 MAC_ADDRESS_STR,
8523 __func__,
8524 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8525 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8526 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8527 pNeighborRoamInfo->prevConnProfile.bssid,
8528 sizeof(tSirMacAddr));
8529 }
8530 }
8531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 }
8533 else
8534#endif
8535 {
8536 csrRoamComplete( pMac, result, NULL );
8537 }
8538 }
8539 /* Should we handle this similar to handling the join failure? Is it ok
8540 * to call csrRoamComplete() with state as CsrJoinFailure */
8541 else
8542 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008543 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308545 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8546 WLAN_LOG_INDICATOR_HOST_DRIVER,
8547 WLAN_LOG_REASON_ROAM_FAIL,
8548 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008549#ifdef WLAN_FEATURE_VOWIFI_11R
8550 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308551 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8552 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 {
8554 // Inform HDD to turn off FT flag in HDD
8555 if (pNeighborRoamInfo)
8556 {
8557 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8558 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8559 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008560 /*
8561 * Since the above callback sends a disconnect
8562 * to HDD, we should clean-up our state
8563 * machine as well to be in sync with the upper
8564 * layers. There is no need to send a disassoc
8565 * since: 1) we will never reassoc to the current
8566 * AP in LFR, and 2) there is no need to issue a
8567 * disassoc to the AP with which we were trying
8568 * to reassoc.
8569 */
8570 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8571 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 }
8573 }
8574#endif
8575 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8576 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8577 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8578 //The disassoc rsp message will remove the command from active list
8579 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8580 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8581 {
8582 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8583 }
8584 }
8585}
8586
Jeff Johnson295189b2012-06-20 16:38:30 -07008587static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8588{
Jeff Johnson295189b2012-06-20 16:38:30 -07008589#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8590 {
8591 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8593 if(pIbssLog)
8594 {
8595 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8596 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8597 {
8598 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8599 }
8600 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8601 }
8602 }
8603#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008604 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8605 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8606 {
8607 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8608 }
8609 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8610 {
8611 csrRoamReissueRoamCommand(pMac);
8612 }
8613}
8614
Jeff Johnson295189b2012-06-20 16:38:30 -07008615void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8616{
8617 tSirResultCodes statusCode;
8618#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8619 tScanResultHandle hBSSList;
8620 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8621 eHalStatus status;
8622 tCsrRoamInfo roamInfo;
8623 tCsrScanResultFilter *pScanFilter = NULL;
8624 tANI_U32 roamId = 0;
8625 tCsrRoamProfile *pCurRoamProfile = NULL;
8626 tListElem *pEntry = NULL;
8627 tSmeCmd *pCommand = NULL;
8628#endif
8629 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308630 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008631
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 tSirSmeDisassocRsp SmeDisassocRsp;
8633
8634 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8635 sessionId = SmeDisassocRsp.sessionId;
8636 statusCode = SmeDisassocRsp.statusCode;
8637
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008638 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008639
8640 if ( csrIsConnStateInfra( pMac, sessionId ) )
8641 {
8642 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008645
8646 if(!pSession)
8647 {
8648 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8649 return;
8650 }
8651
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8653 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308654 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8656 }
8657 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8658 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8659 {
8660 if ( eSIR_SME_SUCCESS == statusCode )
8661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008662 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8664 }
8665 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8668 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8670 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008671#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008672 /*
8673 * First ensure if the roam profile is in the scan cache.
8674 * If not, post a reassoc failure and disconnect.
8675 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308676 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8677 if ( NULL == pScanFilter )
8678 status = eHAL_STATUS_FAILURE;
8679 else
8680 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008681 if(HAL_STATUS_SUCCESS(status))
8682 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308683 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008684 status = csrRoamPrepareFilterFromProfile(pMac,
8685 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8686 if(!HAL_STATUS_SUCCESS(status))
8687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008688 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008689 __func__, status);
8690 goto POST_ROAM_FAILURE;
8691 }
8692 else
8693 {
8694 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8695 if (!HAL_STATUS_SUCCESS(status))
8696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008697 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008698 __func__, status);
8699 goto POST_ROAM_FAILURE;
8700 }
8701 }
8702 }
8703 else
8704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008705 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008706 __func__, status);
8707 goto POST_ROAM_FAILURE;
8708 }
8709
8710 /*
8711 * After ensuring that the roam profile is in the scan result list,
8712 * dequeue the command from the active list.
8713 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8715 if ( pEntry )
8716 {
8717 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008718 /* If the head of the queue is Active and it is a ROAM command, remove
8719 * and put this on the Free queue.
8720 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 if ( eSmeCommandRoam == pCommand->command )
8722 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008723
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008724 /*
8725 * we need to process the result first before removing it from active list
8726 * because state changes still happening insides roamQProcessRoamResults so
8727 * no other roam command should be issued.
8728 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8730 if(pCommand->u.roamCmd.fReleaseProfile)
8731 {
8732 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8733 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 else
8738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008739 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008740 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 }
8742 }
8743 else
8744 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008745 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 }
8747 }
8748 else
8749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008750 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008752
8753 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8755
Kiet Lam64c1b492013-07-12 13:56:44 +05308756 vos_mem_copy(roamInfo.bssid,
8757 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8758 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008759
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008760 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8761 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008762
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008763 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308764 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8765 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308767 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008768 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8769 //make sure to put it at the head of the cmd queue
8770 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8771 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8772 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8773
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 if(!HAL_STATUS_SUCCESS(status))
8775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008776 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008777 __func__, status);
8778 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
8780
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008781 /* Notify sub-modules like QoS etc. that handoff happening */
8782 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308783 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008784 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308785 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308787 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008788 return;
8789 }
8790
8791POST_ROAM_FAILURE:
8792 if (pScanFilter)
8793 {
8794 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308795 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008796 }
8797 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308798 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008799
8800 /* Inform the upper layers that the reassoc failed */
8801 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8802 csrRoamCallCallback(pMac, sessionId,
8803 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8804
8805 /*
8806 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8807 * Upon success, we would re-enter this routine after receiving the disassoc
8808 * response and will fall into the reassoc fail sub-state. And, eventually
8809 * call csrRoamComplete which would remove the roam command from SME active
8810 * queue.
8811 */
8812 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8813 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008815 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008816 __func__, status);
8817 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008819#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008820
Jeff Johnson295189b2012-06-20 16:38:30 -07008821 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8822 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8823 {
8824 // Disassoc due to Reassoc failure falls into this codepath....
8825 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8826 }
8827 else
8828 {
8829 if ( eSIR_SME_SUCCESS == statusCode )
8830 {
8831 // Successfully disassociated from the 'old' Bss...
8832 //
8833 // We get Disassociate response in three conditions.
8834 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8835 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8836 // Infrastructure network.
8837 // - Third is where we are doing an Infra to Infra roam between networks with different
8838 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8839
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008840 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 }
8842 else
8843 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008844 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008845 }
8846 //We are not done yet. Get the data and continue roaming
8847 csrRoamReissueRoamCommand(pMac);
8848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008849}
8850
Jeff Johnson295189b2012-06-20 16:38:30 -07008851static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8852{
8853 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008855 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8857 {
8858 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8859 }
8860 else
8861 {
8862 if ( eSIR_SME_SUCCESS == statusCode )
8863 {
8864 // Successfully deauth from the 'old' Bss...
8865 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008866 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 }
8868 else
8869 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008870 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 }
8872 //We are not done yet. Get the data and continue roaming
8873 csrRoamReissueRoamCommand(pMac);
8874 }
8875}
8876
Jeff Johnson295189b2012-06-20 16:38:30 -07008877static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8878{
8879 eCsrRoamCompleteResult result;
8880
8881 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008883 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 result = eCsrStartBssSuccess;
8885 }
8886 else
8887 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008888 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 //Let csrRoamComplete decide what to do
8890 result = eCsrStartBssFailure;
8891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008893}
8894
Jeff Johnson295189b2012-06-20 16:38:30 -07008895/*
8896 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8897 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8898 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8899 For the messages where sender allocates memory for specific structures, then it can be
8900 cast accordingly.
8901*/
8902void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8903{
8904 tSirSmeRsp *pSmeRsp;
8905 tSmeIbssPeerInd *pIbssPeerInd;
8906 tCsrRoamInfo roamInfo;
8907 // TODO Session Id need to be acquired in this function
8908 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308910 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8911 pSmeRsp->messageType, pSmeRsp->messageType,
8912 macTraceGetcsrRoamSubState(
8913 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 pSmeRsp->messageType = (pSmeRsp->messageType);
8915 pSmeRsp->length = (pSmeRsp->length);
8916 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 switch (pSmeRsp->messageType)
8918 {
8919
8920 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8921 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8922 {
8923 //We sent a JOIN_REQ
8924 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8925 }
8926 break;
8927
8928 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8929 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8930 {
8931 //We sent a AUTH_REQ
8932 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8933 }
8934 break;
8935
8936 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8937 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8938 {
8939 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8940 }
8941 break;
8942
8943 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8944 {
8945 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8946 }
8947 break;
8948
8949 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8950 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8951 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8952 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8953 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8954 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8955//HO
8956 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8957 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308958 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8959 macTraceGetcsrRoamSubState(
8960 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308962 if (pMac->roam.configParam.roamDelayStatsEnabled)
8963 {
8964 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 }
8967 break;
8968
8969 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8970 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8971 {
8972 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8973 }
8974 break;
8975
8976 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8977 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8978 {
8979 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8980 }
8981 break;
8982
8983 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8984 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8985 {
8986 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8990 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8991 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008992 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308993 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8994 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8996 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308997 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8998 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9000 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9001 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9002 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05309003 case eWNI_SME_LOST_LINK_PARAMS_IND:
9004 {
9005 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
9006 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9007 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9008 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9009 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
9010 pRoamInfo = &roamInfo;
9011 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
9012 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
9013 break;
9014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309016 smsLog(pMac, LOG1,
9017 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9018 pSmeRsp->messageType, pSmeRsp->messageType,
9019 macTraceGetcsrRoamSubState(
9020 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009021
9022 //If we are connected, check the link status change
9023 if(!csrIsConnStateDisconnected(pMac, sessionId))
9024 {
9025 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
9026 }
9027 break;
9028 }
9029}
9030
Jeff Johnson295189b2012-06-20 16:38:30 -07009031void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
9032{
9033 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 switch (pSirMsg->messageType)
9035 {
9036 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009037 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009038 csrRoamStatsRspProcessor( pMac, pSirMsg );
9039 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9041 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309042 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009043 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9044 tCsrRoamInfo roamInfo;
9045 tCsrRoamInfo *pRoamInfo = NULL;
9046 tANI_U32 sessionId;
9047 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009048 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05309049 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
9052 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9053 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009054
9055 if(!pSession)
9056 {
9057 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9058 return;
9059 }
9060
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9062 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9064 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9065 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9067 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309068 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9069 sizeof(tSirMacAddr));
9070 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9071 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009072 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309073#ifdef WLAN_FEATURE_AP_HT40_24G
9074 pRoamInfo->HT40MHzIntoEnabledSta =
9075 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9076 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9077 pRoamInfo->HT40MHzIntoEnabledSta);
9078#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309079 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309080 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9081 pRoamInfo->chan_info = pUpperLayerAssocCnf->chan_info;
9082 if (pUpperLayerAssocCnf->HTCaps.present)
9083 pRoamInfo->ht_caps = pUpperLayerAssocCnf->HTCaps;
9084 if (pUpperLayerAssocCnf->VHTCaps.present)
9085 pRoamInfo->vht_caps = pUpperLayerAssocCnf->VHTCaps;
9086
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9088 {
9089 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9090 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9091 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9092 }
9093 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9094 {
9095 vos_sleep( 100 );
9096 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9097 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9098 }
9099
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 }
9101 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 default:
9103 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9104 break;
9105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009106}
9107
Jeff Johnson295189b2012-06-20 16:38:30 -07009108eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9109 tSirBssDescription *pBssDescription,
9110 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9111 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9112 tANI_U8 keyId, tANI_U16 keyLength,
9113 tANI_U8 *pKey, tANI_U8 paeRole )
9114{
9115 eHalStatus status = eHAL_STATUS_SUCCESS;
9116 tAniEdType edType;
9117
9118 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9119 {
9120 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9121 }
9122
9123 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9124
9125 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9126 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9127 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9128 addKey )
9129 {
9130 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 setKey.encType = EncryptType;
9132 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309133 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 setKey.paeRole = paeRole; //0 for supplicant
9135 setKey.keyId = keyId; // Kye index
9136 setKey.keyLength = keyLength;
9137 if( keyLength )
9138 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309139 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 }
9141 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 return (status);
9144}
9145
Jeff Johnson295189b2012-06-20 16:38:30 -07009146static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9147 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9148{
9149 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9150 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009151#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009153#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009154
9155 do
9156 {
9157 pCommand = csrGetCommandBuffer(pMac);
9158 if(NULL == pCommand)
9159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009160 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 status = eHAL_STATUS_RESOURCES;
9162 break;
9163 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309164 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009165 pCommand->command = eSmeCommandSetKey;
9166 pCommand->sessionId = (tANI_U8)sessionId;
9167 // validate the key length, Adjust if too long...
9168 // for static WEP the keys are not set thru' SetContextReq
9169 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9170 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9171 {
9172 //KeyLength maybe 0 for static WEP
9173 if( pSetKey->keyLength )
9174 {
9175 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009177 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 break;
9179 }
9180
9181 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309182 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9183 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 }
9185 }
9186 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9187 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9188 {
9189 //KeyLength maybe 0 for static WEP
9190 if( pSetKey->keyLength )
9191 {
9192 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009194 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 break;
9196 }
9197
9198 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309199 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9200 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 }
9202 }
9203 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9204 {
9205 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009207 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009208 break;
9209 }
9210 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309211 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9212 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 }
9214 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9215 {
9216 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009218 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 break;
9220 }
9221 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309222 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9223 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 }
9225#ifdef FEATURE_WLAN_WAPI
9226 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9227 {
9228 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009230 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 break;
9232 }
9233 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309234 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9235 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 }
9237#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009238#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9240 {
9241 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009243 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 break;
9245 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009246 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309247 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009248 pSession->eseCckmInfo.reassoc_req_num=1;
9249 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009250 status = eHAL_STATUS_SUCCESS;
9251 break;
9252 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009253#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009254
Jeff Johnson295189b2012-06-20 16:38:30 -07009255#ifdef WLAN_FEATURE_11W
9256 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009257 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009259 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009261 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 break;
9263 }
9264 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309265 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 }
9267#endif
9268 status = eHAL_STATUS_SUCCESS;
9269 pCommand->u.setKeyCmd.roamId = roamId;
9270 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9271 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309272 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9273 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009274 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9275 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309276 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009277 //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
9278
9279 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9280 if( !HAL_STATUS_SUCCESS( status ) )
9281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009282 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 }
9284 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009286 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009287 if ( ( NULL != pCommand ) &&
9288 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009289#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009291#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009292 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009293 {
9294 csrReleaseCommandSetKey( pMac, pCommand );
9295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 return( status );
9297}
9298
Jeff Johnson295189b2012-06-20 16:38:30 -07009299eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9300 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9301{
9302 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9303 tSmeCmd *pCommand = NULL;
9304 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 do
9306 {
9307 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009309 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 status = eHAL_STATUS_CSR_WRONG_STATE;
9311 break;
9312 }
9313 pCommand = csrGetCommandBuffer(pMac);
9314 if(NULL == pCommand)
9315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009316 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 status = eHAL_STATUS_RESOURCES;
9318 break;
9319 }
9320 pCommand->command = eSmeCommandRemoveKey;
9321 pCommand->sessionId = (tANI_U8)sessionId;
9322 pCommand->u.removeKeyCmd.roamId = roamId;
9323 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309324 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9325 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9327 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9328 {
9329 //in this case, put it to the end of the Q incase there is a set key pending.
9330 fImediate = eANI_BOOLEAN_FALSE;
9331 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009332 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009334 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9336 if( !HAL_STATUS_SUCCESS( status ) )
9337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009338 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 break;
9340 }
9341 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9343 {
9344 csrReleaseCommandRemoveKey( pMac, pCommand );
9345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 return (status );
9347}
9348
Jeff Johnson295189b2012-06-20 16:38:30 -07009349eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9350{
9351 eHalStatus status;
9352 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9353 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9354 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9355 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009356#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9358 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309359 if(!pSession)
9360 {
9361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9362 return eHAL_STATUS_FAILURE;
9363 }
lukez3c809222013-05-03 10:23:02 -07009364 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009365 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309366 vos_mem_set(&setKeyEvent,
9367 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9369 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309370 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009371 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9372 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9373 }
9374 else
9375 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309376 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9378 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9379 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309380 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009381 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 {
9383 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 //It has to be static WEP here
9385 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9386 {
9387 setKeyEvent.keyId = (v_U8_t)defKeyId;
9388 }
9389 }
9390 else
9391 {
9392 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9393 }
9394 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9395 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9396 }
9397#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 if( csrIsSetKeyAllowed(pMac, sessionId) )
9399 {
9400 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9401 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9402 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9403 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9404 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9405 pCommand->u.setKeyCmd.keyRsc);
9406 }
9407 else
9408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009409 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 //Set this status so the error handling take care of the case.
9411 status = eHAL_STATUS_CSR_WRONG_STATE;
9412 }
9413 if( !HAL_STATUS_SUCCESS(status) )
9414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009415 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009417#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009418 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009419 {
9420 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9421 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309422 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 }
9424 else
9425 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309426 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 }
9428 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9429 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9430 }
9431#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 return ( status );
9434}
9435
Jeff Johnson295189b2012-06-20 16:38:30 -07009436eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9437{
9438 eHalStatus status;
9439 tpSirSmeRemoveKeyReq pMsg = NULL;
9440 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9441 tANI_U8 *p;
9442 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009443#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9444 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9445 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309446 if(!pSession)
9447 {
9448 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9449 return eHAL_STATUS_FAILURE;
9450 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309451 vos_mem_set(&removeKeyEvent,
9452 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009453 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9454 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9455 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309456 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9458 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9459 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9460#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 if( csrIsSetKeyAllowed(pMac, sessionId) )
9462 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309463 pMsg = vos_mem_malloc(wMsgLen);
9464 if ( NULL == pMsg )
9465 status = eHAL_STATUS_FAILURE;
9466 else
9467 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 }
9469 else
9470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009471 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 //Set the error status so error handling kicks in below
9473 status = eHAL_STATUS_CSR_WRONG_STATE;
9474 }
9475 if( HAL_STATUS_SUCCESS( status ) )
9476 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309477 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9479 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 pMsg->sessionId = (tANI_U8)sessionId;
9481 pMsg->transactionId = 0;
9482 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9483 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9484 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309485 vos_mem_copy(p,
9486 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9487 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 p += sizeof(tSirMacAddr);
9489 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309490 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 p += sizeof(tSirMacAddr);
9492 // edType
9493 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9494 p++;
9495 // weptype
9496 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9497 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9498 {
9499 *p = (tANI_U8)eSIR_WEP_STATIC;
9500 }
9501 else
9502 {
9503 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9504 }
9505 p++;
9506 //keyid
9507 *p = pCommand->u.removeKeyCmd.keyId;
9508 p++;
9509 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 status = palSendMBMessage(pMac->hHdd, pMsg);
9511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 if( !HAL_STATUS_SUCCESS( status ) )
9513 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009514 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009515#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9516 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009517 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009518 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9519#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 return ( status );
9523}
9524
Jeff Johnson295189b2012-06-20 16:38:30 -07009525eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9526{
9527 eHalStatus status;
9528
9529 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9530 {
9531 status = eHAL_STATUS_CSR_WRONG_STATE;
9532 }
9533 else
9534 {
9535 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 return ( status );
9538}
9539
Jeff Johnson295189b2012-06-20 16:38:30 -07009540/*
9541 Prepare a filter base on a profile for parsing the scan results.
9542 Upon successful return, caller MUST call csrFreeScanFilter on
9543 pScanFilter when it is done with the filter.
9544*/
9545eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9546 tCsrScanResultFilter *pScanFilter)
9547{
9548 eHalStatus status = eHAL_STATUS_SUCCESS;
9549 tANI_U32 size = 0;
9550 tANI_U8 index = 0;
9551
9552 do
9553 {
9554 if(pProfile->BSSIDs.numOfBSSIDs)
9555 {
9556 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309557 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9558 if ( NULL == pScanFilter->BSSIDs.bssid )
9559 status = eHAL_STATUS_FAILURE;
9560 else
9561 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 if(!HAL_STATUS_SUCCESS(status))
9563 {
9564 break;
9565 }
9566 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309567 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 }
9569 if(pProfile->SSIDs.numOfSSIDs)
9570 {
9571 if( !CSR_IS_WDS_STA( pProfile ) )
9572 {
9573 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9574 }
9575 else
9576 {
9577 //For WDS station
9578 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9579 pScanFilter->SSIDs.numOfSSIDs = 1;
9580 }
9581 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309582 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9583 if ( NULL == pScanFilter->SSIDs.SSIDList )
9584 status = eHAL_STATUS_FAILURE;
9585 else
9586 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 if(!HAL_STATUS_SUCCESS(status))
9588 {
9589 break;
9590 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309591 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9592 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 }
9594 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9595 {
9596 pScanFilter->ChannelInfo.numOfChannels = 0;
9597 pScanFilter->ChannelInfo.ChannelList = NULL;
9598 }
9599 else if(pProfile->ChannelInfo.numOfChannels)
9600 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309601 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9602 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9603 pProfile->ChannelInfo.numOfChannels);
9604 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9605 status = eHAL_STATUS_FAILURE;
9606 else
9607 status = eHAL_STATUS_SUCCESS;
9608
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 pScanFilter->ChannelInfo.numOfChannels = 0;
9610 if(HAL_STATUS_SUCCESS(status))
9611 {
9612 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9613 {
9614 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9615 {
9616 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9617 = pProfile->ChannelInfo.ChannelList[index];
9618 pScanFilter->ChannelInfo.numOfChannels++;
9619 }
9620 else
9621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009622 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 }
9625 }
9626 else
9627 {
9628 break;
9629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 }
9631 else
9632 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309633 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 status = eHAL_STATUS_FAILURE;
9635 break;
9636 }
9637 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9638 pScanFilter->authType = pProfile->AuthType;
9639 pScanFilter->EncryptionType = pProfile->EncryptionType;
9640 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9641 pScanFilter->BSSType = pProfile->BSSType;
9642 pScanFilter->phyMode = pProfile->phyMode;
9643#ifdef FEATURE_WLAN_WAPI
9644 //check if user asked for WAPI with 11n or auto mode, in that case modify
9645 //the phymode to 11g
9646 if(csrIsProfileWapi(pProfile))
9647 {
9648 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9649 {
9650 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9651 }
9652 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9653 {
9654 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9655 }
9656 if(!pScanFilter->phyMode)
9657 {
9658 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9659 }
9660 }
9661#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 /*Save the WPS info*/
9663 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009664 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 if( pProfile->countryCode[0] )
9666 {
9667 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309668 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9669 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 }
9671#ifdef WLAN_FEATURE_VOWIFI_11R
9672 if (pProfile->MDID.mdiePresent)
9673 {
9674 pScanFilter->MDID.mdiePresent = 1;
9675 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9676 }
9677#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309678 vos_mem_copy(pScanFilter->bssid_hint,
9679 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309680
9681#ifdef WLAN_FEATURE_11W
9682 // Management Frame Protection
9683 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9684 pScanFilter->MFPRequired = pProfile->MFPRequired;
9685 pScanFilter->MFPCapable = pProfile->MFPCapable;
9686#endif
9687
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 }while(0);
9689
9690 if(!HAL_STATUS_SUCCESS(status))
9691 {
9692 csrFreeScanFilter(pMac, pScanFilter);
9693 }
9694
9695 return(status);
9696}
9697
Jeff Johnson295189b2012-06-20 16:38:30 -07009698tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9699 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9700{
9701 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9702 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 do
9704 {
9705 // Validate the type is ok...
9706 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9707 pCommand = csrGetCommandBuffer( pMac );
9708 if ( !pCommand )
9709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009710 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 break;
9712 }
9713 //Change the substate in case it is waiting for key
9714 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9715 {
9716 csrRoamStopWaitForKeyTimer( pMac );
9717 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9718 }
9719 pCommand->command = eSmeCommandWmStatusChange;
9720 pCommand->sessionId = (tANI_U8)sessionId;
9721 pCommand->u.wmStatusChangeCmd.Type = Type;
9722 if ( eCsrDisassociated == Type )
9723 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309724 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9725 pSmeRsp,
9726 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 }
9728 else
9729 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309730 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9731 pSmeRsp,
9732 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 }
9734 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9735 {
9736 fCommandQueued = eANI_BOOLEAN_TRUE;
9737 }
9738 else
9739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009740 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 csrReleaseCommandWmStatusChange( pMac, pCommand );
9742 }
9743
Jeff Johnson295189b2012-06-20 16:38:30 -07009744 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9745 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 return( fCommandQueued );
9748}
9749
Jeff Johnson295189b2012-06-20 16:38:30 -07009750static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9751{
9752 v_S7_t rssi = 0;
9753 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9754 if(pGetRssiReq)
9755 {
9756 if(NULL != pGetRssiReq->pVosContext)
9757 {
9758 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9759 }
9760 else
9761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009762 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 return;
9764 }
9765
9766 if(NULL != pGetRssiReq->rssiCallback)
9767 {
9768 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9769 }
9770 else
9771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009772 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 return;
9774 }
9775 }
9776 else
9777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009778 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009779 }
9780 return;
9781}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309782
9783static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9784{
9785 tANI_S8 snr = 0;
9786 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9787
9788 if (pGetSnrReq)
9789 {
9790 if (VOS_STATUS_SUCCESS !=
9791 WDA_GetSnr(pGetSnrReq->staId, &snr))
9792 {
9793 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9794 return;
9795 }
9796
9797 if (pGetSnrReq->snrCallback)
9798 {
9799 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9800 pGetSnrReq->pDevContext);
9801 }
9802 else
9803 {
9804 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9805 return;
9806 }
9807 }
9808 else
9809 {
9810 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9811 }
9812 return;
9813}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009814#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009815void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9816{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009817 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9818
Jeff Johnson36d483b2013-04-08 11:08:53 -07009819 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009820 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009821 /* Get roam Rssi request is backed up and passed back to the response,
9822 Extract the request message to fetch callback */
9823 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9824 v_S7_t rssi = pRoamRssiRsp->rssi;
9825
9826 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009827 {
9828 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9829 reqBkp->rssiCallback = NULL;
9830 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009831 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009832 }
9833 else
9834 {
9835 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9836 if (NULL != reqBkp)
9837 {
9838 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009839 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009840 }
9841 }
9842 }
9843 else
9844 {
9845 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9846 }
9847 return;
9848}
9849#endif
9850
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009851
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009852#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009853void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9854{
9855 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9856
9857 if (NULL != pTsmStatsRsp)
9858 {
9859 /* Get roam Rssi request is backed up and passed back to the response,
9860 Extract the request message to fetch callback */
9861 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9862
9863 if (NULL != reqBkp)
9864 {
9865 if (NULL != reqBkp->tsmStatsCallback)
9866 {
9867 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9868 pTsmStatsRsp->staId, reqBkp->pDevContext);
9869 reqBkp->tsmStatsCallback = NULL;
9870 }
9871 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009872 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009873 }
9874 else
9875 {
9876 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9877 if (NULL != reqBkp)
9878 {
9879 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009880 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009881 }
9882 }
9883 }
9884 else
9885 {
9886 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9887 }
9888 return;
9889}
9890
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009891void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009892{
9893 tANI_U32 roamTS2 = 0;
9894 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009895 tpPESession pSessionEntry = NULL;
9896 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009897
9898 if (NULL == pSession)
9899 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009900 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009901 return;
9902 }
9903
9904 roamTS2 = vos_timer_get_system_time();
9905 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009906 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9907 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009908 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009909
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009910 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9911 if (NULL == pSessionEntry)
9912 {
9913 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9914 return;
9915 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009916 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009917 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009918 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009919}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009920#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009921
Jeff Johnsone7245742012-09-05 17:12:55 -07009922static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9923{
9924 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9925 if(pTlRssiInd)
9926 {
9927 if(NULL != pTlRssiInd->tlCallback)
9928 {
9929 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009930 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009931 }
9932 else
9933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009934 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009935 }
9936 }
9937 else
9938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009939 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009940 }
9941 return;
9942}
Jeff Johnson295189b2012-06-20 16:38:30 -07009943
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309944eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9945{
9946 tpSirResetAPCapsChange pMsg;
9947 tANI_U16 len;
9948 eHalStatus status = eHAL_STATUS_SUCCESS;
9949
9950 /* Create the message and send to lim */
9951 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309952 pMsg = vos_mem_malloc(len);
9953 if ( NULL == pMsg )
9954 status = eHAL_STATUS_FAILURE;
9955 else
9956 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309957 if (HAL_STATUS_SUCCESS(status))
9958 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309959 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309960 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9961 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309962 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009963 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9964 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309965 status = palSendMBMessage(pMac->hHdd, pMsg);
9966 }
9967 else
9968 {
9969 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9970 }
9971 return status;
9972}
9973
Jeff Johnson295189b2012-06-20 16:38:30 -07009974void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9975{
9976 tSirSmeAssocInd *pAssocInd;
9977 tSirSmeDisassocInd *pDisassocInd;
9978 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +05309979 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9981 tSirSmeNewBssInfo *pNewBss;
9982 tSmeIbssPeerInd *pIbssPeerInd;
9983 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9984 tSirSmeApNewCaps *pApNewCaps;
9985 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9986 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9987 tCsrRoamInfo *pRoamInfo = NULL;
9988 tCsrRoamInfo roamInfo;
9989 eHalStatus status;
9990 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9991 tCsrRoamSession *pSession = NULL;
9992 tpSirSmeSwitchChannelInd pSwitchChnInd;
9993 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309994 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009995
9996
9997 if (NULL == pSirMsg)
9998 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9999 return;
10000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 switch( pSirMsg->messageType )
10002 {
10003 case eWNI_SME_ASSOC_IND:
10004 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053010005 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053010006 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
10008 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
10009 if( HAL_STATUS_SUCCESS( status ) )
10010 {
10011 pSession = CSR_GET_SESSION(pMac, sessionId);
10012
Jeff Johnson32d95a32012-09-10 13:15:23 -070010013 if(!pSession)
10014 {
10015 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10016 return;
10017 }
10018
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 pRoamInfo = &roamInfo;
10020
10021 // Required for indicating the frames to upper layer
10022 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
10023 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
10024
10025 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
10026 pRoamInfo->beaconLength = pAssocInd->beaconLength;
10027 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
10028 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10029
10030 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
10031 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
10032 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10033
10034 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
10035 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +053010036 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
10037 sizeof(tSirMacAddr));
10038 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
10039 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +053010041 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053010042#ifdef WLAN_FEATURE_AP_HT40_24G
10043 pRoamInfo->HT40MHzIntoEnabledSta =
10044 pAssocInd->HT40MHzIntoEnabledSta;
10045 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
10046 pRoamInfo->HT40MHzIntoEnabledSta);
10047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
10051 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010052#ifdef SAP_AUTH_OFFLOAD
10053 if (pMac->sap_auth_offload)
10054 {
10055 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
10056 pRoamInfo->fAuthRequired = FALSE;
10057 }
10058 else
10059 {
10060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10062 {
10063 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10064 pSession->pConnectBssDesc,
10065 &(pRoamInfo->peerMac),
10066 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10067 pRoamInfo->fAuthRequired = FALSE;
10068 }
10069 else
10070 {
10071 pRoamInfo->fAuthRequired = TRUE;
10072 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010073#ifdef SAP_AUTH_OFFLOAD
10074 }
10075#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10077 if (!HAL_STATUS_SUCCESS(status))
10078 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 /* Send Association completion message to PE */
10081 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10082
10083 /* send a message to CSR itself just to avoid the EAPOL frames going
10084 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10086 {
10087 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10090 {
10091 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10092 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10093 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010095 }
10096 }
10097 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010100 // Check if AP dis-associated us because of MIC failure. If so,
10101 // then we need to take action immediately and not wait till the
10102 // the WmStatusChange requests is pushed and processed
10103 tSmeCmd *pCommand;
10104
10105 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10106 status = csrRoamGetSessionIdFromBSSID( pMac,
10107 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10108 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010110 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10111 " for session %d "), sessionId);
10112 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10113 MAC_ADDRESS_STR " "
10114 " reason = %d status = %d "),
10115 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10116 pDisassocInd->reasonCode,
10117 pDisassocInd->statusCode);
10118 // If we are in neighbor preauth done state then on receiving
10119 // disassoc or deauth we dont roam instead we just disassoc
10120 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010121 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010122#ifdef WLAN_FEATURE_VOWIFI_11R
10123 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10124 {
10125 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010127#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010128#ifdef FEATURE_WLAN_ESE
10129 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010130 {
10131 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010133#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010134#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010135 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10136 {
10137 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10138 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010139#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010140#ifdef WLAN_FEATURE_LFR_MBB
10141 csr_stop_preauth_reassoc_mbb_timer(pMac);
10142#endif
10143
Agarwal Ashish4f616132013-12-30 23:32:50 +053010144 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010145
Agarwal Ashish4f616132013-12-30 23:32:50 +053010146 if (!pSession)
10147 {
10148 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10149 return;
10150 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010151
Agarwal Ashish4f616132013-12-30 23:32:50 +053010152 if ( csrIsConnStateInfra( pMac, sessionId ) )
10153 {
10154 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10155 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010156#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010157 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010158#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010159 csrRoamLinkDown(pMac, sessionId);
10160 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10161 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10162 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010163 /*
10164 * STA/P2P client got disassociated so remove any pending deauth
10165 * commands in sme pending list
10166 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010167 pCommand = csrGetCommandBuffer(pMac);
10168 if (NULL == pCommand)
10169 {
10170 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10171 status = eHAL_STATUS_RESOURCES;
10172 return;
10173 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010174 pCommand->command = eSmeCommandRoam;
10175 pCommand->sessionId = (tANI_U8)sessionId;
10176 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10177 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10178 pDisassocInd->peerMacAddr,
10179 sizeof(tSirMacAddr));
10180 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10181 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010182
Agarwal Ashish4f616132013-12-30 23:32:50 +053010183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010185 else
10186 {
10187 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10188 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10189 }
Kiet Lam82004c62013-11-11 13:24:28 +053010190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010192 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010193 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10195 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10196 if( HAL_STATUS_SUCCESS( status ) )
10197 {
10198 // If we are in neighbor preauth done state then on receiving
10199 // disassoc or deauth we dont roam instead we just disassoc
10200 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010201 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010202#ifdef WLAN_FEATURE_VOWIFI_11R
10203 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10204 {
10205 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10206 }
10207#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010208#ifdef FEATURE_WLAN_ESE
10209 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 {
10211 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10212 }
10213#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010214#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010215 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010216 {
10217 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10218 }
10219#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010220#ifdef WLAN_FEATURE_LFR_MBB
10221 csr_stop_preauth_reassoc_mbb_timer(pMac);
10222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 pSession = CSR_GET_SESSION( pMac, sessionId );
10224
Jeff Johnson32d95a32012-09-10 13:15:23 -070010225 if(!pSession)
10226 {
10227 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10228 return;
10229 }
10230
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 if ( csrIsConnStateInfra( pMac, sessionId ) )
10232 {
10233 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010235#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10236 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10237#endif
10238 csrRoamLinkDown(pMac, sessionId);
10239 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 }
10241 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010242
10243 case eWNI_SME_DISCONNECT_DONE_IND:
10244 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10245 smsLog( pMac, LOG1,
10246 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10247 pDisConDoneInd->reasonCode);
10248 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10249 {
10250 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10251 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10252 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10253 sizeof(tSirMacAddr));
10254 status = csrRoamCallCallback(pMac,
10255 pDisConDoneInd->sessionId,
10256 &roamInfo, 0,
10257 eCSR_ROAM_LOSTLINK,
10258 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010259 pSession = CSR_GET_SESSION(pMac,
10260 pDisConDoneInd->sessionId);
10261 if (pSession &&
10262 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10263 csrRoamStateChange(pMac,
10264 eCSR_ROAMING_STATE_IDLE,
10265 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010266 }
10267 else
10268 {
10269 smsLog(pMac, LOGE, FL("Inactive session %d"),
10270 pDisConDoneInd->sessionId);
10271 }
10272 break;
10273
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 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 -080010275 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10277 //Update with the new channel id.
10278 //The channel id is hidden in the statusCode.
10279 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10280 if( HAL_STATUS_SUCCESS( status ) )
10281 {
10282 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010283 if(!pSession)
10284 {
10285 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10286 return;
10287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10289 if(pSession->pConnectBssDesc)
10290 {
10291 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10292 }
10293 }
10294 break;
10295
10296 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010297 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 {
10299 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10300 sessionId = pDeauthRsp->sessionId;
10301 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10302 {
10303 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10305 {
10306 pRoamInfo = &roamInfo;
10307 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010308 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10309 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010310 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10311 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10312 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10313 }
10314 }
10315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010316 break;
10317
10318 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010319 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010320 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 {
10322 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10323 sessionId = pDisassocRsp->sessionId;
10324 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10325 {
10326 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010327 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10328 {
10329 pRoamInfo = &roamInfo;
10330 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010331 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10332 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10334 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10335 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10336 }
10337 }
10338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010340 case eWNI_SME_LOST_LINK_PARAMS_IND:
10341 {
10342 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10343 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10344 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10345 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10346 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10347 pRoamInfo = &roamInfo;
10348 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10349 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10350 break;
10351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 case eWNI_SME_MIC_FAILURE_IND:
10353 {
10354 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10355 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10356 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010357
10358 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10359 if( HAL_STATUS_SUCCESS( status ) )
10360 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010361 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010362 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10363 pRoamInfo = &roamInfo;
10364 if(pMicInd->info.multicast)
10365 {
10366 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10367 }
10368 else
10369 {
10370 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10371 }
10372 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10373 }
10374
Jeff Johnson295189b2012-06-20 16:38:30 -070010375#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10376 {
lukez3c809222013-05-03 10:23:02 -070010377 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010379 if(!pSession)
10380 {
10381 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10382 return;
10383 }
lukez3c809222013-05-03 10:23:02 -070010384
Kiet Lam64c1b492013-07-12 13:56:44 +053010385 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10387 secEvent.encryptionModeMulticast =
10388 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10389 secEvent.encryptionModeUnicast =
10390 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10391 secEvent.authMode =
10392 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010393 vos_mem_copy(secEvent.bssid,
10394 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010395 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10396 }
10397#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 }
10399 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10401 {
10402 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10403 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010404 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010405
10406 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10407 if( HAL_STATUS_SUCCESS( status ) )
10408 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010409 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10411 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10412 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10413 }
10414 }
10415 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010416
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10418 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10419 switch( pStatusChangeMsg->statusChangeCode )
10420 {
10421 case eSIR_SME_IBSS_ACTIVE:
10422 sessionId = csrFindIbssSession( pMac );
10423 if( CSR_SESSION_ID_INVALID != sessionId )
10424 {
10425 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010426 if(!pSession)
10427 {
10428 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10429 return;
10430 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010431 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10432 if(pSession->pConnectBssDesc)
10433 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010434 vos_mem_copy(&roamInfo.bssid,
10435 pSession->pConnectBssDesc->bssId,
10436 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10438 pRoamInfo = &roamInfo;
10439 }
10440 else
10441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010442 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 }
10444 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10445 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10446 }
10447 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010448 case eSIR_SME_IBSS_INACTIVE:
10449 sessionId = csrFindIbssSession( pMac );
10450 if( CSR_SESSION_ID_INVALID != sessionId )
10451 {
10452 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010453 if(!pSession)
10454 {
10455 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10456 return;
10457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10459 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10460 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10461 }
10462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10464 sessionId = csrFindIbssSession( pMac );
10465 if( CSR_SESSION_ID_INVALID != sessionId )
10466 {
10467 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010468 if(!pSession)
10469 {
10470 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10471 return;
10472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 // update the connection state information
10474 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010475#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10476 {
10477 vos_log_ibss_pkt_type *pIbssLog;
10478 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010479 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10480 if(pIbssLog)
10481 {
10482 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10483 if(pNewBss)
10484 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010485 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 if(pNewBss->ssId.length)
10487 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010488 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
10489 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 }
10491 pIbssLog->operatingChannel = pNewBss->channelNumber;
10492 }
10493 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10494 {
10495 //***U8 is not enough for beacon interval
10496 pIbssLog->beaconInterval = (v_U8_t)bi;
10497 }
10498 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10499 }
10500 }
10501#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010502 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010503
10504 if ((eCSR_ENCRYPT_TYPE_NONE ==
10505 pSession->connectedProfile.EncryptionType ))
10506 {
10507 csrRoamIssueSetContextReq( pMac, sessionId,
10508 pSession->connectedProfile.EncryptionType,
10509 pSession->pConnectBssDesc,
10510 &Broadcastaddr,
10511 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010513 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10514 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010515 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10516 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 pRoamInfo = &roamInfo;
10518 //This BSSID is th ereal BSSID, let's save it
10519 if(pSession->pConnectBssDesc)
10520 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010521 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10522 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010525 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010527 // detection by LIM that the capabilities of the associated AP have changed.
10528 case eSIR_SME_AP_CAPS_CHANGED:
10529 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010530 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10532 if( HAL_STATUS_SUCCESS( status ) )
10533 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010534 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10535 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010536 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010537 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10538 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10539 )
10540 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010541 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10542 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010543 }
10544 else
10545 {
10546 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010547 FL("Skipping csrScanForCapabilityChange as "
10548 "CSR is in state %s and sub-state %s"),
10549 macTraceGetcsrRoamState(
10550 pMac->roam.curState[sessionId]),
10551 macTraceGetcsrRoamSubState(
10552 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010553 /* We ignore the caps change event if CSR is not in full connected state.
10554 * Send one event to PE to reset limSentCapsChangeNtf
10555 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10556 * otherwise lim cannot send any CAPS change events to SME */
10557 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 }
10560 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010561
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 default:
10563 roamStatus = eCSR_ROAM_FAILED;
10564 result = eCSR_ROAM_RESULT_NONE;
10565 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 } // end switch on statusChangeCode
10567 if(eCSR_ROAM_RESULT_NONE != result)
10568 {
10569 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10570 }
10571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 case eWNI_SME_IBSS_NEW_PEER_IND:
10573 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010574#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10575 {
10576 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10578 if(pIbssLog)
10579 {
10580 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010581 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10583 }
10584 }
10585#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 sessionId = csrFindIbssSession( pMac );
10587 if( CSR_SESSION_ID_INVALID != sessionId )
10588 {
10589 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010590
10591 if(!pSession)
10592 {
10593 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10594 return;
10595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10597 if(pSession->pConnectBssDesc)
10598 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010599 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10600 sizeof(tCsrBssid));
10601 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10602 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10604 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010605 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10606 - sizeof(tSmeIbssPeerInd)));
10607 if ( NULL == roamInfo.pbFrames )
10608 status = eHAL_STATUS_FAILURE;
10609 else
10610 status = eHAL_STATUS_SUCCESS;
10611 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010612 {
10613 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010614 vos_mem_copy(roamInfo.pbFrames,
10615 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10616 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 }
10618 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10619 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10620 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010621 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10622 if ( NULL == roamInfo.pBssDesc )
10623 status = eHAL_STATUS_FAILURE;
10624 else
10625 status = eHAL_STATUS_SUCCESS;
10626 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010628 vos_mem_copy(roamInfo.pBssDesc,
10629 pSession->pConnectBssDesc,
10630 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010631 }
10632 if(HAL_STATUS_SUCCESS(status))
10633 {
10634 pRoamInfo = &roamInfo;
10635 }
10636 else
10637 {
10638 if(roamInfo.pbFrames)
10639 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010640 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 }
10642 if(roamInfo.pBssDesc)
10643 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010644 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 }
10646 }
10647 }
10648 else
10649 {
10650 pRoamInfo = &roamInfo;
10651 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010652 if ((eCSR_ENCRYPT_TYPE_NONE ==
10653 pSession->connectedProfile.EncryptionType ))
10654 {
10655 csrRoamIssueSetContextReq( pMac, sessionId,
10656 pSession->connectedProfile.EncryptionType,
10657 pSession->pConnectBssDesc,
10658 &(pIbssPeerInd->peerAddr),
10659 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 }
10662 else
10663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010664 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 }
10666 //send up the sec type for the new peer
10667 if (pRoamInfo)
10668 {
10669 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10670 }
10671 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10672 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10673 if(pRoamInfo)
10674 {
10675 if(roamInfo.pbFrames)
10676 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010677 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 }
10679 if(roamInfo.pBssDesc)
10680 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010681 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 }
10683 }
10684 }
10685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10687 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10688 sessionId = csrFindIbssSession( pMac );
10689 if( CSR_SESSION_ID_INVALID != sessionId )
10690 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010691#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10692 {
10693 vos_log_ibss_pkt_type *pIbssLog;
10694
10695 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10696 if(pIbssLog)
10697 {
10698 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10699 if(pIbssPeerInd)
10700 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010701 vos_mem_copy(pIbssLog->peerMacAddr,
10702 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 }
10704 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10705 }
10706 }
10707#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010708 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10710 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10711 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010712 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10713 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010714 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10715 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10716 }
10717 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 case eWNI_SME_SETCONTEXT_RSP:
10719 {
10720 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10721 tListElem *pEntry;
10722 tSmeCmd *pCommand;
10723
10724 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10725 if ( pEntry )
10726 {
10727 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10728 if ( eSmeCommandSetKey == pCommand->command )
10729 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010730 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010732
10733 if(!pSession)
10734 {
10735 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10736 return;
10737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010738
10739#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10740 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10741 {
10742 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010743 vos_mem_set(&setKeyEvent,
10744 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 if( pRsp->peerMacAddr[0] & 0x01 )
10746 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010747 setKeyEvent.eventId =
10748 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 }
10750 else
10751 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010752 setKeyEvent.eventId =
10753 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010755 if( pRsp->peerMacAddr[0] & 0x01 )
10756 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010757 pMac->pmc.full_power_till_set_key = false;
10758 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010759 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 setKeyEvent.encryptionModeMulticast =
10761 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10762 setKeyEvent.encryptionModeUnicast =
10763 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010764 vos_mem_copy(setKeyEvent.bssid,
10765 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 setKeyEvent.authMode =
10767 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010768 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010769 {
10770 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10771 }
10772 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10773 }
10774#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10775 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10776 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010777 csrRoamStopWaitForKeyTimer( pMac );
10778
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 //We are done with authentication, whethere succeed or not
10780 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 //We do it here because this linkup function is not called after association
10782 //when a key needs to be set.
10783 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10784 {
10785 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10786 }
10787 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010788 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010790 vos_mem_copy(&roamInfo.peerMac,
10791 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010792 //Make sure we install the GTK before indicating to HDD as authenticated
10793 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010794 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10795 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010796 {
Yathish9f22e662012-12-10 14:21:35 -080010797#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10798 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10799 {
10800 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010801 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010802 if (NULL == pMsg)
10803 {
10804 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10805 return;
10806 }
10807
Yathish9f22e662012-12-10 14:21:35 -080010808 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010809 pMsg->length = pal_cpu_to_be16(sizeof(
10810 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010811 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010812 vos_mem_copy(pMsg->bssid,
10813 pSession->connectedProfile.bssid,
10814 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010815 status = palSendMBMessage(pMac->hHdd, pMsg );
10816 }
10817#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010818 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010819 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010820 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010821 && (pSession->connectState ==
10822 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10823 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010824 && (VOS_P2P_GO_MODE !=
10825 pSession->pCurRoamProfile->csrPersona
10826 && VOS_STA_SAP_MODE !=
10827 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010828 {
10829 tpSirSmeHT40OBSSScanInd pMsg;
10830 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010831 if (NULL == pMsg)
10832 {
10833 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10834 return;
10835 }
10836
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010837 pMsg->messageType =
10838 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10839 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010840 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10841 vos_mem_copy(pMsg->peerMacAddr,
10842 pSession->connectedProfile.bssid,
10843 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010844 status = palSendMBMessage(pMac->hHdd,
10845 pMsg );
10846 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010847 else
10848 {
10849 smsLog( pMac, LOG1,FL("OBSS SCAN"
10850 "Indication not sent to FW"
10851 "channel %d OBSS_SCAN: %d"),
10852 pSession->connectedProfile.
10853 operationChannel,
10854 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10855 smsLog( pMac, LOG1,FL("connectState %d"
Jeff Johnson89477502017-09-19 08:35:23 -070010856 "pCurRoamProfile %pK"),
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010857 pSession->connectState,
10858 pSession->pCurRoamProfile);
10859 }
10860
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010861 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010862 }
10863 else
10864 {
10865 result = eCSR_ROAM_RESULT_NONE;
10866 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010867 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 }
10869 else
10870 {
10871 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010872 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10873 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10874 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010876 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10878 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10880 // can go ahead and initiate the TSPEC if any are pending
10881 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010882#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 //Send Adjacent AP repot to new AP.
10884 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10885 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010886 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010888#ifdef FEATURE_WLAN_ESE_UPLOAD
10889 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010890#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010891 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010892#endif
10893 pSession->isPrevApInfoValid = FALSE;
10894 }
10895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010896 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10897 {
10898 csrReleaseCommandSetKey( pMac, pCommand );
10899 }
10900 }
10901 else
10902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010903 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 }
10905 }
10906 else
10907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010908 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 smeProcessPendingQueue( pMac );
10911 }
10912 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 case eWNI_SME_REMOVEKEY_RSP:
10914 {
10915 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10916 tListElem *pEntry;
10917 tSmeCmd *pCommand;
10918
10919 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10920 if ( pEntry )
10921 {
10922 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10923 if ( eSmeCommandRemoveKey == pCommand->command )
10924 {
10925 sessionId = pCommand->sessionId;
10926 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010927
10928 if(!pSession)
10929 {
10930 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10931 return;
10932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010933#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10934 {
10935 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010936 vos_mem_set(&removeKeyEvent,
10937 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10939 removeKeyEvent.encryptionModeMulticast =
10940 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10941 removeKeyEvent.encryptionModeUnicast =
10942 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010943 vos_mem_copy( removeKeyEvent.bssid,
10944 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010945 removeKeyEvent.authMode =
10946 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010947 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 {
10949 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10950 }
10951 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10952 }
10953#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010954 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010956 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10957 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010958 result = eCSR_ROAM_RESULT_NONE;
10959 pRoamInfo = &roamInfo;
10960 }
10961 else
10962 {
10963 result = eCSR_ROAM_RESULT_FAILURE;
10964 }
10965 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10966 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10967 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10968 {
10969 csrReleaseCommandRemoveKey( pMac, pCommand );
10970 }
10971 }
10972 else
10973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010974 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010975 }
10976 }
10977 else
10978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010979 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 smeProcessPendingQueue( pMac );
10982 }
10983 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010985 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010986 csrRoamStatsRspProcessor( pMac, pSirMsg );
10987 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010988#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010989 case eWNI_SME_GET_ROAM_RSSI_RSP:
10990 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10991 csrRoamRssiRspProcessor( pMac, pSirMsg );
10992 break;
10993#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010994#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010995 case eWNI_SME_GET_TSM_STATS_RSP:
10996 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10997 csrTsmStatsRspProcessor( pMac, pSirMsg );
10998 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010999#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011001 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 csrUpdateRssi( pMac, pSirMsg );
11003 break;
11004
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011005 case eWNI_SME_GET_SNR_REQ:
11006 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
11007 csrUpdateSnr(pMac, pSirMsg);
11008 break;
11009
Jeff Johnson295189b2012-06-20 16:38:30 -070011010#ifdef WLAN_FEATURE_VOWIFI_11R
11011 case eWNI_SME_FT_PRE_AUTH_RSP:
11012 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
11013 break;
11014#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053011015#ifdef WLAN_FEATURE_LFR_MBB
11016 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
11017 csr_roam_preauth_rsp_mbb_processor(pMac,
11018 (tpSirFTPreAuthRsp)pSirMsg);
11019 break;
11020#endif
11021
Jeff Johnson295189b2012-06-20 16:38:30 -070011022 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11023 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011024 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 -070011025 sessionId = pSmeMaxAssocInd->sessionId;
11026 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011027 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
11028 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11030 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11031 break;
11032
11033 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011034 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 btampEstablishLogLinkHdlr( pSirMsg );
11036 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070011037 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011038 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011039 csrRoamRssiIndHdlr( pMac, pSirMsg );
11040 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011041#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11042 case eWNI_SME_CANDIDATE_FOUND_IND:
11043 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
11044 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
11045 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070011046 case eWNI_SME_HANDOFF_REQ:
11047 smsLog( pMac, LOG2, FL("Handoff Req from self"));
11048 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
11049 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011050#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011051
11052 default:
11053 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070011055}
11056
Jeff Johnson295189b2012-06-20 16:38:30 -070011057void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
11058 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
11059{
11060 if(pSession)
11061 {
11062 if(pSession->bRefAssocStartCnt)
11063 {
11064 pSession->bRefAssocStartCnt--;
11065 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11066 //Need to call association_completion because there is an assoc_start pending.
11067 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11068 eCSR_ROAM_ASSOCIATION_COMPLETION,
11069 eCSR_ROAM_RESULT_FAILURE);
11070 }
11071 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11072 }
11073 else
11074 {
11075 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11076 }
11077}
11078
11079
11080eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11081{
11082 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11084 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11085 {
11086 status = csrScanRequestLostLink1( pMac, sessionId );
11087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011088 return(status);
11089}
11090
Jeff Johnson295189b2012-06-20 16:38:30 -070011091//return a boolean to indicate whether roaming completed or continue.
11092tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11093 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11094{
11095 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11096 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11097 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11098 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011099 if(!pSession)
11100 {
11101 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11102 return eANI_BOOLEAN_FALSE;
11103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011104 //Check whether time is up
11105 if(pSession->fCancelRoaming || fForce ||
11106 ((curTime - pSession->roamingStartTime) > roamTime) ||
11107 eCsrReassocRoaming == pSession->roamingReason ||
11108 eCsrDynamicRoaming == pSession->roamingReason)
11109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011110 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011111 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11112 {
11113 //roaming is cancelled, tell HDD to indicate disconnect
11114 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11115 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11116 //to be eSIR_BEACON_MISSED
11117 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11118 {
11119 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11120 }
11121 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11122 {
11123 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11124 }
11125 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11126 {
11127 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11128 }
11129 else
11130 {
11131 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11132 }
11133 }
11134 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11135 pSession->roamingReason = eCsrNotRoaming;
11136 }
11137 else
11138 {
11139 pSession->roamResult = roamResult;
11140 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11141 {
11142 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11143 pSession->roamingReason = eCsrNotRoaming;
11144 }
11145 else
11146 {
11147 fCompleted = eANI_BOOLEAN_FALSE;
11148 }
11149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 return(fCompleted);
11151}
11152
Jeff Johnson295189b2012-06-20 16:38:30 -070011153void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11154{
11155 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011156
11157 if(!pSession)
11158 {
11159 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11160 return;
11161 }
11162
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 if(CSR_IS_ROAMING(pSession))
11164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011165 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011166 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11167 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11168 {
11169 //No need to do anything in here because the handler takes care of it
11170 }
11171 else
11172 {
11173 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11174 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11175 //Roaming is stopped after here
11176 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11177 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011178 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 csrRoamStopRoamingTimer(pMac, sessionId);
11180 }
11181 }
11182}
11183
Jeff Johnson295189b2012-06-20 16:38:30 -070011184void csrRoamRoamingTimerHandler(void *pv)
11185{
11186 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11187 tpAniSirGlobal pMac = pInfo->pMac;
11188 tANI_U32 sessionId = pInfo->sessionId;
11189 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011190
11191 if(!pSession)
11192 {
11193 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11194 return;
11195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011196
11197 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11198 {
11199 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11200 {
11201 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11202 pSession->roamingReason = eCsrNotRoaming;
11203 }
11204 }
11205}
11206
Jeff Johnson295189b2012-06-20 16:38:30 -070011207eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11208{
11209 eHalStatus status;
11210 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011211
11212 if(!pSession)
11213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011214 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011215 return eHAL_STATUS_FAILURE;
11216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011217
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011218 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011220 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011221
11222 return (status);
11223}
11224
Jeff Johnson295189b2012-06-20 16:38:30 -070011225eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11226{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011227 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011228}
11229
Jeff Johnson295189b2012-06-20 16:38:30 -070011230void csrRoamWaitForKeyTimeOutHandler(void *pv)
11231{
11232 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11233 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011234 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011235 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011236
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011237 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011238 macTraceGetNeighbourRoamState(
11239 pMac->roam.neighborRoamInfo.neighborRoamState),
11240 macTraceGetcsrRoamSubState(
11241 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011242
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011243 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011245 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011246 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11247 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011248 //Change the substate so command queue is unblocked.
11249 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11250 pMac->roam.curSubState[pInfo->sessionId] =
11251 eCSR_ROAM_SUBSTATE_NONE;
11252 vos_spin_lock_release(&pMac->roam.roam_state_lock);
11253
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011254#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011255 if (csrNeighborRoamIsHandoffInProgress(pMac))
11256 {
11257 /*
11258 * Enable heartbeat timer when hand-off is in progress
11259 * and Key Wait timer expired.
11260 */
11261 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11262 " (nHBCount=%d)",
11263 pMac->roam.configParam.HeartbeatThresh24);
11264 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11265 pMac->roam.configParam.HeartbeatThresh24,
11266 NULL, eANI_BOOLEAN_FALSE);
11267 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011268#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011269
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011270 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011271
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011272 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011273 {
11274 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11275 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011276 status = sme_AcquireGlobalLock(&pMac->sme);
11277 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011278 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011279 csrRoamDisconnect(pMac, pInfo->sessionId,
11280 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11281 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011282 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011283 }
11284 else
11285 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011286 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11287 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011288 }
11289 }
11290 else
11291 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011292 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011293 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 }
11296
11297}
11298
Jeff Johnson295189b2012-06-20 16:38:30 -070011299eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11300{
11301 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011302#ifdef FEATURE_WLAN_LFR
11303 if (csrNeighborRoamIsHandoffInProgress(pMac))
11304 {
11305 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011306 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11307 macTraceGetNeighbourRoamState(
11308 pMac->roam.neighborRoamInfo.neighborRoamState),
11309 macTraceGetcsrRoamSubState(
11310 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11311 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011312 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11313 }
11314#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011315 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011316 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011317
11318 return (status);
11319}
11320
Jeff Johnson295189b2012-06-20 16:38:30 -070011321eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11322{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011323 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11324 macTraceGetNeighbourRoamState(
11325 pMac->roam.neighborRoamInfo.neighborRoamState),
11326 macTraceGetcsrRoamSubState(
11327 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011328#ifdef FEATURE_WLAN_LFR
11329 if (csrNeighborRoamIsHandoffInProgress(pMac))
11330 {
11331 /*
11332 * Enable heartbeat timer when hand-off is in progress
11333 * and Key Wait timer got stopped for some reason
11334 */
11335 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011336 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011337 pMac->roam.configParam.HeartbeatThresh24);
11338 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11339 pMac->roam.configParam.HeartbeatThresh24,
11340 NULL, eANI_BOOLEAN_FALSE);
11341 }
11342#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011343 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011344}
11345
Jeff Johnson295189b2012-06-20 16:38:30 -070011346void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11347 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11348{
11349 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11350 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011351 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11352 /* To silence the KW tool Null chaeck is added */
11353 if(!pSession)
11354 {
11355 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11356 return;
11357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011358
11359 if(pCommand)
11360 {
11361 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11365 {
11366 //if success, force roaming completion
11367 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11368 }
11369 else
11370 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011371 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011372 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11374 }
11375}
11376
Jeff Johnson295189b2012-06-20 16:38:30 -070011377eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11378{
11379 eHalStatus status = eHAL_STATUS_SUCCESS;
11380 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11381 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11382 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011384 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011386 /* To silence the KW tool Null chaeck is added */
11387 if(!pSession)
11388 {
11389 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11390 return eHAL_STATUS_FAILURE;
11391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011393 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011395 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 if ( eWNI_SME_DISASSOC_IND == type )
11397 {
11398 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11399 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11400 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011401 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011402 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11403 sizeof(tSirMacAddr));
11404 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 }
11406 else if ( eWNI_SME_DEAUTH_IND == type )
11407 {
11408 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11409 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11410 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011411 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011412 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11413 sizeof(tSirMacAddr));
11414 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 }
11416 else
11417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011418 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011420 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011422 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11423 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11424 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
11425
11426 if (type == eWNI_SME_DEAUTH_IND || type == eWNI_SME_DISASSOC_IND) {
11427 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11428 eCSR_ROAM_LOSTLINK_DETECTED, result);
11429 } else if(!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11430 csrRoamCallCallback(pMac, sessionId, NULL, 0,
11431 eCSR_ROAM_LOSTLINK_DETECTED, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 }
11433
11434 if ( eWNI_SME_DISASSOC_IND == type )
11435 {
11436 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11437 }
11438 else if ( eWNI_SME_DEAUTH_IND == type )
11439 {
11440 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011442 if(!HAL_STATUS_SUCCESS(status))
11443 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011444 //If fail to send confirmation to PE, not to trigger roaming
11445 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 }
11447
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011448
11449 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11450 that we are roaming. But if we cannot possibly roam, or if we are unable to
11451 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 if(fToRoam)
11453 {
11454 //Only remove the connected BSS in infrastructure mode
11455 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11456 //Not to do anying for lostlink with WDS
11457 if( pMac->roam.configParam.nRoamingTime )
11458 {
11459 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
11460 ( eWNI_SME_DEAUTH_IND == type ) ?
11461 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
11462 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011463 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 //For IBSS, we need to give some more info to HDD
11465 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
11466 {
11467 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
11468 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11469 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11470 }
11471 else
11472 {
11473 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
11474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
11476 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
11477 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011478 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 }
11480 else
11481 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011482 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 fToRoam = eANI_BOOLEAN_FALSE;
11484 }
11485 }
11486 else
11487 {
11488 //We are told not to roam, indicate lostlink
11489 fToRoam = eANI_BOOLEAN_FALSE;
11490 }
11491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 if(!fToRoam)
11493 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011494 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 Still enable idle scan for polling in case concurrent sessions are running */
11496 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11497 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011498 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 }
11500 }
11501
11502 return (status);
11503}
11504
Jeff Johnson295189b2012-06-20 16:38:30 -070011505eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11506{
11507 eHalStatus status = eHAL_STATUS_SUCCESS;
11508 tListElem *pEntry = NULL;
11509 tSmeCmd *pCommand = NULL;
11510 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011511
11512 if(!pSession)
11513 {
11514 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11515 return eHAL_STATUS_FAILURE;
11516 }
11517
Jeff Johnson295189b2012-06-20 16:38:30 -070011518 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 //Only remove the connected BSS in infrastructure mode
11520 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11521 if(pMac->roam.configParam.nRoamingTime)
11522 {
11523 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11524 {
11525 //before starting the lost link logic release the roam command for handoff
11526 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11527 if(pEntry)
11528 {
11529 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11530 }
11531 if(pCommand)
11532 {
11533 if (( eSmeCommandRoam == pCommand->command ) &&
11534 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11535 {
11536 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11537 {
11538 csrReleaseCommandRoam( pMac, pCommand );
11539 }
11540 }
11541 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011542 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 }
11544 }
11545 else
11546 {
11547 //We are told not to roam, indicate lostlink
11548 status = eHAL_STATUS_FAILURE;
11549 }
11550
11551 return (status);
11552}
Jeff Johnson295189b2012-06-20 16:38:30 -070011553void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11554{
11555 tListElem *pEntry;
11556 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11558 if ( pEntry )
11559 {
11560 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11561 if ( eSmeCommandWmStatusChange == pCommand->command )
11562 {
11563 // Nothing to process in a Lost Link completion.... It just kicks off a
11564 // roaming sequence.
11565 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11566 {
11567 csrReleaseCommandWmStatusChange( pMac, pCommand );
11568 }
11569 else
11570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011571 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 }
11573
11574 }
11575 else
11576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011577 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011578 }
11579 }
11580 else
11581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011582 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 smeProcessPendingQueue( pMac );
11585}
11586
Jeff Johnson295189b2012-06-20 16:38:30 -070011587void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11588{
11589 eHalStatus status = eHAL_STATUS_FAILURE;
11590 tSirSmeRsp *pSirSmeMsg;
11591 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011592
11593 if(!pSession)
11594 {
11595 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11596 return;
11597 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011598 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11599 pCommand->sessionId,
11600 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 switch ( pCommand->u.wmStatusChangeCmd.Type )
11602 {
11603 case eCsrDisassociated:
11604 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11605 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11606 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 case eCsrDeauthenticated:
11608 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11609 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011612 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 break;
11614 }
11615 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11616 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11617 {
11618 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11619 {
11620 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011621 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011622 }
11623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11625 // command here since there is nothing else to do.
11626 csrRoamWmStatusChangeComplete( pMac );
11627}
11628
Jeff Johnson295189b2012-06-20 16:38:30 -070011629//This function returns band and mode information.
11630//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11631//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011632static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11633 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011634{
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11636 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11637 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011639
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 //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 -070011641 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11642 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11643 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11644 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 {
11646 switch( pMac->roam.configParam.uCfgDot11Mode )
11647 {
11648 case eCSR_CFG_DOT11_MODE_11A:
11649 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11650 eBand = eCSR_BAND_5G;
11651 break;
11652 case eCSR_CFG_DOT11_MODE_11B:
11653 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11654 eBand = eCSR_BAND_24;
11655 break;
11656 case eCSR_CFG_DOT11_MODE_11G:
11657 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11658 eBand = eCSR_BAND_24;
11659 break;
11660 case eCSR_CFG_DOT11_MODE_11N:
11661 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011662 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11663 break;
11664#ifdef WLAN_FEATURE_11AC
11665 case eCSR_CFG_DOT11_MODE_11AC:
11666 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11667 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011668 /* If the operating channel is in 2.4 GHz band, check for
11669 * INI item to disable VHT operation in 2.4 GHz band
11670 */
11671 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11672 !pMac->roam.configParam.enableVhtFor24GHz)
11673 {
11674 /* Disable 11AC operation */
11675 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11676 }
11677 else
11678 {
11679 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11680 }
11681 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011682 }
11683 else
11684 {
11685 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11686 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11687 }
11688 break;
11689 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11690 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11691 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011692 /* If the operating channel is in 2.4 GHz band, check for
11693 * INI item to disable VHT operation in 2.4 GHz band
11694 */
11695 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11696 !pMac->roam.configParam.enableVhtFor24GHz)
11697 {
11698 /* Disable 11AC operation */
11699 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11700 }
11701 else
11702 {
11703 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11704 }
11705 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011706 }
11707 else
11708 {
11709 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11710 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11711 }
11712 break;
11713#endif
11714 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011715#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011716 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11717 {
11718 /* If the operating channel is in 2.4 GHz band, check for
11719 * INI item to disable VHT operation in 2.4 GHz band
11720 */
11721 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11722 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011723 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011724 /* Disable 11AC operation */
11725 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011726 }
11727 else
11728 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011729 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11730 }
11731 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11732 }
11733 else
11734 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011735 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11736 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011737 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011738#else
11739 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11740 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11741#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011742 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 default:
11744 // Global dot11 Mode setting is 11a/b/g.
11745 // use the channel number to determine the Mode setting.
11746 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11747 {
11748 eBand = pMac->roam.configParam.eBand;
11749 if(eCSR_BAND_24 == eBand)
11750 {
11751 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11752 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11753 }
11754 else
11755 {
11756 //prefer 5GHz
11757 eBand = eCSR_BAND_5G;
11758 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11759 }
11760 }
11761 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11762 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011763 // WiFi tests require IBSS networks to start in 11b mode
11764 // without any change to the default parameter settings
11765 // on the adapter. We use ACU to start an IBSS through
11766 // creation of a startIBSS profile. This startIBSS profile
11767 // has Auto MACProtocol and the adapter property setting
11768 // for dot11Mode is also AUTO. So in this case, let's
11769 // start the IBSS network in 11b mode instead of 11g mode.
11770 // So this is for Auto=profile->MacProtocol && Auto=Global.
11771 // dot11Mode && profile->channel is < 14, then start the IBSS
11772 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011773 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011774 // Note: we used to have this start as an 11g IBSS for best
11775 // performance... now to specify that the user will have to
11776 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11778 eBand = eCSR_BAND_24;
11779 }
11780 else
11781 {
11782 // else, it's a 5.0GHz channel. Set mode to 11a.
11783 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11784 eBand = eCSR_BAND_5G;
11785 }
11786 break;
11787 }//switch
11788 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11789 else
11790 {
11791 //dot11 mode is set, lets pick the band
11792 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11793 {
11794 // channel is Auto also.
11795 eBand = pMac->roam.configParam.eBand;
11796 if(eCSR_BAND_ALL == eBand)
11797 {
11798 //prefer 5GHz
11799 eBand = eCSR_BAND_5G;
11800 }
11801 }
11802 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11803 {
11804 eBand = eCSR_BAND_24;
11805 }
11806 else
11807 {
11808 eBand = eCSR_BAND_5G;
11809 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 if(pBand)
11812 {
11813 *pBand = eBand;
11814 }
11815
11816 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011817 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11819 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011820
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011821 /* 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 +053011822 if (
11823#ifdef SAP_AUTH_OFFLOAD
11824 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11825#endif
11826 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11827 ((pProfile->privacy == 1) &&
11828 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011829 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011830#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011831 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011832#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011833 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11834 {
11835 //We cannot do 11n here
11836 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11837 {
11838 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11839 }
11840 else
11841 {
11842 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11843 }
11844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011845 return( cfgDot11Mode );
11846}
11847
Jeff Johnson295189b2012-06-20 16:38:30 -070011848eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11849{
11850 eHalStatus status;
11851 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011852
11853 if(!pSession)
11854 {
11855 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11856 return eHAL_STATUS_FAILURE;
11857 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011858
11859#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11860 {
11861 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11863 if(pIbssLog)
11864 {
11865 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11866 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11867 }
11868 }
11869#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 // Set the roaming substate to 'stop Bss request'...
11871 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11872
11873 // attempt to stop the Bss (reason code is ignored...)
11874 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011875 if(!HAL_STATUS_SUCCESS(status))
11876 {
11877 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 return (status);
11880}
11881
Jeff Johnson295189b2012-06-20 16:38:30 -070011882//pNumChan is a caller allocated space with the sizeof pChannels
11883eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11884{
11885
11886 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11887 (tANI_U8 *)pChannels,
11888 pNumChan));
11889}
11890
Kiran4a17ebe2013-01-31 10:43:43 -080011891tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11892{
11893 tANI_U32 cfgLength = 0;
11894 tANI_U16 cfgId = 0;
11895 tPowerdBm maxTxPwr = 0;
11896 tANI_U8 *pCountryInfo = NULL;
11897 eHalStatus status;
11898 tANI_U8 count = 0;
11899 tANI_U8 firstChannel;
11900 tANI_U8 maxChannels;
11901
11902 if (CSR_IS_CHANNEL_5GHZ(channel))
11903 {
11904 cfgId = WNI_CFG_MAX_TX_POWER_5;
11905 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11906 }
11907 else if (CSR_IS_CHANNEL_24GHZ(channel))
11908 {
11909 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11910 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11911 }
11912 else
11913 return maxTxPwr;
11914
Kiet Lam64c1b492013-07-12 13:56:44 +053011915 pCountryInfo = vos_mem_malloc(cfgLength);
11916 if ( NULL == pCountryInfo )
11917 status = eHAL_STATUS_FAILURE;
11918 else
11919 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011920 if (status != eHAL_STATUS_SUCCESS)
11921 {
11922 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011923 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011924 __FUNCTION__, status);
11925 goto error;
11926 }
11927 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11928 if (status != eHAL_STATUS_SUCCESS)
11929 {
11930 goto error;
11931 }
11932 /* Identify the channel and maxtxpower */
11933 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11934 {
11935 firstChannel = pCountryInfo[count++];
11936 maxChannels = pCountryInfo[count++];
11937 maxTxPwr = pCountryInfo[count++];
11938
11939 if ((channel >= firstChannel) &&
11940 (channel < (firstChannel + maxChannels)))
11941 {
11942 break;
11943 }
11944 }
11945
11946error:
11947 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011948 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011949
11950 return maxTxPwr;
11951}
11952
11953
Jeff Johnson295189b2012-06-20 16:38:30 -070011954tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11955{
11956 tANI_BOOLEAN fValid = FALSE;
11957 tANI_U32 idxValidChannels;
11958 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11959
11960 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11961 {
11962 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11963 {
11964 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11965 {
11966 fValid = TRUE;
11967 break;
11968 }
11969 }
11970 }
11971 pMac->roam.numValidChannels = len;
11972 return fValid;
11973}
11974
Jeff Johnson295189b2012-06-20 16:38:30 -070011975tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11976{
11977 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11978 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11980 {
11981 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11982 {
11983 fValid = eANI_BOOLEAN_TRUE;
11984 break;
11985 }
11986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 return (fValid);
11988}
11989
Jeff Johnson295189b2012-06-20 16:38:30 -070011990//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011991 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011992{
Jeff Johnsone7245742012-09-05 17:12:55 -070011993 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 tANI_U8 centerChn;
11995 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011996
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11998 {
11999 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
12000 }
12001 else
12002 {
12003 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
12004 }
12005 //Figure what the other side's CB mode
12006 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
12007 {
12008 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
12009 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053012010 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
12011 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
12012 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
12013 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012014 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
12015 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053012016 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012017 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053012018
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080012019 {
12020 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
12021 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12022 }
12023
12024 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012026 /* This is called during INFRA STA/CLIENT and should use the merged value of
12027 * supported channel width and recommended tx width as per standard
12028 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012029 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070012030 pIes->HTCaps.supportedChannelWidthSet,
12031 pIes->HTInfo.recommendedTxWidthSet,
12032 pIes->HTInfo.secondaryChannelOffset);
12033
12034 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12035 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 else
Jeff Johnsone7245742012-09-05 17:12:55 -070012037 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12038 switch (eRet) {
12039 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12040 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12041 break;
12042 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12043 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12044 break;
12045 case PHY_SINGLE_CHANNEL_CENTERED:
12046 default:
12047 centerChn = primaryChn;
12048 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012050 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070012051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012052 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012053 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012055 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12056 {
12057 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12058 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 }
12061 }
12062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 return eRet;
12064}
Jeff Johnson295189b2012-06-20 16:38:30 -070012065tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12066{
12067 tANI_BOOLEAN fFound = FALSE;
12068 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12070 {
12071 if( pCipherList->encryptionType[idx] == encryptionType )
12072 {
12073 fFound = TRUE;
12074 break;
12075 }
12076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 return fFound;
12078}
Jeff Johnson295189b2012-06-20 16:38:30 -070012079tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12080{
12081 tANI_BOOLEAN fFound = FALSE;
12082 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12084 {
12085 if( pAuthList->authType[idx] == authType )
12086 {
12087 fFound = TRUE;
12088 break;
12089 }
12090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012091 return fFound;
12092}
Jeff Johnson295189b2012-06-20 16:38:30 -070012093tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12094{
12095 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12096 tCsrScanResultFilter *pScanFilter = NULL;
12097 eHalStatus status = eHAL_STATUS_SUCCESS;
12098
12099 if(pProfile1 && pProfile2)
12100 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012101 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12102 if ( NULL == pScanFilter )
12103 status = eHAL_STATUS_FAILURE;
12104 else
12105 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 if(HAL_STATUS_SUCCESS(status))
12107 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012108 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12110 if(HAL_STATUS_SUCCESS(status))
12111 {
12112 fCheck = eANI_BOOLEAN_FALSE;
12113 do
12114 {
12115 tANI_U32 i;
12116 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12117 {
12118 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12119 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12120 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12121 if ( fCheck ) break;
12122 }
12123 if(!fCheck)
12124 {
12125 break;
12126 }
12127 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12128 || pProfile2->BSSType != pProfile1->BSSType
12129 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12130 )
12131 {
12132 fCheck = eANI_BOOLEAN_FALSE;
12133 break;
12134 }
12135#ifdef WLAN_FEATURE_VOWIFI_11R
12136 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12137 {
12138 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12139 {
12140 fCheck = eANI_BOOLEAN_FALSE;
12141 break;
12142 }
12143 }
12144#endif
12145 //Match found
12146 fCheck = eANI_BOOLEAN_TRUE;
12147 }while(0);
12148 csrFreeScanFilter(pMac, pScanFilter);
12149 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012150 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 }
12152 }
12153
12154 return (fCheck);
12155}
12156
Jeff Johnson295189b2012-06-20 16:38:30 -070012157tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12158{
12159 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12160 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 do
12162 {
12163 //Only check for static WEP
12164 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12165 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12166 {
12167 fCheck = eANI_BOOLEAN_TRUE;
12168 break;
12169 }
12170 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12171 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12172 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12173 {
12174 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012175 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12176 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 {
12178 break;
12179 }
12180 }
12181 if( i == CSR_MAX_NUM_KEY)
12182 {
12183 fCheck = eANI_BOOLEAN_TRUE;
12184 }
12185 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 return (fCheck);
12187}
12188
Jeff Johnson295189b2012-06-20 16:38:30 -070012189//IBSS
12190
Jeff Johnson295189b2012-06-20 16:38:30 -070012191tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12192{
12193 tANI_U8 channel = 0;
12194 tANI_U32 idx;
12195 tANI_U32 idxValidChannels;
12196 tANI_BOOLEAN fFound = FALSE;
12197 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12198
12199 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12200 {
12201 channel = pMac->roam.configParam.AdHocChannel5G;
12202 if(!csrRoamIsChannelValid(pMac, channel))
12203 {
12204 channel = 0;
12205 }
12206 }
12207 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12208 {
12209 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12210 {
12211 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12212 {
12213 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12214 {
12215 fFound = TRUE;
12216 channel = csrStartIbssChannels50[ idx ];
12217 }
12218 }
12219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12221 if (!fFound)
12222 {
12223 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12224 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012225 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012227 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 break;
12229 }
12230 }
12231 }
12232 }//if
12233
12234 return( channel );
12235}
12236
Jeff Johnson295189b2012-06-20 16:38:30 -070012237tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12238{
12239 tANI_U8 channel = 1;
12240 tANI_U32 idx;
12241 tANI_U32 idxValidChannels;
12242 tANI_BOOLEAN fFound = FALSE;
12243 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12244
12245 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12246 {
12247 channel = pMac->roam.configParam.AdHocChannel24;
12248 if(!csrRoamIsChannelValid(pMac, channel))
12249 {
12250 channel = 0;
12251 }
12252 }
12253
12254 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12255 {
12256 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12257 {
12258 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12259 {
12260 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12261 {
12262 fFound = TRUE;
12263 channel = csrStartIbssChannels24[ idx ];
12264 }
12265 }
12266 }
12267 }
12268
12269 return( channel );
12270}
12271
Jeff Johnson295189b2012-06-20 16:38:30 -070012272static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12273 tCsrRoamStartBssParams *pParam )
12274{
12275 eCsrCfgDot11Mode cfgDot11Mode;
12276 eCsrBand eBand;
12277 tANI_U8 channel = 0;
12278 tSirNwType nwType;
12279 tANI_U8 operationChannel = 0;
12280
12281 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12282 {
12283 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12284 }
12285
Jeff Johnson295189b2012-06-20 16:38:30 -070012286 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012287
Jeff Johnson295189b2012-06-20 16:38:30 -070012288 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12289 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12290 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12291 )
12292 {
12293 /* This should never happen */
12294 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012295 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 pProfile->csrPersona);
12297 VOS_ASSERT(0);
12298 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 switch( cfgDot11Mode )
12300 {
12301 case eCSR_CFG_DOT11_MODE_11G:
12302 nwType = eSIR_11G_NW_TYPE;
12303 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 case eCSR_CFG_DOT11_MODE_11B:
12305 nwType = eSIR_11B_NW_TYPE;
12306 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 case eCSR_CFG_DOT11_MODE_11A:
12308 nwType = eSIR_11A_NW_TYPE;
12309 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 default:
12311 case eCSR_CFG_DOT11_MODE_11N:
12312 case eCSR_CFG_DOT11_MODE_TAURUS:
12313 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12314 if(eCSR_BAND_24 == eBand)
12315 {
12316 nwType = eSIR_11G_NW_TYPE;
12317 }
12318 else
12319 {
12320 nwType = eSIR_11A_NW_TYPE;
12321 }
12322 break;
12323 }
12324
12325 pParam->extendedRateSet.numRates = 0;
12326
12327 switch ( nwType )
12328 {
12329 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012330 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 case eSIR_11A_NW_TYPE:
12332
12333 pParam->operationalRateSet.numRates = 8;
12334
12335 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12336 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12337 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12338 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12339 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12340 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12341 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12342 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12343
12344 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12345 {
12346 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12347 if( 0 == channel &&
12348 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12349 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12350 )
12351 {
12352 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12353 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12354 nwType = eSIR_11B_NW_TYPE;
12355 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12356 pParam->operationalRateSet.numRates = 4;
12357 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12358 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12359 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12360 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12361 }
12362 }
12363 else
12364 {
12365 channel = operationChannel;
12366 }
12367 break;
12368
12369 case eSIR_11B_NW_TYPE:
12370 pParam->operationalRateSet.numRates = 4;
12371 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12372 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12373 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12374 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12376 {
12377 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12378 }
12379 else
12380 {
12381 channel = operationChannel;
12382 }
12383
12384 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 /* For P2P Client and P2P GO, disable 11b rates */
12387 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12388 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12389 )
12390 {
12391 pParam->operationalRateSet.numRates = 8;
12392
12393 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12394 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12395 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12396 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12397 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12398 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12399 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12400 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12401 }
12402 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 {
12404 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12406 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12407 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12408 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12409
12410 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012411 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12412 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12413 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12414 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12415 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12416 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12417 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12418 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12419 }
12420
12421 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12422 {
12423 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12424 }
12425 else
12426 {
12427 channel = operationChannel;
12428 }
12429
12430 break;
12431 }
12432 pParam->operationChn = channel;
12433 pParam->sirNwType = nwType;
12434}
12435
Jeff Johnson295189b2012-06-20 16:38:30 -070012436static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12437 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12438{
12439
12440 if( pParam )
12441 {
12442 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012443 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012445 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012446
12447 if( pIes )
12448 {
12449 if(pIes->SuppRates.present)
12450 {
12451 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12452 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012454 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 -070012455 pIes->SuppRates.num_rates);
12456 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12457 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012458 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12459 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012461 if (pIes->ExtSuppRates.present)
12462 {
12463 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012464 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012465 {
12466 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12467 SIR_MAC_RATESET_EID_MAX, resetting to \
12468 SIR_MAC_RATESET_EID_MAX"),
12469 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012470 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012471 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012472 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012473 pIes->ExtSuppRates.rates,
12474 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 if( pIes->SSID.present )
12477 {
12478 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012479 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12480 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012481 }
12482 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 }
12484 else
12485 {
12486 pParam->ssId.length = 0;
12487 pParam->operationalRateSet.numRates = 0;
12488 }
12489 }
12490}
12491
Jeff Johnson295189b2012-06-20 16:38:30 -070012492static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12493{
12494 tANI_U8 MaxRate = 0;
12495 tANI_U32 i;
12496 tANI_U8 *pRate;
12497
12498 pRate = pSirRateSet->rate;
12499 for ( i = 0; i < pSirRateSet->numRates; i++ )
12500 {
12501 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12502 }
12503
12504 // Save the max rate in the connected state information...
12505
12506 // modify LastRates variable as well
12507
12508 return;
12509}
12510
Jeff Johnson295189b2012-06-20 16:38:30 -070012511eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12512 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12513{
12514 eHalStatus status = eHAL_STATUS_SUCCESS;
12515 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 // Set the roaming substate to 'Start BSS attempt'...
12517 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012518#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12519 //Need to figure out whether we need to log WDS???
12520 if( CSR_IS_IBSS( pProfile ) )
12521 {
12522 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12524 if(pIbssLog)
12525 {
12526 if(pBssDesc)
12527 {
12528 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012529 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 }
12531 else
12532 {
12533 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12534 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012535 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 if(pProfile->ChannelInfo.numOfChannels == 0)
12537 {
12538 pIbssLog->channelSetting = AUTO_PICK;
12539 }
12540 else
12541 {
12542 pIbssLog->channelSetting = SPECIFIED;
12543 }
12544 pIbssLog->operatingChannel = pParam->operationChn;
12545 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12546 }
12547 }
12548#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12549 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012550 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12551 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012552
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 pParam->privacy = pProfile->privacy;
12554 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12555 pParam->authType = pProfile->csr80211AuthType;
12556 pParam->beaconInterval = pProfile->beaconInterval;
12557 pParam->dtimPeriod = pProfile->dtimPeriod;
12558 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12559 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12560 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12561 {
12562 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12563 {
12564 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12565 }
12566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 pParam->protEnabled = pProfile->protEnabled;
12568 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12569 pParam->ht_protection = pProfile->cfg_protection;
12570 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012571
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12573 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012575
12576#ifdef WLAN_FEATURE_11W
12577 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12578 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12579#endif
12580
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 // When starting an IBSS, start on the channel from the Profile.
12582 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 return (status);
12584}
12585
Jeff Johnson295189b2012-06-20 16:38:30 -070012586static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012587 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012588{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012589 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012590 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012592
12593 if(!pSession)
12594 {
12595 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12596 return;
12597 }
12598
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 if( pBssDesc )
12600 {
12601 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12602 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12603 //The following code has to be do after that.
12604 //For WDS station, use selfMac as the self BSSID
12605 if( CSR_IS_WDS_STA( pProfile ) )
12606 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012607 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12608 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 }
12610 }
12611 else
12612 {
12613 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 //Use the first SSID
12615 if(pProfile->SSIDs.numOfSSIDs)
12616 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012617 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12618 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 }
12620 //For WDS station, use selfMac as the self BSSID
12621 if( CSR_IS_WDS_STA( pProfile ) )
12622 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012623 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12624 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 }
12626 //Use the first BSSID
12627 else if( pProfile->BSSIDs.numOfBSSIDs )
12628 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012629 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12630 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 }
12632 else
12633 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012634 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 }
12636 }
12637 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 //Set operating channel in pProfile which will be used
12639 //in csrRoamSetBssConfigCfg() to determine channel bonding
12640 //mode and will be configured in CFG later
12641 pProfile->operationChannel = Channel;
12642
12643 if(Channel == 0)
12644 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012645 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 }
12647 else
12648 {
12649
12650 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012651 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012652 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012653 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012654 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012655#ifdef WLAN_FEATURE_AP_HT40_24G
12656 if (CSR_IS_INFRA_AP(pProfile))
12657 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12658 else
12659 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12660#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012661 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012662#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012663 }
12664 else
12665 {
12666 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12667 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012668 pBssConfig->cbMode = cbMode;
12669 pSession->bssParams.cbMode = cbMode;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012670 if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
12671 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
12672 else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
12673 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
12674 else
12675 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
12676 smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
12677 pSession->bssParams.orig_ch_width);
Jeff Johnsone7245742012-09-05 17:12:55 -070012678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 }
12680}
12681
Jeff Johnson295189b2012-06-20 16:38:30 -070012682static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12683 tANI_BOOLEAN *pfSameIbss )
12684{
12685 eHalStatus status = eHAL_STATUS_SUCCESS;
12686 tANI_BOOLEAN fSameIbss = FALSE;
12687
12688 if ( csrIsConnStateIbss( pMac, sessionId ) )
12689 {
12690 // Check if any profile parameter has changed ? If any profile parameter
12691 // has changed then stop old BSS and start a new one with new parameters
12692 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12693 {
12694 fSameIbss = TRUE;
12695 }
12696 else
12697 {
12698 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12699 }
12700 }
12701 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12702 {
12703 // Disassociate from the connected Infrastructure network...
12704 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12705 }
12706 else
12707 {
12708 tBssConfigParam *pBssConfig;
12709
Kiet Lam64c1b492013-07-12 13:56:44 +053012710 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12711 if ( NULL == pBssConfig )
12712 status = eHAL_STATUS_FAILURE;
12713 else
12714 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 if(HAL_STATUS_SUCCESS(status))
12716 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012717 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012718 // there is no Bss description before we start an IBSS so we need to adopt
12719 // all Bss configuration parameters from the Profile.
12720 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12721 if(HAL_STATUS_SUCCESS(status))
12722 {
12723 //save dotMode
12724 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12725 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012726 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012727 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12728 NULL, pBssConfig,
12729 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012731
12732 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 }//Allocate memory
12734 }
12735
12736 if(pfSameIbss)
12737 {
12738 *pfSameIbss = fSameIbss;
12739 }
12740 return( status );
12741}
12742
Jeff Johnson295189b2012-06-20 16:38:30 -070012743static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12744 tSirSmeNewBssInfo *pNewBss )
12745{
12746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012747
12748 if(!pSession)
12749 {
12750 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12751 return;
12752 }
12753
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 if( pNewBss )
12755 {
12756 // Set the operating channel.
12757 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12758 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012759 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12760 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 return;
12763}
12764
Jeff Johnson295189b2012-06-20 16:38:30 -070012765#ifdef FEATURE_WLAN_WAPI
12766eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12767 tANI_U32 numItems )
12768{
12769 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012770 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012773 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 return status;
12775 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012776 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 pSession = CSR_GET_SESSION( pMac, sessionId );
12778 if(numItems <= CSR_MAX_BKID_ALLOWED)
12779 {
12780 status = eHAL_STATUS_SUCCESS;
12781 //numItems may be 0 to clear the cache
12782 pSession->NumBkidCache = (tANI_U16)numItems;
12783 if(numItems && pBKIDCache)
12784 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012785 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12786 sizeof(tBkidCacheInfo) * numItems);
12787 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 }
12789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 return (status);
12791}
Jeff Johnson295189b2012-06-20 16:38:30 -070012792eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12793 tBkidCacheInfo *pBkidCache)
12794{
12795 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012796 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012799 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 return status;
12801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 pSession = CSR_GET_SESSION( pMac, sessionId );
12803 if(pNum && pBkidCache)
12804 {
12805 if(pSession->NumBkidCache == 0)
12806 {
12807 *pNum = 0;
12808 status = eHAL_STATUS_SUCCESS;
12809 }
12810 else if(*pNum >= pSession->NumBkidCache)
12811 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012812 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012814 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 -070012815 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012816 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012818 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12819 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 *pNum = pSession->NumBkidCache;
12821 status = eHAL_STATUS_SUCCESS;
12822 }
12823 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012825}
Jeff Johnson295189b2012-06-20 16:38:30 -070012826tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12827{
12828 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012829}
12830#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012831eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012832 tPmkidCacheInfo *pPMKIDCache,
12833 tANI_U32 numItems,
12834 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012835{
12836 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12837 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012838
12839 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012840 {
12841 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12842 return eHAL_STATUS_FAILURE;
12843 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012844
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012845 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012846
12847 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 {
12849#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12850 {
12851 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012852 vos_mem_set(&secEvent,
12853 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12855 secEvent.encryptionModeMulticast =
12856 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12857 secEvent.encryptionModeUnicast =
12858 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012859 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 secEvent.authMode =
12861 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12862 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12863 }
12864#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012866 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012867 if (numItems && pPMKIDCache)
12868 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012869 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012870 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12871 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012872 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012873 }
12874 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012875 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012876 tPmkidCacheInfo *pmksa;
12877
12878 for (i = 0; i < numItems; i++) {
12879 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012880
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012881 /* Delete the entry if present */
12882 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12883
12884 /* Add entry to the cache */
12885 vos_mem_copy(
12886 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12887 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12888 vos_mem_copy(
12889 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12890 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12891
12892 /* Increment the CSR local cache index */
12893 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12894 pSession->CurCacheIndex++;
12895 else
12896 pSession->CurCacheIndex = 0;
12897
12898 pSession->NumPmkidCache++;
12899 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12900 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 }
12903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 return (status);
12905}
12906
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012907eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012908#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12909 const tANI_U8 *pBSSId,
12910#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012911 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012912#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012913 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012914{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012915 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12916 tANI_BOOLEAN fMatchFound = FALSE;
12917 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012918 tANI_U32 CurIndex;
12919 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012920
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012921 if(!pSession)
12922 {
12923 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12924 return eHAL_STATUS_FAILURE;
12925 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012926
12927 /* Check if there are no entries to delete */
12928 if (0 == pSession->NumPmkidCache) {
12929 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12930 return eHAL_STATUS_SUCCESS;
12931 }
12932
12933 if (!flush_cache) {
12934 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12935 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12936 pBSSId, VOS_MAC_ADDR_SIZE)) {
12937 fMatchFound = 1;
12938
12939 /* Clear this - the matched entry */
12940 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12941 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012942 break;
12943 }
12944 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012945
12946 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12947 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12948 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012949 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012950 else {
12951 /* Match Found */
12952 CurIndex = pSession->CurCacheIndex;
12953 if(Index < CurIndex) {
12954 for(i = Index; i < (CurIndex-1); i++) {
12955 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12956 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12957 }
12958 pSession->CurCacheIndex--;
12959 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12960 sizeof(tPmkidCacheInfo));
12961 } else if(Index > CurIndex) {
12962 for(i = Index; i > (CurIndex); i--) {
12963 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12964 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12965 }
12966 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12967 sizeof(tPmkidCacheInfo));
12968 }
12969 pSession->NumPmkidCache--;
12970 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012971 } else {
12972 /* Flush the entire cache */
12973 vos_mem_zero(pSession->PmkidCacheInfo,
12974 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12975 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012976 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012977 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012978
12979 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012980}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012981
Jeff Johnson295189b2012-06-20 16:38:30 -070012982tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12983{
12984 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12985}
12986
Jeff Johnson295189b2012-06-20 16:38:30 -070012987eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12988{
12989 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12990 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012991 tPmkidCacheInfo *pmksa;
12992 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012993
12994 if(!pSession)
12995 {
12996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12997 return eHAL_STATUS_FAILURE;
12998 }
12999
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 if(pNum && pPmkidCache)
13001 {
13002 if(pSession->NumPmkidCache == 0)
13003 {
13004 *pNum = 0;
13005 status = eHAL_STATUS_SUCCESS;
13006 }
13007 else if(*pNum >= pSession->NumPmkidCache)
13008 {
13009 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
13010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013011 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 -070013012 pSession->NumPmkidCache);
13013 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13014 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013015
13016 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
13017 pmksa = &pSession->PmkidCacheInfo[i];
13018 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
13019 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
13020 pPmkidCache++;
13021 j++;
13022 }
13023 }
13024
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 *pNum = pSession->NumPmkidCache;
13026 status = eHAL_STATUS_SUCCESS;
13027 }
13028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013029 return (status);
13030}
13031
Jeff Johnson295189b2012-06-20 16:38:30 -070013032eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13033{
13034 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13035 tANI_U32 len;
13036 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013037
13038 if(!pSession)
13039 {
13040 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13041 return eHAL_STATUS_FAILURE;
13042 }
13043
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 if(pLen)
13045 {
13046 len = *pLen;
13047 *pLen = pSession->nWpaRsnReqIeLength;
13048 if(pBuf)
13049 {
13050 if(len >= pSession->nWpaRsnReqIeLength)
13051 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013052 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13053 pSession->nWpaRsnReqIeLength);
13054 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 }
13056 }
13057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 return (status);
13059}
13060
Jeff Johnson295189b2012-06-20 16:38:30 -070013061eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13062{
13063 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13064 tANI_U32 len;
13065 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013066
13067 if(!pSession)
13068 {
13069 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13070 return eHAL_STATUS_FAILURE;
13071 }
13072
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 if(pLen)
13074 {
13075 len = *pLen;
13076 *pLen = pSession->nWpaRsnRspIeLength;
13077 if(pBuf)
13078 {
13079 if(len >= pSession->nWpaRsnRspIeLength)
13080 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013081 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13082 pSession->nWpaRsnRspIeLength);
13083 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 }
13085 }
13086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 return (status);
13088}
Jeff Johnson295189b2012-06-20 16:38:30 -070013089#ifdef FEATURE_WLAN_WAPI
13090eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13091{
13092 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13093 tANI_U32 len;
13094 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013095
13096 if(!pSession)
13097 {
13098 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13099 return eHAL_STATUS_FAILURE;
13100 }
13101
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 if(pLen)
13103 {
13104 len = *pLen;
13105 *pLen = pSession->nWapiReqIeLength;
13106 if(pBuf)
13107 {
13108 if(len >= pSession->nWapiReqIeLength)
13109 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013110 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13111 pSession->nWapiReqIeLength);
13112 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 }
13114 }
13115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 return (status);
13117}
Jeff Johnson295189b2012-06-20 16:38:30 -070013118eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13119{
13120 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13121 tANI_U32 len;
13122 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013123
13124 if(!pSession)
13125 {
13126 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13127 return eHAL_STATUS_FAILURE;
13128 }
13129
Jeff Johnson295189b2012-06-20 16:38:30 -070013130 if(pLen)
13131 {
13132 len = *pLen;
13133 *pLen = pSession->nWapiRspIeLength;
13134 if(pBuf)
13135 {
13136 if(len >= pSession->nWapiRspIeLength)
13137 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013138 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13139 pSession->nWapiRspIeLength);
13140 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 }
13142 }
13143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 return (status);
13145}
13146#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013147eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13148{
13149 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13150 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013151
13152 if(!pSession)
13153 {
13154 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13155 return (retStatus);
13156 }
13157
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 if(CSR_IS_ROAMING(pSession))
13159 {
13160 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13161 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 return (retStatus);
13164}
13165
Jeff Johnson295189b2012-06-20 16:38:30 -070013166//This function remove the connected BSS from te cached scan result
13167eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13168 tCsrRoamConnectedProfile *pConnProfile)
13169{
13170 eHalStatus status = eHAL_STATUS_FAILURE;
13171 tCsrScanResultFilter *pScanFilter = NULL;
13172 tListElem *pEntry;
13173 tCsrScanResult *pResult;
13174 tDot11fBeaconIEs *pIes;
13175 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13177 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13178 {
13179 do
13180 {
13181 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013182 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13183 if ( NULL == pScanFilter )
13184 status = eHAL_STATUS_FAILURE;
13185 else
13186 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013188 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13189 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13190 if ( NULL == pScanFilter->BSSIDs.bssid )
13191 status = eHAL_STATUS_FAILURE;
13192 else
13193 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013195 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13196 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13198 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13199 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013200 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13201 if ( NULL == pScanFilter->SSIDs.SSIDList )
13202 status = eHAL_STATUS_FAILURE;
13203 else
13204 status = eHAL_STATUS_SUCCESS;
13205 if (!HAL_STATUS_SUCCESS(status)) break;
13206 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13207 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 }
13209 pScanFilter->authType.numEntries = 1;
13210 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13211 pScanFilter->BSSType = pConnProfile->BSSType;
13212 pScanFilter->EncryptionType.numEntries = 1;
13213 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13214 pScanFilter->mcEncryptionType.numEntries = 1;
13215 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13216 //We ignore the channel for now, BSSID should be enough
13217 pScanFilter->ChannelInfo.numOfChannels = 0;
13218 //Also ignore the following fields
13219 pScanFilter->uapsd_mask = 0;
13220 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013221 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 pScanFilter->countryCode[0] = 0;
13223 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 csrLLLock(&pMac->scan.scanResultList);
13225 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13226 while( pEntry )
13227 {
13228 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13229 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13230 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13231 pScanFilter, NULL, NULL, NULL, &pIes);
13232 //Release the IEs allocated by csrMatchBSS is needed
13233 if( !pResult->Result.pvIes )
13234 {
13235 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013236 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 }
13238 if(fMatch)
13239 {
13240 //We found the one
13241 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13242 {
13243 //Free the memory
13244 csrFreeScanResultEntry( pMac, pResult );
13245 }
13246 break;
13247 }
13248 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13249 }//while
13250 csrLLUnlock(&pMac->scan.scanResultList);
13251 }while(0);
13252 if(pScanFilter)
13253 {
13254 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013255 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 }
13257 }
13258 return (status);
13259}
13260
Jeff Johnson295189b2012-06-20 16:38:30 -070013261//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013262eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13263{
13264 eHalStatus status = eHAL_STATUS_SUCCESS;
13265 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13267 {
13268 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13269 {
13270 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13271 {
13272 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013273 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 status = eHAL_STATUS_CSR_WRONG_STATE;
13275 break;
13276 }
13277 if( csrIsConnStateInfra( pMac, sessionId ) )
13278 {
13279 if( chnId &&
13280 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013282 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13284 status = eHAL_STATUS_CSR_WRONG_STATE;
13285 break;
13286 }
13287 }
13288 }
13289 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 return ( status );
13291}
13292
Jeff Johnson295189b2012-06-20 16:38:30 -070013293static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13294{
13295 eHalStatus status = eHAL_STATUS_SUCCESS;
13296 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13297 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013298
13299 if(!pSession)
13300 {
13301 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13302 return eHAL_STATUS_FAILURE;
13303 }
13304
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 if ( csrIsConnStateIbss( pMac, sessionId ) )
13306 {
13307 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13308 }
13309 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13310 {
13311 // Disassociate from the connected Infrastructure network...
13312 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13313 }
13314 else
13315 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13317 //Otherwise we need to add code to handle the
13318 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13319 //send stop_bss to PE, before we can continue.
13320 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013321 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013323 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13324 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 // there is no Bss description before we start an WDS so we need
13326 // to adopt all Bss configuration parameters from the Profile.
13327 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13328 if(HAL_STATUS_SUCCESS(status))
13329 {
13330 //Save profile for late use
13331 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013332 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13333 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013335 vos_mem_set(pSession->pCurRoamProfile,
13336 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013340 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013341 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13342 NULL, &bssConfig,
13343 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 }
13345 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013346
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 return( status );
13348}
13349
Jeff Johnson295189b2012-06-20 16:38:30 -070013350////////////////////Mail box
13351
Jeff Johnson295189b2012-06-20 16:38:30 -070013352//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13353//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013354static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13355 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13357{
13358 tCsrChannelSet channelGroup;
13359 tSirMacCapabilityInfo *pAP_capabilityInfo;
13360 tAniBool fTmp;
13361 tANI_BOOLEAN found = FALSE;
13362 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013363 tANI_S8 pwrLimit = 0;
13364 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13366 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13367 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13368 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 // 802.11h
13370 //We can do this because it is in HOST CPU order for now.
13371 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013372 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13373 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13374 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 fTmp = (tAniBool)pal_cpu_to_be32(1);
13376 }
13377 else
13378 fTmp = (tAniBool)0;
13379
13380 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013383 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013384 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 // This is required for 11k test VoWiFi Ent: Test 2.
13386 // We need the power capabilities for Assoc Req.
13387 // This macro is provided by the halPhyCfg.h. We pick our
13388 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013389 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13390 if (0 != pwrLimit)
13391 {
13392 *pBuf++ = pwrLimit;
13393 }
13394 else
13395 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013396 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 size = sizeof(pMac->roam.validChannelList);
13399 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013400 {
13401 tANI_U8 *actualSize = pBuf++;
13402 *actualSize = 0;
13403
13404 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013406 /* Only add 5ghz channels*/
13407 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13408 {
13409 *actualSize +=1;
13410 *pBuf++ = pMac->roam.validChannelList[ i ];
13411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 }
13413 }
13414 else
13415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013416 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 *pBuf++ = 0; //tSirSupChnl->numChnl
13418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 //Check whether it is ok to enter UAPSD
13420#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13421 if( btcIsReadyForUapsd(pMac) )
13422#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13423 {
13424 *pBuf++ = uapsdMask;
13425 }
13426#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13427 else
13428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013429 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 *pBuf++ = 0;
13431 }
13432#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13433
Jeff Johnson295189b2012-06-20 16:38:30 -070013434 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013435 vos_mem_copy(pBuf, pBssDescription,
13436 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13438}
13439
Jeff Johnson295189b2012-06-20 16:38:30 -070013440/*
13441 * The communication between HDD and LIM is thru mailbox (MB).
13442 * Both sides will access the data structure "tSirSmeJoinReq".
13443 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13444 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13445 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13446 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13447 */
13448eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013449 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013450{
13451 eHalStatus status = eHAL_STATUS_SUCCESS;
13452 tSirSmeJoinReq *pMsg;
13453 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013454 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 tANI_U16 msgLen, wTmp, ieLen;
13456 tSirMacRateSet OpRateSet;
13457 tSirMacRateSet ExRateSet;
13458 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13459 tANI_U32 dwTmp;
13460 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013461 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013462 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013463 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013464
13465 if(!pSession)
13466 {
13467 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13468 return eHAL_STATUS_FAILURE;
13469 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013470 /* To satisfy klockworks */
13471 if (NULL == pBssDescription)
13472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013473 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013474 return eHAL_STATUS_FAILURE;
13475 }
13476
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 do {
13478 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13479 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013480 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13482 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13483 // IE fields, but the length field in the bssDescription needs to be interpreted to
13484 // determine length of the IE fields.
13485 //
13486 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13487 // add in the length from the bssDescription (then add the size of the 'length' field
13488 // itself because that is NOT included in the length field).
13489 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13490 pBssDescription->length + sizeof( pBssDescription->length ) +
13491 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 +053013492 pMsg = vos_mem_malloc(msgLen);
13493 if (NULL == pMsg)
13494 status = eHAL_STATUS_FAILURE;
13495 else
13496 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013498 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013499 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 pMsg->length = pal_cpu_to_be16(msgLen);
13501 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 // sessionId
13503 *pBuf = (tANI_U8)sessionId;
13504 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 // transactionId
13506 *pBuf = 0;
13507 *( pBuf + 1 ) = 0;
13508 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 // ssId
13510 if( pIes->SSID.present && pIes->SSID.num_ssid )
13511 {
13512 // ssId len
13513 *pBuf = pIes->SSID.num_ssid;
13514 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013515 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 pBuf += pIes->SSID.num_ssid;
13517 }
13518 else
13519 {
13520 *pBuf = 0;
13521 pBuf++;
13522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013524 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13525 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 pBuf += sizeof(tSirMacAddr);
13527 // bsstype
13528 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13529 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013530 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 pBuf += sizeof(tSirBssType);
13532 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013533 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13534 if (pBssDescription->channelId <= 14 &&
13535 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13536 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13537 {
13538 //Need to disable VHT operation in 2.4 GHz band
13539 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13540 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013541 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13542 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13543
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013544 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 //Persona
13547 *pBuf = (tANI_U8)pProfile->csrPersona;
13548 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013549 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13550 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013551 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13552 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013553 //CBMode
13554 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13555 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013556 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13557 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013558
13559 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013560 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13561 pProfile->csrPersona, pSession->bssParams.cbMode,
13562 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013563
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 // uapsdPerAcBitmask
13565 *pBuf = pProfile->uapsd_mask;
13566 pBuf++;
13567
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013568
13569
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013570 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013571 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 {
13573 // OperationalRateSet
13574 if (OpRateSet.numRates) {
13575 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013576 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 pBuf += OpRateSet.numRates;
13578 } else *pBuf++ = 0;
13579 // ExtendedRateSet
13580 if (ExRateSet.numRates) {
13581 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013582 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 pBuf += ExRateSet.numRates;
13584 } else *pBuf++ = 0;
13585 }
13586 else
13587 {
13588 *pBuf++ = 0;
13589 *pBuf++ = 0;
13590 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013591
13592 //rateBitmap
13593 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13594 pBuf += sizeof(tANI_U16);
13595
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 // rsnIE
13597 if ( csrIsProfileWpa( pProfile ) )
13598 {
13599 // Insert the Wpa IE into the join request
13600 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13601 (tCsrWpaIe *)( wpaRsnIE ) );
13602 }
13603 else if( csrIsProfileRSN( pProfile ) )
13604 {
13605 // Insert the RSN IE into the join request
13606 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13607 (tCsrRSNIe *)( wpaRsnIE ) );
13608 }
13609#ifdef FEATURE_WLAN_WAPI
13610 else if( csrIsProfileWapi( pProfile ) )
13611 {
13612 // Insert the WAPI IE into the join request
13613 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13614 (tCsrWapiIe *)( wpaRsnIE ) );
13615 }
13616#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 else
13618 {
13619 ieLen = 0;
13620 }
13621 //remember the IE for future use
13622 if( ieLen )
13623 {
13624 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013626 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 -070013627 ieLen = DOT11F_IE_RSN_MAX_LEN;
13628 }
13629#ifdef FEATURE_WLAN_WAPI
13630 if( csrIsProfileWapi( pProfile ) )
13631 {
13632 //Check whether we need to allocate more memory
13633 if(ieLen > pSession->nWapiReqIeLength)
13634 {
13635 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13636 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013637 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013639 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13640 if (NULL == pSession->pWapiReqIE)
13641 status = eHAL_STATUS_FAILURE;
13642 else
13643 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 if(!HAL_STATUS_SUCCESS(status)) break;
13645 }
13646 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013647 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013649 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013651 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 pBuf += ieLen;
13653 }
13654 else//should be WPA/WPA2 otherwise
13655#endif /* FEATURE_WLAN_WAPI */
13656 {
13657 //Check whether we need to allocate more memory
13658 if(ieLen > pSession->nWpaRsnReqIeLength)
13659 {
13660 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13661 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013662 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013664 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13665 if (NULL == pSession->pWpaRsnReqIE)
13666 status = eHAL_STATUS_FAILURE;
13667 else
13668 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 if(!HAL_STATUS_SUCCESS(status)) break;
13670 }
13671 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013672 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013674 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013676 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 pBuf += ieLen;
13678 }
13679 }
13680 else
13681 {
13682 //free whatever old info
13683 pSession->nWpaRsnReqIeLength = 0;
13684 if(pSession->pWpaRsnReqIE)
13685 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013686 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 pSession->pWpaRsnReqIE = NULL;
13688 }
13689#ifdef FEATURE_WLAN_WAPI
13690 pSession->nWapiReqIeLength = 0;
13691 if(pSession->pWapiReqIE)
13692 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013693 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 pSession->pWapiReqIE = NULL;
13695 }
13696#endif /* FEATURE_WLAN_WAPI */
13697 //length is two bytes
13698 *pBuf = 0;
13699 *(pBuf + 1) = 0;
13700 pBuf += 2;
13701 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013702#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013703 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013705 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 //length is two bytes
13707 *pBuf = 0;
13708 *(pBuf + 1) = 0;
13709 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013710 }
13711 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013713 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013714 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013715 {
13716 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013717#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013718 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013719 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013720 pSession->suppCckmIeInfo.cckmIe, ieLen);
13721#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013722 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013723 pSession,
13724 pProfile,
13725 pBssDescription,
13726 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 pSession->nWpaRsnReqIeLength,
13728 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013729#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013730 }
13731 else
13732 {
13733 ieLen = 0;
13734 }
13735 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13736 if( ieLen )
13737 {
13738 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13739 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013740 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013741 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013742 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013743 pBuf += ieLen;
13744 }
13745 else
13746 {
13747 //Indicate you have no CCKM IE
13748 //length is two bytes
13749 *pBuf = 0;
13750 *(pBuf + 1) = 0;
13751 pBuf += 2;
13752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013754#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013756 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 {
13758 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013759 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013761 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013763 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013765 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 pBuf += ieLen;
13767 }
13768 else
13769 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013770 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 *pBuf = 0;
13773 *(pBuf + 1) = 0;
13774 pBuf += 2;
13775 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 // addIEAssoc
13777 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13778 {
13779 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 if(ieLen > pSession->nAddIEAssocLength)
13781 {
13782 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013783 {
13784 vos_mem_free(pSession->pAddIEAssoc);
13785 }
13786 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13787 if (NULL == pSession->pAddIEAssoc)
13788 status = eHAL_STATUS_FAILURE;
13789 else
13790 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013794 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013796 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013798 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 pBuf += ieLen;
13800 }
13801 else
13802 {
13803 pSession->nAddIEAssocLength = 0;
13804 if(pSession->pAddIEAssoc)
13805 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013806 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 pSession->pAddIEAssoc = NULL;
13808 }
13809 *pBuf = 0;
13810 *(pBuf + 1) = 0;
13811 pBuf += 2;
13812 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013813
13814 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013816 //Unmask any AC in reassoc that is ACM-set
13817 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13818 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013820 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13821 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013822#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013823 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013824#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013825 }
13826 else
13827 {
13828 uapsd_mask = 0;
13829 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 }
13831 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013832
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013834 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013835 pBuf += sizeof(tANI_U32);
13836
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013838 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013839 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013840#ifdef WLAN_FEATURE_11W
13841 //MgmtEncryption
13842 if (pProfile->MFPEnabled)
13843 {
13844 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13845 }
13846 else
13847 {
13848 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13849 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013850 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013851 pBuf += sizeof(tANI_U32);
13852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013853#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013854 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013855 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013856#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013857 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013858 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013859#endif
13860 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013861 {
13862 // is11Rconnection;
13863 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013864 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013865 pBuf += sizeof(tAniBool);
13866 }
13867 else
13868 {
13869 // is11Rconnection;
13870 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013871 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013872 pBuf += sizeof(tAniBool);
13873 }
13874#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013875#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013876
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013877 // isESEFeatureIniEnabled
13878 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013879 {
13880 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013881 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013882 pBuf += sizeof(tAniBool);
13883 }
13884 else
13885 {
13886 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013887 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013888 pBuf += sizeof(tAniBool);
13889 }
13890
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013891 /* A profile can not be both ESE and 11R. But an 802.11R AP
13892 * may be advertising support for ESE as well. So if we are
13893 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013894 * If we are associating explictly 11R only then we will get
13895 * 11R.
13896 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013897 if ((csrIsProfileESE(pProfile) ||
13898 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013899 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13900 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13901 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13902 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13903#ifdef WLAN_FEATURE_11W
13904 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013905 || (pProfile->negotiatedAuthType ==
13906 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013907#endif
13908 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013909 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013910 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013911 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013912 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013914 pBuf += sizeof(tAniBool);
13915 }
13916 else
13917 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013918 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013919 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013920 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013921 pBuf += sizeof(tAniBool);
13922 }
13923
13924 if (eWNI_SME_JOIN_REQ == messageType)
13925 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013926 tESETspecInfo eseTspec;
13927 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013928 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013929 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13930 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13931 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013932 }
13933 else if (eWNI_SME_REASSOC_REQ == messageType)
13934 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013935 if ((csrIsProfileESE(pProfile) ||
13936 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013937 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13938 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13939 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13940 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13941#ifdef WLAN_FEATURE_11W
13942 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013943 || (pProfile->negotiatedAuthType ==
13944 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013945#endif
13946 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013947 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013949 tESETspecInfo eseTspec;
13950 // ESE Tspec information
13951 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13952 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13953 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013956 if (eseTspec.numTspecs) {
13957 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13958 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013960 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013962 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013964 tESETspecInfo eseTspec;
13965 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013967 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13968 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13969 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 }
13971 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013972#endif // FEATURE_WLAN_ESE
13973#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013975 if (pMac->roam.configParam.isFastTransitionEnabled
13976#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013977 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013978#endif
13979 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013981 dwTmp = pal_cpu_to_be32(TRUE);
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 Johnson295189b2012-06-20 16:38:30 -070013984 }
13985 else
13986 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013987 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013988 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013989 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 }
13991#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013992#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013993 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013994 {
13995 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013996 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013997 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013998 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013999 }
14000 else
14001 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014002 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014003 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014004 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014005 }
14006#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014007
14008 // txLdpcIniFeatureEnabled
14009 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
14010 pBuf++;
14011
Kiran4a17ebe2013-01-31 10:43:43 -080014012 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
14013 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
14014 {
14015 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
14016 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
14017 csrApplyPower2Current(pMac);
14018 }
14019
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014020#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014021 // txBFIniFeatureEnabled
14022 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14023 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014024
14025 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014026 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014027 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014028 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14029 if (pIes->VHTCaps.numSoundingDim)
14030 txBFCsnValue = CSR_ROAM_MIN
14031 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014032 }
14033 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014034 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014035
14036 /* Only enable MuBf if no other MuBF session exist
14037 * and FW and HOST is MuBF capable.
14038 */
14039 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14040 {
14041 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14042 pBuf++;
14043 }
14044 else
14045 {
14046 *pBuf = 0;
14047 pBuf++;
14048 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014049#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014050 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14051 pBuf++;
14052
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014053 // WME
14054 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14055 {
14056 //WME enabled
14057 dwTmp = pal_cpu_to_be32(TRUE);
14058 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14059 pBuf += sizeof(tAniBool);
14060 }
14061 else
14062 {
14063 dwTmp = pal_cpu_to_be32(FALSE);
14064 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14065 pBuf += sizeof(tAniBool);
14066 }
14067
14068 // QOS
14069 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14070 {
14071 //QOS enabled
14072 dwTmp = pal_cpu_to_be32(TRUE);
14073 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14074 pBuf += sizeof(tAniBool);
14075 }
14076 else
14077 {
14078 dwTmp = pal_cpu_to_be32(FALSE);
14079 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14080 pBuf += sizeof(tAniBool);
14081 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014082 //BssDesc
14083 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14084 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014085
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014086 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014087 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14088 pMsg = NULL;
14089
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014090 if(!HAL_STATUS_SUCCESS(status))
14091 {
14092 break;
14093 }
14094 else
14095 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014096#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014097 if (eWNI_SME_JOIN_REQ == messageType)
14098 {
14099 //Tush-QoS: notify QoS module that join happening
14100 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14101 }
14102 else if (eWNI_SME_REASSOC_REQ == messageType)
14103 {
14104 //Tush-QoS: notify QoS module that reassoc happening
14105 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014107#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014108 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014110
14111 if (pMsg != NULL)
14112 {
14113 vos_mem_free( pMsg );
14114 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014115 pMac->roam.roamSession[sessionId].connect_req_start_time =
14116 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014117
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014119}
14120
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014121#ifdef WLAN_FEATURE_LFR_MBB
14122/**
14123 * csr_prepare_reassoc_req () - Prepares reassoc request
14124 * @mac: MAC context
14125 * @session_id: session id
14126 * @pbss_description: bss description
14127 * @ies: pointer to beacon IE's
14128 * @reassoc_req: pointer to reassociation request
14129 *
14130 *Return: None
14131 */
14132eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14133 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14134 tSirSmeJoinReq **reassoc_req)
14135{
14136 eHalStatus status = eHAL_STATUS_SUCCESS;
14137 tSirSmeJoinReq *csr_join_req;
14138 tANI_U8 *buf;
14139 v_U8_t acm_mask = 0, uapsd_mask;
14140 tANI_U16 msg_len, w_tmp, ie_len;
14141 tSirMacRateSet op_rate_set;
14142 tSirMacRateSet ex_rate_set;
14143 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14144 tANI_U32 dw_tmp;
14145 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14146 tANI_U32 uc_dot11_mode = 0;
14147 tANI_U8 tx_bf_csn_value = 0;
14148 tANI_U16 rate_bitmap = 0;
14149 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014150 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014151
14152 if(!session) {
14153 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14154 return eHAL_STATUS_FAILURE;
14155 }
14156
14157 if (NULL == bss_description) {
14158 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14159 return eHAL_STATUS_FAILURE;
14160 }
14161
14162 smsLog(mac, LOG1,
14163 FL("session_id %d"), session_id);
14164
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014165 profile = vos_mem_malloc(sizeof(*profile));
14166 if (NULL == profile) {
14167 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14168 return eHAL_STATUS_RESOURCES;
14169 }
14170
14171 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014172 if(!HAL_STATUS_SUCCESS(status)) {
14173 smsLog(mac, LOGE, FL("Profile copy failed"));
14174 return eHAL_STATUS_FAILURE;
14175 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014176
14177 do {
14178 /*
14179 * There are a number of variable length fields to consider.
14180 * First, the tSirSmeJoinReq includes a single bssDescription.
14181 * bssDescription includes a single tANI_U32 for the IE fields,
14182 * but the length field in the bssDescription needs to be
14183 * interpreted to determine length of the IE fields.
14184 * So, take the size of the JoinReq, subtract the size of the
14185 * bssDescription and add in the length from the bssDescription
14186 * (then add the size of the 'length' field itself because that is
14187 * NOT included in the length field). msgLen =
14188 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14189 * pBssDescription->length + sizeof( pBssDescription->length ) +
14190 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14191 * add in the size of the WPA IE that we may build.
14192 */
14193
14194 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14195 bss_description->length + sizeof(bss_description->length) +
14196 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14197
14198 csr_join_req = vos_mem_malloc(msg_len);
14199 if (NULL == csr_join_req)
14200 status = eHAL_STATUS_FAILURE;
14201 else
14202 status = eHAL_STATUS_SUCCESS;
14203 if (!HAL_STATUS_SUCCESS(status)) break;
14204
14205 vos_mem_set(csr_join_req, msg_len, 0);
14206 *reassoc_req = csr_join_req;
14207
14208 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14209 csr_join_req->length = pal_cpu_to_be16(msg_len);
14210 buf = &csr_join_req->sessionId;
14211
14212 /* session_id */
14213 *buf = (tANI_U8)session_id;
14214 buf++;
14215
14216 /* transactionId */
14217 *buf = 0;
14218 *(buf + 1) = 0;
14219 buf += sizeof(tANI_U16);
14220
14221 /* ssId */
14222 if(ies->SSID.present && ies->SSID.num_ssid)
14223 {
14224 /* ssId len */
14225 *buf = ies->SSID.num_ssid;
14226 buf++;
14227 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14228 buf += ies->SSID.num_ssid;
14229 }
14230 else
14231 {
14232 *buf = 0;
14233 buf++;
14234 }
14235
14236 /* selfMacAddr */
14237 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14238 sizeof(tSirMacAddr));
14239 buf += sizeof(tSirMacAddr);
14240
14241 /* bsstype */
14242 dw_tmp =
14243 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14244 /* Override BssType for BTAMP */
14245 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14246 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14247 buf += sizeof(tSirBssType);
14248
14249 /* dot11mode */
14250 uc_dot11_mode =
14251 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14252 if (bss_description->channelId <= 14 &&
14253 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14254 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14255 {
14256 /* Need to disable VHT operation in 2.4 GHz band */
14257 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14258 }
14259 *buf = (tANI_U8)uc_dot11_mode;
14260 buf++;
14261
14262 /* Persona */
14263 *buf = (tANI_U8)profile->csrPersona;
14264 buf++;
14265 *buf = (tANI_U8)profile->bOSENAssociation;
14266 buf++;
14267 *buf = (tANI_U8)profile->bWPSAssociation;
14268 buf++;
14269
14270 /* CBMode */
14271 *buf = (tANI_U8)session->bssParams.cbMode;
14272 buf++;
14273
14274 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14275 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14276 session->bssParams.cbMode);
14277
14278 /* uapsdPerAcBitmask */
14279 *buf = profile->uapsd_mask;
14280 buf++;
14281
14282
14283 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14284 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14285 if (HAL_STATUS_SUCCESS(status))
14286 {
14287 /* OperationalRateSet */
14288 if (op_rate_set.numRates) {
14289 *buf++ = op_rate_set.numRates;
14290 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14291 buf += op_rate_set.numRates;
14292 } else *buf++ = 0;
14293
14294 /* ExtendedRateSet */
14295 if (ex_rate_set.numRates) {
14296 *buf++ = ex_rate_set.numRates;
14297 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14298 buf += ex_rate_set.numRates;
14299 } else *buf++ = 0;
14300 }
14301 else
14302 {
14303 *buf++ = 0;
14304 *buf++ = 0;
14305 }
14306
14307 /* rateBitmap */
14308 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14309 buf += sizeof(tANI_U16);
14310
14311 profile->negotiatedAuthType =
14312 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14313 profile->negotiatedUCEncryptionType =
14314 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14315
14316 /* rsnIE */
14317 if ( csrIsProfileWpa(profile))
14318 {
14319 /* Insert the Wpa IE into the join request */
14320 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14321 (tCsrWpaIe *)(wpa_rsn_ie));
14322 }
14323 else if( csrIsProfileRSN(profile))
14324 {
14325 /* Insert the RSN IE into the join request */
14326 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14327 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14328 }
14329#ifdef FEATURE_WLAN_WAPI
14330 else if( csrIsProfileWapi(profile))
14331 {
14332 /* Insert the WAPI IE into the join request */
14333 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14334 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14335 }
14336#endif
14337 else
14338 {
14339 ie_len = 0;
14340 }
14341 /* remember the IE for future use */
14342 if(ie_len)
14343 {
14344 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14345 {
14346 smsLog(mac, LOGE,
14347 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14348 ie_len, DOT11F_IE_RSN_MAX_LEN);
14349 ie_len = DOT11F_IE_RSN_MAX_LEN;
14350 }
14351#ifdef FEATURE_WLAN_WAPI
14352 if( csrIsProfileWapi(profile))
14353 {
14354 /* Check whether we need to allocate more memory */
14355 if(ie_len > session->nWapiReqIeLength)
14356 {
14357 if(session->pWapiReqIE && session->nWapiReqIeLength)
14358 {
14359 vos_mem_free(session->pWapiReqIE);
14360 }
14361 session->pWapiReqIE = vos_mem_malloc(ie_len);
14362 if (NULL == session->pWapiReqIE)
14363 status = eHAL_STATUS_FAILURE;
14364 else
14365 status = eHAL_STATUS_SUCCESS;
14366 if(!HAL_STATUS_SUCCESS(status)) break;
14367 }
14368 session->nWapiReqIeLength = ie_len;
14369 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14370 w_tmp = pal_cpu_to_be16(ie_len);
14371 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14372 buf += sizeof(tANI_U16);
14373 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14374 buf += ie_len;
14375 }
14376 else /* should be WPA/WPA2 otherwise */
14377#endif
14378 {
14379 /* Check whether we need to allocate more memory */
14380 if(ie_len > session->nWpaRsnReqIeLength)
14381 {
14382 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14383 {
14384 vos_mem_free(session->pWpaRsnReqIE);
14385 }
14386 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14387 if (NULL == session->pWpaRsnReqIE)
14388 status = eHAL_STATUS_FAILURE;
14389 else
14390 status = eHAL_STATUS_SUCCESS;
14391 if(!HAL_STATUS_SUCCESS(status)) break;
14392 }
14393 session->nWpaRsnReqIeLength = ie_len;
14394 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14395 w_tmp = pal_cpu_to_be16(ie_len);
14396 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14397 buf += sizeof(tANI_U16);
14398 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14399 buf += ie_len;
14400 }
14401 }
14402 else
14403 {
14404 /* free whatever old info */
14405 session->nWpaRsnReqIeLength = 0;
14406 if(session->pWpaRsnReqIE)
14407 {
14408 vos_mem_free(session->pWpaRsnReqIE);
14409 session->pWpaRsnReqIE = NULL;
14410 }
14411#ifdef FEATURE_WLAN_WAPI
14412 session->nWapiReqIeLength = 0;
14413 if(session->pWapiReqIE)
14414 {
14415 vos_mem_free(session->pWapiReqIE);
14416 session->pWapiReqIE = NULL;
14417 }
14418#endif
14419 /* length is two bytes */
14420 *buf = 0;
14421 *(buf + 1) = 0;
14422 buf += 2;
14423 }
14424#ifdef FEATURE_WLAN_ESE
14425 if(eWNI_SME_JOIN_REQ == message_type)
14426 {
14427 /*
14428 * Never include the cckmIE in an Join Request
14429 * length is two bytes
14430 */
14431 *buf = 0;
14432 *(buf + 1) = 0;
14433 buf += 2;
14434 }
14435 else if(eWNI_SME_REASSOC_REQ == message_type)
14436 {
14437 /* cckmIE */
14438 if( csrIsProfileESE(profile))
14439 {
14440 /* Insert the CCKM IE into the join request */
14441#ifdef FEATURE_WLAN_ESE_UPLOAD
14442 ie_len = session->suppCckmIeInfo.cckmIeLen;
14443 vos_mem_copy((void *) (wpa_rsn_ie),
14444 session->suppCckmIeInfo.cckmIe, ie_len);
14445#else
14446 ie_len = csrConstructEseCckmIe(mac,
14447 session,
14448 profile,
14449 bss_description,
14450 session->pWpaRsnReqIE,
14451 session->nWpaRsnReqIeLength,
14452 (void *)(wpa_rsn_ie));
14453#endif
14454 }
14455 else
14456 {
14457 ie_len = 0;
14458 }
14459 /*
14460 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14461 * message buffer
14462 */
14463 if(ie_len)
14464 {
14465 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14466 w_tmp = pal_cpu_to_be16(ie_len);
14467 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14468 buf += sizeof(tANI_U16);
14469 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14470 buf += ie_len;
14471 }
14472 else
14473 {
14474 /* Indicate you have no CCKM IE length is two bytes */
14475 *buf = 0;
14476 *(buf + 1) = 0;
14477 buf += 2;
14478 }
14479 }
14480#endif
14481 /* addIEScan */
14482 if (profile->nAddIEScanLength)
14483 {
14484 ie_len = profile->nAddIEScanLength;
14485 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14486 session->nAddIEScanLength = ie_len;
14487 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14488 w_tmp = pal_cpu_to_be16(ie_len);
14489 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14490 buf += sizeof(tANI_U16);
14491 vos_mem_copy(buf, profile->addIEScan, ie_len);
14492 buf += ie_len;
14493 }
14494 else
14495 {
14496 memset(session->addIEScan, 0, session->nAddIEScanLength);
14497 session->nAddIEScanLength = 0;
14498 *buf = 0;
14499 *(buf + 1) = 0;
14500 buf += 2;
14501 }
14502 /* addIEAssoc */
14503 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14504 {
14505 ie_len = profile->nAddIEAssocLength;
14506 if(ie_len > session->nAddIEAssocLength)
14507 {
14508 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14509 {
14510 vos_mem_free(session->pAddIEAssoc);
14511 }
14512 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14513 if (NULL == session->pAddIEAssoc)
14514 status = eHAL_STATUS_FAILURE;
14515 else
14516 status = eHAL_STATUS_SUCCESS;
14517 if(!HAL_STATUS_SUCCESS(status)) break;
14518 }
14519 session->nAddIEAssocLength = ie_len;
14520 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14521 w_tmp = pal_cpu_to_be16(ie_len);
14522 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14523 buf += sizeof(tANI_U16);
14524 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14525 buf += ie_len;
14526 }
14527 else
14528 {
14529 session->nAddIEAssocLength = 0;
14530 if(session->pAddIEAssoc)
14531 {
14532 vos_mem_free(session->pAddIEAssoc);
14533 session->pAddIEAssoc = NULL;
14534 }
14535 *buf = 0;
14536 *(buf + 1) = 0;
14537 buf += 2;
14538 }
14539
14540 if(eWNI_SME_REASSOC_REQ == message_type )
14541 {
14542 /*Unmask any AC in reassoc that is ACM-set */
14543 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14544 if( uapsd_mask && (NULL != bss_description))
14545 {
14546 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14547 {
14548#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14549 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14550#endif
14551 }
14552 else
14553 {
14554 uapsd_mask = 0;
14555 }
14556 }
14557 }
14558
14559 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14560 profile->negotiatedUCEncryptionType));
14561 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14562 buf += sizeof(tANI_U32);
14563
14564 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14565 profile->negotiatedMCEncryptionType));
14566 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14567 buf += sizeof(tANI_U32);
14568#ifdef WLAN_FEATURE_11W
14569 /* MgmtEncryption */
14570 if (profile->MFPEnabled)
14571 {
14572 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14573 }
14574 else
14575 {
14576 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14577 }
14578 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14579 buf += sizeof(tANI_U32);
14580#endif
14581#ifdef WLAN_FEATURE_VOWIFI_11R
14582 profile->MDID.mdiePresent = bss_description->mdiePresent;
14583 if (csrIsProfile11r(profile)
14584#ifdef FEATURE_WLAN_ESE
14585 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14586 (ies->ESEVersion.present) &&
14587 (mac->roam.configParam.isEseIniFeatureEnabled))
14588#endif
14589 )
14590 {
14591 /* is11Rconnection */
14592 dw_tmp = pal_cpu_to_be32(TRUE);
14593 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14594 buf += sizeof(tAniBool);
14595 }
14596 else
14597 {
14598 /* is11Rconnection */
14599 dw_tmp = pal_cpu_to_be32(FALSE);
14600 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14601 buf += sizeof(tAniBool);
14602 }
14603#endif
14604#ifdef FEATURE_WLAN_ESE
14605
14606 /* isESEFeatureIniEnabled */
14607 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14608 {
14609 dw_tmp = pal_cpu_to_be32(TRUE);
14610 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14611 buf += sizeof(tAniBool);
14612 }
14613 else
14614 {
14615 dw_tmp = pal_cpu_to_be32(FALSE);
14616 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14617 buf += sizeof(tAniBool);
14618 }
14619
14620 /* A profile can not be both ESE and 11R. But an 802.11R AP
14621 * may be advertising support for ESE as well. So if we are
14622 * associating Open or explicitly ESE then we will get ESE.
14623 * If we are associating explictly 11R only then we will get
14624 * 11R.
14625 */
14626 if ((csrIsProfileESE(profile) ||
14627 ((ies->ESEVersion.present)
14628 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14629 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14630 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14631 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14632#ifdef WLAN_FEATURE_11W
14633 || (profile->negotiatedAuthType ==
14634 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14635 || (profile->negotiatedAuthType ==
14636 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14637#endif
14638 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14639 && (mac->roam.configParam.isEseIniFeatureEnabled))
14640 {
14641 /* isESEconnection */
14642 dw_tmp = pal_cpu_to_be32(TRUE);
14643 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14644 buf += sizeof(tAniBool);
14645 }
14646 else
14647 {
14648 /* isESEconnection */
14649 dw_tmp = pal_cpu_to_be32(FALSE);
14650 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14651 buf += sizeof(tAniBool);
14652 }
14653
14654 if (eWNI_SME_JOIN_REQ == message_type)
14655 {
14656 tESETspecInfo eseTspec;
14657 /*
14658 * ESE-Tspec IEs in the ASSOC request is presently not supported
14659 * so nullify the TSPEC parameters
14660 */
14661 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14662 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14663 buf += sizeof(tESETspecInfo);
14664 }
14665 else if (eWNI_SME_REASSOC_REQ == message_type)
14666 {
14667 if ((csrIsProfileESE(profile) ||
14668 ((ies->ESEVersion.present)
14669 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14670 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14671 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14672 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14673#ifdef WLAN_FEATURE_11W
14674 || (profile->negotiatedAuthType ==
14675 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14676 || (profile->negotiatedAuthType ==
14677 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14678#endif
14679 || (profile->negotiatedAuthType ==
14680 eCSR_AUTH_TYPE_RSN_PSK))))
14681 && (mac->roam.configParam.isEseIniFeatureEnabled))
14682 {
14683 tESETspecInfo eseTspec;
14684 /* ESE Tspec information */
14685 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14686 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14687 (tTspecInfo *) &eseTspec.tspec[0]);
14688 *buf = eseTspec.numTspecs;
14689 buf += sizeof(tANI_U8);
14690 // Copy the TSPEC information only if present
14691 if (eseTspec.numTspecs) {
14692 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14693 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14694 }
14695 buf += sizeof(eseTspec.tspec);
14696 }
14697 else
14698 {
14699 tESETspecInfo eseTspec;
14700 /*
14701 * ESE-Tspec IEs in the ASSOC request is presently
14702 * not supported so nullify the TSPEC parameters
14703 */
14704 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14705 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14706 buf += sizeof(tESETspecInfo);
14707 }
14708 }
14709#endif
14710#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14711 /* Fill in isFastTransitionEnabled */
14712 if (mac->roam.configParam.isFastTransitionEnabled
14713#ifdef FEATURE_WLAN_LFR
14714 || csrRoamIsFastRoamEnabled(mac, session_id)
14715#endif
14716 )
14717 {
14718 dw_tmp = pal_cpu_to_be32(TRUE);
14719 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14720 buf += sizeof(tAniBool);
14721 }
14722 else
14723 {
14724 dw_tmp = pal_cpu_to_be32(FALSE);
14725 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14726 buf += sizeof(tAniBool);
14727 }
14728#endif
14729#ifdef FEATURE_WLAN_LFR
14730 if(csrRoamIsFastRoamEnabled(mac, session_id))
14731 {
14732 /* legacy fast roaming enabled */
14733 dw_tmp = pal_cpu_to_be32(TRUE);
14734 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14735 buf += sizeof(tAniBool);
14736 }
14737 else
14738 {
14739 dw_tmp = pal_cpu_to_be32(FALSE);
14740 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14741 buf += sizeof(tAniBool);
14742 }
14743#endif
14744
14745 /* txLdpcIniFeatureEnabled */
14746 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14747 buf++;
14748
14749 if ((csrIs11hSupported(mac)) &&
14750 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14751 (ies->Country.present) &&\
14752 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14753 {
14754 csrSaveToChannelPower2G_5G(mac,
14755 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14756 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14757 csrApplyPower2Current(mac);
14758 }
14759
14760#ifdef WLAN_FEATURE_11AC
14761 /* txBFIniFeatureEnabled */
14762 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14763 buf++;
14764
14765 /* txBFCsnValue */
14766 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14767 {
14768 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14769 if (ies->VHTCaps.numSoundingDim)
14770 tx_bf_csn_value = CSR_ROAM_MIN
14771 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14772 }
14773 *buf = tx_bf_csn_value;
14774 buf++;
14775
14776 /* Only enable MuBf if no other MuBF session exist
14777 * and FW and HOST is MuBF capable.
14778 */
14779 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14780 {
14781 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14782 buf++;
14783 }
14784 else
14785 {
14786 *buf = 0;
14787 buf++;
14788 }
14789#endif
14790 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14791 buf++;
14792
14793 /* WME */
14794 if(mac->roam.roamSession[session_id].fWMMConnection)
14795 {
14796 /* WME enabled */
14797 dw_tmp = pal_cpu_to_be32(TRUE);
14798 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14799 buf += sizeof(tAniBool);
14800 }
14801 else
14802 {
14803 dw_tmp = pal_cpu_to_be32(FALSE);
14804 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14805 buf += sizeof(tAniBool);
14806 }
14807
14808 /* QOS */
14809 if(mac->roam.roamSession[session_id].fQOSConnection)
14810 {
14811 /* QOS enabled */
14812 dw_tmp = pal_cpu_to_be32(TRUE);
14813 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14814 buf += sizeof(tAniBool);
14815 }
14816 else
14817 {
14818 dw_tmp = pal_cpu_to_be32(FALSE);
14819 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14820 buf += sizeof(tAniBool);
14821 }
14822 /* BssDesc */
14823 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14824 (tANI_U8)profile->uapsd_mask);
14825 } while( 0 );
14826
14827 smsLog(mac, LOG1, FL("status %d"), status);
14828
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014829 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014830 return status;
14831}
14832#endif
14833
Jeff Johnson295189b2012-06-20 16:38:30 -070014834//
14835eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14836{
14837 eHalStatus status = eHAL_STATUS_SUCCESS;
14838 tSirSmeDisassocReq *pMsg;
14839 tANI_U8 *pBuf;
14840 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14842 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14843 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014845 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14846 if (NULL == pMsg)
14847 status = eHAL_STATUS_FAILURE;
14848 else
14849 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014851 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14853 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 pBuf = &pMsg->sessionId;
14855 // sessionId
14856 *pBuf++ = (tANI_U8)sessionId;
14857 // transactionId
14858 *pBuf = 0;
14859 *( pBuf + 1 ) = 0;
14860 pBuf += sizeof(tANI_U16);
14861
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014862 if ( (pSession->pCurRoamProfile != NULL) &&
14863 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14864 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 {
14866 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014867 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14868 sizeof( tSirMacAddr ));
14869 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014870 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014872 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14873 //perMacAddr is passed as bssId for softAP
14874 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 pBuf = pBuf + sizeof ( tSirMacAddr );
14876 }
14877 else
14878 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014879 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014880 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14881 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053014883 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
14884 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014887 if(!HAL_STATUS_SUCCESS(status))
14888 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014889 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014890 break;
14891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 // reasonCode
14893 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014894 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
14895 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 if(!HAL_STATUS_SUCCESS(status))
14897 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014898 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 break;
14900 }
14901 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14903 Here we should not send the disassoc over the air to the AP */
14904 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14905#ifdef WLAN_FEATURE_VOWIFI_11R
14906 && csrRoamIs11rAssoc(pMac)
14907#endif
14908 )
14909 {
14910 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14911 }
14912 pBuf += sizeof(tANI_U8);
14913 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 return( status );
14916}
Jeff Johnson295189b2012-06-20 16:38:30 -070014917eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14918{
14919 eHalStatus status = eHAL_STATUS_SUCCESS;
14920 tSirSmeTkipCntrMeasReq *pMsg;
14921 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 do
14923 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014924 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14925 if ( NULL == pMsg )
14926 status = eHAL_STATUS_FAILURE;
14927 else
14928 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014929 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014930 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14932 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 pBuf = &pMsg->sessionId;
14934 // sessionId
14935 *pBuf++ = (tANI_U8)sessionId;
14936 // transactionId
14937 *pBuf = 0;
14938 *( pBuf + 1 ) = 0;
14939 pBuf += sizeof(tANI_U16);
14940 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014941 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14942 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014943 pBuf = pBuf + sizeof ( tSirMacAddr );
14944 // bEnable
14945 *pBuf = (tANI_BOOLEAN)bEnable;
14946 if(!HAL_STATUS_SUCCESS(status))
14947 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014948 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 break;
14950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 return( status );
14954}
Jeff Johnson295189b2012-06-20 16:38:30 -070014955eHalStatus
14956csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
14957 VOS_MODULE_ID modId, tSirMacAddr bssId,
14958 void *pUsrContext, void *pfnSapEventCallback,
14959 tANI_U8 *pAssocStasBuf )
14960{
14961 eHalStatus status = eHAL_STATUS_SUCCESS;
14962 tSirSmeGetAssocSTAsReq *pMsg;
14963 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14964 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 do
14966 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014967 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
14968 if ( NULL == pMsg )
14969 status = eHAL_STATUS_FAILURE;
14970 else
14971 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014973 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 pBuf = (tANI_U8 *)&pMsg->bssId;
14976 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014978 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014980 // modId
14981 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014982 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014985 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
14986 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014988 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
14989 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080014991 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
14992 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 status = palSendMBMessage( pMac->hHdd, pMsg );
14995 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 return( status );
14997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014998eHalStatus
14999csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
15000 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
15001 {
15002 eHalStatus status = eHAL_STATUS_SUCCESS;
15003 tSirSmeGetWPSPBCSessionsReq *pMsg;
15004 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080015005
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 do
15007 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015008 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
15009 if ( NULL == pMsg )
15010 status = eHAL_STATUS_FAILURE;
15011 else
15012 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015014 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070015017 VOS_ASSERT(pBuf);
15018
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015021 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15022 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015024 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15025 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015026 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015027 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015030 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015033 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 return( status );
15036}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015037
15038eHalStatus
15039csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15040{
15041 tpSirChangeBIParams pMsg;
15042 tANI_U16 len = 0;
15043 eHalStatus status = eHAL_STATUS_SUCCESS;
15044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15045
15046 if(!pSession)
15047 {
15048 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15049 return eHAL_STATUS_FAILURE;
15050 }
15051
15052 //NO need to update the Beacon Params if update beacon parameter flag is not set
15053 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15054 return eHAL_STATUS_SUCCESS;
15055
15056 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15057
15058 /* Create the message and send to lim */
15059 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015060 pMsg = vos_mem_malloc(len);
15061 if ( NULL == pMsg )
15062 status = eHAL_STATUS_FAILURE;
15063 else
15064 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015065 if(HAL_STATUS_SUCCESS(status))
15066 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015067 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015068 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15069 pMsg->length = len;
15070
15071 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015072 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15073 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015074 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15075 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015076 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015077 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015078 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15079 status = palSendMBMessage(pMac->hHdd, pMsg);
15080 }
15081 return status;
15082}
15083
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015084#ifdef WLAN_FEATURE_AP_HT40_24G
15085eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15086{
15087 tpSirSetHT2040Mode pMsg;
15088 tANI_U16 len = 0;
15089 eHalStatus status = eHAL_STATUS_SUCCESS;
15090 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15091
15092 if(!pSession)
15093 {
15094 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15095 return eHAL_STATUS_FAILURE;
15096 }
15097
15098 /* Create the message and send to lim */
15099 len = sizeof(tSirSetHT2040Mode);
15100 pMsg = vos_mem_malloc(len);
15101
15102 if ( NULL == pMsg )
15103 {
15104 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15105 status = eHAL_STATUS_FAILURE;
15106 }
15107 else
15108 status = eHAL_STATUS_SUCCESS;
15109
15110 if(HAL_STATUS_SUCCESS(status))
15111 {
15112 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15113 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15114 pMsg->length = len;
15115
15116 // bssId
15117 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15118 sizeof(tSirMacAddr));
15119
15120 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15121 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15122 MAC_ADDR_ARRAY(pMsg->bssId));
15123
15124 pMsg->sessionId = sessionId;
15125 pMsg->cbMode = cbMode;
15126
15127 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15128 sessionId, cbMode);
15129
15130 status = palSendMBMessage(pMac->hHdd, pMsg);
15131 }
15132 return status;
15133}
15134#endif
15135
Jeff Johnson295189b2012-06-20 16:38:30 -070015136eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15137{
15138 eHalStatus status = eHAL_STATUS_SUCCESS;
15139 tSirSmeDeauthReq *pMsg;
15140 tANI_U8 *pBuf;
15141 tANI_U16 wTmp;
15142 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15143 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15144 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015145 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015146 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15147 if ( NULL == pMsg )
15148 status = eHAL_STATUS_FAILURE;
15149 else
15150 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015152 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15154 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15155 //sessionId
15156 pBuf = &pMsg->sessionId;
15157 *pBuf++ = (tANI_U8)sessionId;
15158
15159 //tansactionId
15160 *pBuf = 0;
15161 *(pBuf + 1 ) = 0;
15162 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015163 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15166 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015167 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15168 sizeof( pMsg->peerMacAddr ) );
15169 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 pBuf = pBuf + sizeof(tSirMacAddr);
15171 }
15172 else
15173 {
15174 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015175 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15176 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 }
15179 if(!HAL_STATUS_SUCCESS(status))
15180 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015181 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 break;
15183 }
15184 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015185 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15186 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 pBuf = pBuf + sizeof(tSirMacAddr);
15188 if(!HAL_STATUS_SUCCESS(status))
15189 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015190 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 break;
15192 }
15193 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015194 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15195 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 if(!HAL_STATUS_SUCCESS(status))
15197 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015198 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 break;
15200 }
15201 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015202 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015203 return( status );
15204}
15205
Jeff Johnson295189b2012-06-20 16:38:30 -070015206eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15207{
15208 eHalStatus status = eHAL_STATUS_SUCCESS;
15209 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015210 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015211 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15212 if ( NULL == pMsg )
15213 status = eHAL_STATUS_FAILURE;
15214 else
15215 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015217 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15219 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15220 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015221 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015222 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15223 sizeof(pMsg->peerMacAddr));
15224 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 if(!HAL_STATUS_SUCCESS(status))
15226 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015227 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 break;
15229 }
15230//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015231 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15232 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 if(!HAL_STATUS_SUCCESS(status))
15234 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015235 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 break;
15237 }
15238//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015239 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015240 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 return( status );
15242}
15243
Jeff Johnson295189b2012-06-20 16:38:30 -070015244eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15245{
15246 eHalStatus status = eHAL_STATUS_SUCCESS;
15247 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015248 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015249 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15250 if ( NULL == pMsg )
15251 status = eHAL_STATUS_FAILURE;
15252 else
15253 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015255 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15257 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15258 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015259 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015260 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15261 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015262 if(!HAL_STATUS_SUCCESS(status))
15263 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015264 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 break;
15266 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015267 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15268 sizeof(pMsg->peerMacAddr));
15269 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 if(!HAL_STATUS_SUCCESS(status))
15271 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015272 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 break;
15274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015275 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015276 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 return( status );
15278}
Jeff Johnson295189b2012-06-20 16:38:30 -070015279eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15280{
15281 eHalStatus status = eHAL_STATUS_SUCCESS;
15282 tSirSmeAssocCnf *pMsg;
15283 tANI_U8 *pBuf;
15284 tSirResultCodes statusCode;
15285 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015286
15287 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15288 "HalStatus : %d"),
15289 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015291 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15292 if ( NULL == pMsg )
15293 status = eHAL_STATUS_FAILURE;
15294 else
15295 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015296 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015297 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15299 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015300 pBuf = (tANI_U8 *)&pMsg->statusCode;
15301 if(HAL_STATUS_SUCCESS(Halstatus))
15302 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15303 else
15304 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015305 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 pBuf += sizeof(tSirResultCodes);
15307 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015308 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15309 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 pBuf += sizeof (tSirMacAddr);
15311 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015312 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15313 sizeof(tSirMacAddr));
15314 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 pBuf += sizeof (tSirMacAddr);
15316 // aid
15317 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015318 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 pBuf += sizeof (tANI_U16);
15320 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015321 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15322 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 pBuf += sizeof (tSirMacAddr);
15324 // alternateChannelId
15325 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070015326 status = palSendMBMessage( pMac->hHdd, pMsg );
15327 if(!HAL_STATUS_SUCCESS(status))
15328 {
15329 //pMsg is freed by palSendMBMessage
15330 break;
15331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015333 return( status );
15334}
Jeff Johnson295189b2012-06-20 16:38:30 -070015335eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15336 tpSirSmeAssocInd pAssocInd,
15337 eHalStatus Halstatus,
15338 tANI_U8 sessionId)
15339{
15340 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15342 tANI_U8 *pBuf;
15343 tSirResultCodes statusCode;
15344 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015346 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15347 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15348 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015349
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15351 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15352
15353 pMsg->sessionId = sessionId;
15354
15355 pBuf = (tANI_U8 *)&pMsg->statusCode;
15356 if(HAL_STATUS_SUCCESS(Halstatus))
15357 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15358 else
15359 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015360 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 pBuf += sizeof(tSirResultCodes);
15362 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015363 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 pBuf += sizeof (tSirMacAddr);
15365 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015366 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15367 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 pBuf += sizeof (tSirMacAddr);
15369 // StaId
15370 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015371 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 pBuf += sizeof (tANI_U16);
15373 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015374 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 pBuf += sizeof (tSirMacAddr);
15376 // alternateChannelId
15377 *pBuf = 11;
15378 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015379 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 //Wmm
15381 *pBuf = pAssocInd->wmmEnabledSta;
15382 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015384 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015387 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 //reassocReq
15390 *pBuf = pAssocInd->reassocReq;
15391 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015392#ifdef WLAN_FEATURE_AP_HT40_24G
15393 // 40 MHz Intolerant
15394 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15395 pBuf += sizeof (tANI_U8);
15396#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015397 *pBuf = pAssocInd->rate_flags;
15398 pBuf += sizeof (uint32_t);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053015399
15400 pBuf = (tANI_U8 *)&pMsg->chan_info;
15401 vos_mem_copy((void *)pBuf, &pAssocInd->chan_info,
15402 sizeof(tSirSmeChanInfo));
15403
15404 pBuf = (tANI_U8 *)&pMsg->ch_width;
15405 *pBuf = pAssocInd->ch_width;
15406
15407 if (pAssocInd->HTCaps.present) {
15408 pBuf = (tANI_U8 *)&pMsg->HTCaps;
15409 vos_mem_copy(pBuf, &pAssocInd->HTCaps, sizeof(pMsg->HTCaps));
15410 }
15411
15412 if (pAssocInd->VHTCaps.present) {
15413 pBuf = (tANI_U8 *)&pMsg->VHTCaps;
15414 vos_mem_copy(pBuf, &pAssocInd->VHTCaps, sizeof(pMsg->VHTCaps));
15415 }
15416
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15418 msgQ.bodyptr = pMsg;
15419 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015422 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015423}
Jeff Johnson295189b2012-06-20 16:38:30 -070015424
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015425eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15427 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15428 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15429 tANI_U8 *pKeyRsc )
15430{
15431 tSirSmeSetContextReq *pMsg;
15432 tANI_U16 msgLen;
15433 eHalStatus status = eHAL_STATUS_FAILURE;
15434 tAniEdType tmpEdType;
15435 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015436 tANI_U8 *pBuf = NULL;
15437 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015439 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15440 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15444 // key set. Since we only support upto one key, we always allocate memory for 1 key
15445 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15446 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15447 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15448 ( sizeof( pMsg->keyMaterial.key ) );
15449
Kiet Lam64c1b492013-07-12 13:56:44 +053015450 pMsg = vos_mem_malloc(msgLen);
15451 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15452 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15454 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 //sessionId
15456 pBuf = &pMsg->sessionId;
15457 *pBuf = (tANI_U8)sessionId;
15458 pBuf++;
15459 // transactionId
15460 *pBuf = 0;
15461 *(pBuf + 1) = 0;
15462 pBuf += sizeof(tANI_U16);
15463 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015464 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015465
15466 pBuf += sizeof(tSirMacAddr);
15467
15468 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015469 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15470 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015471
15472 pBuf += sizeof(tSirMacAddr);
15473
15474 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015475 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15476 // in the tSirKeyMaterial keyMaterial; field).
15477 //
15478 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15479 // shorter than this max size. Is LIM interpreting this ok ?
15480 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 -070015481 // set pMsg->keyMaterial.edType
15482 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015483 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 // set the pMsg->keyMaterial.numKeys field
15486 *p = numKeys;
15487 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 // set pSirKey->keyId = keyId;
15489 *p = keyId;
15490 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015491 // set pSirKey->unicast = (tANI_U8)fUnicast;
15492 *p = (tANI_U8)fUnicast;
15493 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 // set pSirKey->keyDirection = aniKeyDirection;
15495 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015496 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 p += sizeof(tAniKeyDirection);
15498 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015499 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015500 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 // set pSirKey->paeRole
15502 *p = paeRole; // 0 is Supplicant
15503 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015504 // set pSirKey->keyLength = keyLength;
15505 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015507 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070015508 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015510 return( status );
15511}
15512
Jeff Johnson295189b2012-06-20 16:38:30 -070015513eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15514 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15515{
15516 eHalStatus status;
15517 tSirSmeStartBssReq *pMsg;
15518 tANI_U8 *pBuf = NULL;
15519 tANI_U8 *wTmpBuf = NULL;
15520 tANI_U16 msgLen, wTmp;
15521 tANI_U32 dwTmp;
15522 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015523 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015524 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015525 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015526
15527 if(!pSession)
15528 {
15529 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15530 return eHAL_STATUS_FAILURE;
15531 }
15532
Jeff Johnson295189b2012-06-20 16:38:30 -070015533 do {
15534 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15535 pSession->joinFailStatusCode.reasonCode = 0;
15536 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015537 pMsg = vos_mem_malloc(msgLen);
15538 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15539 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 //sessionId
15544 *pBuf = (tANI_U8)sessionId;
15545 pBuf++;
15546 // transactionId
15547 *pBuf = 0;
15548 *(pBuf + 1) = 0;
15549 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015550 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015551 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 pBuf += sizeof(tSirMacAddr);
15553 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015554 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015555 pBuf += sizeof(tSirMacAddr);
15556 // beaconInterval
15557 if( pBssDesc && pBssDesc->beaconInterval )
15558 {
15559 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015561 else if(pParam->beaconInterval)
15562 {
15563 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015565 else
15566 {
15567 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15568 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015569 if(csrIsconcurrentsessionValid (pMac, sessionId,
15570 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015571 == eHAL_STATUS_SUCCESS )
15572 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015573 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015574 pParam->bssPersona);
15575 //Update the beacon Interval
15576 pParam->beaconInterval = wTmp;
15577 }
15578 else
15579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015580 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015581 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015582 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015583 return status;
15584 }
15585
Kiet Lam64c1b492013-07-12 13:56:44 +053015586 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015587 pBuf += sizeof(tANI_U16);
15588 // dot11mode
15589 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15590 pBuf += 1;
15591 // bssType
15592 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015593 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015594 pBuf += sizeof(tSirBssType);
15595 // ssId
15596 if( pParam->ssId.length )
15597 {
15598 // ssId len
15599 *pBuf = pParam->ssId.length;
15600 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015601 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 pBuf += pParam->ssId.length;
15603 }
15604 else
15605 {
15606 *pBuf = 0;
15607 pBuf++;
15608 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015609 // set the channel Id
15610 *pBuf = pParam->operationChn;
15611 pBuf++;
15612 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015613 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015614 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015615 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015616
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 // Set privacy
15618 *pBuf = pParam->privacy;
15619 pBuf++;
15620
15621 //Set Uapsd
15622 *pBuf = pParam->ApUapsdEnable;
15623 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 //Set SSID hidden
15625 *pBuf = pParam->ssidHidden;
15626 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15628 pBuf++;
15629
15630 //Ht protection Enable/Disable
15631 *pBuf = (tANI_U8)pParam->protEnabled;
15632 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 //Enable Beacons to Receive for OBSS protection Enable/Disable
15634 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15635 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015636 //set cfg related to protection
15637 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015638 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 // Set Auth type
15641 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015642 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015643 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 // Set DTIM
15645 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015646 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 // Set wps_state
15649 *pBuf = pParam->wps_state;
15650 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015651 // set isCoalesingInIBSSAllowed
15652 *pBuf = pMac->isCoalesingInIBSSAllowed;
15653 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015654 //Persona
15655 *pBuf = (tANI_U8)pParam->bssPersona;
15656 pBuf++;
15657
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015658 //txLdpcIniFeatureEnabled
15659 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15660 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015661
Chet Lanctot8cecea22014-02-11 19:09:36 -080015662#ifdef WLAN_FEATURE_11W
15663 // Set MFP capable/required
15664 *pBuf = (tANI_U8)pParam->mfpCapable;
15665 pBuf++;
15666 *pBuf = (tANI_U8)pParam->mfpRequired;
15667 pBuf++;
15668#endif
15669
krunal soni4f087d22013-07-29 16:32:26 -070015670 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015671 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15672 {
15673 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015674 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015675 break;
15676 }
15677 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015678 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 pBuf += sizeof(tANI_U16);
15680 if( wTmp )
15681 {
15682 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015683 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015684 pBuf += wTmp;
15685 }
15686 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015687 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15690 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015691 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15692 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015693 pBuf += pParam->operationalRateSet.numRates ;
15694 *pBuf++ = pParam->extendedRateSet.numRates;
15695 if(0 != pParam->extendedRateSet.numRates)
15696 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015697 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15698 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 pBuf += pParam->extendedRateSet.numRates;
15700 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015701#ifdef WLAN_FEATURE_AP_HT40_24G
15702 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15703#endif
krunal sonie9002db2013-11-25 14:24:17 -080015704
Jeff Johnson295189b2012-06-20 16:38:30 -070015705 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15706 pMsg->length = pal_cpu_to_be16(msgLen);
15707
15708 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015709 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015710 return( status );
15711}
15712
Jeff Johnson295189b2012-06-20 16:38:30 -070015713eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15714{
15715 eHalStatus status = eHAL_STATUS_FAILURE;
15716 tSirSmeStopBssReq *pMsg;
15717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15718 tANI_U8 *pBuf;
15719 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015720
15721 if(!pSession)
15722 {
15723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15724 return eHAL_STATUS_FAILURE;
15725 }
15726
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015727 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15728 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15729 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15730 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15731 pBuf = &pMsg->sessionId;
15732 //sessionId
15733 *pBuf = (tANI_U8)sessionId;
15734 pBuf++;
15735 // transactionId
15736 *pBuf = 0;
15737 pBuf += sizeof(tANI_U16);
15738 //reason code
15739 *pBuf = 0;
15740 pBuf += sizeof(tSirResultCodes);
15741 // bssid
15742 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15743 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15744 {
15745 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15746 sizeof(tSirMacAddr));
15747 }
15748 else
15749 {
15750 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15751 sizeof(tSirMacAddr));
15752 }
15753 pBuf += sizeof(tSirMacAddr);
15754 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15755 pMsg->length = pal_cpu_to_be16(msgLen);
15756 status = palSendMBMessage( pMac->hHdd, pMsg );
15757
Jeff Johnson295189b2012-06-20 16:38:30 -070015758 return( status );
15759}
15760
Jeff Johnson295189b2012-06-20 16:38:30 -070015761eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15762 tCsrRoamModifyProfileFields *pModProfileFields,
15763 tANI_U32 *pRoamId, v_BOOL_t fForce)
15764{
Jeff Johnson295189b2012-06-20 16:38:30 -070015765 eHalStatus status = eHAL_STATUS_FAILURE;
15766 tANI_U32 roamId = 0;
15767 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015768 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015769 (fForce || (!vos_mem_compare( &pModProfileFields,
15770 &pSession->connectedProfile.modifyProfileFields,
15771 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015772 {
15773 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15774 if(pRoamId)
15775 {
15776 *pRoamId = roamId;
15777 }
15778
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15780 eCsrSmeIssuedReassocToSameAP, roamId,
15781 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 return status;
15784}
Jeff Johnson295189b2012-06-20 16:38:30 -070015785static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15786{
15787 eHalStatus status = eHAL_STATUS_SUCCESS;
15788 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015789 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015790 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15791 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15792 return (status);
15793}
Jeff Johnson295189b2012-06-20 16:38:30 -070015794eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15795{
15796 eHalStatus status = eHAL_STATUS_SUCCESS;
15797 tListElem *pEntry = NULL;
15798 tSmeCmd *pCommand = NULL;
15799 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015800 do
15801 {
15802 if(pMsg == NULL)
15803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015804 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015805 status = eHAL_STATUS_FAILURE;
15806 break;
15807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15809 if(pEntry)
15810 {
15811 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15812 if(eSmeCommandAddStaSession == pCommand->command)
15813 {
15814 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015815 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015816 if (pRsp->status == eSIR_FAILURE) {
15817 VOS_ASSERT( 0 );
15818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 //Remove this command out of the active list
15822 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15823 {
15824 //Now put this command back on the avilable command list
15825 csrReleaseCommand(pMac, pCommand);
15826 }
15827 smeProcessPendingQueue( pMac );
15828 }
15829 else
15830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015831 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 -070015832 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 status = eHAL_STATUS_FAILURE;
15834 break;
15835 }
15836 }
15837 else
15838 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015839 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 -070015840 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 status = eHAL_STATUS_FAILURE;
15842 break;
15843 }
15844 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015845 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015846}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015847eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15848 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015849{
15850 tSirSmeAddStaSelfReq *pMsg;
15851 tANI_U16 msgLen;
15852 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015853 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015854 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015855 pMsg = vos_mem_malloc(msgLen);
15856 if ( NULL == pMsg ) break;
15857 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015858 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15859 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015860 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015861 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015862 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15863
15864 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
15865
Arif Hussain24bafea2013-11-15 15:10:03 -080015866 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
15867 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015868 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015870 return( status );
15871}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015872eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
15873 tANI_U32 sessionId,
15874 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070015875{
15876 eHalStatus status = eHAL_STATUS_SUCCESS;
15877 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 pCommand = csrGetCommandBuffer(pMac);
15879 if(NULL == pCommand)
15880 {
15881 status = eHAL_STATUS_RESOURCES;
15882 }
15883 else
15884 {
15885 pCommand->command = eSmeCommandAddStaSession;
15886 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053015887 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
15888 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015889 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015890 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
15891 if( !HAL_STATUS_SUCCESS( status ) )
15892 {
15893 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015894 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 }
15896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015897 return (status);
15898}
Jeff Johnson295189b2012-06-20 16:38:30 -070015899eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15900{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015901 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070015902}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015903eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
15904 csrRoamCompleteCallback callback,
15905 void *pContext, tANI_U8 *pSelfMacAddr,
15906 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070015907{
15908 eHalStatus status = eHAL_STATUS_SUCCESS;
15909 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053015910 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015911 *pbSessionId = CSR_SESSION_ID_INVALID;
15912 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15913 {
15914 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15915 {
15916 pSession = CSR_GET_SESSION( pMac, i );
15917 status = eHAL_STATUS_SUCCESS;
15918 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15919 pSession->sessionId = (tANI_U8)i;
15920 pSession->callback = callback;
15921 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015922 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015923 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015924 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15925 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015926 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015927 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015929 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 break;
15931 }
15932#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015933 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15934 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015935 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015936 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015938 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 break;
15940 }
15941#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015942 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 break;
15944 }
15945 }
15946 if( CSR_ROAM_SESSION_MAX == i )
15947 {
15948 //No session is available
15949 status = eHAL_STATUS_RESOURCES;
15950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015951 return ( status );
15952}
Jeff Johnson295189b2012-06-20 16:38:30 -070015953eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15954{
15955 eHalStatus status = eHAL_STATUS_SUCCESS;
15956 tListElem *pEntry = NULL;
15957 tSmeCmd *pCommand = NULL;
15958 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015959 do
15960 {
15961 if(pMsg == NULL)
15962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015963 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015964 status = eHAL_STATUS_FAILURE;
15965 break;
15966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015967 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15968 if(pEntry)
15969 {
15970 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15971 if(eSmeCommandDelStaSession == pCommand->command)
15972 {
15973 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015975 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015976 //This session is done.
15977 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 if(pCommand->u.delStaSessionCmd.callback)
15979 {
15980
15981 status = sme_ReleaseGlobalLock( &pMac->sme );
15982 if ( HAL_STATUS_SUCCESS( status ) )
15983 {
15984 pCommand->u.delStaSessionCmd.callback(
15985 pCommand->u.delStaSessionCmd.pContext);
15986 status = sme_AcquireGlobalLock( &pMac->sme );
15987 if (! HAL_STATUS_SUCCESS( status ) )
15988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015989 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015990 return status;
15991 }
15992 }
15993 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015994 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 }
15996 }
15997
15998 //Remove this command out of the active list
15999 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
16000 {
16001 //Now put this command back on the avilable command list
16002 csrReleaseCommand(pMac, pCommand);
16003 }
16004 smeProcessPendingQueue( pMac );
16005 }
16006 else
16007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016008 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 -070016009 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016010 status = eHAL_STATUS_FAILURE;
16011 break;
16012 }
16013 }
16014 else
16015 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016016 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 -070016017 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016018 status = eHAL_STATUS_FAILURE;
16019 break;
16020 }
16021 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016023}
Jeff Johnson295189b2012-06-20 16:38:30 -070016024eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16025{
16026 tSirSmeDelStaSelfReq *pMsg;
16027 tANI_U16 msgLen;
16028 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016030 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16031 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016032 pMsg = vos_mem_malloc(msgLen);
16033 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16034 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16036 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016037 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016038 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16039 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016042 return( status );
16043}
Jeff Johnson295189b2012-06-20 16:38:30 -070016044eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016045 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 tSirMacAddr sessionMacAddr,
16047 csrRoamSessionCloseCallback callback,
16048 void *pContext)
16049{
16050 eHalStatus status = eHAL_STATUS_SUCCESS;
16051 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016052 pCommand = csrGetCommandBuffer(pMac);
16053 if(NULL == pCommand)
16054 {
16055 status = eHAL_STATUS_RESOURCES;
16056 }
16057 else
16058 {
16059 pCommand->command = eSmeCommandDelStaSession;
16060 pCommand->sessionId = (tANI_U8)sessionId;
16061 pCommand->u.delStaSessionCmd.callback = callback;
16062 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016063 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16064 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016065 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 if( !HAL_STATUS_SUCCESS( status ) )
16067 {
16068 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016069 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 }
16071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016072 return (status);
16073}
Jeff Johnson295189b2012-06-20 16:38:30 -070016074eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16075{
16076 return csrSendMBDelSelfStaReqMsg( pMac,
16077 pCommand->u.delStaSessionCmd.selfMacAddr );
16078}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016079static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16080 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016081{
16082 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16083 tListElem *pEntry, *pNext;
16084 tSmeCmd *pCommand;
16085 tDblLinkList localList;
16086
16087 vos_mem_zero(&localList, sizeof(tDblLinkList));
16088 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16089 {
16090 smsLog(pMac, LOGE, FL(" failed to open list"));
16091 return;
16092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016093 csrLLLock(pList);
16094 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16095 while(pEntry != NULL)
16096 {
16097 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16098 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016099
16100 if (!flush_all &&
16101 csr_is_disconnect_full_power_cmd(pCommand)) {
16102 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16103 pEntry = pNext;
16104 continue;
16105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016106 if(pCommand->sessionId == sessionId)
16107 {
16108 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16109 {
16110 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16111 }
16112 }
16113 pEntry = pNext;
16114 }
16115 csrLLUnlock(pList);
16116
16117 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16118 {
16119 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16120 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16121 }
16122 csrLLClose(&localList);
16123}
16124
Jeff Johnson295189b2012-06-20 16:38:30 -070016125void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16126{
16127 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16128 {
16129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016130 csrRoamStop(pMac, sessionId);
16131 csrFreeConnectBssDesc(pMac, sessionId);
16132 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16133 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016134 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016135#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016136 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016137#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016138 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016139 csrInitSession(pMac, sessionId);
16140 }
16141}
16142
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016143void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16144 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016145{
16146 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016147 &pMac->sme.smeCmdPendingList,
16148 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016149 if (pMac->fScanOffload)
16150 {
16151 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016152 &pMac->sme.smeScanCmdPendingList,
16153 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016154 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016155 purgeCsrSessionCmdList(pMac, sessionId,
16156 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016157}
16158
Jeff Johnson295189b2012-06-20 16:38:30 -070016159eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016160 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016161 csrRoamSessionCloseCallback callback,
16162 void *pContext )
16163{
16164 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16166 {
16167 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16168 if(fSync)
16169 {
16170 csrCleanupSession(pMac, sessionId);
16171 }
16172 else
mukul sharmabab477d2015-06-11 17:14:55 +053016173 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016174 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016175 /* If bPurgeList is FALSE, it means HDD already free all the
16176 * cmd and later queue few essential cmd. Now sme should process
16177 * the cmd in pending queue order only.Hence we should
16178 * avoid DEL_SELF_STA as high priority cmd.
16179 */
16180 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016181 pSession->selfMacAddr, callback, pContext);
16182 }
16183 }
16184 else
16185 {
16186 status = eHAL_STATUS_INVALID_PARAMETER;
16187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016188 return ( status );
16189}
16190
Jeff Johnson295189b2012-06-20 16:38:30 -070016191static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16192{
16193 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016194
16195 if(!pSession)
16196 {
16197 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16198 return;
16199 }
16200
Jeff Johnson295189b2012-06-20 16:38:30 -070016201 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16202 pSession->sessionId = CSR_SESSION_ID_INVALID;
16203 pSession->callback = NULL;
16204 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16206 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16207 csrFreeRoamProfile( pMac, sessionId );
16208 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16209 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16210 csrFreeConnectBssDesc(pMac, sessionId);
16211 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016212 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16213 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016214 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016215 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016216 pSession->pWpaRsnReqIE = NULL;
16217 }
16218 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016219 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016220 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016221 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016222 pSession->pWpaRsnRspIE = NULL;
16223 }
16224 pSession->nWpaRsnRspIeLength = 0;
16225#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016226 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016228 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016229 pSession->pWapiReqIE = NULL;
16230 }
16231 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016232 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016233 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016234 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016235 pSession->pWapiRspIE = NULL;
16236 }
16237 pSession->nWapiRspIeLength = 0;
16238#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016239 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016240 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016241 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016242 }
16243 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016244
Kiet Lam64c1b492013-07-12 13:56:44 +053016245 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016246 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016247 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016248 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016250 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016251}
16252
Jeff Johnson295189b2012-06-20 16:38:30 -070016253eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16254{
16255 eHalStatus status = eHAL_STATUS_FAILURE;
16256 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016257 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16258 {
16259 if( CSR_IS_SESSION_VALID( pMac, i ) )
16260 {
16261 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16262 {
16263 //Found it
16264 status = eHAL_STATUS_SUCCESS;
16265 *pSessionId = i;
16266 break;
16267 }
16268 }
16269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016270 return( status );
16271}
16272
Jeff Johnson295189b2012-06-20 16:38:30 -070016273//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16274//session because for IBSS, the bssid changes.
16275static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16276{
16277 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16278 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016279 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16280 {
16281 if( CSR_IS_SESSION_VALID( pMac, i ) )
16282 {
16283 pSession = CSR_GET_SESSION( pMac, i );
16284 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16285 {
16286 //Found it
16287 nRet = i;
16288 break;
16289 }
16290 }
16291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016292 return (nRet);
16293}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016294void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016295{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016296 VOS_STATUS status = VOS_STATUS_SUCCESS;
16297
16298 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016299 profile info from pmac global structure */
16300
Arif Hussain24bafea2013-11-15 15:10:03 -080016301 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16302 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 /* Check for user misconfig of RSSI trigger threshold */
16304 pMac->roam.configParam.vccRssiThreshold =
16305 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16306 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16307 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016308 /* Check for user misconfig of UL MAC Loss trigger threshold */
16309 pMac->roam.configParam.vccUlMacLossThreshold =
16310 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16311 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016312#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16313 {
16314 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016315 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 /* Indicate the neighbor roal algorithm about the connect indication */
16317 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16318 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016319
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016320 /* Making sure we are roaming force fully to 5GHz AP only once and
16321 * only when we connected to 2.4GH AP only during initial association.
16322 */
16323 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16324 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16325 SIR_BAND_2_4_GHZ)
16326 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016327 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016328 status = vos_timer_start(
16329 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16330 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016331 if ( status != VOS_STATUS_SUCCESS )
16332 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016333 smsLog(pMac, LOGE,
16334 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16335 status);
16336 //Send RSO start because in case 5G roaming
16337 //host have not enabled at initial connection
16338 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016339 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016340 else
16341 {
16342 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16343 __func__);
16344 }
16345 }
16346 /*
16347 * Making ini value to false here only so we just roam to
16348 * only once for whole driver load to unload tenure
16349 * This feature is only applicable for first connection only
16350 */
16351 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16352 {
16353 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16354 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016356 }
16357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016358}
16359
Jeff Johnson295189b2012-06-20 16:38:30 -070016360static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16361{
16362 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016363
16364 if(!pSession)
16365 {
16366 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16367 return;
16368 }
16369
Jeff Johnson295189b2012-06-20 16:38:30 -070016370 //Only to handle the case for Handover on infra link
16371 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16372 {
16373 return;
16374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016375 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16376 csrRoamDeregStatisticsReq(pMac);
16377 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16378#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16379 /* Indicate the neighbor roal algorithm about the disconnect indication */
16380 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16381#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016382
16383 //Remove this code once SLM_Sessionization is supported
16384 //BMPS_WORKAROUND_NOT_NEEDED
16385 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016386 csrIsInfraApStarted( pMac ) &&
16387 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016388 {
16389 pMac->roam.configParam.doBMPSWorkaround = 0;
16390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016391}
16392
Jeff Johnson295189b2012-06-20 16:38:30 -070016393void csrRoamTlStatsTimerHandler(void *pv)
16394{
16395 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16396 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016397 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16398
Jeff Johnsone7245742012-09-05 17:12:55 -070016399 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16400
Jeff Johnson295189b2012-06-20 16:38:30 -070016401#if 0
16402 // TODO Persession .???
16403 //req TL for stats
16404 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016406 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016407 }
16408 else
16409 {
16410 //save in SME
16411 csrRoamSaveStatsFromTl(pMac, tlStats);
16412 }
16413#endif
16414 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16415 {
16416 if(pMac->roam.tlStatsReqInfo.periodicity)
16417 {
16418 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016419 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16420 pMac->roam.tlStatsReqInfo.periodicity);
16421 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016423 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016424 return;
16425 }
16426 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16427 }
16428 }
16429}
Jeff Johnson295189b2012-06-20 16:38:30 -070016430void csrRoamPeStatsTimerHandler(void *pv)
16431{
16432 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16433 eHalStatus status;
16434 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16435 VOS_STATUS vosStatus;
16436 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016437 pPeStatsReqListEntry->timerRunning = FALSE;
16438 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16439 {
16440 // If we entered here, meaning the timer could not be successfully
16441 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16442
16443 /* Destroy the timer */
16444 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16445 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016447 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 }
16449
16450 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016451 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 pPeStatsReqListEntry = NULL;
16453 }
16454 else
16455 {
16456 if(!pPeStatsReqListEntry->rspPending)
16457 {
16458 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16459 pPeStatsReqListEntry->staId);
16460 if(!HAL_STATUS_SUCCESS(status))
16461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016462 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 }
16464 else
16465 {
16466 pPeStatsReqListEntry->rspPending = TRUE;
16467 }
16468 }
16469
16470 //send down a req
16471 if(pPeStatsReqListEntry->periodicity &&
16472 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16473 {
16474 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16475 if(ePMC_FULL_POWER == powerState)
16476 {
16477 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16478 {
16479 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16480 }
16481 }
16482 else
16483 {
16484 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16485 {
16486 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16487 }
16488 }
16489 //start timer
16490 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16491 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016493 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 return;
16495 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 pPeStatsReqListEntry->timerRunning = TRUE;
16497
16498 }
16499
16500 }
16501}
Jeff Johnson295189b2012-06-20 16:38:30 -070016502void csrRoamStatsClientTimerHandler(void *pv)
16503{
16504 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16506 {
16507#if 0
16508 // TODO Stats fix for multisession
16509 //start the timer
16510 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16511
16512 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016514 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016515 }
16516#endif
16517 }
16518#if 0
16519 //send up the stats report
16520 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16521 pStaEntry->staId, pStaEntry->pContext);
16522#endif
16523}
16524
16525
16526
Jeff Johnson295189b2012-06-20 16:38:30 -070016527eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16528{
16529 tAniGetPEStatsReq *pMsg;
16530 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016531 tSirMsgQ msgQ;
16532
Kiet Lam64c1b492013-07-12 13:56:44 +053016533 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16534 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016536 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016537 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016538 }
16539 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016540 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016541 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16542 pMsg->staId = staId;
16543 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016544
16545 msgQ.type = WDA_GET_STATISTICS_REQ;
16546 msgQ.reserved = 0;
16547 msgQ.bodyptr = pMsg;
16548 msgQ.bodyval = 0;
16549 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016550 if(!HAL_STATUS_SUCCESS(status))
16551 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016552 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016553 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016554 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016555 return status;
16556}
Jeff Johnson295189b2012-06-20 16:38:30 -070016557void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16558{
16559 tAniGetPEStatsRsp *pSmeStatsRsp;
16560 eHalStatus status = eHAL_STATUS_FAILURE;
16561 tListElem *pEntry = NULL;
16562 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16563 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16564 tANI_U32 tempMask = 0;
16565 tANI_U8 counter = 0;
16566 tANI_U8 *pStats = NULL;
16567 tANI_U32 length = 0;
16568 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016569 v_S7_t rssi = 0, snr = 0;
16570 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016571 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016572 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16574 if(pSmeStatsRsp->rc)
16575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016576 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016577 goto post_update;
16578 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016579 tempMask = pSmeStatsRsp->statsMask;
16580 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016581 /* subtract all statistics from this length, and after processing the entire
16582 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16583 * in this 'stats' message.
16584 */
16585 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 //new stats info from PE, fill up the stats strucutres in PMAC
16587 while(tempMask)
16588 {
16589 if(tempMask & 1)
16590 {
16591 switch(counter)
16592 {
16593 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016594 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016595 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16596 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 pStats += sizeof(tCsrSummaryStatsInfo);
16598 length -= sizeof(tCsrSummaryStatsInfo);
16599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016600 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016601 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016602 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16603 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016604 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16605 length -= sizeof(tCsrGlobalClassAStatsInfo);
16606 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016607 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016608 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016609 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16610 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016611 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16612 length -= sizeof(tCsrGlobalClassBStatsInfo);
16613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016615 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016616 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16617 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016618 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16619 length -= sizeof(tCsrGlobalClassCStatsInfo);
16620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016621 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016622 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016623 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16624 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016625 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016626 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16627 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016628 }
16629 else
16630 {
16631 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016632 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016633 VOS_ASSERT( 0 );
16634 }
16635 if(!HAL_STATUS_SUCCESS(status))
16636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016637 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016638 }
16639 pStats += sizeof(tCsrPerStaStatsInfo);
16640 length -= sizeof(tCsrPerStaStatsInfo);
16641 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016642 case eCsrPerPktStats:
16643 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16644 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16645 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16646 {
16647 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16648 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16649 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016650 /* for reserved bytes */
16651 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16652 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016653 }
16654 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016655 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016656 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 }
16659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 tempMask >>=1;
16661 counter++;
16662 }
16663 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16664 if (length != 0)
16665 {
16666 pRssi = (tANI_U32*)pStats;
16667 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016668 pStats += sizeof(tANI_U32);
16669 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016670 }
16671 else
16672 {
16673 /* If riva is not sending rssi, continue to use the hack */
16674 rssi = RSSI_HACK_BMPS;
16675 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016676 /* send positive value of rssi to wifi_hal */
16677 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016678 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016679 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016680
16681 if (length != 0)
16682 {
16683 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016684 pStats += sizeof(tANI_U32);
16685 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016686 }
16687 else
16688 {
16689 linkCapacity = 0;
16690 }
16691
16692 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016693
16694 if (length != 0)
16695 {
16696 pSnr = (tANI_U32*)pStats;
16697 snr = (v_S7_t)*pSnr;
16698 }
16699 else
16700 {
16701 snr = SNR_HACK_BMPS;
16702 }
16703
16704 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016705post_update:
16706 //make sure to update the pe stats req list
16707 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16708 if(pEntry)
16709 {
16710 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16711 pPeStaEntry->rspPending = FALSE;
16712
16713 }
16714 //check the one timer cases
16715 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16716 if(pEntry)
16717 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016719 if(pTempStaEntry->timerExpired)
16720 {
16721 //send up the stats report
16722 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16723 pTempStaEntry->staId, pTempStaEntry->pContext);
16724 //also remove from the client list
16725 csrRoamRemoveStatListEntry(pMac, pEntry);
16726 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016727 }
16728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016729}
Jeff Johnson295189b2012-06-20 16:38:30 -070016730tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16731{
16732 tListElem *pEntry = NULL;
16733 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016734 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016735 if(!pEntry)
16736 {
16737 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016738 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 return NULL;
16740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016741 while( pEntry )
16742 {
16743 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 if(pTempStaEntry->statsMask == statsMask)
16745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016746 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 break;
16748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016749 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016751 return pEntry;
16752}
16753
Jeff Johnson295189b2012-06-20 16:38:30 -070016754tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16755 tANI_BOOLEAN update)
16756{
16757 tListElem *pEntry;
16758 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016759 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016760 if(!pEntry)
16761 {
16762 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016763 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016764 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 return NULL;
16766 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016767 while( pEntry )
16768 {
16769 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16771 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016773 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016774 if(update)
16775 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016776 pTempStaEntry->periodicity = pStaEntry->periodicity;
16777 pTempStaEntry->callback = pStaEntry->callback;
16778 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 }
16780 break;
16781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016782 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016784 return pEntry;
16785}
Jeff Johnson295189b2012-06-20 16:38:30 -070016786tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16787{
16788 tListElem *pEntry;
16789 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016790 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016791 if(!pEntry)
16792 {
16793 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016794 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016795 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 return NULL;
16797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016798 while( pEntry )
16799 {
16800 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016801 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016803 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016804 break;
16805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016808 return pEntry;
16809}
Jeff Johnson295189b2012-06-20 16:38:30 -070016810eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16811 csrRoamLinkQualityIndCallback callback,
16812 void *pContext)
16813{
16814 pMac->roam.linkQualityIndInfo.callback = callback;
16815 pMac->roam.linkQualityIndInfo.context = pContext;
16816 if( NULL == callback )
16817 {
16818 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16819 }
16820 else
16821 {
16822 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016823 /* do we need to invoke the callback to notify client of initial value ?? */
16824 }
16825 return eHAL_STATUS_SUCCESS;
16826}
Jeff Johnson295189b2012-06-20 16:38:30 -070016827void csrRoamVccTrigger(tpAniSirGlobal pMac)
16828{
16829 eCsrRoamLinkQualityInd newVccLinkQuality;
16830 tANI_U32 ul_mac_loss = 0;
16831 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016832 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16833 /*-------------------------------------------------------------------------
16834 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 Check for a change in link quality and notify client if necessary
16836 -------------------------------------------------------------------------*/
16837 ul_mac_loss_trigger_threshold =
16838 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016839 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016840 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016841 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016842 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016844 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016845 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16846 }
16847 else
16848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016849 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16851 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16853 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016854 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016856 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016857 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016859 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016860 newVccLinkQuality );
16861
16862 /* we now invoke the callback once to notify client of initial value */
16863 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16864 pMac->roam.linkQualityIndInfo.context );
16865 //event: EVENT_WLAN_VCC
16866 }
16867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016868 pMac->roam.vccLinkQuality = newVccLinkQuality;
16869
Jeff Johnson295189b2012-06-20 16:38:30 -070016870}
Jeff Johnson295189b2012-06-20 16:38:30 -070016871VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
16872 v_U8_t rssiNotification,
16873 void * context)
16874{
16875 tpAniSirGlobal pMac = PMAC_STRUCT( context );
16876 eCsrRoamLinkQualityInd newVccLinkQuality;
16877 // TODO : Session info unavailable
16878 tANI_U32 sessionId = 0;
16879 VOS_STATUS status = VOS_STATUS_SUCCESS;
16880 /*-------------------------------------------------------------------------
16881 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 Check for a change in link quality and notify client if necessary
16883 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016884 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 pMac->roam.configParam.vccRssiThreshold);
16886 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
16887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016888 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070016889 return VOS_STATUS_SUCCESS;
16890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016891 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
16892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016893 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16895 }
16896 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
16897 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016898 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016899 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16900 }
16901 else
16902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016903 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 //Set to this so the code below won't do anything
16905 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016906 VOS_ASSERT(0);
16907 }
16908
Jeff Johnson295189b2012-06-20 16:38:30 -070016909 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016911 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016912 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016914 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016916 /* we now invoke the callback once to notify client of initial value */
16917 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16918 pMac->roam.linkQualityIndInfo.context );
16919 //event: EVENT_WLAN_VCC
16920 }
16921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016922 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016923 return status;
16924}
Jeff Johnson295189b2012-06-20 16:38:30 -070016925tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16926 tDblLinkList *pStaList,
16927 tCsrStatsClientReqInfo *pStaEntry)
16928{
16929 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016930 //if same entity requested for same set of stats with different periodicity &
16931 // callback update it
16932 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16933 {
16934
Kiet Lam64c1b492013-07-12 13:56:44 +053016935 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16936 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016937 {
16938 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016939 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016940 return NULL;
16941 }
16942
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 pNewStaEntry->callback = pStaEntry->callback;
16944 pNewStaEntry->pContext = pStaEntry->pContext;
16945 pNewStaEntry->periodicity = pStaEntry->periodicity;
16946 pNewStaEntry->requesterId = pStaEntry->requesterId;
16947 pNewStaEntry->statsMask = pStaEntry->statsMask;
16948 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16949 pNewStaEntry->pMac = pStaEntry->pMac;
16950 pNewStaEntry->staId = pStaEntry->staId;
16951 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16952
16953 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
16954 }
16955 return pNewStaEntry;
16956}
16957
Jeff Johnson295189b2012-06-20 16:38:30 -070016958tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
16959 tDblLinkList *pStaList,
16960 tCsrPeStatsReqInfo *pStaEntry)
16961{
16962 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016963 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
16964 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016965 {
16966 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016967 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016968 return NULL;
16969 }
16970
Jeff Johnson295189b2012-06-20 16:38:30 -070016971 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
16972 pNewStaEntry->numClient = pStaEntry->numClient;
16973 pNewStaEntry->periodicity = pStaEntry->periodicity;
16974 pNewStaEntry->statsMask = pStaEntry->statsMask;
16975 pNewStaEntry->pMac = pStaEntry->pMac;
16976 pNewStaEntry->staId = pStaEntry->staId;
16977 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
16978 pNewStaEntry->rspPending = pStaEntry->rspPending;
16979
16980 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016981 return pNewStaEntry;
16982}
Jeff Johnson295189b2012-06-20 16:38:30 -070016983eHalStatus csrGetRssi(tpAniSirGlobal pMac,
16984 tCsrRssiCallback callback,
16985 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16986{
16987 eHalStatus status = eHAL_STATUS_SUCCESS;
16988 vos_msg_t msg;
16989 tANI_U32 sessionId;
16990
16991 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016992 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016993 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16994 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016996 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016997 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016998 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016999 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17000
17001 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
17002 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17003 pMsg->sessionId = sessionId;
17004 pMsg->staId = staId;
17005 pMsg->rssiCallback = callback;
17006 pMsg->pDevContext = pContext;
17007 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070017008 msg.type = eWNI_SME_GET_RSSI_REQ;
17009 msg.bodyptr = pMsg;
17010 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017011 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017013 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017014 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017015 status = eHAL_STATUS_FAILURE;
17016 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017017 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017018 return status;
17019}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017020
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017021eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17022 tCsrSnrCallback callback,
17023 tANI_U8 staId, tCsrBssid bssId,
17024 void *pContext)
17025{
17026 eHalStatus status = eHAL_STATUS_SUCCESS;
17027 vos_msg_t msg;
17028 tANI_U32 sessionId;
17029
17030 tAniGetSnrReq *pMsg;
17031
17032 smsLog(pMac, LOG2, FL("called"));
17033
17034 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17035 if (NULL == pMsg )
17036 {
17037 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17038 return status;
17039 }
17040
17041 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17042
17043 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17044 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17045 pMsg->sessionId = sessionId;
17046 pMsg->staId = staId;
17047 pMsg->snrCallback = callback;
17048 pMsg->pDevContext = pContext;
17049 msg.type = eWNI_SME_GET_SNR_REQ;
17050 msg.bodyptr = pMsg;
17051 msg.reserved = 0;
17052
17053 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17054 {
17055 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17056 vos_mem_free((v_VOID_t *)pMsg);
17057 status = eHAL_STATUS_FAILURE;
17058 }
17059
17060 smsLog(pMac, LOG2, FL("returned"));
17061 return status;
17062}
17063
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017064#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017065eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17066 tCsrRssiCallback callback,
17067 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17068{
17069 eHalStatus status = eHAL_STATUS_SUCCESS;
17070 tAniGetRssiReq *pMsg;
17071
Kiet Lam64c1b492013-07-12 13:56:44 +053017072 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17073 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017074 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017075 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017076 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017077 }
17078 // need to initiate a stats request to PE
17079 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17080 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17081 pMsg->staId = staId;
17082 pMsg->rssiCallback = callback;
17083 pMsg->pDevContext = pContext;
17084 pMsg->pVosContext = pVosContext;
17085 status = palSendMBMessage(pMac->hHdd, pMsg );
17086 if(!HAL_STATUS_SUCCESS(status))
17087 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017088 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017089 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017090 status = eHAL_STATUS_FAILURE;
17091 }
17092 return status;
17093}
17094#endif
17095
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017096
17097
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017098#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017099eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17100 tCsrTsmStatsCallback callback,
17101 tANI_U8 staId,
17102 tCsrBssid bssId,
17103 void *pContext,
17104 void* pVosContext,
17105 tANI_U8 tid)
17106{
17107 eHalStatus status = eHAL_STATUS_SUCCESS;
17108 tAniGetTsmStatsReq *pMsg = NULL;
17109
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017110 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17111 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017112 {
17113 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017114 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017115 }
17116 // need to initiate a stats request to PE
17117 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17118 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17119 pMsg->staId = staId;
17120 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017121 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017122 pMsg->tsmStatsCallback = callback;
17123 pMsg->pDevContext = pContext;
17124 pMsg->pVosContext = pVosContext;
17125 status = palSendMBMessage(pMac->hHdd, pMsg );
17126 if(!HAL_STATUS_SUCCESS(status))
17127 {
17128 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17129 //pMsg is freed by palSendMBMessage
17130 status = eHAL_STATUS_FAILURE;
17131 }
17132 return status;
17133}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017134#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017135
17136
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017137/* ---------------------------------------------------------------------------
17138 \fn csrGetTLSTAState
17139 \helper function to get teh TL STA State whenever the function is called.
17140
17141 \param staId - The staID to be passed to the TL
17142 to get the relevant TL STA State
17143 \return the state as tANI_U16
17144 ---------------------------------------------------------------------------*/
17145tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17146{
17147 WLANTL_STAStateType tlSTAState;
17148 tlSTAState = WLANTL_STA_INIT;
17149
17150 //request TL for STA State
17151 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17152 {
17153 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17154 }
17155
17156 return tlSTAState;
17157}
17158
Jeff Johnson295189b2012-06-20 16:38:30 -070017159eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17160 tANI_U32 statsMask,
17161 tCsrStatsCallback callback,
17162 tANI_U32 periodicity, tANI_BOOLEAN cache,
17163 tANI_U8 staId, void *pContext)
17164{
17165 tCsrStatsClientReqInfo staEntry;
17166 tCsrStatsClientReqInfo *pStaEntry = NULL;
17167 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17168 tListElem *pEntry = NULL;
17169 tANI_BOOLEAN found = FALSE;
17170 eHalStatus status = eHAL_STATUS_SUCCESS;
17171 tANI_BOOLEAN insertInClientList = FALSE;
17172 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017173 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017174
17175 if( csrIsAllSessionDisconnected(pMac) )
17176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017177 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017178 return eHAL_STATUS_FAILURE;
17179 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017180
17181 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17182 {
17183 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17184 return eHAL_STATUS_FAILURE;
17185 }
17186
Jeff Johnson295189b2012-06-20 16:38:30 -070017187 if((!statsMask) && (!callback))
17188 {
17189 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017190 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017191 return eHAL_STATUS_FAILURE;
17192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017193 //for the search list method for deregister
17194 staEntry.requesterId = requesterId;
17195 staEntry.statsMask = statsMask;
17196 //requester wants to deregister or just an error
17197 if((statsMask) && (!callback))
17198 {
17199 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17200 if(!pEntry)
17201 {
17202 //msg
17203 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017204 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017205 return eHAL_STATUS_FAILURE;
17206 }
17207 else
17208 {
17209 //clean up & return
17210 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017211 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017212 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017213 pStaEntry->pPeStaEntry->numClient--;
17214 //check if we need to delete the entry from peStatsReqList too
17215 if(!pStaEntry->pPeStaEntry->numClient)
17216 {
17217 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017219 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017220
Jeff Johnson295189b2012-06-20 16:38:30 -070017221 //check if we need to stop the tl stats timer too
17222 pMac->roam.tlStatsReqInfo.numClient--;
17223 if(!pMac->roam.tlStatsReqInfo.numClient)
17224 {
17225 if(pMac->roam.tlStatsReqInfo.timerRunning)
17226 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017227 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17228 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017230 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017231 return eHAL_STATUS_FAILURE;
17232 }
17233 }
17234 pMac->roam.tlStatsReqInfo.periodicity = 0;
17235 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17236 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017237 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017238 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017239 vos_timer_stop(&pStaEntry->timer);
17240 // Destroy the vos timer
17241 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17242 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17243 {
17244 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017247 csrRoamRemoveStatListEntry(pMac, pEntry);
17248 pStaEntry = NULL;
17249 return eHAL_STATUS_SUCCESS;
17250 }
17251 }
17252
17253 if(cache && !periodicity)
17254 {
17255 //return the cached stats
17256 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17257 }
17258 else
17259 {
17260 //add the request in the client req list
17261 staEntry.callback = callback;
17262 staEntry.pContext = pContext;
17263 staEntry.periodicity = periodicity;
17264 staEntry.pPeStaEntry = NULL;
17265 staEntry.staId = staId;
17266 staEntry.pMac = pMac;
17267 staEntry.timerExpired = FALSE;
17268
17269
Jeff Johnson295189b2012-06-20 16:38:30 -070017270 //if periodic report requested with non cached result from PE/TL
17271 if(periodicity)
17272 {
17273
17274 //if looking for stats from PE
17275 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17276 {
17277
17278 //check if same request made already & waiting for rsp
17279 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17280 periodicity, &found, staId);
17281 if(!pPeStaEntry)
17282 {
17283 //bail out, maxed out on number of req for PE
17284 return eHAL_STATUS_FAILURE;
17285 }
17286 else
17287 {
17288 staEntry.pPeStaEntry = pPeStaEntry;
17289 }
17290
17291 }
17292 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17293 if(statsMask & (1 << eCsrGlobalClassDStats))
17294 {
17295 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017297 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017298 }
17299 else
17300 {
17301
17302 //update periodicity
17303 if(pMac->roam.tlStatsReqInfo.periodicity)
17304 {
17305 pMac->roam.tlStatsReqInfo.periodicity =
17306 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17307 }
17308 else
17309 {
17310 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17311 }
17312 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17313 {
17314 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17315 }
17316
17317 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17318 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017319 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017320 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017321 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017322 //req TL for class D stats
17323 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017325 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017326 }
17327 else
17328 {
17329 //save in SME
17330 csrRoamSaveStatsFromTl(pMac, pTlStats);
17331 }
17332 vos_mem_free(pTlStats);
17333 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017334 }
17335 else
17336 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017337 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017338 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017339
Jeff Johnson295189b2012-06-20 16:38:30 -070017340 if(pMac->roam.tlStatsReqInfo.periodicity)
17341 {
17342 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017343 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17344 pMac->roam.tlStatsReqInfo.periodicity);
17345 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017347 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017348 return eHAL_STATUS_FAILURE;
17349 }
17350 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17351 }
17352 }
17353 }
17354 pMac->roam.tlStatsReqInfo.numClient++;
17355 }
17356
17357 insertInClientList = TRUE;
17358 }
17359 //if one time report requested with non cached result from PE/TL
17360 else if(!cache && !periodicity)
17361 {
17362 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17363 {
17364 //send down a req
17365 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17366 if(!HAL_STATUS_SUCCESS(status))
17367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017368 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017369 }
17370 //so that when the stats rsp comes back from PE we respond to upper layer
17371 //right away
17372 staEntry.timerExpired = TRUE;
17373 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017374 }
17375 if(statsMask & (1 << eCsrGlobalClassDStats))
17376 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017377 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017378 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017379 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017380 //req TL for class D stats
17381 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017383 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017384 }
17385 else
17386 {
17387 //save in SME
17388 csrRoamSaveStatsFromTl(pMac, pTlStats);
17389 }
17390 vos_mem_free(pTlStats);
17391 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017392 }
17393 else
17394 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017395 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017397
17398 }
17399 //if looking for stats from TL only
17400 if(!insertInClientList)
17401 {
17402 //return the stats
17403 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017406 if(insertInClientList)
17407 {
17408 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17409 if(!pStaEntry)
17410 {
17411 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017412 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017413 return eHAL_STATUS_FAILURE;
17414 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017415 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017416 //Init & start timer if needed
17417 if(periodicity)
17418 {
17419 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17420 csrRoamStatsClientTimerHandler, pStaEntry );
17421 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017423 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017424 return eHAL_STATUS_FAILURE;
17425 }
17426 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17427 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017429 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017430 return eHAL_STATUS_FAILURE;
17431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 }
17435 return eHAL_STATUS_SUCCESS;
17436}
17437
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017438#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17439
17440static tSirRetStatus
17441csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17442 tANI_U8* pBD,
17443 tANI_U8 type,
17444 tANI_U8 subType,
17445 tSirMacAddr peerAddr,
17446 tSirMacAddr selfMacAddr)
17447{
17448 tSirRetStatus statusCode = eSIR_SUCCESS;
17449 tpSirMacMgmtHdr pMacHdr;
17450
17451 /* Prepare MAC management header */
17452 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17453
17454 /* Prepare FC */
17455 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17456 pMacHdr->fc.type = type;
17457 pMacHdr->fc.subType = subType;
17458
17459 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017460 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17461 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017462
17463 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17464
17465 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017466 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17467 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017468 return statusCode;
17469} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17470
17471static tSirRetStatus
17472csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17473 tANI_U8 nChannelNum,
17474 tANI_U32 dot11mode,
17475 tSirMacAddr selfMacAddr,
17476 tANI_U8 *pFrame,
17477 tANI_U16 *pusLen)
17478{
17479 tDot11fProbeRequest pr;
17480 tANI_U32 nStatus, nBytes, nPayload;
17481 tSirRetStatus nSirStatus;
17482 /*Bcast tx*/
17483 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17484 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17485
17486
Kiet Lam64c1b492013-07-12 13:56:44 +053017487 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017488
17489 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17490
17491 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17492 {
17493 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17494 }
17495
17496
17497 if (IS_DOT11_MODE_HT(dot11mode))
17498 {
17499 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17500 }
17501
17502
17503 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17504 if ( DOT11F_FAILED( nStatus ) )
17505 {
17506 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17507 "Failed to calculate the packed size f"
17508 "or a Probe Request (0x%08x).\n", nStatus );
17509
17510
17511 nPayload = sizeof( tDot11fProbeRequest );
17512 }
17513 else if ( DOT11F_WARNED( nStatus ) )
17514 {
17515 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17516 "There were warnings while calculating"
17517 "the packed size for a Probe Request ("
17518 "0x%08x).\n", nStatus );
17519 }
17520
17521 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17522
17523 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017524 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017525
17526
17527 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017528 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017529
17530 if ( eSIR_SUCCESS != nSirStatus )
17531 {
17532 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17533 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17534 nSirStatus );
17535 return nSirStatus;
17536 }
17537
17538
17539 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17540 sizeof( tSirMacMgmtHdr ),
17541 nPayload, &nPayload );
17542 if ( DOT11F_FAILED( nStatus ) )
17543 {
17544 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17545 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17546 return eSIR_FAILURE;
17547 }
17548 else if ( DOT11F_WARNED( nStatus ) )
17549 {
17550 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017551 "There were warnings while packing a Probe Request (0x%08x).\n",
17552 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017553 }
17554
17555 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17556 return eSIR_SUCCESS;
17557}
17558
Mukul Sharmad68cda62015-03-20 21:25:41 +053017559/*
17560 * Below Table describe whether RSO command can be send down to fimrware or not.
17561 * Host check it on the basis of previous RSO command sent down to firmware.
17562||===========================================================================||
17563|| New cmd | LAST SENT COMMAND ---> ||
17564||====|======================================================================||
17565|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17566|| --------------------------------------------------------------------------||
17567|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017568|| RSO_STOP | YES | NO | YES | YES ||
17569|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017570|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17571||===========================================================================||
17572*/
17573
17574#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17575#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17576#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17577#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17578
17579#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17580#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017581 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017582#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17583 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017584#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017585 RSO_START_BIT)
17586
17587tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17588{
17589 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17590 tANI_U8 desiredMask = 0;
17591 switch(command)
17592 {
17593 case ROAM_SCAN_OFFLOAD_START:
17594 desiredMask = RSO_START_ALLOW_MASK;
17595 break;
17596 case ROAM_SCAN_OFFLOAD_STOP:
17597 desiredMask = RSO_STOP_ALLOW_MASK;
17598 break;
17599 case ROAM_SCAN_OFFLOAD_RESTART:
17600 desiredMask = RSO_RESTART_ALLOW_MASK;
17601 break;
17602 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17603 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17604 break;
17605 default:
17606 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17607 FL("Wrong RSO command %d, not allowed"), command);
17608 return 0;/*Cmd Not allowed*/
17609 }
17610 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17611}
17612
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017613eCsrBand GetCurrentBand(tANI_U8 channel)
17614{
17615 tSirRFBand Rfband;
17616 eCsrBand band;
17617
17618 Rfband = GetRFBand(channel);
17619
17620 if (Rfband == SIR_BAND_5_GHZ)
17621 band = eCSR_BAND_5G;
17622 else if (Rfband == SIR_BAND_2_4_GHZ)
17623 band = eCSR_BAND_24;
17624 else if (Rfband == SIR_BAND_UNKNOWN)
17625 band = eCSR_BAND_MAX;
17626
17627 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17628 "channel %d Rfband %d band %d", channel, Rfband, band);
17629
17630 return band;
17631}
17632
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017633eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17634{
17635 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017636 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017637 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017638 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017639 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017640 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017641 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017642 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017643 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017644 eHalStatus status = eHAL_STATUS_SUCCESS;
17645 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017646 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017647 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017648 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017649 tSirBssDescription *pBssDesc = NULL;
17650 tDot11fBeaconIEs *pIes = NULL;
17651 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017652 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017653
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017654 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17655
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017656 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017657 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017658 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017659 return eHAL_STATUS_FAILURE;
17660 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017661
17662 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17663 {
17664 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17665 return eHAL_STATUS_FAILURE;
17666 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017667
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017668 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17669 * It is important to ensure that the command is passed down to the FW only
17670 * if the Infra Station is in a connected state.A connected station could also be
17671 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17672 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17673 * irrespective of whichever state we are in.*/
17674 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17675 (command != ROAM_SCAN_OFFLOAD_STOP))
17676 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017677 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17678 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17679 macTraceGetNeighbourRoamState(
17680 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017681 return eHAL_STATUS_FAILURE;
17682 }
17683
Mukul Sharmad68cda62015-03-20 21:25:41 +053017684 if (!CsrIsRSOCommandAllowed(pMac, command))
17685 {
17686 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17687 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17688 command, pNeighborRoamInfo->lastSentCmd);
17689 return eHAL_STATUS_FAILURE;
17690 }
17691
Abhishek Singh3e915632014-11-01 17:14:50 +053017692 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17693 * Also there are cases where pNeighborRoamInfo->currAPbssid
17694 * is set to 0 during disconnect and so we might return without stopping
17695 * the roam scan. So no need to find the session if command is
17696 * ROAM_SCAN_OFFLOAD_STOP.
17697 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017698 status = csrRoamGetSessionIdFromBSSID(pMac,
17699 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17700 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017701 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017702 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017703 if ( !HAL_STATUS_SUCCESS( status ) )
17704 {
17705 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17706 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17707 return eHAL_STATUS_FAILURE;
17708 }
17709 pSession = CSR_GET_SESSION( pMac, sessionId );
17710 if (NULL == pSession)
17711 {
17712 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080017713 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053017714 return eHAL_STATUS_FAILURE;
17715 }
17716 pBssDesc = pSession->pConnectBssDesc;
17717 if (pBssDesc == NULL)
17718 {
17719 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17720 "%s: pBssDesc not found for current session", __func__);
17721 return eHAL_STATUS_FAILURE;
17722 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017723
17724 operationChannel = pSession->connectedProfile.operationChannel;
17725 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17726 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017727 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017728 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17729 if (NULL == pRequestBuf)
17730 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017731 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17732 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17733 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017734 }
17735
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017736#ifdef FEATURE_WLAN_DIAG_SUPPORT
17737 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17738 eSIR_SUCCESS, eSIR_SUCCESS);
17739#endif
17740
Abhishek Singh3e915632014-11-01 17:14:50 +053017741 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17742 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17743 * host driver reloads, but Riva still up and running*/
17744 pRequestBuf->Command = command;
17745 if(command == ROAM_SCAN_OFFLOAD_STOP)
17746 {
17747 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017748 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017749 /*For a STOP Command, there is no need to
17750 * go through filling up all the below parameters
17751 * since they are not required for the STOP command*/
17752 goto send_roam_scan_offload_cmd;
17753 }
17754 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017755 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017756 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17757 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017758 sizeof(tCsrBssid));
17759 pRequestBuf->ConnectedNetwork.ssId.length =
17760 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17761 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17762 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17763 pRequestBuf->ConnectedNetwork.ssId.length);
17764 pRequestBuf->ConnectedNetwork.authentication =
17765 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17766 pRequestBuf->ConnectedNetwork.encryption =
17767 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17768 pRequestBuf->ConnectedNetwork.mcencryption =
17769 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017770 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17771 {
17772 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017773 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017774 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17775 }
17776 else
17777 {
17778 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017779
17780 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17781 {
17782 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17783 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17784 vos_mem_free(pRequestBuf);
17785 return eHAL_STATUS_FAILURE;
17786 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017787 if(NULL == pIes)
17788 {
17789 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17790 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017791 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017792 return eHAL_STATUS_FAILURE;
17793 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017794 if (pIes->SuppRates.present)
17795 {
17796 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17797 /*Check for both basic rates and extended rates.*/
17798 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17799 {
17800 /*Check if the Rate is Mandatory or Not*/
17801 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17802 && (pIes->SuppRates.rates[i] & 0x80))
17803 {
17804 /*Retrieve the actual data rate*/
17805 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17806 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17807 if (minRate == 0)
17808 minRate = dataRate;
17809 else
17810 minRate = (minRate < dataRate) ? minRate:dataRate;
17811 }
17812 }
17813
17814 if (pIes->ExtSuppRates.present)
17815 {
17816 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17817 {
17818 /*Check if the Rate is Mandatory or Not*/
17819 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17820 && (pIes->ExtSuppRates.rates[i] & 0x80))
17821 {
17822 /*Retrieve the actual data rate*/
17823 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17824 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17825 if (minRate == 0)
17826 minRate = dataRate;
17827 else
17828 minRate = (minRate < dataRate) ? minRate:dataRate;
17829 }
17830 }
17831 }
17832 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17833 }
17834 else
17835 {
17836 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17837 "%s: Supp Rates not present in pIes", __func__);
17838 vos_mem_free(pRequestBuf);
17839 return eHAL_STATUS_FAILURE;
17840 }
17841 if (NULL != pIes)
17842 {
17843 vos_mem_free(pIes);
17844 pIes = NULL;
17845 }
17846 switch (minRate)
17847 {
17848 case 1:
17849 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
17850 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
17851 break;
17852 case 2:
17853 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
17854 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
17855 break;
17856 case 5:
17857 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
17858 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
17859 break;
17860 case 6:
17861 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17862 {
17863 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
17864 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
17865 }
17866 else
17867 {
17868 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
17869 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
17870 }
17871 break;
17872 case 11:
17873 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
17874 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
17875 break;
17876 case 12:
17877 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17878 {
17879 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
17880 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
17881 }
17882 else
17883 {
17884 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
17885 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
17886 }
17887 break;
17888 case 24:
17889 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17890 {
17891 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
17892 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
17893 }
17894 else
17895 {
17896 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
17897 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
17898 }
17899 break;
17900 default:
17901 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
17902 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17903 break;
17904 }
17905 }
17906 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17907 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
17908 operationChannel, minRate,
17909 pRequestBuf->RxSensitivityThreshold,
17910 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017911 pRequestBuf->RoamRssiDiff =
17912 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017913 pRequestBuf->StartScanReason = reason;
17914 pRequestBuf->NeighborScanTimerPeriod =
17915 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
17916 pRequestBuf->NeighborRoamScanRefreshPeriod =
17917 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
17918 pRequestBuf->NeighborScanChannelMinTime =
17919 pNeighborRoamInfo->cfgParams.minChannelScanTime;
17920 pRequestBuf->NeighborScanChannelMaxTime =
17921 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
17922 pRequestBuf->EmptyRefreshScanPeriod =
17923 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080017924 /* MAWC feature */
17925 pRequestBuf->MAWCEnabled =
17926 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017927
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017928#ifdef FEATURE_WLAN_ESE
17929 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017930#endif
17931 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017932#ifdef FEATURE_WLAN_ESE
17933 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017934 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17935 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017936 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17937#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017938 currChannelListInfo->numOfChannels == 0)
17939 {
17940
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017941 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
17942 * Give Preference to INI Channels.*/
17943 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
17944 {
17945 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
17946 /*The INI channels need to be filtered with respect to the current
17947 * band that is supported.*/
17948 eBand = pMac->roam.configParam.bandCapability;
17949 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017950 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017951 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17952 "Invalid band, No operation carried out (Band %d)", eBand);
17953 vos_mem_free(pRequestBuf);
17954 return eHAL_STATUS_FAILURE;
17955 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017956
17957 if (pMac->roam.configParam.nRoamIntraBand)
17958 {
17959 eBand = GetCurrentBand(operationChannel);
17960 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17961 "Current Band %d", eBand);
17962 }
17963
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017964 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
17965 {
17966 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17967 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
17968 (eCSR_BAND_ALL == eBand))
17969 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017970 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
17971 ((pMac->roam.configParam.allowDFSChannelRoam) ||
17972 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
17973 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017974 {
17975 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
17976 }
17977 }
17978 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017979 }
17980 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17981 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017982 }
17983 else
17984 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017985 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017986
17987 if (pMac->roam.configParam.nRoamIntraBand)
17988 {
17989 Rfband = GetCurrentBand(operationChannel);
17990 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17991 "Current Band %d", Rfband);
17992 }
17993
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017994 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
17995 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017996 if(((eCSR_BAND_24 == Rfband) &&
17997 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17998 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
17999 || (eCSR_BAND_ALL == Rfband))
18000 {
18001 /* Allow DFS channels only if the DFS channel roam flag is
18002 * enabled
18003 */
18004 if(*ChannelList && ((pMac->roam.configParam.
18005 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
18006 && (num_channels < SIR_ROAM_MAX_CHANNELS))
18007 {
18008 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
18009 = *ChannelList;
18010 }
18011 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018012 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018013 }
18014 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18015 /* If the profile changes as to what it was earlier, inform the FW through
18016 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
18017 * for the earlier profile and try to learn them afresh.*/
18018 if (reason == REASON_FLUSH_CHANNEL_LIST)
18019 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18020 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018021 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18022 (pMac->roam.configParam.nRoamIntraBand))
18023 pRequestBuf->ChannelCacheType =
18024 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018025 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018026 pRequestBuf->ChannelCacheType =
18027 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018028 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018029 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018030 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018031#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018032 else
18033 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018034 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018035 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018036 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018037 if (currChannelListInfo->numOfChannels != 0)
18038 {
18039 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018040
18041 if (pMac->roam.configParam.nRoamIntraBand)
18042 {
18043 Rfband = GetCurrentBand(operationChannel);
18044 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18045 "Current Band %d", Rfband);
18046 }
18047
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018048 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018049 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018050 if(((eCSR_BAND_24 == Rfband) &&
18051 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18052 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18053 || (eCSR_BAND_ALL == Rfband))
18054 {
18055 if(*ChannelList && ((pMac->roam.configParam.
18056 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18057 {
18058 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018059 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018060 }
18061 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018062 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018063 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018064 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018065 if (pMac->roam.configParam.nRoamIntraBand)
18066 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18067 else
18068 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018069 }
18070 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018071#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018072 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18073 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018074 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018075 if (j < sizeof(ChannelCacheStr))
18076 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018077 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18078 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018079 }
18080 else
18081 {
18082 break;
18083 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018084 }
18085 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18086 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18087 pRequestBuf->ChannelCacheType,
18088 pRequestBuf->ConnectedNetwork.ChannelCount,
18089 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018090 num_channels = 0;
18091 ChannelList = NULL;
18092
18093 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018094 host_channels = sizeof(pMac->roam.validChannelList);
18095 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018096 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018097 ChannelList = pMac->roam.validChannelList;
18098 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018099 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018100 else
18101 {
18102 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18103 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018104 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018105 return eHAL_STATUS_FAILURE;
18106 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018107
18108 if (pMac->roam.configParam.nRoamIntraBand)
18109 {
18110 Rfband = GetCurrentBand(operationChannel);
18111 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18112 Rfband);
18113 }
18114
Srinivas Girigowda56076852013-08-20 14:00:50 -070018115 for(i=0; i<pMac->roam.numValidChannels; i++)
18116 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018117 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18118 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18119 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018120 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018121 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18122 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18123 {
18124 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18125 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018126 }
18127 ChannelList++;
18128 }
18129 pRequestBuf->ValidChannelCount = num_channels;
18130
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018131 pRequestBuf->MDID.mdiePresent =
18132 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18133 pRequestBuf->MDID.mobilityDomain =
18134 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018135 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18136
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018137 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018138 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18139 * where RFS is the RF Switching time. It is twice RFS to consider the
18140 * time to go off channel and return to the home channel. */
18141 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18142 {
18143 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18144 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18145 " Hence enforcing home away time to disable (0)",
18146 __func__, pRequestBuf->HomeAwayTime,
18147 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18148 pRequestBuf->HomeAwayTime = 0;
18149 }
18150 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018151
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018152 pRequestBuf->WeakZoneRssiThresholdForRoam =
18153 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018154 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18155 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18156 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18157 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18158 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18159
18160 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18161 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018162send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018163 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018164 msg.reserved = 0;
18165 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018166 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18167 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018168 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18169 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018170 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18171 vos_mem_free(pRequestBuf);
18172 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018173 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018174 else
18175 {
18176 if (ROAM_SCAN_OFFLOAD_START == command)
18177 bRoamScanOffloadStarted = VOS_TRUE;
18178 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18179 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018180
18181 /*update the last sent cmd*/
18182 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018183 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018184
18185 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 +053018186
18187 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018188 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18189 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018190 {
18191
18192 /* PER ROAM SCAN */
18193 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18194 if (!PERRoamReqBuf)
18195 {
18196 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18197 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18198 return eHAL_STATUS_FAILURE;
18199 }
18200 /* PER Roam Config */
18201 PERRoamReqBuf->rateUpThreshold =
18202 pMac->roam.configParam.rateUpThreshold;
18203 PERRoamReqBuf->rateDownThreshold =
18204 pMac->roam.configParam.rateDownThreshold;
18205 PERRoamReqBuf->waitPeriodForNextPERScan =
18206 pMac->roam.configParam.waitPeriodForNextPERScan;
18207 PERRoamReqBuf->PERtimerThreshold =
18208 pMac->roam.configParam.PERtimerThreshold;
18209 PERRoamReqBuf->isPERRoamCCAEnabled =
18210 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018211 PERRoamReqBuf->PERRoamFullScanThreshold =
18212 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018213 PERRoamReqBuf->PERroamTriggerPercent =
18214 pMac->roam.configParam.PERroamTriggerPercent;
18215 PERRoamReqBuf->sessionId = sessionId;
18216
18217 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18218 PERroamScanConfigMsg.reserved = 0;
18219 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18220 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18221 &PERroamScanConfigMsg))) {
18222 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18223 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18224 vos_mem_free(PERRoamReqBuf);
18225 return eHAL_STATUS_FAILURE;
18226 }
18227 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18228 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18229 PERRoamReqBuf->rateUpThreshold,
18230 PERRoamReqBuf->rateDownThreshold,
18231 PERRoamReqBuf->waitPeriodForNextPERScan,
18232 PERRoamReqBuf->PERtimerThreshold);
18233 }
18234
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018235 return status;
18236}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018237
18238eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18239{
18240 switch(reason)
18241 {
18242 case 0:
18243 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18244 break;
18245 case REASON_OS_REQUESTED_ROAMING_NOW:
18246 csrNeighborRoamProceedWithHandoffReq(pMac);
18247 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018248 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18249 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18250 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018251 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018252 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 -070018253 }
18254 return eHAL_STATUS_SUCCESS;
18255}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018256#endif
18257
Jeff Johnson295189b2012-06-20 16:38:30 -070018258tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18259 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18260{
18261 tANI_BOOLEAN found = FALSE;
18262 eHalStatus status = eHAL_STATUS_SUCCESS;
18263 tCsrPeStatsReqInfo staEntry;
18264 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18265 tListElem *pStaEntry = NULL;
18266 VOS_STATUS vosStatus;
18267 tPmcPowerState powerState;
18268 *pFound = FALSE;
18269
18270 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18271 if(pStaEntry)
18272 {
18273 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18274 if(pTempStaEntry->periodicity)
18275 {
18276 pTempStaEntry->periodicity =
18277 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18278 }
18279 else
18280 {
18281 pTempStaEntry->periodicity = periodicity;
18282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018283 pTempStaEntry->numClient++;
18284 found = TRUE;
18285 }
18286 else
18287 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018288 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018289 staEntry.numClient = 1;
18290 staEntry.periodicity = periodicity;
18291 staEntry.pMac = pMac;
18292 staEntry.rspPending = FALSE;
18293 staEntry.staId = staId;
18294 staEntry.statsMask = statsMask;
18295 staEntry.timerRunning = FALSE;
18296 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18297 if(!pTempStaEntry)
18298 {
18299 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018300 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018301 return NULL;
18302 }
18303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018304 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18305 if(ePMC_FULL_POWER == powerState)
18306 {
18307 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18308 {
18309 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18310 }
18311 }
18312 else
18313 {
18314 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18315 {
18316 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18317 }
18318 }
18319 if(!pTempStaEntry->timerRunning)
18320 {
18321 //send down a req in case of one time req, for periodic ones wait for timer to expire
18322 if(!pTempStaEntry->rspPending &&
18323 !pTempStaEntry->periodicity)
18324 {
18325 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18326 if(!HAL_STATUS_SUCCESS(status))
18327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018328 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018329 }
18330 else
18331 {
18332 pTempStaEntry->rspPending = TRUE;
18333 }
18334 }
18335 if(pTempStaEntry->periodicity)
18336 {
18337 if(!found)
18338 {
18339
18340 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18341 csrRoamPeStatsTimerHandler, pTempStaEntry );
18342 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18343 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018344 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018345 return NULL;
18346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018347 }
18348 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018349 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018350 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18351 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018353 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018354 return NULL;
18355 }
18356 pTempStaEntry->timerRunning = TRUE;
18357 }
18358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018359 *pFound = found;
18360 return pTempStaEntry;
18361}
18362
Jeff Johnson295189b2012-06-20 16:38:30 -070018363/*
18364 pStaEntry is no longer invalid upon the return of this function.
18365*/
18366static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18367{
18368 if(pEntry)
18369 {
18370 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18371 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018372 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018374 }
18375 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018376
18377void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18378{
18379 tListElem *pEntry;
18380 tCsrPeStatsReqInfo *pTempStaEntry;
18381 VOS_STATUS vosStatus;
18382 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018383 if(!pEntry)
18384 {
18385 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018386 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018387 return;
18388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018389 while( pEntry )
18390 {
18391 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018392 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18393 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018394 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018395 if(pTempStaEntry->timerRunning)
18396 {
18397 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18398 /* If we are not able to stop the timer here, just remove
18399 * the entry from the linked list. Destroy the timer object
18400 * and free the memory in the timer CB
18401 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018402 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018403 {
18404 /* the timer is successfully stopped */
18405 pTempStaEntry->timerRunning = FALSE;
18406
18407 /* Destroy the timer */
18408 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18409 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018411 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018412 }
18413 }
18414 else
18415 {
18416 // the timer could not be stopped. Hence destroy and free the
18417 // memory for the PE stat entry in the timer CB.
18418 pTempStaEntry->timerStopFailed = TRUE;
18419 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018421
18422 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18423 {
18424 // Only free the memory if we could stop the timer successfully
18425 if(!pTempStaEntry->timerStopFailed)
18426 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018427 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018428 pTempStaEntry = NULL;
18429 }
18430 break;
18431 }
18432
18433 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18434 }
18435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018436 return;
18437}
18438
18439
Jeff Johnsone7245742012-09-05 17:12:55 -070018440void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018441{
18442
Jeff Johnsone7245742012-09-05 17:12:55 -070018443 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18444 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18445 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18446 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18447 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18448 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18449 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018450 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018451 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18452 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18453 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18454 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18455 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18456 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018457 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018458 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18459 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018460
18461}
18462
Jeff Johnson295189b2012-06-20 16:38:30 -070018463void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18464 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18465{
18466 tANI_U8 stats[500];
18467 tANI_U8 *pStats = NULL;
18468 tANI_U32 tempMask = 0;
18469 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018470 if(!callback)
18471 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018472 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018473 return;
18474 }
18475 if(!statsMask)
18476 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018477 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018478 return;
18479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018480 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018481 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018482 while(tempMask)
18483 {
18484 if(tempMask & 1)
18485 {
18486 //new stats info from PE, fill up the stats strucutres in PMAC
18487 switch(counter)
18488 {
18489 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018490 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018491 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18492 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018493 pStats += sizeof(tCsrSummaryStatsInfo);
18494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018495 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018496 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018497 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18498 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018499 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018501 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018502 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018503 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18504 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018505 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018506 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018507 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018508 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018509 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18510 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018511 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018513 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018514 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018515 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18516 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018517 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018518 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018519 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018520 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018521 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18522 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018523 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018524 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018525 case eCsrPerPktStats:
18526 smsLog( pMac, LOG2, FL("PerPkt stats"));
18527 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18528 sizeof(tPerTxPacketFrmFw));
18529 pStats += sizeof(tPerTxPacketFrmFw);
18530 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018531 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018532 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018533 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018534 }
18535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018536 tempMask >>=1;
18537 counter++;
18538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018539 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018540}
18541
Jeff Johnson295189b2012-06-20 16:38:30 -070018542eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18543{
18544 tListElem *pEntry = NULL;
18545 tListElem *pPrevEntry = NULL;
18546 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18547 eHalStatus status = eHAL_STATUS_SUCCESS;
18548 VOS_STATUS vosStatus;
18549 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018550 if(!pEntry)
18551 {
18552 //list empty
18553 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018554 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018555 return status;
18556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018557 while( pEntry )
18558 {
18559 if(pPrevEntry)
18560 {
18561 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18562 //send up the stats report
18563 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18564 pTempStaEntry->staId, pTempStaEntry->pContext);
18565 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018567 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018568 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18569 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018570 pTempStaEntry->pPeStaEntry->numClient--;
18571 //check if we need to delete the entry from peStatsReqList too
18572 if(!pTempStaEntry->pPeStaEntry->numClient)
18573 {
18574 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018577 //check if we need to stop the tl stats timer too
18578 pMac->roam.tlStatsReqInfo.numClient--;
18579 if(!pMac->roam.tlStatsReqInfo.numClient)
18580 {
18581 if(pMac->roam.tlStatsReqInfo.timerRunning)
18582 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018583 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18584 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018586 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018587 //we will continue
18588 }
18589 }
18590 pMac->roam.tlStatsReqInfo.periodicity = 0;
18591 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018593 if (pTempStaEntry->periodicity)
18594 {
18595 //While creating StaEntry in csrGetStatistics,
18596 //Initializing and starting timer only when periodicity is set.
18597 //So Stop and Destroy timer only when periodicity is set.
18598
Jeff Johnsone7245742012-09-05 17:12:55 -070018599 vos_timer_stop( &pTempStaEntry->timer );
18600 // Destroy the vos timer...
18601 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18602 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018604 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018606 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018607
Jeff Johnson295189b2012-06-20 16:38:30 -070018608
18609 pPrevEntry = pEntry;
18610 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18611 }
18612 //the last one
18613 if(pPrevEntry)
18614 {
18615 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18616 //send up the stats report
18617 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18618 pTempStaEntry->staId, pTempStaEntry->pContext);
18619 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018621 return status;
18622
18623}
18624
Jeff Johnson295189b2012-06-20 16:38:30 -070018625eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18626 tRequestFullPowerReason *pReason,
18627 tANI_BOOLEAN *pfNeedPower )
18628{
18629 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18630 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18631 tPmcState pmcState;
18632 eHalStatus status = eHAL_STATUS_SUCCESS;
18633 // TODO : Session info unavailable
18634 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018635 if( pfNeedPower )
18636 {
18637 *pfNeedPower = eANI_BOOLEAN_FALSE;
18638 }
18639 //We only handle CSR commands
18640 if( !(eSmeCsrCommandMask & pCommand->command) )
18641 {
18642 return eHAL_STATUS_SUCCESS;
18643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018644 //Check PMC state first
18645 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018646 switch( pmcState )
18647 {
18648 case REQUEST_IMPS:
18649 case IMPS:
18650 if( eSmeCommandScan == pCommand->command )
18651 {
18652 switch( pCommand->u.scanCmd.reason )
18653 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018654#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18655 case eCsrScanGetLfrResult:
18656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018657 case eCsrScanGetResult:
18658 case eCsrScanBGScanAbort:
18659 case eCsrScanBGScanEnable:
18660 case eCsrScanGetScanChnInfo:
18661 //Internal process, no need for full power
18662 fNeedFullPower = eANI_BOOLEAN_FALSE;
18663 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018664 default:
18665 //Other scans are real scan, ask for power
18666 fNeedFullPower = eANI_BOOLEAN_TRUE;
18667 break;
18668 } //switch
18669 }
18670 else
18671 {
18672 //ask for power for roam and status change
18673 fNeedFullPower = eANI_BOOLEAN_TRUE;
18674 }
18675 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018676 case REQUEST_BMPS:
18677 case BMPS:
18678 case REQUEST_START_UAPSD:
18679 case UAPSD:
18680 //We treat WOWL same as BMPS
18681 case REQUEST_ENTER_WOWL:
18682 case WOWL:
18683 if( eSmeCommandRoam == pCommand->command )
18684 {
18685 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18686 tCsrScanResult *pScanResult;
18687 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018688 switch ( pCommand->u.roamCmd.roamReason )
18689 {
18690 case eCsrForcedDisassoc:
18691 case eCsrForcedDisassocMICFailure:
18692 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18693 fNeedFullPower = eANI_BOOLEAN_TRUE;
18694 break;
18695 case eCsrSmeIssuedDisassocForHandoff:
18696 case eCsrForcedDeauth:
18697 case eCsrHddIssuedReassocToSameAP:
18698 case eCsrSmeIssuedReassocToSameAP:
18699 fNeedFullPower = eANI_BOOLEAN_TRUE;
18700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018701 case eCsrCapsChange:
18702 fNeedFullPower = eANI_BOOLEAN_TRUE;
18703 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018704 case eCsrForcedDisassocSta:
18705 case eCsrForcedDeauthSta:
18706 fNeedFullPower = eANI_BOOLEAN_FALSE;
18707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018708 default:
18709 //Check whether the profile is already connected. If so, no need for full power
18710 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18711 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18712 {
18713 //Only need to check the first one
18714 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18715 if( pEntry )
18716 {
18717 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18718#if 0
18719 // TODO : Session Specific info pConnectBssDesc
18720 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18721 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18722 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18723 {
18724 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18725 // with Authenticating first. To force this, stop the current association (Disassociate) and
18726 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18727 // a new Association.
18728 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18729 {
18730 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18731 {
18732 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18733 //No need for full power
18734 //Set the flag so the code later can avoid to do the above
18735 //check again.
18736 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18737 break;
18738 }
18739 }
18740 }
18741#endif
18742 }
18743 }
18744 //If we are here, full power is needed
18745 fNeedFullPower = eANI_BOOLEAN_TRUE;
18746 break;
18747 }
18748 }
18749 else if( eSmeCommandWmStatusChange == pCommand->command )
18750 {
18751 //need full power for all
18752 fNeedFullPower = eANI_BOOLEAN_TRUE;
18753 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18754 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018755#ifdef FEATURE_WLAN_TDLS
18756 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18757 {
18758 //TDLS link is getting established. need full power
18759 fNeedFullPower = eANI_BOOLEAN_TRUE;
18760 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18761 }
18762#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018763 else if (eSmeCommandDelStaSession == pCommand->command)
18764 {
18765 //need full power for all
18766 fNeedFullPower = eANI_BOOLEAN_TRUE;
18767 }
18768
Jeff Johnson295189b2012-06-20 16:38:30 -070018769 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018770 case REQUEST_STOP_UAPSD:
18771 case REQUEST_EXIT_WOWL:
18772 if( eSmeCommandRoam == pCommand->command )
18773 {
18774 fNeedFullPower = eANI_BOOLEAN_TRUE;
18775 switch ( pCommand->u.roamCmd.roamReason )
18776 {
18777 case eCsrForcedDisassoc:
18778 case eCsrForcedDisassocMICFailure:
18779 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18780 break;
18781 default:
18782 break;
18783 }
18784 }
18785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018786 case STOPPED:
18787 case REQUEST_STANDBY:
18788 case STANDBY:
18789 case LOW_POWER:
18790 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018791 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18792 " stopped/standby state %s (%d)" ),
18793 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018794 status = eHAL_STATUS_FAILURE;
18795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018796 case FULL_POWER:
18797 case REQUEST_FULL_POWER:
18798 default:
18799 //No need to ask for full power. This has to be FULL_POWER state
18800 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018801 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018802 if( pReason )
18803 {
18804 *pReason = reason;
18805 }
18806 if( pfNeedPower )
18807 {
18808 *pfNeedPower = fNeedFullPower;
18809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018810 return ( status );
18811}
18812
Jeff Johnson295189b2012-06-20 16:38:30 -070018813static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18814{
18815 eHalStatus status = eHAL_STATUS_SUCCESS;
18816 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18817 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018818 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018819 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18820 {
18821 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18822 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018823 return ( status );
18824}
18825
Jeff Johnson295189b2012-06-20 16:38:30 -070018826tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18827{
18828 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018829 if( pCmd )
18830 {
18831 pMac->roam.sPendingCommands++;
18832 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018833 return ( pCmd );
18834}
18835
Jeff Johnson295189b2012-06-20 16:38:30 -070018836void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18837{
18838 if (pMac->roam.sPendingCommands > 0)
18839 {
18840 //All command allocated through csrGetCommandBuffer need to
18841 //decrement the pending count when releasing.
18842 pMac->roam.sPendingCommands--;
18843 smeReleaseCommand( pMac, pCommand );
18844 }
18845 else
18846 {
18847 smsLog(pMac, LOGE, FL( "no pending commands"));
18848 VOS_ASSERT(0);
18849 }
18850}
18851
Jeff Johnson295189b2012-06-20 16:38:30 -070018852//Return SUCCESS is the command is queued, failed
18853eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
18854{
18855 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053018856
18857 if (!SME_IS_START(pMac))
18858 {
18859 smsLog( pMac, LOGE, FL("Sme in stop state"));
18860 return eHAL_STATUS_FAILURE;
18861 }
18862
Jeff Johnson295189b2012-06-20 16:38:30 -070018863 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
18864 {
18865 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
18866 pCommand->u.scanCmd.reason);
18867 return eHAL_STATUS_CSR_WRONG_STATE;
18868 }
18869
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018870 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
18871 {
18872 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
18873 &pCommand->Link, LL_ACCESS_LOCK);
18874 // process the command queue...
18875 smeProcessPendingQueue(pMac);
18876 status = eHAL_STATUS_SUCCESS;
18877 goto end;
18878 }
18879
Jeff Johnson295189b2012-06-20 16:38:30 -070018880 //We can call request full power first before putting the command into pending Q
18881 //because we are holding SME lock at this point.
18882 status = csrRequestFullPower( pMac, pCommand );
18883 if( HAL_STATUS_SUCCESS( status ) )
18884 {
18885 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070018886 //make sure roamCmdPendingList is not empty first
18887 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
18888 if( fNoCmdPending )
18889 {
18890 smePushCommand( pMac, pCommand, fHighPriority );
18891 }
18892 else
18893 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018894 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070018895 //no list lock is needed since SME lock is held
18896 if( !fHighPriority )
18897 {
18898 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18899 }
18900 else {
18901 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18902 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018904 }
18905 else if( eHAL_STATUS_PMC_PENDING == status )
18906 {
18907 //no list lock is needed since SME lock is held
18908 if( !fHighPriority )
18909 {
18910 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18911 }
18912 else {
18913 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18914 }
18915 //Let caller know the command is queue
18916 status = eHAL_STATUS_SUCCESS;
18917 }
18918 else
18919 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018920 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070018921 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018922 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070018923 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018924end:
Jeff Johnson295189b2012-06-20 16:38:30 -070018925 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070018926}
Jeff Johnson295189b2012-06-20 16:38:30 -070018927eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
18928{
18929 eHalStatus status = eHAL_STATUS_SUCCESS;
18930 tSirUpdateAPWPSIEsReq *pMsg;
18931 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
18932
18933 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18934 if (NULL == pSession)
18935 {
18936 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18937 return eHAL_STATUS_FAILURE;
18938 }
18939
Jeff Johnson295189b2012-06-20 16:38:30 -070018940 do
18941 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018942 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
18943 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18944 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018945 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
18946
18947 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070018948 VOS_ASSERT(pBuf);
18949
Jeff Johnson295189b2012-06-20 16:38:30 -070018950 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018951 // transactionId
18952 *pBuf = 0;
18953 *( pBuf + 1 ) = 0;
18954 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070018955 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018956 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18957 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070018958 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018959 //sessionId
18960 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018961 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018962 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070018963 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070018964 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018965 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018966 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018967 return ( status );
18968}
Jeff Johnson295189b2012-06-20 16:38:30 -070018969eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
18970{
18971 eHalStatus status = eHAL_STATUS_SUCCESS;
18972 tSirUpdateAPWPARSNIEsReq *pMsg;
18973 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018974 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18975 if (NULL == pSession)
18976 {
18977 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18978 return eHAL_STATUS_FAILURE;
18979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018980 do
18981 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018982 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
18983 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18984 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018985 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070018986 pBuf = (tANI_U8 *)&pMsg->transactionId;
18987 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018988 // transactionId
18989 *pBuf = 0;
18990 *( pBuf + 1 ) = 0;
18991 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070018992 VOS_ASSERT(pBuf);
18993
Jeff Johnson295189b2012-06-20 16:38:30 -070018994 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018995 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18996 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070018997 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018998 // sessionId
18999 *pBuf++ = (tANI_U8)sessionId;
19000
19001 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019002 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070019003 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070019004 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019005 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019006 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019007 return ( status );
19008}
Jeff Johnson295189b2012-06-20 16:38:30 -070019009
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019010tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
19011 tpSirBssDescription pBssDescription)
19012{
19013 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19014 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19015 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
19016 eHalStatus status;
19017 tDot11fBeaconIEs *ies_local = NULL;
19018 tANI_U32 dot11mode = 0;
19019
19020 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19021
19022 /* Get IE's */
19023 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19024 if (!HAL_STATUS_SUCCESS(status)) {
19025 smsLog(pMac, LOGE,
19026 FL("csrGetParsedBssDescriptionIEs failed"));
19027 return 0;
19028 }
19029 if(ies_local == NULL) {
19030 smsLog(pMac, LOGE,
19031 FL("ies_local is NULL"));
19032 return 0;
19033 }
19034
19035 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19036 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19037 uCfgDot11Mode = cfgDot11Mode;
19038 else
19039 {
19040 smsLog(pMac, LOGE, "Can not find match phy mode");
19041 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19042 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19043 else
19044 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19045 }
19046
19047 /* dot11mode */
19048 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19049 smsLog(pMac, LOG1,
19050 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19051
19052 if (pBssDescription->channelId <= 14 &&
19053 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19054 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19055 {
19056 /* Need to disable VHT operation in 2.4 GHz band */
19057 dot11mode = WNI_CFG_DOT11_MODE_11N;
19058 }
19059 vos_mem_free(ies_local);
19060 return dot11mode;
19061}
19062
Jeff Johnson295189b2012-06-20 16:38:30 -070019063#ifdef WLAN_FEATURE_VOWIFI_11R
19064//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19065eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19066{
19067 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19068 tpSirFTPreAuthReq pftPreAuthReq;
19069 tANI_U16 auth_req_len = 0;
19070 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019071 auth_req_len = sizeof(tSirFTPreAuthReq);
19072 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019073 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019074 {
19075 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19076 return eHAL_STATUS_RESOURCES;
19077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019078 // Save the SME Session ID here. We need it while processing the preauth response
19079 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019080 vos_mem_zero(pftPreAuthReq, auth_req_len);
19081
19082 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19083 sizeof(pBssDescription->length) + pBssDescription->length);
19084
19085 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19086
19087 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019088 pftPreAuthReq->dot11mode =
19089 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19090 if (!pftPreAuthReq->dot11mode)
19091 {
19092 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19093 vos_mem_free(pftPreAuthReq);
19094 return eHAL_STATUS_FAILURE;
19095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019096
Kiet Lam64c1b492013-07-12 13:56:44 +053019097 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19098 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19099 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19100 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019101
Jeff Johnson295189b2012-06-20 16:38:30 -070019102#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019103 if (csrRoamIs11rAssoc(pMac) &&
19104 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019105 {
19106 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019107 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19108 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019109 }
19110 else
19111#endif
19112 {
19113 pftPreAuthReq->ft_ies_length = 0;
19114 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019115 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19116 sizeof(pBssDescription->length) + pBssDescription->length);
19117 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019118 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19119}
Jeff Johnson295189b2012-06-20 16:38:30 -070019120/*--------------------------------------------------------------------------
19121 * This will receive and process the FT Pre Auth Rsp from the current
19122 * associated ap.
19123 *
19124 * This will invoke the hdd call back. This is so that hdd can now
19125 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19126 ------------------------------------------------------------------------*/
19127void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19128{
19129 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19130 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019131#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019132 tCsrRoamInfo roamInfo;
19133#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019134 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019135
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019136#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019137 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019138 if (status != eHAL_STATUS_SUCCESS) {
19139 /*
19140 * Bail out if pre-auth was not even processed.
19141 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019142 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19143 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019144 return;
19145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019147 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19148 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19149 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019150 // Implies a success
19151 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019152 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19153 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019154 /* No need to notify qos module if this is a non 11r & ESE roam*/
19155 if (csrRoamIs11rAssoc(pMac)
19156#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19157 || csrRoamIsESEAssoc(pMac)
19158#endif
19159 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019160 {
19161 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19162 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019163 if (pMac->roam.configParam.roamDelayStatsEnabled)
19164 {
19165 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019167 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19168 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019169 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19170 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019171 if (pMac->roam.configParam.roamDelayStatsEnabled)
19172 {
19173 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019175 if (eHAL_STATUS_SUCCESS != status)
19176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019177 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019178 return;
19179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019180 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019181 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19182 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019183 if (csrRoamIs11rAssoc(pMac))
19184 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19185 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19186
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019187#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19188 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019189 {
19190 /* read TSF */
19191 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19192
19193 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019194 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019195 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19196 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019197#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019198#ifdef FEATURE_WLAN_LFR
19199 // If Legacy Fast Roaming is enabled, signal the supplicant
19200 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019201 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019202 {
19203 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019204 vos_mem_copy((void *)&roamInfo.bssid,
19205 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019206 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19207 }
19208
19209#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019210
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019211 // If its an Open Auth, FT IEs are not provided by supplicant
19212 // Hence populate them here
19213 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19214 pMac->ft.ftSmeContext.addMDIE = FALSE;
19215 if( csrRoamIs11rAssoc(pMac) &&
19216 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19217 {
19218 tANI_U16 ft_ies_length;
19219 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19220
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019221 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19222 connectedProfile.MDID.mdiePresent)
19223 pMac->ft.ftSmeContext.addMDIE = TRUE;
19224
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019225 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19226 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19227 {
19228 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19229 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19230 }
19231
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019232 if (!ft_ies_length)
19233 {
19234 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19235 return;
19236 }
19237
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019238 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19239 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19240 {
19241 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19242 }
19243 else
19244 {
19245 // Copy the RIC IEs to reassoc IEs
19246 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19247 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19248 pFTPreAuthRsp->ric_ies_length);
19249 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19250 pMac->ft.ftSmeContext.addMDIE = TRUE;
19251 }
19252 }
19253
Jeff Johnson295189b2012-06-20 16:38:30 -070019254 // Done with it, init it.
19255 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19256}
19257#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019258
Jeff Johnson295189b2012-06-20 16:38:30 -070019259#ifdef FEATURE_WLAN_BTAMP_UT_RF
19260void csrRoamJoinRetryTimerHandler(void *pv)
19261{
19262 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19263 tpAniSirGlobal pMac = pInfo->pMac;
19264 tANI_U32 sessionId = pInfo->sessionId;
19265 tCsrRoamSession *pSession;
19266
19267 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019269 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019270 pSession = CSR_GET_SESSION( pMac, sessionId );
19271 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19272 {
19273 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019275 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019276 }
19277 }
19278 }
19279}
Jeff Johnson295189b2012-06-20 16:38:30 -070019280eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19281{
19282 eHalStatus status = eHAL_STATUS_FAILURE;
19283 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19284
19285 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019287 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019288 pSession->maxRetryCount--;
19289 pSession->joinRetryTimerInfo.pMac = pMac;
19290 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019291 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19292 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019294 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019295 }
19296 }
19297 else
19298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019299 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019300 pSession->maxRetryCount);
19301 }
19302
19303 return (status);
19304}
Jeff Johnson295189b2012-06-20 16:38:30 -070019305eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19306{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019307 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019308 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19309 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019310 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019311 }
19312
19313 return eHAL_STATUS_SUCCESS;
19314}
19315#endif
19316
19317
19318/*
19319 pBuf points to the beginning of the message
19320 LIM packs disassoc rsp as below,
19321 messageType - 2 bytes
19322 messageLength - 2 bytes
19323 sessionId - 1 byte
19324 transactionId - 2 bytes (tANI_U16)
19325 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19326 peerMacAddr - 6 bytes
19327 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19328*/
19329static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19330{
19331 if(pBuf && pRsp)
19332 {
19333 pBuf += 4; //skip type and length
19334 pRsp->sessionId = *pBuf++;
19335 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19336 pBuf += 2;
19337 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19338 pBuf += 4;
19339 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19340 }
19341}
19342
Jeff Johnsond13512a2012-07-17 11:42:19 -070019343eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19344{
19345 static uNvTables nvTables;
19346 eHalStatus status = eHAL_STATUS_SUCCESS;
19347 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19348
19349 /* read the country code from NV and use it */
19350 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19351 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019352 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19353 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019354 return status;
19355 }
19356 else
19357 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019358 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019359 status = eHAL_STATUS_FAILURE;
19360 return status;
19361 }
19362}
19363
19364eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19365{
Kiet Lam64c1b492013-07-12 13:56:44 +053019366 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019367 return eHAL_STATUS_SUCCESS;
19368}
schang86c22c42013-03-13 18:41:24 -070019369
19370eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19371{
19372 tSirSetTxPowerReq *pMsg = NULL;
19373 eHalStatus status = eHAL_STATUS_SUCCESS;
19374 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19375
19376 if (!pSession)
19377 {
19378 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19379 return eHAL_STATUS_FAILURE;
19380 }
19381
Kiet Lam64c1b492013-07-12 13:56:44 +053019382 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19383 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19384 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19385 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19386 pMsg->length = sizeof(tSirSetTxPowerReq);
19387 pMsg->mwPower = mW;
19388 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19389 sizeof(tSirMacAddr));
19390 status = palSendMBMessage(pMac->hHdd, pMsg);
19391 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019392 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019393 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19394 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019395 }
19396 return status;
19397}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019398
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019399eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19400{
19401 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19402 eHalStatus status = eHAL_STATUS_SUCCESS;
19403 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19404
19405 if (!pSession)
19406 {
19407 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19408 return eHAL_STATUS_FAILURE;
19409 }
19410 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19411 {
19412 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019413
19414 if( NULL == pMsg )
19415 {
19416 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19417 return eHAL_STATUS_FAILURE;
19418 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019419 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19420 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019421 pMsg->length =
19422 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019423 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019424 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19425 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019426 status = palSendMBMessage(pMac->hHdd, pMsg);
19427 if (!HAL_STATUS_SUCCESS(status))
19428 {
19429 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19430 //pMsg is freed by palSendMBMessage
19431 }
19432 }
19433 else
19434 {
19435 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19436 status = eHAL_STATUS_FAILURE;
19437 }
19438 return status;
19439}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019440/* Returns whether a session is in VOS_STA_MODE...or not */
19441tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19442{
19443 tCsrRoamSession *pSession = NULL;
19444 pSession = CSR_GET_SESSION ( pMac, sessionId );
19445 if(!pSession)
19446 {
19447 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19448 return eANI_BOOLEAN_FALSE;
19449 }
19450 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19451 {
19452 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19453 return eANI_BOOLEAN_FALSE;
19454 }
19455 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19456 {
19457 return eANI_BOOLEAN_FALSE;
19458 }
19459 /* There is a possibility that the above check may fail,because
19460 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19461 * when it is connected.So,we may sneak through the above check even
19462 * if we are not a STA mode INFRA station. So, if we sneak through
19463 * the above condition, we can use the following check if we are
19464 * really in STA Mode.*/
19465
19466 if ( NULL != pSession->pCurRoamProfile )
19467 {
19468 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19469 {
19470 return eANI_BOOLEAN_TRUE;
19471 } else {
19472 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19473 return eANI_BOOLEAN_FALSE;
19474 }
19475 }
19476
19477 return eANI_BOOLEAN_FALSE;
19478}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019479
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019480/**
19481 * csr_set_src_handoff_request() - Set handoff source to
19482 * SME handoff request
19483 * @pHandoffInfo: Pointer to Handoff info
19484 * @pMsg: Pointer to SME handoff request message
19485 *
19486 * Return: None
19487 */
19488#ifndef QCA_WIFI_ISOC
19489static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19490 tCsrHandoffRequest *pHandoffInfo)
19491{
19492 pMsg->handoff_src = pHandoffInfo->src;
19493}
19494#else
19495static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19496 tCsrHandoffRequest *pHandoffInfo)
19497{
19498}
19499#endif
19500
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019501#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19502eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19503 tCsrHandoffRequest *pHandoffInfo)
19504{
19505 eHalStatus status = eHAL_STATUS_SUCCESS;
19506 vos_msg_t msg;
19507
19508 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019509 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19510 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019511 {
19512 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019513 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019514 }
19515 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19516 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19517 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19518 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019519 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019520 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019521 pHandoffInfo->bssid,
19522 6);
19523 msg.type = eWNI_SME_HANDOFF_REQ;
19524 msg.bodyptr = pMsg;
19525 msg.reserved = 0;
19526 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19527 {
19528 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019529 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019530 status = eHAL_STATUS_FAILURE;
19531 }
19532 return status;
19533}
19534#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019535
Abhishek Singh00b71972016-01-07 10:51:04 +053019536#ifdef WLAN_FEATURE_RMC
19537eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19538{
19539 tSirSetRMCReq *pMsg = NULL;
19540 eHalStatus status = eHAL_STATUS_SUCCESS;
19541 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19542
19543 if (!pSession)
19544 {
19545 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19546 return eHAL_STATUS_FAILURE;
19547 }
19548
19549 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19550 if (NULL != pMsg)
19551 {
19552 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19553 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19554 pMsg->msgLen = sizeof(tSirSetRMCReq);
19555 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19556 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19557
19558 status = palSendMBMessage(pMac->hHdd, pMsg);
19559 if (!HAL_STATUS_SUCCESS(status))
19560 {
19561 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19562 //pMsg is freed by palSendMBMessage
19563 }
19564 }
19565 else
19566 {
19567 return eHAL_STATUS_FAILURE;
19568 }
19569 return status;
19570}
19571
19572eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19573{
19574 tSirSetRMCReq *pMsg = NULL;
19575 eHalStatus status = eHAL_STATUS_SUCCESS;
19576 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19577
19578 if (!pSession)
19579 {
19580 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19581 return eHAL_STATUS_FAILURE;
19582 }
19583
19584 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19585 if (NULL != pMsg)
19586 {
19587 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19588 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19589 pMsg->msgLen = sizeof(tSirSetRMCReq);
19590 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19591 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19592
19593 status = palSendMBMessage(pMac->hHdd, pMsg);
19594 if (!HAL_STATUS_SUCCESS(status))
19595 {
19596 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19597 //pMsg is freed by palSendMBMessage
19598 }
19599 }
19600 else
19601 {
19602 return eHAL_STATUS_FAILURE;
19603 }
19604 return status;
19605}
19606
19607#endif /* WLAN_FEATURE_RMC */
19608
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019609
19610#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019611/* ---------------------------------------------------------------------------
19612 \fn csrSetCCKMIe
19613 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19614 data structure and this IE will be packed inside reassociation request
19615 \param pMac - pMac global structure
19616 \param sessionId - Current session id
19617 \param pCckmIe - pointer to CCKM IE data
19618 \param ccKmIeLen - length of the CCKM IE
19619 \- return Success or failure
19620 -------------------------------------------------------------------------*/
19621VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19622 const tANI_U8 *pCckmIe,
19623 const tANI_U8 ccKmIeLen)
19624{
19625 eHalStatus status = eHAL_STATUS_SUCCESS;
19626 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19627
19628 if (!pSession)
19629 {
19630 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19631 return eHAL_STATUS_FAILURE;
19632 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019633 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019634 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19635 return status;
19636}
19637
19638/* ---------------------------------------------------------------------------
19639 \fn csrRoamReadTSF
19640 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19641 probe response reception from the hand off AP to arrive at the latest TSF value.
19642 \param pMac - pMac global structure
19643 \param pTimestamp - output TSF timestamp
19644 \- return Success or failure
19645 -------------------------------------------------------------------------*/
19646VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19647{
19648 eHalStatus status = eHAL_STATUS_SUCCESS;
19649 tCsrNeighborRoamBSSInfo handoffNode;
19650 tANI_U32 timer_diff = 0;
19651 tANI_U32 timeStamp[2];
19652 tpSirBssDescription pBssDescription = NULL;
19653
19654 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19655 pBssDescription = handoffNode.pBssDescription;
19656
19657 // Get the time diff in milli seconds
19658 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19659 // Convert msec to micro sec timer
19660 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19661
19662 timeStamp[0] = pBssDescription->timeStamp[0];
19663 timeStamp[1] = pBssDescription->timeStamp[1];
19664
19665 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19666
Kiet Lamf2f201e2013-11-16 21:24:16 +053019667 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019668 sizeof (tANI_U32) * 2);
19669 return status;
19670}
19671
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019672#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019673
Agarwal Ashish738843c2014-09-25 12:27:56 +053019674/* ---------------------------------------------------------------------------
19675 \fn csrDisableDfsChannel
19676 \brief This function will call csrApplyChannelPowerCountryInfo to
19677 \ to trim the list on basis of NO_DFS flag.
19678 \param pMac - pMac global structure
19679 \- return void
19680 -------------------------------------------------------------------------*/
19681void csrDisableDfsChannel(tpAniSirGlobal pMac)
19682{
19683 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19684 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19685}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019686
19687/* ---------------------------------------------------------------------------
19688 \fn csrGetStaticUapsdMask
19689 \brief This function will get the static uapsd settings for an existing
19690 \ Infra session.
19691 \param pMac - pMac global structure
19692 \- return void
19693 -------------------------------------------------------------------------*/
19694void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19695{
19696 tANI_S8 sessionId;
19697 tCsrRoamSession *pSession = NULL;
19698
19699 *staticUapsdMask = 0;
19700 sessionId = csrGetInfraSessionId(pMac);
19701 if(sessionId == -1)
19702 smsLog(pMac, LOGE, FL("Valid session not present."));
19703 else
19704 pSession = CSR_GET_SESSION(pMac, sessionId);
19705
19706 if(!pSession || !pSession->pCurRoamProfile)
19707 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019708 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019709 else
19710 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19711}
19712
Abhishek Singh02605092017-10-25 14:06:12 +053019713VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19714 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19715{
19716 VOS_STATUS status = VOS_STATUS_SUCCESS;
19717 struct sir_ecsa_ie_req *msg;
19718
19719 msg = vos_mem_malloc(sizeof(*msg));
19720 if (!msg) {
19721 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19722 return VOS_STATUS_E_NOMEM;
19723 }
19724
19725 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19726 msg->len = sizeof(*msg);
19727
19728 msg->new_chan = new_chan;
19729 msg->cb_mode = cb_mode;
19730 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19731
19732 status = palSendMBMessage(mac_ctx->hHdd, msg);
19733 if (!VOS_IS_STATUS_SUCCESS(status))
19734 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019735 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019736 return status;
19737}
19738
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019739VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19740 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19741{
19742 VOS_STATUS status = VOS_STATUS_SUCCESS;
19743 struct sir_channel_chanege_req *msg;
19744 tCsrRoamStartBssParams param;
19745
19746 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19747
19748 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19749
19750 msg = vos_mem_malloc(sizeof(*msg));
19751 if (!msg) {
19752 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19753 return VOS_STATUS_E_NOMEM;
19754 }
19755
19756 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19757 msg->len = sizeof(*msg);
19758
19759 msg->new_chan = new_chan;
19760 msg->cb_mode = cb_mode;
19761 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19762 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19763 mac_ctx->roam.configParam.uCfgDot11Mode);
19764 if (IS_24G_CH(msg->new_chan) &&
19765 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19766 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19767 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19768 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19769
19770 vos_mem_copy(&msg->operational_rateset,
19771 &param.operationalRateSet, sizeof(msg->operational_rateset));
19772 vos_mem_copy(&msg->extended_rateset,
19773 &param.extendedRateSet, sizeof(msg->extended_rateset));
19774
19775 status = palSendMBMessage(mac_ctx->hHdd, msg);
19776 if (!VOS_IS_STATUS_SUCCESS(status))
19777 smsLog(mac_ctx, LOGE,
19778 FL(" channel switch req fauiled status %d "), status);
19779 return status;
19780}