blob: f53ba362f8a29fe3daa3abcae9822b871010abe1 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302 * Copyright (c) 2012-2019 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
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121/*--------------------------------------------------------------------------
122 Type declarations
123 ------------------------------------------------------------------------*/
124#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700125int diagAuthTypeFromCSRType(eCsrAuthType authType)
126{
127 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 switch(authType)
129 {
130 case eCSR_AUTH_TYPE_SHARED_KEY:
131 n = AUTH_SHARED;
132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700133 case eCSR_AUTH_TYPE_WPA:
134 n = AUTH_WPA_EAP;
135 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700136 case eCSR_AUTH_TYPE_WPA_PSK:
137 n = AUTH_WPA_PSK;
138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530140#ifdef WLAN_FEATURE_11W
141 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 n = AUTH_WPA2_EAP;
144 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700146#ifdef WLAN_FEATURE_11W
147 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 n = AUTH_WPA2_PSK;
150 break;
151#ifdef FEATURE_WLAN_WAPI
152 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
153 n = AUTH_WAPI_CERT;
154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
156 n = AUTH_WAPI_PSK;
157 break;
158#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 default:
160 break;
161 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 return (n);
163}
Jeff Johnson295189b2012-06-20 16:38:30 -0700164int diagEncTypeFromCSRType(eCsrEncryptionType encType)
165{
166 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 switch(encType)
168 {
169 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP40:
171 n = ENC_MODE_WEP40;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
174 case eCSR_ENCRYPT_TYPE_WEP104:
175 n = ENC_MODE_WEP104;
176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 case eCSR_ENCRYPT_TYPE_TKIP:
178 n = ENC_MODE_TKIP;
179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case eCSR_ENCRYPT_TYPE_AES:
181 n = ENC_MODE_AES;
182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#ifdef FEATURE_WLAN_WAPI
184 case eCSR_ENCRYPT_TYPE_WPI:
185 n = ENC_MODE_SMS4;
186 break;
187#endif /* FEATURE_WLAN_WAPI */
188 default:
189 break;
190 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 return (n);
192}
Jeff Johnson295189b2012-06-20 16:38:30 -0700193#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700194static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
195static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700196static void initConfigParam(tpAniSirGlobal pMac);
197static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
198 eCsrRoamCompleteResult Result, void *Context );
199static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
200 tCsrRoamProfile *pProfile,
201 tANI_BOOLEAN *pfSameIbss );
202static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
203static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700204 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
205static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
207static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
208eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
209eHalStatus csrRoamClose(tpAniSirGlobal pMac);
210void csrRoamMICErrorTimerHandler(void *pv);
211void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
212tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
213
214static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
215static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
216static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700217eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
218static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700219static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700220static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700221eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
222 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
223 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
224 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
225 tANI_U8 *pKeyRsc );
226static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
227 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
228 tCsrRoamProfile *pProfile );
229void csrRoamStatisticsTimerHandler(void *pv);
230void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700231VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
232 v_U8_t rssiNotification,
233 void * context);
234static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
235void csrRoamVccTrigger(tpAniSirGlobal pMac);
236eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
237/*
238 pStaEntry is no longer invalid upon the return of this function.
239*/
240static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700242static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700243tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
244 tDblLinkList *pStaList,
245 tCsrStatsClientReqInfo *pStaEntry);
246void csrRoamStatsClientTimerHandler(void *pv);
247tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
248 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
249void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
250 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700251void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700252void csrRoamTlStatsTimerHandler(void *pv);
253void csrRoamPeStatsTimerHandler(void *pv);
254tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
255void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
256tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
257eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
258static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
259static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
260static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
261static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
262 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
263//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
264static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
265void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
266#ifdef FEATURE_WLAN_BTAMP_UT_RF
267void csrRoamJoinRetryTimerHandler(void *pv);
268#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530269void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700270extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530271#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700272extern void btampEstablishLogLinkHdlr(void* pMsg);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530273#endif
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
Sushant Kaushikece4b562015-04-09 18:27:33 +0530608 if (!pChanList->chanParam[num_channel].pwr)
609 {
610 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
611 "setting to default %d"),
612 pChanList->chanParam[num_channel].chanId,
613 TX_POWER_DEFAULT);
614 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
615 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530616 if (channel_state == NV_CHANNEL_DFS)
617 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
618 else
619 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
620
621 /* When DFS mode is 2, mark static channels as active */
622 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
623 {
624 cfgnumChannels =
625 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
626 cfgChannelList =
627 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
628
629 if (cfgChannelList)
630 {
631 for(j=0; j< cfgnumChannels; j++)
632 {
633 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
634 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
635 {
636 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
638 "%s Marked DFS ch %d as active\n", __func__,
639 cfgChannelList[j]);
640 }
641 }
642 }
643 else
644 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
645 "%s cfgChannelList is NULL \n", __func__);
646 }
647
648 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
649 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
650 pChanList->chanParam[num_channel].chanId,
651 pChanList->chanParam[num_channel].dfsSet,
652 pChanList->chanParam[num_channel].pwr);
653 num_channel++;
654 }
655 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530656
Sachin Ahuja2d15ff62015-06-30 12:46:44 +0530657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
658 "%s : regID : %d \n", __func__,
659 pChanList->regId);
660
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530661 pChanList->numChan = num_channel;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530662
663 status = sme_AcquireGlobalLock(&pMac->sme);
664 if (HAL_STATUS_SUCCESS(status)) {
665 command = csrGetCommandBuffer(pMac);
666 if (command) {
667 command->command = eSmeCommandUpdateChannelList;
668 command->u.chan_list = pChanList;
669
670 status = csrQueueSmeCommand(pMac, command, eANI_BOOLEAN_TRUE);
671 if (!HAL_STATUS_SUCCESS(status)) {
672 smsLog(pMac, LOGE, FL("fail to send msg status = %d"), status);
673 csrReleaseCommand(pMac, command);
674 }
675 } else {
676 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
677 status = eHAL_STATUS_RESOURCES;
678 }
679 sme_ReleaseGlobalLock(&pMac->sme);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530680 }
681
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530682 return status;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530683}
684
Jeff Johnson295189b2012-06-20 16:38:30 -0700685eHalStatus csrStart(tpAniSirGlobal pMac)
686{
687 eHalStatus status = eHAL_STATUS_SUCCESS;
688 tANI_U32 i;
689
690 do
691 {
692 //save the global vos context
693 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
694 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
695 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
696
697 status = csrRoamStart(pMac);
698 if(!HAL_STATUS_SUCCESS(status)) break;
699 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
700 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
701 if(!HAL_STATUS_SUCCESS(status)) break;
702 pMac->roam.sPendingCommands = 0;
703 csrScanEnable(pMac);
704#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
705 status = csrNeighborRoamInit(pMac);
706#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
707 pMac->roam.tlStatsReqInfo.numClient = 0;
708 pMac->roam.tlStatsReqInfo.periodicity = 0;
709 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
710 //init the link quality indication also
711 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
712 if(!HAL_STATUS_SUCCESS(status))
713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800714 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 break;
716 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530717
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700719#if defined(ANI_LOGDUMP)
720 csrDumpInit(pMac);
721#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 return (status);
723}
724
Kiet Lama72a2322013-11-15 11:18:11 +0530725eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700726{
727 tANI_U32 sessionId;
728 tANI_U32 i;
729
730 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
731 {
mukul sharmabab477d2015-06-11 17:14:55 +0530732 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 csrScanDisable(pMac);
735 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
736 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
738
739#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
740 csrNeighborRoamClose(pMac);
741#endif
742 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 // deregister from PMC since we register during csrStart()
744 // (ignore status since there is nothing we can do if it fails)
745 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 //Reset the domain back to the deault
747 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700748
749 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
750 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530751 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530752 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE, i);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 }
754
Kiet Lama72a2322013-11-15 11:18:11 +0530755#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
756 /* When HAL resets all the context information
757 * in HAL is lost, so we might need to send the
758 * scan offload request again when it comes
759 * out of reset for scan offload to be functional
760 */
761 if (HAL_STOP_TYPE_SYS_RESET == stopType)
762 {
763 bRoamScanOffloadStarted = VOS_FALSE;
764 }
765#endif
766
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return (eHAL_STATUS_SUCCESS);
768}
769
Jeff Johnson295189b2012-06-20 16:38:30 -0700770eHalStatus csrReady(tpAniSirGlobal pMac)
771{
772 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 csrScanGetSupportedChannels( pMac );
774 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
775 //use it to init the background scan list
776 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 //Store the AC weights in TL for later use
778 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 status = csrInitChannelList( pMac );
780 if ( ! HAL_STATUS_SUCCESS( status ) )
781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800782 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 status );
784 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 return (status);
786}
Jeff Johnson295189b2012-06-20 16:38:30 -0700787void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
788{
789 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
791 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
792}
Jeff Johnson295189b2012-06-20 16:38:30 -0700793void csrSetGlobalCfgs( tpAniSirGlobal pMac )
794{
Jeff Johnsone7245742012-09-05 17:12:55 -0700795
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
797 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
798 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
799 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
800 NULL, eANI_BOOLEAN_FALSE);
801 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700802 /* 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
803 * Once session is established we will use the session related params stored in PE session for CB mode
804 */
805 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
807
808 //Update the operating mode to configured value during initialization,
809 //So that client can advertise full capabilities in Probe request frame.
810 csrSetDefaultDot11Mode( pMac );
811}
812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
814{
815 eHalStatus status = eHAL_STATUS_SUCCESS;
816 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +0530817 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 do
819 {
820 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
821 {
822 pSession = CSR_GET_SESSION( pMac, i );
823 pSession->roamingTimerInfo.pMac = pMac;
824 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
825 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
827 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530828 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
829 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530831 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800833 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 break;
835 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530836 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
837 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
838 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800840 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 return eHAL_STATUS_FAILURE;
842 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530843 vos_spin_lock_init(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 return (status);
846}
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848eHalStatus csrRoamClose(tpAniSirGlobal pMac)
849{
850 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
852 {
mukul sharmabab477d2015-06-11 17:14:55 +0530853 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530855 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
856 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
857 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
858 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530859 vos_spin_lock_destroy(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 return (eHAL_STATUS_SUCCESS);
861}
862
Jeff Johnson295189b2012-06-20 16:38:30 -0700863eHalStatus csrRoamStart(tpAniSirGlobal pMac)
864{
865 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 return (eHAL_STATUS_SUCCESS);
867}
868
Jeff Johnson295189b2012-06-20 16:38:30 -0700869void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
870{
871 csrRoamStopRoamingTimer(pMac, sessionId);
872 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
873 csrRoamDeregStatisticsReq(pMac);
874}
Jeff Johnson295189b2012-06-20 16:38:30 -0700875eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
876{
877 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800878 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 {
880 status = eHAL_STATUS_SUCCESS;
881 *pState = pMac->roam.roamSession[sessionId].connectState;
882 }
883 return (status);
884}
885
Jeff Johnson295189b2012-06-20 16:38:30 -0700886eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
887{
888 eHalStatus status = eHAL_STATUS_FAILURE;
889 tANI_U32 size = 0;
890 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700891
892 if(!pSession)
893 {
894 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
895 return eHAL_STATUS_FAILURE;
896 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898 if(pProfile)
899 {
900 if(pSession->pConnectBssDesc)
901 {
902 do
903 {
904 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
905 if(size)
906 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530907 pProfile->pBssDesc = vos_mem_malloc(size);
908 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530910 vos_mem_copy(pProfile->pBssDesc,
911 pSession->pConnectBssDesc, size);
912 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 }
914 else
915 break;
916 }
917 else
918 {
919 pProfile->pBssDesc = NULL;
920 }
921 pProfile->AuthType = pSession->connectedProfile.AuthType;
922 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
923 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
924 pProfile->BSSType = pSession->connectedProfile.BSSType;
925 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
926 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530927 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
928 sizeof(tCsrBssid));
929 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
930 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700931#ifdef WLAN_FEATURE_VOWIFI_11R
932 if (pSession->connectedProfile.MDID.mdiePresent)
933 {
934 pProfile->MDID.mdiePresent = 1;
935 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
936 }
937 else
938 {
939 pProfile->MDID.mdiePresent = 0;
940 pProfile->MDID.mobilityDomain = 0;
941 }
942#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800943#ifdef FEATURE_WLAN_ESE
944 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
945 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800947 vos_mem_copy (pProfile->eseCckmInfo.krk,
948 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530949 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800950 pProfile->eseCckmInfo.reassoc_req_num=
951 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
952 pProfile->eseCckmInfo.krk_plumbed =
953 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 }
955#endif
956 }while(0);
957 }
958 }
959
960 return (status);
961}
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
964{
965 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700966
967 if((csrIsConnStateConnected(pMac, sessionId)) ||
968 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 {
970 if(pProfile)
971 {
972 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
973 }
974 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 return (status);
976}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
979{
980 eHalStatus status = eHAL_STATUS_SUCCESS;
981
Kiet Lam64c1b492013-07-12 13:56:44 +0530982 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530984 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530986 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700987 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530988 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700989 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530990 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
991
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
993 return (status);
994}
995
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530996eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700997{
998 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 if( pConnectedInfo->pbFrames )
1000 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301001 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 pConnectedInfo->pbFrames = NULL;
1003 }
1004 pConnectedInfo->nBeaconLength = 0;
1005 pConnectedInfo->nAssocReqLength = 0;
1006 pConnectedInfo->nAssocRspLength = 0;
1007 pConnectedInfo->staId = 0;
1008#ifdef WLAN_FEATURE_VOWIFI_11R
1009 pConnectedInfo->nRICRspLength = 0;
1010#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001011#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 pConnectedInfo->nTspecIeLength = 0;
1013#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 return ( status );
1015}
1016
Jeff Johnson295189b2012-06-20 16:38:30 -07001017
1018
Jeff Johnsone7245742012-09-05 17:12:55 -07001019
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001020void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1021{
1022 csrReinitPreauthCmd(pMac, pCommand);
1023 csrReleaseCommand( pMac, pCommand );
1024}
1025
Jeff Johnson295189b2012-06-20 16:38:30 -07001026void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1027{
1028 csrReinitRoamCmd(pMac, pCommand);
1029 csrReleaseCommand( pMac, pCommand );
1030}
1031
Jeff Johnson295189b2012-06-20 16:38:30 -07001032void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1033{
1034 csrReinitScanCmd(pMac, pCommand);
1035 csrReleaseCommand( pMac, pCommand );
1036}
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1039{
1040 csrReinitWmStatusChangeCmd(pMac, pCommand);
1041 csrReleaseCommand( pMac, pCommand );
1042}
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1045{
Kiet Lam64c1b492013-07-12 13:56:44 +05301046 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001047}
1048
Jeff Johnson295189b2012-06-20 16:38:30 -07001049void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1050{
Kiet Lam64c1b492013-07-12 13:56:44 +05301051 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001052}
1053
Jeff Johnson295189b2012-06-20 16:38:30 -07001054void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1055{
1056 csrReinitSetKeyCmd(pMac, pCommand);
1057 csrReleaseCommand( pMac, pCommand );
1058}
Jeff Johnson295189b2012-06-20 16:38:30 -07001059void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1060{
1061 csrReinitRemoveKeyCmd(pMac, pCommand);
1062 csrReleaseCommand( pMac, pCommand );
1063}
Abhishek Singh7b2d0812016-04-28 11:44:29 +05301064
1065/**
1066 * csr_is_disconnect_full_power_cmd() - Check if command is for
1067 * disconnect or for fullpower
1068 * @command: command to check
1069 *
1070 * Return: true if disconnect or full power command else false
1071 */
1072bool csr_is_disconnect_full_power_cmd(tSmeCmd *command)
1073{
1074 switch (command->command) {
1075 case eSmeCommandRoam:
1076 if (CSR_IS_DISCONNECT_COMMAND(command))
1077 return true;
1078 break;
1079 case eSmeCommandWmStatusChange:
1080 case eSmeCommandExitImps:
1081 case eSmeCommandExitBmps:
1082 case eSmeCommandExitUapsd:
1083 case eSmeCommandExitWowl:
1084 return true;
1085 default:
1086 return false;
1087 }
1088 return false;
1089}
1090
Jeff Johnson295189b2012-06-20 16:38:30 -07001091void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1092{
1093
1094 if( eSmeCsrCommandMask & pCommand->command )
1095 {
1096 switch (pCommand->command)
1097 {
1098 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001099 // We need to inform the requester before dropping the scan command
Jeff Johnson89477502017-09-19 08:35:23 -07001100 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %pK",
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001101 __func__, pCommand->u.scanCmd.reason,
1102 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 if (NULL != pCommand->u.scanCmd.callback)
1104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001105 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1107 }
1108 csrReleaseCommandScan( pMac, pCommand );
1109 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 case eSmeCommandRoam:
1111 csrReleaseCommandRoam( pMac, pCommand );
1112 break;
1113
1114 case eSmeCommandWmStatusChange:
1115 csrReleaseCommandWmStatusChange( pMac, pCommand );
1116 break;
1117
1118 case eSmeCommandSetKey:
1119 csrReleaseCommandSetKey( pMac, pCommand );
1120 break;
1121
1122 case eSmeCommandRemoveKey:
1123 csrReleaseCommandRemoveKey( pMac, pCommand );
1124 break;
1125
1126 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001127 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 csrReleaseCommand( pMac, pCommand );
1129 break;
1130 }
1131 }
1132}
1133
Jeff Johnson295189b2012-06-20 16:38:30 -07001134void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1135{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301136 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1137 macTraceGetcsrRoamSubState(NewSubstate),
1138 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001139
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1141 {
1142 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001143 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301144 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 pMac->roam.curSubState[sessionId] = NewSubstate;
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301146 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001147}
1148
Jeff Johnson295189b2012-06-20 16:38:30 -07001149eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1150{
1151 eCsrRoamState PreviousState;
1152
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301153 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1154 macTraceGetcsrRoamState(NewRoamState),
1155 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001156
1157 PreviousState = pMac->roam.curState[sessionId];
1158
1159 if ( NewRoamState != pMac->roam.curState[sessionId] )
1160 {
1161 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1162 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1163 {
1164 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1165 }
1166
1167 pMac->roam.curState[sessionId] = NewRoamState;
1168 }
1169 return( PreviousState );
1170}
1171
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001172void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001173{
1174 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 if(catOffset)
1176 {
1177 pMac->roam.configParam.bCatRssiOffset = catOffset;
1178 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1179 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001180 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 -07001181 }
1182 }
1183}
1184
Jeff Johnson295189b2012-06-20 16:38:30 -07001185static void initConfigParam(tpAniSirGlobal pMac)
1186{
1187 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301189 pMac->roam.configParam.channelBondingMode24GHz =
1190 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1191 pMac->roam.configParam.channelBondingMode5GHz =
1192 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1194 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1195 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1196 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1197 pMac->roam.configParam.HeartbeatThresh24 = 40;
1198 pMac->roam.configParam.HeartbeatThresh50 = 40;
1199 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1200 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1201 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001202 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 pMac->roam.configParam.RTSThreshold = 2346;
1204 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1205 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1206 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1207 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1208 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1209 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1210 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1211 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1212 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1213 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1214 {
1215 pMac->roam.configParam.BssPreferValue[i] = i;
1216 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001217 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1219 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1220 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1222 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301223 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1225 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1226 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1227 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301228 pMac->roam.configParam.max_chntime_btc_esco =
1229 CSR_ACTIVE_MAX_CHANNEL_TIME_ESCO_BTC;
1230 pMac->roam.configParam.min_chntime_btc_esco =
1231 CSR_ACTIVE_MIN_CHANNEL_TIME_ESCO_BTC;
1232 pMac->roam.configParam.min_chntime_btc_sco =
1233 CSR_ACTIVE_MIN_CHANNEL_TIME_SCO_BTC;
1234 pMac->roam.configParam.max_chntime_btc_sco=
1235 CSR_ACTIVE_MAX_CHANNEL_TIME_SCO_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001236 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001237#ifdef WLAN_AP_STA_CONCURRENCY
1238 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1239 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1240 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1241 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1242 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001243 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1244 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1247 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1248 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1249 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001250#ifdef WLAN_FEATURE_VOWIFI_11R
1251 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1252#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001253#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1254 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1255 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1256 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1257 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1258 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1259 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1260 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1261 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1262 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1263 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1264 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001265 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301266 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05301267 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001268#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001269#ifdef WLAN_FEATURE_11AC
1270 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1271#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001272
1273 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1274 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301275 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_FALSE;
1276 pMac->roam.configParam.num_ba_buff_btc_sco = DEFAULT_NUM_BUFF_BTC_SCO;
1277 pMac->roam.configParam.num_ba_buff = WNI_CFG_NUM_BUFF_ADVERT_STADEF;
Mohit Khanna349bc392012-09-11 17:24:52 -07001278
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001279 //Remove this code once SLM_Sessionization is supported
1280 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001281 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001282
Jeff Johnsone7245742012-09-05 17:12:55 -07001283}
Jeff Johnson295189b2012-06-20 16:38:30 -07001284eCsrBand csrGetCurrentBand(tHalHandle hHal)
1285{
1286 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1287 return pMac->roam.configParam.bandCapability;
1288}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001289
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001290
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001291#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001292/*
1293 This function flushes the roam scan cache
1294*/
1295eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1296{
1297 eHalStatus status = eHAL_STATUS_SUCCESS;
1298 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1299
1300 /* Free up the memory first (if required) */
1301 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1302 {
1303 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1304 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1305 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1306 }
1307 return status;
1308}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001309#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001310
1311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001312#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001313/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001314 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001315*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001316eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001317{
1318 eHalStatus status = eHAL_STATUS_SUCCESS;
1319 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1320
1321 /* Free up the memory first (if required) */
1322 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1323 {
1324 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1325 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001326 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001327 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001328 return status;
1329}
1330
1331
1332
1333/*
1334 This function flushes the roam scan cache and creates fresh cache
1335 based on the input channel list
1336*/
1337eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1338 const tANI_U8 *pChannelList,
1339 const tANI_U8 numChannels)
1340{
1341 eHalStatus status = eHAL_STATUS_SUCCESS;
1342 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1343
Srinivas Girigowdade697412013-02-14 16:31:48 -08001344 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1345
1346 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1347 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1348
1349 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1350 {
1351 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1352 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1353 return eHAL_STATUS_RESOURCES;
1354 }
1355
1356 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301357 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1358 pChannelList,
1359 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001360 return status;
1361}
1362
1363/* This function modifies the bgscan channel list set via config ini or
1364 runtime, whenever the band changes.
1365 if the band is auto, then no operation is performed on the channel list
1366 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1367 if the band is 5G, then make sure channel list contains only 5G valid channels
1368*/
1369eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1370 eCsrBand eBand)
1371{
1372 eHalStatus status = eHAL_STATUS_SUCCESS;
1373 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1374 tANI_U8 outNumChannels = 0;
1375 tANI_U8 inNumChannels = 0;
1376 tANI_U8 *inPtr = NULL;
1377 tANI_U8 i = 0;
1378 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1379
1380 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1381
1382 {
1383 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1384 "No update required for channel list "
1385 "either cfg.ini channel list is not set up or "
1386 "auto band (Band %d)", eBand);
1387 return status;
1388 }
1389
1390 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1391 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1392 if (eCSR_BAND_24 == eBand)
1393 {
1394 for (i = 0; i < inNumChannels; i++)
1395 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001396 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001397 {
1398 ChannelList[outNumChannels++] = inPtr[i];
1399 }
1400 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001401 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001402 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001403 }
1404 else if (eCSR_BAND_5G == eBand)
1405 {
1406 for (i = 0; i < inNumChannels; i++)
1407 {
1408 /* Add 5G Non-DFS channel */
1409 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001410 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001411 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1412 {
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_ALL == eBand)
1420 {
1421 for (i = 0; i < inNumChannels; i++)
1422 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001423 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001424 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1425 {
1426 ChannelList[outNumChannels++] = inPtr[i];
1427 }
1428 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001429 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001430 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001431 }
1432 else
1433 {
1434 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1435 "Invalid band, No operation carried out (Band %d)", eBand);
1436 status = eHAL_STATUS_INVALID_PARAMETER;
1437 }
1438
1439 return status;
1440}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001441#endif
1442
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001443#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001444/* This function modifies the roam scan channel list as per AP neighbor
1445 report; AP neighbor report may be empty or may include only other AP
1446 channels; in any case, we merge the channel list with the learned occupied
1447 channels list.
1448 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1449 if the band is 5G, then make sure channel list contains only 5G valid channels
1450*/
1451eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1452 tANI_U8 *pChannelList,
1453 tANI_U8 numChannels,
1454 const eCsrBand eBand)
1455{
1456 eHalStatus status = eHAL_STATUS_SUCCESS;
1457 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1458 tANI_U8 outNumChannels = 0;
1459 tANI_U8 inNumChannels = numChannels;
1460 tANI_U8 *inPtr = pChannelList;
1461 tANI_U8 i = 0;
1462 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1463 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1464 tANI_U8 mergedOutputNumOfChannels = 0;
1465 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1466
1467 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1468 * report Channels. This increases the chances of the DUT to get a candidate AP while
1469 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1470 if (pMac->scan.occupiedChannels.numChannels)
1471 {
1472 csrNeighborRoamMergeChannelLists(pMac,
1473 &pMac->scan.occupiedChannels.channelList[0],
1474 pMac->scan.occupiedChannels.numChannels,
1475 inPtr,
1476 inNumChannels,
1477 &mergedOutputNumOfChannels);
1478 inNumChannels = mergedOutputNumOfChannels;
1479 }
1480
1481 if (eCSR_BAND_24 == eBand)
1482 {
1483 for (i = 0; i < inNumChannels; i++)
1484 {
1485 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1486 {
1487 ChannelList[outNumChannels++] = inPtr[i];
1488 }
1489 }
1490 }
1491 else if (eCSR_BAND_5G == eBand)
1492 {
1493 for (i = 0; i < inNumChannels; i++)
1494 {
1495 /* Add 5G Non-DFS channel */
1496 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1497 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1498 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1499 {
1500 ChannelList[outNumChannels++] = inPtr[i];
1501 }
1502 }
1503 }
1504 else if (eCSR_BAND_ALL == eBand)
1505 {
1506 for (i = 0; i < inNumChannels; i++)
1507 {
1508 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1509 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1510 {
1511 ChannelList[outNumChannels++] = inPtr[i];
1512 }
1513 }
1514 }
1515 else
1516 {
1517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1518 "Invalid band, No operation carried out (Band %d)", eBand);
1519 return eHAL_STATUS_INVALID_PARAMETER;
1520 }
1521
1522 /* if roaming within band is enabled, then select only the
1523 in band channels .
1524 This is required only if the band capability is set to ALL,
1525 E.g., if band capability is only 2.4G then all the channels in the
1526 list are already filtered for 2.4G channels, hence ignore this check*/
1527
1528 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1529 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301530 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001531 pMac,
1532 ChannelList,
1533 outNumChannels,
1534 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301535 &outNumChannels,
1536 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301537 vos_mem_copy(ChannelList,
1538 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001539 }
1540
1541 /* Prepare final roam scan channel list */
1542 if(outNumChannels)
1543 {
1544 /* Clear the channel list first */
1545 if (NULL != currChannelListInfo->ChannelList)
1546 {
1547 vos_mem_free(currChannelListInfo->ChannelList);
1548 currChannelListInfo->ChannelList = NULL;
1549 currChannelListInfo->numOfChannels = 0;
1550 }
1551
1552 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1553 if (NULL == currChannelListInfo->ChannelList)
1554 {
1555 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1556 "Failed to allocate memory for roam scan channel list");
1557 currChannelListInfo->numOfChannels = 0;
1558 return VOS_STATUS_E_RESOURCES;
1559 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301560 vos_mem_copy(currChannelListInfo->ChannelList,
1561 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001562 }
1563 return status;
1564}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001565#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001566
Jeff Johnson295189b2012-06-20 16:38:30 -07001567eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1568{
1569 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1570 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1572 (eBand == eCSR_BAND_24))
1573 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001574 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001577 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 pMac->roam.configParam.uCfgDot11Mode, eBand);
1579 return eHAL_STATUS_INVALID_PARAMETER;
1580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1582 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1583 (eBand == eCSR_BAND_5G))
1584 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001585 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001587 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001588 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 pMac->roam.configParam.uCfgDot11Mode, eBand);
1590 return eHAL_STATUS_INVALID_PARAMETER;
1591 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001593 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001594 pMac->roam.configParam.eBand = eBand;
1595 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001597#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001598 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1599 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001600#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 status = csrInitGetChannels( pMac );
1602 if (eHAL_STATUS_SUCCESS == status)
1603 csrInitChannelList( hHal );
1604 return status;
1605}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001606
1607
Jeff Johnsone7245742012-09-05 17:12:55 -07001608/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1609 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1610 * Ideally we should have kept the ini value and enum value same and representing the same
1611 * cb values as in 11n standard i.e.
1612 * Set to 1 (SCA) if the secondary channel is above the primary channel
1613 * Set to 3 (SCB) if the secondary channel is below the primary channel
1614 * Set to 0 (SCN) if no secondary channel is present
1615 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1616 * 0 - secondary none
1617 * 1 - secondary LOW
1618 * 2 - secondary HIGH
1619 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1620 * The enum values are as follows:
1621 * PHY_SINGLE_CHANNEL_CENTERED = 0
1622 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1623 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1624 */
1625ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1626{
1627
1628 ePhyChanBondState phyCbState;
1629 switch (cbIniValue) {
1630 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301631 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001632 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1633 break;
1634 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301635 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001636 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1637 break;
1638 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301639 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001640 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1641 break;
1642#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301643 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1644 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001645 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301646 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1648 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301649 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1650 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1651 break;
1652 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001653 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1654 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301655 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001656 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301657 break;
1658 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001659 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1660 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301661 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001662 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301663 break;
1664#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001665 default:
1666 // If an invalid value is passed, disable CHANNEL BONDING
1667 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1668 break;
1669 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301670
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 return phyCbState;
1672}
1673
1674v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1675{
1676
1677 v_U32_t cbIniValue;
1678 switch (phyCbState) {
1679 // secondary none
1680 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301681 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001682 break;
1683 // secondary LOW
1684 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301685 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001686 break;
1687 // secondary HIGH
1688 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301689 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001690 break;
1691#ifdef WLAN_FEATURE_11AC
1692 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301693 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001694 break;
1695 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301696 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001697 break;
1698 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301699 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001700 break;
1701 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301702 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001703 break;
1704 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301705 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001706 break;
1707 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301708 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001709 break;
1710 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301711 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001712 break;
1713#endif
1714 default:
1715 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301716 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001717 break;
1718 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301719
Jeff Johnsone7245742012-09-05 17:12:55 -07001720 return cbIniValue;
1721}
Jeff Johnson295189b2012-06-20 16:38:30 -07001722
1723eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1724{
1725 eHalStatus status = eHAL_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301726 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001727
1728 if(pParam)
1729 {
1730 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1731 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1732 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1733 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1734 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1735 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1736
1737 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001738 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1739
Jeff Johnsone7245742012-09-05 17:12:55 -07001740 /* channelBondingMode5GHz plays a dual role right now
1741 * 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
1742 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1743 */
1744 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001746 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001747 }
1748 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1749 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1750 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001751 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001752 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301753#ifdef WLAN_FEATURE_AP_HT40_24G
1754 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1755#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001756 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1758 pMac->roam.configParam.phyMode = pParam->phyMode;
1759 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1760 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1761 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1762 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1763 pMac->roam.configParam.TxRate = pParam->TxRate;
1764 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1765 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1766 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1767 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1768 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001769 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 //if HDD passed down non zero values then only update,
1771 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301772 if (pParam->nInitialDwellTime)
1773 {
1774 pMac->roam.configParam.nInitialDwellTime =
1775 pParam->nInitialDwellTime;
1776 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001777 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 {
1779 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301780 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1781 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001783 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 {
1785 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301786 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1787 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001789 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 {
1791 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301792 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1793 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001795 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 {
1797 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301798 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1799 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301801 if (pParam->nOBSSScanWidthTriggerInterval)
1802 {
1803 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1804 pParam->nOBSSScanWidthTriggerInterval;
1805 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1806 pParam->nOBSSScanWidthTriggerInterval);
1807 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301808 if (pParam->max_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001809 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301810 pMac->roam.configParam.max_chntime_btc_esco =
1811 pParam->max_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001812 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301813 if (pParam->min_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001814 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301815 pMac->roam.configParam.min_chntime_btc_esco =
1816 pParam->min_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001817 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301818 if (pParam->min_chntime_btc_sco)
1819 pMac->roam.configParam.min_chntime_btc_sco =
1820 pParam->min_chntime_btc_sco;
1821 if (pParam->max_chntime_btc_sco)
1822 pMac->roam.configParam.max_chntime_btc_sco =
1823 pParam->max_chntime_btc_sco;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001824#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001825 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001826 {
1827 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1828 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001829 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001830 {
1831 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1832 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001833 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001834 {
1835 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1836 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001837 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001838 {
1839 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1840 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001841 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001842 {
1843 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1844 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001845 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001846 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001847 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1848 }
1849 if (pParam->nNumP2PChanCombinedConc)
1850 {
1851 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001852 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001853#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001855 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 {
1857 //Change the unit from second to microsecond
1858 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1860 {
1861 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1862 }
1863 else
1864 {
1865 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1866 }
1867 }
1868 else
1869 {
1870 pMac->roam.configParam.impsSleepTime = 0;
1871 }
1872 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1874 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 //if HDD passed down non zero values for age params, then only update,
1876 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001877 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 {
1879 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 if(pParam->scanAgeTimeNCNPS)
1882 {
1883 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 if(pParam->scanAgeTimeNCPS)
1886 {
1887 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 if(pParam->scanAgeTimeCNPS)
1890 {
1891 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1892 }
1893 if(pParam->scanAgeTimeCPS)
1894 {
1895 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1896 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301897 if (pParam->initialScanSkipDFSCh)
1898 {
1899 pMac->roam.configParam.initialScanSkipDFSCh =
1900 pParam->initialScanSkipDFSCh;
1901 }
1902
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001903 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1905 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1906 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1907 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1908 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1910 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1912 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1913 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1914 //Assign this before calling CsrInit11dInfo
1915 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 if( csrIs11dSupported( pMac ) )
1917 {
1918 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1919 }
1920 else
1921 {
1922 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1923 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001924
1925 /* Initialize the power + channel information if 11h is enabled.
1926 If 11d is enabled this information has already been initialized */
1927 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1928 {
1929 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1930 }
1931
1932
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301933#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301934 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1935 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001936 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001937#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001938#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001940 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001941 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001942 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001943 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001944 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001945 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001946 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001947 pMac->roam.configParam.nProbes = pParam->nProbes;
1948 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001949#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001950#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301951 pMac->roam.configParam.isRoamOffloadScanEnabled =
1952 pParam->isRoamOffloadScanEnabled;
1953 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1954 pParam->bFastRoamInConIniFeatureEnabled;
1955 pMac->roam.configParam.isPERRoamEnabled =
1956 pParam->isPERRoamEnabled;
1957 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
1958 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
1959 pMac->roam.configParam.waitPeriodForNextPERScan =
1960 pParam->waitPeriodForNextPERScan;
1961 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
1962 pMac->roam.configParam.isPERRoamCCAEnabled =
1963 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05301964 pMac->roam.configParam.PERRoamFullScanThreshold =
1965 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05301966 pMac->roam.configParam.PERroamTriggerPercent =
1967 pParam->PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05301968 pMac->roam.configParam.PERMinRssiThresholdForRoam =
1969 pParam->PERMinRssiThresholdForRoam;
1970 pMac->PERroamTimeout = pParam->waitPeriodForNextPERScan;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001971#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301972
1973#ifdef WLAN_FEATURE_LFR_MBB
1974 pMac->roam.configParam.enable_lfr_mbb = pParam->enable_lfr_mbb;
1975#endif
1976
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001977#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001978 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001979 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001980#endif
1981
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001982#ifdef FEATURE_WLAN_ESE
1983 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001985#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301986 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1987 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001988 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1989 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1990 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1991 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1992 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1993 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1994 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1995 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301996 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05301997 smsLog( pMac, LOG1, "nWeakZoneRssiThresholdForRoam = %d", pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 {
1999 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002000 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 -07002001 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2002 {
2003 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 }
2006#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
2008 pMac->scan.fValidateList = pParam->fValidateList;
2009 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2010 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302011 pMac->scan.disable_scan_during_sco = pParam->disable_scan_during_sco;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08002012 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002014 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05302015 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07002016 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2017 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2018 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2019 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2020 * single session
2021 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002022 //Remove this code once SLM_Sessionization is supported
2023 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002024 pMac->roam.configParam.doBMPSWorkaround = 0;
2025
Jeff Johnsone7245742012-09-05 17:12:55 -07002026#ifdef WLAN_FEATURE_11AC
2027 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002028 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002029 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002030 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302031 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2032 if ( pParam->enableTxBF )
2033 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2034 else
2035 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002036#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002037 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002038
2039 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002040 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302041 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302042 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302043 pMac->roam.configParam.disableP2PMacSpoofing =
2044 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302045 pMac->roam.configParam.enableFatalEvent =
2046 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002047 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2048 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302049 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302050 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302051#ifdef WLAN_FEATURE_AP_HT40_24G
2052 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2053#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302054 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302055 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2056 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302057
2058 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2059 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2060 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2061 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2062 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2063
2064 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2065 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2066 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2067 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2068
2069 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2070 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2071 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2072 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302073 pMac->sta_sap_scc_on_dfs_chan = pParam->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302074 pMac->force_scc_with_ecsa = pParam->force_scc_with_ecsa;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302075 for (i = 0; i < 3; i++) {
2076 pMac->roam.configParam.agg_btc_sco_oui[i] =
2077 pParam->agg_btc_sco_oui[i];
2078 }
2079 pMac->roam.configParam.num_ba_buff_btc_sco =
2080 pParam->num_ba_buff_btc_sco;
2081 pMac->roam.configParam.num_ba_buff = pParam->num_ba_buff;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 }
2083
2084 return status;
2085}
2086
Jeff Johnson295189b2012-06-20 16:38:30 -07002087eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2088{
2089 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302090 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 if(pParam)
2092 {
2093 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2094 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2095 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2096 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2097 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2098 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002099 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302100#ifdef WLAN_FEATURE_AP_HT40_24G
2101 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2102#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002103 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2105 pParam->phyMode = pMac->roam.configParam.phyMode;
2106 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2107 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2108 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2109 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2110 pParam->TxRate = pMac->roam.configParam.TxRate;
2111 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2112 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2113 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2114 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2115 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2117 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2118 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2119 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05302120 pParam->max_chntime_btc_esco =
2121 pMac->roam.configParam.max_chntime_btc_esco;
2122 pParam->min_chntime_btc_esco =
2123 pMac->roam.configParam.min_chntime_btc_esco;
2124 pParam->min_chntime_btc_sco =
2125 pMac->roam.configParam.min_chntime_btc_sco;
2126 pParam->max_chntime_btc_sco =
2127 pMac->roam.configParam.max_chntime_btc_sco;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002128 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002129#ifdef WLAN_AP_STA_CONCURRENCY
2130 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2131 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2132 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2133 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2134 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002135 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2136 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 //Change the unit from microsecond to second
2139 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2140 pParam->eBand = pMac->roam.configParam.eBand;
2141 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2142 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2143 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2144 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2145 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2146 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2147 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2148 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2149 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2150 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2151 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2152 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2153 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2155 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2156 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2157 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2159 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2160 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2161 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302162 pParam->disable_scan_during_sco = pMac->scan.disable_scan_during_sco;
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002164 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002165 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002166 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002167 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302168 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002169#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302170 vos_mem_copy(&pParam->neighborRoamConfig,
2171 &pMac->roam.configParam.neighborRoamConfig,
2172 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002173#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002174#ifdef WLAN_FEATURE_11AC
2175 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002176 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002177 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002178 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302179 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2180 if ( pParam->enableTxBF )
2181 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2182 else
2183 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002184#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002185#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302186 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2187 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002188#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002189#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002190 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2191 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2192 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2193 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2194 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002195 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002196 pParam->nProbes = pMac->roam.configParam.nProbes;
2197 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002198#endif
2199#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2200 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2201 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302202 pParam->isPERRoamEnabled =
2203 pMac->roam.configParam.isPERRoamEnabled;
2204 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2205 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2206 pParam->waitPeriodForNextPERScan =
2207 pMac->roam.configParam.waitPeriodForNextPERScan;
2208 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2209 pParam->isPERRoamCCAEnabled =
2210 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302211 pParam->PERRoamFullScanThreshold =
2212 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302213 pParam->PERroamTriggerPercent =
2214 pMac->roam.configParam.PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302215 pParam->PERMinRssiThresholdForRoam =
2216 pMac->roam.configParam.PERMinRssiThresholdForRoam;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002217#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302218
2219#ifdef WLAN_FEATURE_LFR_MBB
2220 pParam->enable_lfr_mbb = pMac->roam.configParam.enable_lfr_mbb;
2221#endif
2222
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002223#ifdef FEATURE_WLAN_LFR
2224 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2225#endif
2226
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002227#ifdef FEATURE_WLAN_ESE
2228 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002229#endif
2230#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302231 vos_mem_copy(&pParam->neighborRoamConfig,
2232 &pMac->roam.configParam.neighborRoamConfig,
2233 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002234 {
2235 int i;
2236 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2237 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2238 {
2239 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2240 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002241 }
2242#endif
2243
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002244 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002245
krunal soni5afa96c2013-09-06 22:19:02 -07002246 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002247 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302248 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302249 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302250 pParam->disableP2PMacSpoofing =
2251 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302252 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002253
krunal sonie9002db2013-11-25 14:24:17 -08002254 pParam->isCoalesingInIBSSAllowed =
2255 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302256 pParam->allowDFSChannelRoam =
2257 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302258 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302260#ifdef WLAN_FEATURE_AP_HT40_24G
2261 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2262#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302263 pParam->max_chan_for_dwell_time_cfg =
2264 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
Abhishek Singh48cd3402016-03-30 15:20:19 +05302266 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2267 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2268 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2269 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2270 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2271
2272 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2273 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2274 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2275 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2276
2277 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2278 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2279 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2280 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302281 pParam->sta_sap_scc_on_dfs_chan = pMac->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302282 pParam->force_scc_with_ecsa = pMac->force_scc_with_ecsa;
2283
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302284 for (i = 0; i < 3; i++) {
2285 pParam->agg_btc_sco_oui[i] =
2286 pMac->roam.configParam.agg_btc_sco_oui[i];
2287 }
2288 pParam->num_ba_buff_btc_sco =
2289 pMac->roam.configParam.num_ba_buff_btc_sco;
2290 pParam->num_ba_buff = pMac->roam.configParam.num_ba_buff;
2291
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 status = eHAL_STATUS_SUCCESS;
2293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 return (status);
2295}
2296
Jeff Johnson295189b2012-06-20 16:38:30 -07002297eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2298{
2299 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2300 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2301 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2302 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 do
2304 {
2305 if(eCSR_BAND_24 == eBand)
2306 {
2307 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2308 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2309 }
2310 if(eCSR_BAND_5G == eBand)
2311 {
2312 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2313 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2314 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2315 )
2316 {
2317 break;
2318 }
2319 }
2320 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2321 {
2322 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2323 }
2324 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2325 {
2326 newPhyMode = eCSR_DOT11_MODE_AUTO;
2327 }
2328 else
2329 {
2330 //Check for dual band and higher capability first
2331 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2332 {
2333 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2334 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2335 }
2336 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2337 {
2338 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2339 if(eCSR_BAND_24 == eBand) break;
2340 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2341 eBand = eCSR_BAND_5G;
2342 }
2343 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2344 {
2345 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2346 if(eCSR_BAND_5G == eBand) break;
2347 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2348 eBand = eCSR_BAND_24;
2349 }
2350 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2351 {
2352 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2353 if(eCSR_BAND_5G == eBand) break;
2354 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2355 eBand = eCSR_BAND_24;
2356 }
2357 else if(eCSR_DOT11_MODE_11n & phyMode)
2358 {
2359 newPhyMode = eCSR_DOT11_MODE_11n;
2360 }
2361 else if(eCSR_DOT11_MODE_abg & phyMode)
2362 {
2363 newPhyMode = eCSR_DOT11_MODE_abg;
2364 }
2365 else if(eCSR_DOT11_MODE_11a & phyMode)
2366 {
2367 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2368 {
2369 if(eCSR_BAND_ALL == eBand)
2370 {
2371 newPhyMode = eCSR_DOT11_MODE_abg;
2372 }
2373 else
2374 {
2375 //bad setting
2376 break;
2377 }
2378 }
2379 else
2380 {
2381 newPhyMode = eCSR_DOT11_MODE_11a;
2382 eBand = eCSR_BAND_5G;
2383 }
2384 }
2385 else if(eCSR_DOT11_MODE_11g & phyMode)
2386 {
2387 newPhyMode = eCSR_DOT11_MODE_11g;
2388 eBand = eCSR_BAND_24;
2389 }
2390 else if(eCSR_DOT11_MODE_11b & phyMode)
2391 {
2392 newPhyMode = eCSR_DOT11_MODE_11b;
2393 eBand = eCSR_BAND_24;
2394 }
2395 else
2396 {
2397 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002398 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 newPhyMode = eCSR_DOT11_MODE_AUTO;
2400 }
2401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 //Done validating
2403 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 //Now we need to check whether a restart is needed.
2405 if(eBand != pMac->roam.configParam.eBand)
2406 {
2407 fRestartNeeded = eANI_BOOLEAN_TRUE;
2408 break;
2409 }
2410 if(newPhyMode != pMac->roam.configParam.phyMode)
2411 {
2412 fRestartNeeded = eANI_BOOLEAN_TRUE;
2413 break;
2414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 if(HAL_STATUS_SUCCESS(status))
2417 {
2418 pMac->roam.configParam.eBand = eBand;
2419 pMac->roam.configParam.phyMode = newPhyMode;
2420 if(pfRestartNeeded)
2421 {
2422 *pfRestartNeeded = fRestartNeeded;
2423 }
2424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 return (status);
2426}
2427
Jeff Johnson295189b2012-06-20 16:38:30 -07002428void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2429{
2430 tANI_U8 Index;
2431 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 // for dual band NICs, don't need to trim the channel list....
2433 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2434 {
2435 // 2.4 GHz band operation requires the channel list to be trimmed to
2436 // the 2.4 GHz channels only...
2437 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2438 {
2439 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2440 Index++ )
2441 {
2442 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2443 {
2444 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2445 cChannels++;
2446 }
2447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2449 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2450 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2451 // only if we need to.
2452 //
2453 // The amount of memory to clear is the number of channesl that we trimmed
2454 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2455
2456 if ( pChannelList->numChannels > cChannels )
2457 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302458 vos_mem_set(&pChannelList->channelList[ cChannels ],
2459 sizeof( pChannelList->channelList[ 0 ] ) *
2460 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 }
2462
2463 pChannelList->numChannels = cChannels;
2464 }
2465 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2466 {
2467 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2468 {
2469 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2470 {
2471 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2472 cChannels++;
2473 }
2474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2476 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2477 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2478 // only if we need to.
2479 //
2480 // The amount of memory to clear is the number of channesl that we trimmed
2481 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2482 if ( pChannelList->numChannels > cChannels )
2483 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302484 vos_mem_set(&pChannelList->channelList[ cChannels ],
2485 sizeof( pChannelList->channelList[ 0 ] ) *
2486 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 }
2488
2489 pChannelList->numChannels = cChannels;
2490 }
2491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002492}
Jeff Johnson295189b2012-06-20 16:38:30 -07002493#define INFRA_AP_DEFAULT_CHANNEL 6
2494eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2495{
2496 tANI_U8 index= 0;
2497 eHalStatus status = eHAL_STATUS_FAILURE;
2498 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2499 {
2500 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2501 status = eHAL_STATUS_SUCCESS;
2502 break;
2503 }
2504 }
2505 return status;
2506}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002507
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2510{
2511 eHalStatus status = eHAL_STATUS_SUCCESS;
2512 tANI_U8 num20MHzChannelsFound = 0;
2513 VOS_STATUS vosStatus;
2514 tANI_U8 Index = 0;
2515 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002516
Jeff Johnson295189b2012-06-20 16:38:30 -07002517
2518 //TODO: this interface changed to include the 40MHz channel list
2519 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2520 // Read the scan channel list (including the power limit) from EEPROM
2521 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2522 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2523 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002525 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 status = eHAL_STATUS_FAILURE;
2527 }
2528 else
2529 {
2530 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2531 {
2532 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2533 }
2534 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2535 // Move the channel list to the global data
2536 // structure -- this will be used as the scan list
2537 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2538 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 }
2541 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2542 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2543 {
2544 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2545 }
2546 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2547 {
2548 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2549 }
2550 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return (status);
2553}
Jeff Johnson295189b2012-06-20 16:38:30 -07002554eHalStatus csrInitChannelList( tHalHandle hHal )
2555{
2556 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2557 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2559 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002560 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2561 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002563 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302564 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 return (status);
2566}
Jeff Johnson295189b2012-06-20 16:38:30 -07002567eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2568 tCsrUpdateConfigParam *pUpdateConfigParam)
2569{
2570 eHalStatus status = eHAL_STATUS_FAILURE;
2571 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2573 status = CsrInit11dInfo(pMac, ps11dinfo);
2574 return status;
2575}
2576
Jeff Johnson295189b2012-06-20 16:38:30 -07002577static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2578{
2579 eHalStatus status = eHAL_STATUS_FAILURE;
2580 tANI_U8 index;
2581 tANI_U32 count=0;
2582 tSirMacChanInfo *pChanInfo;
2583 tSirMacChanInfo *pChanInfoStart;
2584 tANI_BOOLEAN applyConfig = TRUE;
2585
Mihir Shetebc866f62014-02-13 16:08:53 +05302586 pMac->scan.currentCountryRSSI = -128;
2587
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 if(!ps11dinfo)
2589 {
2590 return (status);
2591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2593 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302594 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2595 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2596 ps11dinfo->Channels.channelList,
2597 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 }
2599 else
2600 {
2601 //No change
2602 return (eHAL_STATUS_SUCCESS);
2603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302605
2606 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2607 WNI_CFG_COUNTRY_CODE_LEN);
2608
2609
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 //Tush: at csropen get this initialized with default, during csr reset if this
2611 // already set with some value no need initilaize with default again
2612 if(0 == pMac->scan.countryCodeCurrent[0])
2613 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302614 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2615 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302618 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2619 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302621 vos_mem_set(pChanInfo,
2622 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2623 0);
2624
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002626 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2627 {
2628 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2629 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2630 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2631 pChanInfo++;
2632 count++;
2633 }
2634 if(count)
2635 {
2636 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2637 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302638 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002639 }
2640 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2641 if( HAL_STATUS_SUCCESS(status) )
2642 {
2643 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2644 {
2645 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2646 {
2647 applyConfig = FALSE;
2648 }
2649 }
2650
2651 if(TRUE == applyConfig)
2652 {
2653 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002654 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002655 }
2656
2657 }
2658 return (status);
2659}
2660/* Initialize the Channel + Power List in the local cache and in the CFG */
2661eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2662{
2663 tANI_U8 index;
2664 tANI_U32 count=0;
2665 tSirMacChanInfo *pChanInfo;
2666 tSirMacChanInfo *pChanInfoStart;
2667
2668 if(!ps11dinfo || !pMac)
2669 {
2670 return eHAL_STATUS_FAILURE;
2671 }
2672
Kiet Lam64c1b492013-07-12 13:56:44 +05302673 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2674 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002675 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302676 vos_mem_set(pChanInfo,
2677 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2678 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002679 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002680
2681 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2682 {
2683 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2684 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2685 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2686 pChanInfo++;
2687 count++;
2688 }
2689 if(count)
2690 {
2691 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2692 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302693 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 }
2695
Jeff Johnsone7245742012-09-05 17:12:55 -07002696 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002697}
2698
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302699/**
2700 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2701 * list
2702 *
2703 * @pMac: pointer to global mac
2704 * @sessionId: session id for the cmd
2705 * @pList: pending list from which cmd needs to be removed
2706 * @pCommand: cmd to be removed, can be NULL
2707 * @eRoamReason: cmd with reason to be removed
2708 *
2709 * Remove duplicate command from the pending list.
2710 *
2711 * Return: void
2712 */
2713void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2714 tANI_U32 sessionId, tDblLinkList *pList,
2715 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002716{
2717 tListElem *pEntry, *pNextEntry;
2718 tSmeCmd *pDupCommand;
2719 tDblLinkList localList;
2720
2721 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302722 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302724 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 return;
2726 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302727 csrLLLock(pList);
2728 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2729 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302731 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2732 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2733 /*
Abhishek Singhd2ce6802018-05-08 15:21:06 +05302734 * If pCommand is not NULL remove the similar duplicate cmd for same
2735 * reason as pCommand. If pCommand is NULL then check if eRoamReason is
2736 * eCsrForcedDisassoc (disconnect) and remove all roam command for the
2737 * sessionId, else if eRoamReason is eCsrHddIssued (connect) remove all
2738 * connect (non disconenct) commands.
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302739 */
2740 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2741 ((pCommand->command == pDupCommand->command) &&
2742 /*
2743 * This peermac check is requried for Softap/GO scenarios
2744 * For STA scenario below OR check will suffice as pCommand
2745 * will always be NULL for STA scenarios
2746 */
2747 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2748 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2749 ((pCommand->u.roamCmd.roamReason ==
2750 pDupCommand->u.roamCmd.roamReason) ||
2751 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2752 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2753 /* OR if pCommand is NULL */
2754 ((sessionId == pDupCommand->sessionId) &&
2755 (eSmeCommandRoam == pDupCommand->command) &&
2756 ((eCsrForcedDisassoc == eRoamReason) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05302757 (eCsrHddIssued == eRoamReason &&
2758 !CSR_IS_DISCONNECT_COMMAND(pDupCommand)))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302760 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2761 pDupCommand->u.roamCmd.roamReason);
2762 /* Remove the 'stale' roam command from the pending list */
2763 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 }
2766 pEntry = pNextEntry;
2767 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302768 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002769
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302770 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 {
2772 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302773 /* Tell caller that the command is cancelled */
2774 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2775 pDupCommand->u.roamCmd.roamId,
2776 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 csrReleaseCommandRoam(pMac, pDupCommand);
2778 }
2779 csrLLClose(&localList);
2780}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302781
2782/**
2783 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2784 * from pending lists.
2785 *
2786 * @pMac: pointer to global mac
2787 * @sessionId: session id for the cmd
2788 * @pCommand: cmd to be removed, can be null
2789 * @eRoamReason: cmd with reason to be removed
2790 *
2791 * Remove duplicate command from the sme and roam pending list.
2792 *
2793 * Return: void
2794 */
2795void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2796 tANI_U32 sessionId, tSmeCmd *pCommand,
2797 eCsrRoamReason eRoamReason)
2798{
2799 /* Always lock active list before locking pending lists */
2800 csrLLLock(&pMac->sme.smeCmdActiveList);
2801 csr_roam_remove_duplicate_cmd_from_list(pMac,
2802 sessionId, &pMac->sme.smeCmdPendingList,
2803 pCommand, eRoamReason);
2804 csr_roam_remove_duplicate_cmd_from_list(pMac,
2805 sessionId, &pMac->roam.roamCmdPendingList,
2806 pCommand, eRoamReason);
2807 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2808}
2809
Jeff Johnson295189b2012-06-20 16:38:30 -07002810eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2811 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2812{
2813 eHalStatus status = eHAL_STATUS_SUCCESS;
2814#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2815 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2816#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302817 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2819 {
2820 pSession = CSR_GET_SESSION( pMac, sessionId );
2821 }
2822 else
2823 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002824 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 VOS_ASSERT(0);
2826 return eHAL_STATUS_FAILURE;
2827 }
krunal soni587bf012014-02-04 12:35:11 -08002828
2829 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2830 {
2831 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2832 return eHAL_STATUS_FAILURE;
2833 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002834
krunal soni587bf012014-02-04 12:35:11 -08002835 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2836
krunal soni7f7d2c92014-02-06 15:08:43 -08002837 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002839 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002841 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2842 /*
2843 * Decrement bRefAssocStartCnt for FT reassoc failure.
2844 * Reason: For FT reassoc failures, we first call
2845 * csrRoamCallCallback before notifying a failed roam
2846 * completion through csrRoamComplete. The latter in
2847 * turn calls csrRoamProcessResults which tries to
2848 * once again call csrRoamCallCallback if bRefAssocStartCnt
2849 * is non-zero. Since this is redundant for FT reassoc
2850 * failure, decrement bRefAssocStartCnt.
2851 */
2852 pSession->bRefAssocStartCnt--;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302853 } else if (u1 == eCSR_ROAM_ECSA_CHAN_CHANGE_RSP && u2 ==
2854 eCSR_ROAM_RESULT_NONE)
2855 pSession->connectedProfile.operationChannel =
2856 pRoamInfo->ap_chan_change_rsp->new_channel;
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002857
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05302858 if (eCSR_ROAM_RESULT_LOSTLINK == u2 ||
2859 eCSR_ROAM_LOSTLINK_DETECTED == u1)
2860 smsLog(pMac, LOG1, "eCSR_ROAM_RESULT_LOSTLINK ");
2861
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 if(NULL != pSession->callback)
2863 {
2864 if( pRoamInfo )
2865 {
2866 pRoamInfo->sessionId = (tANI_U8)sessionId;
2867 }
2868
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302869 /* avoid holding the global lock when making the roaming callback, original change came
2870 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2871 is possible on other OS ports where the callback may need to take locks to protect
2872 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2874 that may actually depend on the lock being held */
2875 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2876 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2877 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2878 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302879 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2880 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002881#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302882 vos_mem_set(&connectionStatus,
2883 sizeof(vos_event_wlan_status_payload_type), 0);
2884
krunal soni7f7d2c92014-02-06 15:08:43 -08002885 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 {
2887 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2888 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2889 if(NULL != pRoamInfo->pBssDesc)
2890 {
2891 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2892 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2895 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2896 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302897 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302898 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2899 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302900
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302902 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2905 {
2906 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2907 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302908 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 if(eCSR_ROAM_RESULT_FORCED == u2)
2911 {
2912 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2913 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
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_RESULT_DISASSOC_IND == u2)
2917 {
2918 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2919 connectionStatus.reason = eCSR_REASON_DISASSOC;
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_DEAUTH_IND == u2)
2923 {
2924 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2925 connectionStatus.reason = eCSR_REASON_DEAUTH;
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#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2929
2930 return (status);
2931}
Jeff Johnson295189b2012-06-20 16:38:30 -07002932// Returns whether handoff is currently in progress or not
2933tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2934{
2935#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2936 return csrNeighborRoamIsHandoffInProgress(pMac);
2937#else
2938 return eANI_BOOLEAN_FALSE;
2939#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002940}
Jeff Johnson295189b2012-06-20 16:38:30 -07002941eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2942 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2943{
2944 eHalStatus status = eHAL_STATUS_SUCCESS;
2945 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2946 tANI_U16 reasonCode;
2947 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002948
2949 if(!pSession)
2950 {
2951 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2952 return eHAL_STATUS_FAILURE;
2953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002954
2955 //Restore AC weight in case we change it
2956 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2957 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002958 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 -07002959 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2960 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2961 }
2962
2963 if ( fMICFailure )
2964 {
2965 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2966 }
2967 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2968 {
2969 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002970 }
2971 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 {
2973 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002975#ifdef WLAN_FEATURE_VOWIFI_11R
2976 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2977 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2978 {
2979 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302980 vos_mem_copy(&bssId,
2981 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2982 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002983 }
2984 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002985#endif
2986 if(pSession->pConnectBssDesc)
2987 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302988 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002990
Jeff Johnson295189b2012-06-20 16:38:30 -07002991
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302992 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2993 " subState = %s reason=%d"),
2994 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2995 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002996
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2998
2999 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
3000
3001 if(HAL_STATUS_SUCCESS(status))
3002 {
3003 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003004#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3005 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
3006 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
3007 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003008 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
3010 }
3011#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003012 }
3013 else
3014 {
3015 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
3016 }
3017
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 return (status);
3019}
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
Jeff Johnson295189b2012-06-20 16:38:30 -07003021/* ---------------------------------------------------------------------------
3022 \fn csrRoamIssueDisassociateStaCmd
3023 \brief csr function that HDD calls to disassociate a associated station
3024 \param sessionId - session Id for Soft AP
3025 \param pPeerMacAddr - MAC of associated station to delete
3026 \param reason - reason code, be one of the tSirMacReasonCodes
3027 \return eHalStatus
3028 ---------------------------------------------------------------------------*/
3029eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303030 tANI_U32 sessionId,
3031#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3032 const tANI_U8 *pPeerMacAddr,
3033#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303035#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 tANI_U32 reason)
3037{
3038 eHalStatus status = eHAL_STATUS_SUCCESS;
3039 tSmeCmd *pCommand;
3040
3041 do
3042 {
3043 pCommand = csrGetCommandBuffer( pMac );
3044 if ( !pCommand )
3045 {
3046 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3047 status = eHAL_STATUS_RESOURCES;
3048 break;
3049 }
3050 pCommand->command = eSmeCommandRoam;
3051 pCommand->sessionId = (tANI_U8)sessionId;
3052 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
3053 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
3054 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
3055 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3056 if( !HAL_STATUS_SUCCESS( status ) )
3057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003058 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 csrReleaseCommandRoam( pMac, pCommand );
3060 }
3061 }while(0);
3062
3063 return status;
3064}
3065
3066
Jeff Johnson295189b2012-06-20 16:38:30 -07003067/* ---------------------------------------------------------------------------
3068 \fn csrRoamIssueDeauthSta
3069 \brief csr function that HDD calls to delete a associated station
3070 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303071 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 \return eHalStatus
3073 ---------------------------------------------------------------------------*/
3074eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303075 tANI_U32 sessionId,
3076 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003077{
3078 eHalStatus status = eHAL_STATUS_SUCCESS;
3079 tSmeCmd *pCommand;
3080
3081 do
3082 {
3083 pCommand = csrGetCommandBuffer( pMac );
3084 if ( !pCommand )
3085 {
3086 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3087 status = eHAL_STATUS_RESOURCES;
3088 break;
3089 }
3090 pCommand->command = eSmeCommandRoam;
3091 pCommand->sessionId = (tANI_U8)sessionId;
3092 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303093 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3094 sizeof(tSirMacAddr));
3095 pCommand->u.roamCmd.reason =
3096 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3098 if( !HAL_STATUS_SUCCESS( status ) )
3099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003100 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 csrReleaseCommandRoam( pMac, pCommand );
3102 }
3103 }while(0);
3104
3105 return status;
3106}
Jeff Johnson295189b2012-06-20 16:38:30 -07003107eHalStatus
3108csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3109 tANI_BOOLEAN bEnable )
3110{
3111 eHalStatus status = eHAL_STATUS_FAILURE;
3112 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3113 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 if (!pSession)
3115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003116 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 return (status);
3118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 if (pSession->pConnectBssDesc)
3120 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303121 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 }
3123 else
3124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003125 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 return (status);
3127 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003128 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3129 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3131 return (status);
3132}
Jeff Johnson295189b2012-06-20 16:38:30 -07003133eHalStatus
3134csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3135 VOS_MODULE_ID modId, void *pUsrContext,
3136 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3137{
3138 eHalStatus status = eHAL_STATUS_SUCCESS;
3139 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3140 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 if (!pSession)
3142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003143 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 return (status);
3145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 if(pSession->pConnectBssDesc)
3147 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303148 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 }
3150 else
3151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003152 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 return (status);
3154 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003155 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3156 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3158 return (status);
3159}
Jeff Johnson295189b2012-06-20 16:38:30 -07003160eHalStatus
3161csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3162 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3163{
3164 eHalStatus status = eHAL_STATUS_SUCCESS;
3165 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3167
3168 if (!pSession)
3169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003170 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 return (status);
3172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 if(pSession->pConnectBssDesc)
3174 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303175 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 }
3177 else
3178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003179 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 return (status);
3181 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003182 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3183 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003184
3185 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3186
3187 return (status);
3188}
Jeff Johnson295189b2012-06-20 16:38:30 -07003189eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3190{
3191 eHalStatus status = eHAL_STATUS_SUCCESS;
3192 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3193 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003194
3195 if (!pSession)
3196 {
3197 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3198 return eHAL_STATUS_FAILURE;
3199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003200
3201 if(pSession->pConnectBssDesc)
3202 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303203 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003205 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3206 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3208
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303209 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303210 if(HAL_STATUS_SUCCESS(status))
3211 {
3212 csrRoamLinkDown(pMac, sessionId);
3213 }
3214 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003215 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303216 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3217 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003218 }
3219
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 return (status);
3221}
3222
Jeff Johnson295189b2012-06-20 16:38:30 -07003223eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3224{
3225 eHalStatus status = eHAL_STATUS_SUCCESS;
3226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3227 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003228
3229 if(!pSession)
3230 {
3231 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3232 return eHAL_STATUS_FAILURE;
3233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003234
3235 // If no BSS description was found in this connection (happens with start IBSS), then
3236 // nix the BSS description that we keep around for the connected BSS) and get out...
3237 if(NULL == pBssDesc)
3238 {
3239 csrFreeConnectBssDesc(pMac, sessionId);
3240 }
3241 else
3242 {
3243 size = pBssDesc->length + sizeof( pBssDesc->length );
3244 if(NULL != pSession->pConnectBssDesc)
3245 {
3246 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3247 {
3248 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3249 csrFreeConnectBssDesc(pMac, sessionId);
3250 }
3251 }
3252 if(NULL == pSession->pConnectBssDesc)
3253 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303254 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303256 if (NULL == pSession->pConnectBssDesc)
3257 status = eHAL_STATUS_FAILURE;
3258 else
3259 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 return (status);
3262}
3263
Jeff Johnson295189b2012-06-20 16:38:30 -07003264eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3265 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3266 tDot11fBeaconIEs *pIes)
3267{
3268 eHalStatus status = eHAL_STATUS_SUCCESS;
3269 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303271 if (pIes == NULL)
3272 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003273
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 do
3275 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303276 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3277 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 //get qos
3279 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3280 //get SSID
3281 if(pIes->SSID.present)
3282 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303283 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3285 }
3286 else
3287 pBssConfig->SSID.length = 0;
3288 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003290 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 //Return failed if profile doesn't have an SSID either.
3292 if(pProfile->SSIDs.numOfSSIDs == 0)
3293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003294 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 status = eHAL_STATUS_FAILURE;
3296 break;
3297 }
3298 }
3299 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3300 {
3301 pBssConfig->eBand = eCSR_BAND_5G;
3302 }
3303 else
3304 {
3305 pBssConfig->eBand = eCSR_BAND_24;
3306 }
3307 //phymode
3308 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3309 {
3310 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3311 }
3312 else
3313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003314 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 //force it
3316 if(eCSR_BAND_24 == pBssConfig->eBand)
3317 {
3318 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3319 }
3320 else
3321 {
3322 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3323 }
3324 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +05303325 smsLog(pMac, LOG1, FL("phyMode %d uCfgDot11Mode %d"),
3326 pProfile->phyMode, pBssConfig->uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 //Qos
3328 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3329 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3330 {
3331 //Joining BSS is not 11n capable and WMM is disabled on client.
3332 //Disable QoS and WMM
3333 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3334 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303335
3336 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303337 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303338 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3339 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3340 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3341 {
3342 //Joining BSS is 11n capable and WMM is disabled on AP.
3343 //Assume all HT AP's are QOS AP's and enable WMM
3344 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3345 }
3346
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 //auth type
3348 switch( pProfile->negotiatedAuthType )
3349 {
3350 default:
3351 case eCSR_AUTH_TYPE_WPA:
3352 case eCSR_AUTH_TYPE_WPA_PSK:
3353 case eCSR_AUTH_TYPE_WPA_NONE:
3354 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3355 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3356 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 case eCSR_AUTH_TYPE_SHARED_KEY:
3358 pBssConfig->authType = eSIR_SHARED_KEY;
3359 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 case eCSR_AUTH_TYPE_AUTOSWITCH:
3361 pBssConfig->authType = eSIR_AUTO_SWITCH;
3362 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303363 case eCSR_AUTH_TYPE_SAE:
3364 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
3365 break;
3366
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 }
3368 //short slot time
3369 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3370 {
3371 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3372 }
3373 else
3374 {
3375 pBssConfig->uShortSlotTime = 0;
3376 }
3377 if(pBssConfig->BssCap.ibss)
3378 {
3379 //We don't support 11h on IBSS
3380 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3381 }
3382 else
3383 {
3384 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3385 }
3386 //power constraint
3387 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3388 //heartbeat
3389 if ( CSR_IS_11A_BSS( pBssDesc ) )
3390 {
3391 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3392 }
3393 else
3394 {
3395 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3396 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303397 /*
3398 * Join timeout, if we find a BeaconInterval in the BssDescription,
3399 * then set the Join Timeout to be 3 BeaconInterval.
3400 */
3401 if (pBssDesc->beaconInterval)
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 {
3403 //Make sure it is bigger than the minimal
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303404 pBssConfig->uJoinTimeOut =
3405 CSR_ROAM_MAX(3 * pBssDesc->beaconInterval,
3406 CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303408 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 {
3410 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3411 }
3412 //validate CB
3413 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Abhishek Singhe3beee22017-07-31 15:35:40 +05303414 if (CSR_IS_CHANNEL_24GHZ(pBssDesc->channelId) &&
3415 pProfile->force_24ghz_in_ht20) {
3416 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
3417 smsLog(pMac, LOG1,
3418 FL("force_24ghz_in_ht20 is set so set cbmode to 0"));
3419 }
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303420 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3421 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 return (status);
3424}
3425
Jeff Johnson295189b2012-06-20 16:38:30 -07003426static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3427 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3428{
3429 eHalStatus status = eHAL_STATUS_SUCCESS;
3430 tANI_U8 operationChannel = 0;
3431 tANI_U8 qAPisEnabled = FALSE;
3432 //SSID
3433 pBssConfig->SSID.length = 0;
3434 if(pProfile->SSIDs.numOfSSIDs)
3435 {
3436 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303437 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3438 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 }
3440 else
3441 {
3442 //SSID must present
3443 return eHAL_STATUS_FAILURE;
3444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 //Settomg up the capabilities
3446 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3447 {
3448 pBssConfig->BssCap.ibss = 1;
3449 }
3450 else
3451 {
3452 pBssConfig->BssCap.ess = 1;
3453 }
3454 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3455 {
3456 pBssConfig->BssCap.privacy = 1;
3457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 pBssConfig->eBand = pMac->roam.configParam.eBand;
3459 //phymode
3460 if(pProfile->ChannelInfo.ChannelList)
3461 {
3462 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3465 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 //QOS
3467 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 if ( pBssConfig->BssCap.ess == 1 )
3469 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 /*For Softap case enable WMM*/
3471 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3472 qAPisEnabled = TRUE;
3473 }
3474 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3476 qAPisEnabled = TRUE;
3477 } else {
3478 qAPisEnabled = FALSE;
3479 }
3480 } else {
3481 qAPisEnabled = TRUE;
3482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3484 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3485 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3486 )
3487 {
3488 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3489 } else {
3490 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3491 }
3492
3493 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003494 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 {
3496 default:
3497 case eCSR_AUTH_TYPE_WPA:
3498 case eCSR_AUTH_TYPE_WPA_PSK:
3499 case eCSR_AUTH_TYPE_WPA_NONE:
3500 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3501 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3502 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 case eCSR_AUTH_TYPE_SHARED_KEY:
3504 pBssConfig->authType = eSIR_SHARED_KEY;
3505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 case eCSR_AUTH_TYPE_AUTOSWITCH:
3507 pBssConfig->authType = eSIR_AUTO_SWITCH;
3508 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303509 case eCSR_AUTH_TYPE_SAE:
3510 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
3511 break;
3512
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 }
3514 //short slot time
3515 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3516 {
3517 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3518 }
3519 else
3520 {
3521 pBssConfig->uShortSlotTime = 0;
3522 }
3523 //power constraint. We don't support 11h on IBSS
3524 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3525 pBssConfig->uPowerLimit = 0;
3526 //heartbeat
3527 if ( eCSR_BAND_5G == pBssConfig->eBand )
3528 {
3529 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3530 }
3531 else
3532 {
3533 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3534 }
3535 //Join timeout
3536 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003537
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 return (status);
3539}
Jeff Johnson295189b2012-06-20 16:38:30 -07003540static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3541{
3542 eHalStatus status = eHAL_STATUS_FAILURE;
3543 tDot11fBeaconIEs *pIes = NULL;
3544
3545 do
3546 {
3547 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3548 {
3549 //err msg
3550 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003551 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 break;
3553 }
3554 //check if the AP is QAP & it supports APSD
3555 if( CSR_IS_QOS_BSS(pIes) )
3556 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303557 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 }
3559 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303560
3561 if (NULL != pIes)
3562 {
3563 vos_mem_free(pIes);
3564 }
3565
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 return status;
3567}
3568
Jeff Johnson295189b2012-06-20 16:38:30 -07003569void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3570{
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3572 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3573 // See !!Note: below in this function...
3574 tANI_U32 PrivacyEnabled = 0;
3575 tANI_U32 RsnEnabled = 0;
3576 tANI_U32 WepDefaultKeyId = 0;
3577 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3578 tANI_U32 Key0Length = 0;
3579 tANI_U32 Key1Length = 0;
3580 tANI_U32 Key2Length = 0;
3581 tANI_U32 Key3Length = 0;
3582
3583 // Reserve for the biggest key
3584 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3585 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3586 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3587 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3588
3589 switch ( pProfile->negotiatedUCEncryptionType )
3590 {
3591 case eCSR_ENCRYPT_TYPE_NONE:
3592
3593 // for NO encryption, turn off Privacy and Rsn.
3594 PrivacyEnabled = 0;
3595 RsnEnabled = 0;
3596
3597 // WEP key length and Wep Default Key ID don't matter in this case....
3598
3599 // clear out the WEP keys that may be hanging around.
3600 Key0Length = 0;
3601 Key1Length = 0;
3602 Key2Length = 0;
3603 Key3Length = 0;
3604
3605 break;
3606
3607 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303608 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003609
3610 // Privacy is ON. NO RSN for Wep40 static key.
3611 PrivacyEnabled = 1;
3612 RsnEnabled = 0;
3613
3614 // Set the Wep default key ID.
3615 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 // Wep key size if 5 bytes (40 bits).
3617 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3618
3619 // set encryption keys in the CFG database or clear those that are not present in this profile.
3620 if ( pProfile->Keys.KeyLength[0] )
3621 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303622 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3623 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3625 }
3626 else
3627 {
3628 Key0Length = 0;
3629 }
3630
3631 if ( pProfile->Keys.KeyLength[1] )
3632 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303633 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3634 WNI_CFG_WEP_KEY_LENGTH_5);
3635 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 }
3637 else
3638 {
3639 Key1Length = 0;
3640 }
3641
3642 if ( pProfile->Keys.KeyLength[2] )
3643 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303644 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3645 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3647 }
3648 else
3649 {
3650 Key2Length = 0;
3651 }
3652
3653 if ( pProfile->Keys.KeyLength[3] )
3654 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303655 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3656 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3658 }
3659 else
3660 {
3661 Key3Length = 0;
3662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 break;
3664
3665 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303666 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003667
3668 // Privacy is ON. NO RSN for Wep40 static key.
3669 PrivacyEnabled = 1;
3670 RsnEnabled = 0;
3671
3672 // Set the Wep default key ID.
3673 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3674
3675 // Wep key size if 13 bytes (104 bits).
3676 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3677
3678 // set encryption keys in the CFG database or clear those that are not present in this profile.
3679 if ( pProfile->Keys.KeyLength[0] )
3680 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303681 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3682 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3684 }
3685 else
3686 {
3687 Key0Length = 0;
3688 }
3689
3690 if ( pProfile->Keys.KeyLength[1] )
3691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303692 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3693 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3695 }
3696 else
3697 {
3698 Key1Length = 0;
3699 }
3700
3701 if ( pProfile->Keys.KeyLength[2] )
3702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303703 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3704 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3706 }
3707 else
3708 {
3709 Key2Length = 0;
3710 }
3711
3712 if ( pProfile->Keys.KeyLength[3] )
3713 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303714 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3715 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3717 }
3718 else
3719 {
3720 Key3Length = 0;
3721 }
3722
3723 break;
3724
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 case eCSR_ENCRYPT_TYPE_TKIP:
3726 case eCSR_ENCRYPT_TYPE_AES:
3727#ifdef FEATURE_WLAN_WAPI
3728 case eCSR_ENCRYPT_TYPE_WPI:
3729#endif /* FEATURE_WLAN_WAPI */
3730 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3731 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3732 PrivacyEnabled = (0 != fPrivacy);
3733
3734 // turn on RSN enabled for WPA associations
3735 RsnEnabled = 1;
3736
3737 // WEP key length and Wep Default Key ID don't matter in this case....
3738
3739 // clear out the static WEP keys that may be hanging around.
3740 Key0Length = 0;
3741 Key1Length = 0;
3742 Key2Length = 0;
3743 Key3Length = 0;
3744
3745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 default:
3747 PrivacyEnabled = 0;
3748 RsnEnabled = 0;
3749 break;
3750 }
3751
3752 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3753 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3754 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3755 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3756 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3757 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3758 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3759 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3760}
3761
Jeff Johnson295189b2012-06-20 16:38:30 -07003762static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3763{
3764 tANI_U32 len = 0;
3765 if(pSSID->length <= WNI_CFG_SSID_LEN)
3766 {
3767 len = pSSID->length;
3768 }
3769 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3770}
3771
Jeff Johnson295189b2012-06-20 16:38:30 -07003772eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3773{
3774 eHalStatus status = eHAL_STATUS_SUCCESS;
3775 tANI_U32 QoSEnabled;
3776 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 // set the CFG enable/disable variables based on the qosType being configured...
3778 switch( qosType )
3779 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3781 QoSEnabled = FALSE;
3782 WmeEnabled = TRUE;
3783 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3785 QoSEnabled = FALSE;
3786 WmeEnabled = TRUE;
3787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3789 QoSEnabled = FALSE;
3790 WmeEnabled = TRUE;
3791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3793 QoSEnabled = TRUE;
3794 WmeEnabled = FALSE;
3795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 case eCSR_MEDIUM_ACCESS_11e_HCF:
3797 QoSEnabled = TRUE;
3798 WmeEnabled = FALSE;
3799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 default:
3801 case eCSR_MEDIUM_ACCESS_DCF:
3802 QoSEnabled = FALSE;
3803 WmeEnabled = FALSE;
3804 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 }
3806 //save the WMM setting for later use
3807 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303808 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 return (status);
3810}
Jeff Johnson295189b2012-06-20 16:38:30 -07003811static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303812 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003813{
3814 eHalStatus status = eHAL_STATUS_FAILURE;
3815 int i;
3816 eCsrCfgDot11Mode cfgDot11Mode;
3817 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303818 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303819 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3820 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003822
3823 if( NULL != pIes )
3824 {
3825 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 // Originally, we thought that for 11a networks, the 11a rates are always
3827 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3828 // appear in the Operational Rate set. Consequently, in either case, we
3829 // would blindly put the rates we support into our Operational Rate set
3830 // (including the basic rates, which we have already verified are
3831 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 // However, it turns out that this is not always the case. Some AP's
3833 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3834 // too. Now, we're a little more careful:
3835 pDstRate = pOpRateSet->rate;
3836 if(pIes->SuppRates.present)
3837 {
3838 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3839 {
3840 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3841 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003842 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3843 {
3844 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3845 *pDstRate++ = pIes->SuppRates.rates[ i ];
3846 pOpRateSet->numRates++;
3847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 }
3849 }
3850 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303851 /* If there are Extended Rates in the beacon, we will reflect those
3852 * extended rates that we support in out Extended Operational Rate
3853 * set*/
3854 pDstRate = pExRateSet->rate;
3855 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303857 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303859 if (csrRatesIsDot11RateSupported(pMac,
3860 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303862 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3863 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303865 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3866 &rateBitmap);
3867 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3868 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 }
3870 }
3871 }
3872 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303873 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 }//Parsing BSSDesc
3875 else
3876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003877 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 }
3879 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3880 return status;
3881}
3882
3883static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3884 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3885{
3886 int i;
3887 tANI_U8 *pDstRate;
3888 eCsrCfgDot11Mode cfgDot11Mode;
3889 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3890 tANI_U32 OperationalRatesLength = 0;
3891 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3892 tANI_U32 ExtendedOperationalRatesLength = 0;
3893 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3894 tANI_U32 ProprietaryOperationalRatesLength = 0;
3895 tANI_U32 PropRatesEnable = 0;
3896 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3897 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 if( NULL != pIes )
3900 {
3901 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 // Originally, we thought that for 11a networks, the 11a rates are always
3903 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3904 // appear in the Operational Rate set. Consequently, in either case, we
3905 // would blindly put the rates we support into our Operational Rate set
3906 // (including the basic rates, which we have already verified are
3907 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 // However, it turns out that this is not always the case. Some AP's
3909 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3910 // too. Now, we're a little more careful:
3911 pDstRate = OperationalRates;
3912 if(pIes->SuppRates.present)
3913 {
3914 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3915 {
3916 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3917 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3918 {
3919 *pDstRate++ = pIes->SuppRates.rates[ i ];
3920 OperationalRatesLength++;
3921 }
3922 }
3923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3925 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3926 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3927 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3928 {
3929 // If there are Extended Rates in the beacon, we will reflect those
3930 // extended rates that we support in out Extended Operational Rate
3931 // set:
3932 pDstRate = ExtendedOperationalRates;
3933 if(pIes->ExtSuppRates.present)
3934 {
3935 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3936 {
3937 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3938 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3939 {
3940 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3941 ExtendedOperationalRatesLength++;
3942 }
3943 }
3944 }
3945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 // Enable proprietary MAC features if peer node is Airgo node and STA
3947 // user wants to use them
3948 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3949 {
3950 PropRatesEnable = 1;
3951 }
3952 else
3953 {
3954 PropRatesEnable = 0;
3955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 // For ANI network companions, we need to populate the proprietary rate
3957 // set with any proprietary rates we found in the beacon, only if user
3958 // allows them...
3959 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3960 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3961 {
3962 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3963 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3964 {
3965 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3966 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303967 vos_mem_copy(ProprietaryOperationalRates,
3968 pIes->Airgo.PropSuppRates.rates,
3969 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
3971 else {
3972 // No proprietary modes...
3973 ProprietaryOperationalRatesLength = 0;
3974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 /* Get MCS Rate */
3976 pDstRate = MCSRateIdxSet;
3977 if ( pIes->HTCaps.present )
3978 {
3979 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3980 {
3981 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3982 {
3983 MCSRateLength++;
3984 *pDstRate++ = i;
3985 }
3986 }
3987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 // Set the operational rate set CFG variables...
3989 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3990 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3991 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3992 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3993 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3994 ProprietaryOperationalRates,
3995 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3996 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3997 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3998 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3999 }//Parsing BSSDesc
4000 else
4001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004002 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 }
4004}
4005
Jeff Johnson295189b2012-06-20 16:38:30 -07004006static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
4007 tCsrRoamProfile *pProfile )
4008{
4009 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4010 { 8,
4011 { SIR_MAC_RATE_6,
4012 SIR_MAC_RATE_9,
4013 SIR_MAC_RATE_12,
4014 SIR_MAC_RATE_18,
4015 SIR_MAC_RATE_24,
4016 SIR_MAC_RATE_36,
4017 SIR_MAC_RATE_48,
4018 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4020 { 4,
4021 { SIR_MAC_RATE_1,
4022 SIR_MAC_RATE_2,
4023 SIR_MAC_RATE_5_5,
4024 SIR_MAC_RATE_11 } } };
4025
4026
4027 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4028 { SIR_MAC_RATE_72,
4029 SIR_MAC_RATE_96,
4030 SIR_MAC_RATE_108 } };
4031 eCsrCfgDot11Mode cfgDot11Mode;
4032 eCsrBand eBand;
4033 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4034 tANI_U32 OperationalRatesLength = 0;
4035 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4036 tANI_U32 ExtendedOperationalRatesLength = 0;
4037 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
4038 tANI_U32 ProprietaryOperationalRatesLength = 0;
4039 tANI_U32 PropRatesEnable = 0;
4040 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 if(pProfile->ChannelInfo.ChannelList)
4042 {
4043 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4047 // networks, the 11b rates appear in the Operational Rate set. In either case,
4048 // we can blindly put the rates we support into our Operational Rate set
4049 // (including the basic rates, which we have already verified are supported
4050 // earlier in the roaming decision).
4051 if ( eCSR_BAND_5G == eBand )
4052 {
4053 // 11a rates into the Operational Rate Set.
4054 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4055 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304056 vos_mem_copy(OperationalRates,
4057 DefaultSupportedRates11a.supportedRateSet.rate,
4058 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004059
4060 // Nothing in the Extended rate set.
4061 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 // populate proprietary rates if user allows them
4063 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4064 {
4065 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4066 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304067 vos_mem_copy(ProprietaryOperationalRates,
4068 DefaultSupportedPropRates.propRate,
4069 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 }
4071 else
4072 {
4073 // No proprietary modes
4074 ProprietaryOperationalRatesLength = 0;
4075 }
4076 }
4077 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4078 {
4079 // 11b rates into the Operational Rate Set.
4080 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4081 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304082 vos_mem_copy(OperationalRates,
4083 DefaultSupportedRates11b.supportedRateSet.rate,
4084 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 // Nothing in the Extended rate set.
4086 ExtendedOperationalRatesLength = 0;
4087 // No proprietary modes
4088 ProprietaryOperationalRatesLength = 0;
4089 }
4090 else
4091 {
4092 // 11G
4093
4094 // 11b rates into the Operational Rate Set.
4095 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4096 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304097 vos_mem_copy(OperationalRates,
4098 DefaultSupportedRates11b.supportedRateSet.rate,
4099 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004100
4101 // 11a rates go in the Extended rate set.
4102 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4103 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304104 vos_mem_copy(ExtendedOperationalRates,
4105 DefaultSupportedRates11a.supportedRateSet.rate,
4106 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004107
4108 // populate proprietary rates if user allows them
4109 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4110 {
4111 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4112 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304113 vos_mem_copy(ProprietaryOperationalRates,
4114 DefaultSupportedPropRates.propRate,
4115 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 }
4117 else
4118 {
4119 // No proprietary modes
4120 ProprietaryOperationalRatesLength = 0;
4121 }
4122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4124 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4125 {
4126 PropRatesEnable = 1;
4127 }
4128 else
4129 {
4130 PropRatesEnable = 0;
4131 }
4132
4133 // Set the operational rate set CFG variables...
4134 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4135 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4136 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4137 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4138 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4139 ProprietaryOperationalRates,
4140 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4141 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004142}
Jeff Johnson295189b2012-06-20 16:38:30 -07004143void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4144{
4145 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004146
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4148 tANI_U32 sessionId;
4149 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 if(NULL == pEntry)
4151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004152 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 return;
4154 }
4155 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4156 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304157 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4158 " current state : %d sub state : %d "),
4159 result, pMac->roam.curState[sessionId],
4160 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4162 {
4163 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4164 }
4165}
4166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4168tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4169{
4170 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4171 {
4172 return (WNI_CFG_PHY_MODE_11B);
4173 }
4174 else
4175 {
4176 if(eCSR_BAND_24 == band)
4177 return (WNI_CFG_PHY_MODE_11G);
4178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 return (WNI_CFG_PHY_MODE_11A);
4180}
Jeff Johnson295189b2012-06-20 16:38:30 -07004181
Jeff Johnsone7245742012-09-05 17:12:55 -07004182
4183#ifdef WLAN_FEATURE_11AC
4184ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4185{
4186 switch ( aniCBMode )
4187 {
4188 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4189 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4190 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4191 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4192 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4193 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4194 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4195 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4196 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004197 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004198 return PHY_SINGLE_CHANNEL_CENTERED;
4199 }
4200}
4201#endif
4202
Jeff Johnson295189b2012-06-20 16:38:30 -07004203//pIes may be NULL
4204eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4205 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304206 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004207{
4208 eHalStatus status = eHAL_STATUS_SUCCESS;
4209 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4210 tANI_U8 channel = 0;
4211 //Make sure we have the domain info for the BSS we try to connect to.
4212 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304213 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304215 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 {
4217 //Make sure the 11d info from this BSSDesc can be applied
4218 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304219 if (VOS_TRUE == resetCountry)
4220 {
4221 csrApplyCountryInformation(pMac, FALSE);
4222 }
4223 else
4224 {
4225 csrApplyCountryInformation(pMac, TRUE);
4226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 }
Kiran4a17ebe2013-01-31 10:43:43 -08004228 if ((csrIs11dSupported (pMac)) && pIes)
4229 {
4230 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004231 {
Kiran4a17ebe2013-01-31 10:43:43 -08004232 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004233 }
4234 else
4235 {
4236 //Let's also update the below to make sure we don't update CC while
4237 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304238 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004239 pBssDesc->bssId, sizeof(tSirMacAddr));
4240 }
Kiran4a17ebe2013-01-31 10:43:43 -08004241 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 //Qos
4244 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4245 //SSID
4246 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4247 //fragment threshold
4248 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4249 //RTS threshold
4250 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4251
4252 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 //Auth type
4254 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4255 //encryption type
4256 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4257 //short slot time
4258 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 //11d
4260 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4261 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4262 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 /*//11h
4264 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4265 */
4266 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4267 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004268
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004269 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 {
4271 channel = pProfile->operationChannel;
4272 }
4273 else
4274 {
4275 if(pBssDesc)
4276 {
4277 channel = pBssDesc->channelId;
4278 }
4279 }
4280 if(0 != channel)
4281 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304282 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4283 !pMac->roam.configParam.channelBondingMode24GHz &&
4284 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4285 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304287 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4288 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4289 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 }
4291 else
4292 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004293 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 }
4295 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004296#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004297 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4298 // in function csrConvertCBIniValueToPhyCBState()
4299 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4300 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004301 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004302 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004303 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004304 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304305 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004306 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004307 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004308 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004309 }
4310 else
4311#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4313 //Rate
4314 //Fixed Rate
4315 if(pBssDesc)
4316 {
4317 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4318 }
4319 else
4320 {
4321 csrSetCfgRateSetFromProfile(pMac, pProfile);
4322 }
4323 //Make this the last CFG to set. The callback will trigger a join_req
4324 //Join time out
4325 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4326
4327 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 return (status);
4329}
4330
Jeff Johnson295189b2012-06-20 16:38:30 -07004331eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4332 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4333{
4334 eHalStatus status;
4335 tBssConfigParam *pBssConfig;
4336 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004337
4338 if(!pSession)
4339 {
4340 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4341 return eHAL_STATUS_FAILURE;
4342 }
4343
Kiet Lam64c1b492013-07-12 13:56:44 +05304344 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4345 if ( NULL == pBssConfig )
4346 status = eHAL_STATUS_FAILURE;
4347 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304349 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4351 if(HAL_STATUS_SUCCESS(status))
4352 {
4353 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004354 /* This will allow to pass cbMode during join req */
4355 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 //For IBSS, we need to prepare some more information
4357 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 )
4360 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004361 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 }
4363 // If we are in an IBSS, then stop the IBSS...
4364 ////Not worry about WDS connection for now
4365 if ( csrIsConnStateIbss( pMac, sessionId ) )
4366 {
4367 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4368 }
4369 else
4370 {
4371 // if we are in an Infrastructure association....
4372 if ( csrIsConnStateInfra( pMac, sessionId ) )
4373 {
4374 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4375 // across SSIDs (roaming to a new SSID)... //
4376 //Not worry about WDS connection for now
4377 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304378 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 {
4380 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304381 status = csrRoamIssueDisassociate( pMac, sessionId,
4382 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304384 else
4385 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4387 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304388 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304390 // Set parameters for this Bss.
4391 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4392 pBssDesc, pBssConfig,
4393 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304397 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 {
4399 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4400 // Nothing to stop.
4401 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304403 )
4404 {
4405 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4406 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4407 // Set parameters for this Bss.
4408 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4409 pBssDesc, pBssConfig,
4410 pIes, is11rRoamingFlag);
4411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 }
4413 }
4414 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304415 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 return (status);
4418}
4419
Jeff Johnson295189b2012-06-20 16:38:30 -07004420eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4421 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4422{
4423 eCsrJoinState eRoamState = eCsrContinueRoaming;
4424 eHalStatus status;
4425 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4426 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004428
4429 if(!pSession)
4430 {
4431 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4432 return (eCsrStopRoaming);
4433 }
4434
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 if( CSR_IS_WDS_STA( pProfile ) )
4436 {
4437 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4438 if( !HAL_STATUS_SUCCESS( status ) )
4439 {
4440 eRoamState = eCsrStopRoaming;
4441 }
4442 }
4443 else
4444 {
4445 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4446 {
4447 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4448 return (eCsrStopRoaming);
4449 }
4450 if ( csrIsInfraBssDesc( pBssDesc ) )
4451 {
4452 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4453 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4454 // have changed and handle the changes (without disturbing the current association).
4455
4456 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4457 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4458 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4459 )
4460 {
4461 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4462 // with Authenticating first. To force this, stop the current association (Disassociate) and
4463 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4464 // a new Association.
4465 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4466 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004467 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4469 {
4470 eRoamState = eCsrReassocToSelfNoCapChange;
4471 }
4472 else
4473 {
4474 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304476 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4478 if(HAL_STATUS_SUCCESS(status))
4479 {
4480 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004481 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304483 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4484 pBssDesc, &bssConfig,
4485 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 if(!HAL_STATUS_SUCCESS(status))
4487 {
4488 eRoamState = eCsrStopRoaming;
4489 }
4490 }
4491 else
4492 {
4493 eRoamState = eCsrStopRoaming;
4494 }
4495 }//same profile
4496 }
4497 else
4498 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304499 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4501 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304502 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4503 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304507 }
4508 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 {
4510 // 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 -07004511 // stop the existing network before attempting to join the new network...
4512 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4513 {
4514 eRoamState = eCsrStopRoaming;
4515 }
4516 }
4517 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304518 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 {
4520 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4521 {
4522 eRoamState = eCsrStopRoaming;
4523 }
4524 }
4525 if( pIesLocal && !pScanResult->pvIes )
4526 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304527 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 }
4529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 return( eRoamState );
4531}
4532
Jeff Johnson295189b2012-06-20 16:38:30 -07004533eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4534 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4535{
4536 eHalStatus status = eHAL_STATUS_SUCCESS;
4537 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304538 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 roamInfo.pBssDesc = pBssDesc;
4540 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4541 return (status);
4542}
Jeff Johnson295189b2012-06-20 16:38:30 -07004543//In case no matching BSS is found, use whatever default we can find
4544static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4545{
4546 //Need to get all negotiated types in place first
4547 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004548 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 {
4550 default:
4551 case eCSR_AUTH_TYPE_WPA:
4552 case eCSR_AUTH_TYPE_WPA_PSK:
4553 case eCSR_AUTH_TYPE_WPA_NONE:
4554 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4555 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4556 break;
4557
4558 case eCSR_AUTH_TYPE_SHARED_KEY:
4559 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4560 break;
4561
4562 case eCSR_AUTH_TYPE_AUTOSWITCH:
4563 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4564 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304565 case eCSR_AUTH_TYPE_SAE:
4566 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4567 eCSR_AUTH_TYPE_SAE;
4568 break;
4569
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 }
4571 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4572 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4573 //In this case, the multicast encryption needs to follow the uncast ones.
4574 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4575 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4576}
4577
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004578
4579static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4580{
4581 switch(pCommand->u.roamCmd.roamReason)
4582 {
4583 case eCsrLostLink1:
4584 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4585 break;
4586 case eCsrLostLink2:
4587 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4588 break;
4589 case eCsrLostLink3:
4590 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4591 break;
4592 default:
4593 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4594 pCommand->u.roamCmd.roamReason);
4595 break;
4596 }
4597}
4598
Jeff Johnson295189b2012-06-20 16:38:30 -07004599static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4600{
4601 eHalStatus status;
4602 tCsrScanResult *pScanResult = NULL;
4603 eCsrJoinState eRoamState = eCsrStopRoaming;
4604 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4605 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4606 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4607#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4608 v_U8_t acm_mask = 0;
4609#endif
4610 tANI_U32 sessionId = pCommand->sessionId;
4611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4612 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4613 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004614
4615 if(!pSession)
4616 {
4617 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4618 return (eCsrStopRoaming);
4619 }
4620
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 do
4622 {
4623 // Check for Cardbus eject condition, before trying to Roam to any BSS
4624 //***if( !balIsCardPresent(pAdapter) ) break;
4625
Kiet Lam64c1b492013-07-12 13:56:44 +05304626 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304627 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 if(NULL != pBSSList)
4629 {
4630 // When handling AP's capability change, continue to associate to
4631 // same BSS and make sure pRoamBssEntry is not Null.
4632 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4633 {
4634 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4635 {
4636 //Try the first BSS
4637 pCommand->u.roamCmd.pLastRoamBss = NULL;
4638 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4639 }
4640 else
4641 {
4642 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4643 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4644 {
4645 //Done with all the BSSs
4646 //In this case, will tell HDD the completion
4647 break;
4648 }
4649 else
4650 {
4651 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304652 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4654 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4655 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4656 pRoamInfo = &roamInfo;
4657 }
4658 }
4659 while(pCommand->u.roamCmd.pRoamBssEntry)
4660 {
4661 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 /*If concurrency enabled take the concurrent connected channel first. */
4663 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304664 if (vos_concurrent_open_sessions_running() &&
4665 !csrIsValidMcConcurrentSession(pMac, sessionId,
4666 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 {
4668 concurrentChannel =
4669 csrGetConcurrentOperationChannel(pMac);
4670 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004671 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 if ((concurrentChannel) &&
4673 (concurrentChannel ==
4674 pScanResult->Result.BssDescriptor.channelId))
4675 {
4676 //make this 0 because we do not want the
4677 //below check to pass as we don't want to
4678 //connect on other channel
4679 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4680 FL("Concurrent channel match =%d"),
4681 concurrentChannel);
4682 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 }
4684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004685
4686 if (!concurrentChannel)
4687 {
4688
4689 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4690 sessionId, &pScanResult->Result.BssDescriptor,
4691 pCommand->u.roamCmd.roamId)))
4692 {
4693 //Ok to roam this
4694 break;
4695 }
4696 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004697 else
4698 {
4699 eRoamState = eCsrStopRoamingDueToConcurrency;
4700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4702 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4703 {
4704 //Done with all the BSSs
4705 fDone = eANI_BOOLEAN_TRUE;
4706 break;
4707 }
4708 }
4709 if(fDone)
4710 {
4711 break;
4712 }
4713 }
4714 }
4715 //We have something to roam, tell HDD when it is infra.
4716 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4717 //For WDS, the indication is eCSR_ROAM_WDS_IND
4718 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4719 {
4720 if(pRoamInfo)
4721 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004722 if(pSession->bRefAssocStartCnt)
4723 {
4724 pSession->bRefAssocStartCnt--;
4725 //Complete the last association attemp because a new one is about to be tried
4726 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4727 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004729 }
4730 }
4731 /* If the roaming has stopped, not to continue the roaming command*/
4732 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4733 {
4734 //No need to complete roaming here as it already completes
4735 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4736 pCommand->u.roamCmd.roamReason);
4737 eRoamState = eCsrStopRoaming;
4738 csrSetAbortRoamingCommand(pMac, pCommand);
4739 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304741 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 if(pScanResult)
4743 {
4744 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004747 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 fDone = eANI_BOOLEAN_TRUE;
4749 eRoamState = eCsrStopRoaming;
4750 break;
4751 }
4752 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4753 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4754 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4755 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4756 CSR_IS_QOS_BSS(pIesLocal) &&
4757 CSR_IS_UAPSD_BSS(pIesLocal) )
4758 {
4759#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4761 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 }
4764 else
4765 {
4766 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4767 }
4768 if( pIesLocal && !pScanResult->Result.pvIes)
4769 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304770 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772 }
4773 else
4774 {
4775 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4776 }
4777 roamInfo.pProfile = pProfile;
4778 pSession->bRefAssocStartCnt++;
4779 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4780 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4783 {
4784 // If this is a start IBSS profile, then we need to start the IBSS.
4785 if ( CSR_IS_START_IBSS(pProfile) )
4786 {
4787 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 // Attempt to start this IBSS...
4789 csrRoamAssignDefaultParam( pMac, pCommand );
4790 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4791 if(HAL_STATUS_SUCCESS(status))
4792 {
4793 if ( fSameIbss )
4794 {
4795 eRoamState = eCsrStartIbssSameIbss;
4796 }
4797 else
4798 {
4799 eRoamState = eCsrContinueRoaming;
4800 }
4801 }
4802 else
4803 {
4804 //it somehow fail need to stop
4805 eRoamState = eCsrStopRoaming;
4806 }
4807 break;
4808 }
4809 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 )
4812 {
4813 // Attempt to start this WDS...
4814 csrRoamAssignDefaultParam( pMac, pCommand );
4815 /* For AP WDS, we dont have any BSSDescription */
4816 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4817 if(HAL_STATUS_SUCCESS(status))
4818 {
4819 eRoamState = eCsrContinueRoaming;
4820 }
4821 else
4822 {
4823 //it somehow fail need to stop
4824 eRoamState = eCsrStopRoaming;
4825 }
4826 }
4827 else
4828 {
4829 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004830 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 eRoamState = eCsrStopRoaming;
4832 break;
4833 }
4834 }
4835 else //We have BSS
4836 {
4837 //Need to assign these value because they are used in csrIsSameProfile
4838 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004839 /* The OSEN IE doesn't provide the cipher suite.
4840 * Therefore set to constant value of AES */
4841 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4842 {
4843 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4844 eCSR_ENCRYPT_TYPE_AES;
4845 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4846 eCSR_ENCRYPT_TYPE_AES;
4847 }
4848 else
4849 {
4850 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4851 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4852 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4853 pScanResult->mcEncryptionType;
4854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4856 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4857 {
4858 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4859 {
4860 eRoamState = eCsrStartIbssSameIbss;
4861 break;
4862 }
4863 }
4864 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4865 {
4866 //trying to connect to the one already connected
4867 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4868 eRoamState = eCsrReassocToSelfNoCapChange;
4869 break;
4870 }
4871 // Attempt to Join this Bss...
4872 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4873 break;
4874 }
4875
4876 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4878 {
4879 //Need to indicate association_completion if association_start has been done
4880 if(pSession->bRefAssocStartCnt > 0)
4881 {
4882 pSession->bRefAssocStartCnt--;
4883 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004884 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4886 eCSR_ROAM_ASSOCIATION_COMPLETION,
4887 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4888 }
4889 }
4890
4891 return( eRoamState );
4892}
4893
Jeff Johnson295189b2012-06-20 16:38:30 -07004894static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4895{
4896 eHalStatus status = eHAL_STATUS_SUCCESS;
4897 eCsrJoinState RoamState;
4898 tANI_U32 sessionId = pCommand->sessionId;
4899
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 //***if( hddIsRadioStateOn( pAdapter ) )
4901 {
4902 // Attept to join a Bss...
4903 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004904
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004906 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 {
4908 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 // and if connected in Infrastructure mode...
4910 if ( csrIsConnStateInfra(pMac, sessionId) )
4911 {
4912 //... then we need to issue a disassociation
4913 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4914 if(!HAL_STATUS_SUCCESS(status))
4915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004916 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 //roam command is completed by caller in the failed case
4918 fComplete = eANI_BOOLEAN_TRUE;
4919 }
4920 }
4921 else if( csrIsConnStateIbss(pMac, sessionId) )
4922 {
4923 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4924 if(!HAL_STATUS_SUCCESS(status))
4925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004926 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 //roam command is completed by caller in the failed case
4928 fComplete = eANI_BOOLEAN_TRUE;
4929 }
4930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4932 {
4933 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4934 if(!HAL_STATUS_SUCCESS(status))
4935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004936 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 //roam command is completed by caller in the failed case
4938 fComplete = eANI_BOOLEAN_TRUE;
4939 }
4940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 else
4942 {
4943 fComplete = eANI_BOOLEAN_TRUE;
4944 }
4945 if(fComplete)
4946 {
4947 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004948 if(eCsrStopRoamingDueToConcurrency == RoamState)
4949 {
4950 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4951 }
4952 else
4953 {
4954 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 }
4957 }
4958 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4959 {
4960 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4961 }
4962 else if ( eCsrStartIbssSameIbss == RoamState )
4963 {
4964 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4965 }
4966 }//hddIsRadioStateOn
4967
4968 return status;
4969}
Jeff Johnson295189b2012-06-20 16:38:30 -07004970eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4971{
4972 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05304973 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 tCsrScanResult *pScanResult = NULL;
4975 tSirBssDescription *pBssDesc = NULL;
4976 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 sessionId = pCommand->sessionId;
4978 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004979
4980 if(!pSession)
4981 {
4982 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4983 return eHAL_STATUS_FAILURE;
4984 }
4985
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4987 {
4988 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004989 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4991 return eHAL_STATUS_FAILURE;
4992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 if (pCommand->u.roamCmd.pRoamBssEntry)
4994 {
4995 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4996 pBssDesc = &pScanResult->Result.BssDescriptor;
4997 }
4998 else
4999 {
5000 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005001 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
5003 return eHAL_STATUS_FAILURE;
5004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
5006 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
5007 return status;
5008}
5009
Jeff Johnson295189b2012-06-20 16:38:30 -07005010eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5011{
5012 eHalStatus status = eHAL_STATUS_SUCCESS;
5013 tCsrRoamInfo roamInfo;
5014 tANI_U32 sessionId = pCommand->sessionId;
5015 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005016
5017 if(!pSession)
5018 {
5019 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5020 return eHAL_STATUS_FAILURE;
5021 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05305022 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5023 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 switch ( pCommand->u.roamCmd.roamReason )
5025 {
5026 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005028 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 case eCsrSmeIssuedDisassocForHandoff:
5031 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
5032#if 0 // TODO : Confirm this change
5033 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
5034#else
5035 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
5036#endif
5037
5038 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005041 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005045 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 case eCsrHddIssuedReassocToSameAP:
5048 case eCsrSmeIssuedReassocToSameAP:
5049 {
5050 tDot11fBeaconIEs *pIes = NULL;
5051
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 if( pSession->pConnectBssDesc )
5053 {
5054 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5055 if(!HAL_STATUS_SUCCESS(status) )
5056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005057 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 }
5059 else
5060 {
5061 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5062 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5063 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5065 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5066 pSession->bRefAssocStartCnt++;
5067 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5068 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5069
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005070 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005071 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5072 &pCommand->u.roamCmd.roamProfile );
5073 if(!HAL_STATUS_SUCCESS(status))
5074 {
5075 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005076 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005077 }
5078
Kiet Lam64c1b492013-07-12 13:56:44 +05305079 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 pIes = NULL;
5081 }
5082 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305083 else
5084 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 break;
5086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005088 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5090 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5091 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005093 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5095 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005096
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 case eCsrStopBss:
5098 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5099 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5100 break;
5101
5102 case eCsrForcedDisassocSta:
5103 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5104 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5105 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5106 pCommand->u.roamCmd.reason);
5107 break;
5108
5109 case eCsrForcedDeauthSta:
5110 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5111 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5112 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5113 pCommand->u.roamCmd.reason);
5114 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005115
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005116 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005117 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005118 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5119 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005120 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005121
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305122#ifdef WLAN_FEATURE_LFR_MBB
5123 case ecsr_mbb_perform_preauth_reassoc:
5124 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5125 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5126 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305127 if (eHAL_STATUS_SUCCESS != status)
5128 {
5129 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5130 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5131 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5132 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305133 break;
5134#endif
5135
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 default:
5137 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5138
5139 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5140 {
5141 //Remember the roaming profile
5142 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305143 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5144 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305146 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5148 }
5149 }
5150
5151 //At this point, original uapsd_mask is saved in pCurRoamProfile
5152 //uapsd_mask in the pCommand may change from this point on.
5153
5154 // Attempt to roam with the new scan results (if we need to..)
5155 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005156 if(!HAL_STATUS_SUCCESS(status))
5157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005158 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 break;
5161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 return (status);
5163}
5164
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005165void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5166{
5167 pCommand->u.roamCmd.pLastRoamBss = NULL;
5168 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5169 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305170 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005171}
5172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5174{
5175 if(pCommand->u.roamCmd.fReleaseBssList)
5176 {
5177 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5178 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5179 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5180 }
5181 if(pCommand->u.roamCmd.fReleaseProfile)
5182 {
5183 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5184 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5185 }
5186 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5187 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305188 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005189}
5190
Jeff Johnson295189b2012-06-20 16:38:30 -07005191void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5192{
Kiet Lam64c1b492013-07-12 13:56:44 +05305193 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005194}
Jeff Johnson295189b2012-06-20 16:38:30 -07005195void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5196{
5197 tListElem *pEntry;
5198 tSmeCmd *pCommand;
5199 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005200 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5202 if ( pEntry )
5203 {
5204 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 // If the head of the queue is Active and it is a ROAM command, remove
5206 // and put this on the Free queue.
5207 if ( eSmeCommandRoam == pCommand->command )
5208 {
5209 //we need to process the result first before removing it from active list because state changes
5210 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5211 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5212 if( fReleaseCommand )
5213 {
5214 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5215 {
5216 csrReleaseCommandRoam( pMac, pCommand );
5217 }
5218 else
5219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005220 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005221 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 }
5223 }
5224 else
5225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005226 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005227 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 }
5229 }
5230 else
5231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005232 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 }
5234 }
5235 else
5236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005237 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 if( fReleaseCommand )
5240 {
5241 smeProcessPendingQueue( pMac );
5242 }
5243}
5244
Jeff Johnson295189b2012-06-20 16:38:30 -07005245void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5246{
5247 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005248 if(!pSession)
5249 {
5250 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5251 return;
5252 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305253 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5254 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 pSession->NumPmkidCandidate = 0;
5256}
Jeff Johnson295189b2012-06-20 16:38:30 -07005257#ifdef FEATURE_WLAN_WAPI
5258void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5259{
5260 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005261 if(!pSession)
5262 {
5263 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5264 return;
5265 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305266 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5267 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 pSession->NumBkidCandidate = 0;
5269}
5270#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005271extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5272
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305273eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5274 tANI_U32 sessionId, eCsrAuthType authType,
5275 tSirBssDescription *pSirBssDesc,
5276 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005277{
5278 eHalStatus status = eHAL_STATUS_SUCCESS;
5279 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5280 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005281
5282 if(!pSession)
5283 {
5284 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5285 return eHAL_STATUS_FAILURE;
5286 }
5287
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 if((eCSR_AUTH_TYPE_WPA == authType) ||
5289 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5290 (eCSR_AUTH_TYPE_RSN == authType) ||
5291 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5292#if defined WLAN_FEATURE_VOWIFI_11R
5293 ||
5294 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5295 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5296#endif /* FEATURE_WLAN_WAPI */
5297#ifdef FEATURE_WLAN_WAPI
5298 ||
5299 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5300 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5301#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005302#ifdef WLAN_FEATURE_11W
5303 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305304 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5305 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005306#endif /* FEATURE_WLAN_WAPI */
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305307 || (eCSR_AUTH_TYPE_SAE == authType))
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005311 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 }
5313 if( pIesLocal )
5314 {
5315 tANI_U32 nIeLen;
5316 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 if((eCSR_AUTH_TYPE_RSN == authType) ||
5318#if defined WLAN_FEATURE_VOWIFI_11R
5319 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5320 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5321#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005322#if defined WLAN_FEATURE_11W
5323 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305324 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005325#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5327 {
5328 if(pIesLocal->RSN.present)
5329 {
5330 //Calculate the actual length
5331 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5332 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5333 + 2 //akm_suite_count
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305334 + pIesLocal->RSN.akm_suite_cnt * 4 //akm_suites
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 + 2; //reserved
5336 if( pIesLocal->RSN.pmkid_count )
5337 {
5338 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5339 }
5340 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305341 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5342 if (NULL == pSession->pWpaRsnRspIE)
5343 status = eHAL_STATUS_FAILURE;
5344 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305346 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5348 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305349 //copy upto akm_suite
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305351 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5352 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005353 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305354 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5355 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005356 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305357 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5358 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005359 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 if( pIesLocal->RSN.pwise_cipher_suite_count )
5361 {
5362 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305363 vos_mem_copy(pIeBuf,
5364 pIesLocal->RSN.pwise_cipher_suites,
5365 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5367 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305368 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_cnt, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 pIeBuf += 2;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305370 if( pIesLocal->RSN.akm_suite_cnt )
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 {
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305372 //copy akm_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305373 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305374 pIesLocal->RSN.akm_suite,
5375 pIesLocal->RSN.akm_suite_cnt * 4);
5376 pIeBuf += pIesLocal->RSN.akm_suite_cnt * 4;
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 }
5378 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305379 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305380 pIesLocal->RSN.akm_suite + pIesLocal->RSN.akm_suite_cnt * 4,
Kiet Lam64c1b492013-07-12 13:56:44 +05305381 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5383 }
5384 }
5385 }
5386 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5387 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5388 {
5389 if(pIesLocal->WPA.present)
5390 {
5391 //Calculate the actual length
5392 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5393 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5394 + 2 //auth_suite_count
5395 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5396 // The WPA capabilities follows the Auth Suite (two octects)--
5397 // this field is optional, and we always "send" zero, so just
5398 // remove it. This is consistent with our assumptions in the
5399 // frames compiler; c.f. bug 15234:
5400 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305401
5402 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5403 if ( NULL == pSession->pWpaRsnRspIE )
5404 status = eHAL_STATUS_FAILURE;
5405 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 {
5407 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5408 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5409 pIeBuf = pSession->pWpaRsnRspIE + 2;
5410 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305411 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305413 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5414 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305416 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5417 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5419 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5420 }
5421 }
5422 }
5423#ifdef FEATURE_WLAN_WAPI
5424 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5425 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5426 {
5427 if(pIesLocal->WAPI.present)
5428 {
5429 //Calculate the actual length
5430 nIeLen = 4 //version + akm_suite_count
5431 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5432 + 2 //pwise_cipher_suite_count
5433 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5434 + 6; //gp_cipher_suite + preauth + reserved
5435 if( pIesLocal->WAPI.bkid_count )
5436 {
5437 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5438 }
5439
5440 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305441 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5442 if ( NULL == pSession->pWapiRspIE )
5443 status = eHAL_STATUS_FAILURE;
5444 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 {
5446 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5447 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5448 pIeBuf = pSession->pWapiRspIE + 2;
5449 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305450 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 pIeBuf += 4;
5452 if( pIesLocal->WAPI.akm_suite_count )
5453 {
5454 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305455 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5456 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305458 }
5459 vos_mem_copy(pIeBuf,
5460 &pIesLocal->WAPI.unicast_cipher_suite_count,
5461 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5464 {
5465 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305466 vos_mem_copy( pIeBuf,
5467 pIesLocal->WAPI.unicast_cipher_suites,
5468 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5470 }
lukez3c809222013-05-03 10:23:02 -07005471 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305472 vos_mem_copy(pIeBuf,
5473 pIesLocal->WAPI.multicast_cipher_suite,
5474 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005475 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305476 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305477 vos_mem_copy(pIeBuf,
5478 pIesLocal->WAPI.multicast_cipher_suite + 4,
5479 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005480 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305481 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305483 //bkid_count
5484 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5485 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305487 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5488 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5490 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305491 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 }
5494 }
5495#endif /* FEATURE_WLAN_WAPI */
5496 if( !pIes )
5497 {
5498 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305499 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 }
5501 }
5502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 return (status);
5504}
5505
Jeff Johnson295189b2012-06-20 16:38:30 -07005506static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5507{
5508 v_U8_t bACWeights[WLANTL_MAX_AC];
5509 v_U8_t paramBk, paramBe, paramVi, paramVo;
5510 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5512 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5513 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5514 //This doesn't address the case where the lower AC needs a real higher weight
5515 if( pIEs->WMMParams.present )
5516 {
5517 //no change to the lowest ones
5518 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5519 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5520 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5521 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5522 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5523 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5524 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5525 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5526 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5527 {
5528 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5529 fWeightChange = VOS_TRUE;
5530 }
5531 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5532 {
5533 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5534 fWeightChange = VOS_TRUE;
5535 }
5536 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5537 {
5538 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5539 fWeightChange = VOS_TRUE;
5540 }
5541 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5542 {
5543 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5544 fWeightChange = VOS_TRUE;
5545 }
5546 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5547 {
5548 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5549 fWeightChange = VOS_TRUE;
5550 }
5551 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5552 {
5553 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5554 fWeightChange = VOS_TRUE;
5555 }
5556 if(fWeightChange)
5557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005558 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 bACWeights[2], bACWeights[3]);
5560 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5561 }
5562 }
5563}
Jeff Johnson295189b2012-06-20 16:38:30 -07005564#ifdef WLAN_FEATURE_VOWIFI_11R
5565//Returns whether the current association is a 11r assoc or not
5566tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5567{
5568#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5569 return csrNeighborRoamIs11rAssoc(pMac);
5570#else
5571 return eANI_BOOLEAN_FALSE;
5572#endif
5573}
5574#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005575#ifdef FEATURE_WLAN_ESE
5576//Returns whether the current association is a ESE assoc or not
5577tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005578{
5579#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005580 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005581#else
5582 return eANI_BOOLEAN_FALSE;
5583#endif
5584}
5585#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005586#ifdef FEATURE_WLAN_LFR
5587//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305588tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005589{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305590 tCsrRoamSession *pSession = NULL;
5591
5592 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5593 {
5594 pSession = CSR_GET_SESSION( pMac, sessionId );
5595 if (NULL != pSession->pCurRoamProfile)
5596 {
5597 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5598 {
5599 return eANI_BOOLEAN_FALSE;
5600 }
5601 }
5602 }
5603
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005604#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5605 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5606 {
5607 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5608 }
5609 else
5610#endif
5611 {
5612 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005613 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005614 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005615}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005616
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005617#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005618/* ---------------------------------------------------------------------------
5619
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005620 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005621
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005622 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005623
5624 \param pMac - The handle returned by macOpen.
5625
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005626 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005627
5628---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005629tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005630{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005631 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005632}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005633#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005634
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005635#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5636//Returns whether "FW based BG scan" is currently enabled...or not
5637tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5638{
5639 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5640}
5641#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005642#endif
5643
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005644#if defined(FEATURE_WLAN_ESE)
5645tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005646{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005647 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005648}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005649#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005650
Jeff Johnson295189b2012-06-20 16:38:30 -07005651//Return true means the command can be release, else not
5652static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5653 eCsrRoamCompleteResult Result, void *Context )
5654{
5655 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5656 tSirBssDescription *pSirBssDesc = NULL;
5657 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5658 tCsrScanResult *pScanResult = NULL;
5659 tCsrRoamInfo roamInfo;
5660 sme_QosAssocInfo assocInfo;
5661 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5662 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5663 tDot11fBeaconIEs *pIes = NULL;
5664 tANI_U32 sessionId = pCommand->sessionId;
5665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5666 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5667 eRoamCmdStatus roamStatus;
5668 eCsrRoamResult roamResult;
5669 eHalStatus status;
5670 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
Jeff Johnson32d95a32012-09-10 13:15:23 -07005673 if(!pSession)
5674 {
5675 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5676 return eANI_BOOLEAN_FALSE;
5677 }
5678
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005679 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 switch( Result )
5681 {
5682 case eCsrJoinSuccess:
5683 // reset the IDLE timer
5684 // !!
5685 // !! fall through to the next CASE statement here is intentional !!
5686 // !!
5687 case eCsrReassocSuccess:
5688 if(eCsrReassocSuccess == Result)
5689 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305690 roamInfo.reassoc = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5692 }
5693 else
5694 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305695 roamInfo.reassoc = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5697 }
5698 // Success Join Response from LIM. Tell NDIS we are connected and save the
5699 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005700 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305701 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 //always free the memory here
5703 if(pSession->pWpaRsnRspIE)
5704 {
5705 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305706 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 pSession->pWpaRsnRspIE = NULL;
5708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005709#ifdef FEATURE_WLAN_WAPI
5710 if(pSession->pWapiRspIE)
5711 {
5712 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305713 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 pSession->pWapiRspIE = NULL;
5715 }
5716#endif /* FEATURE_WLAN_WAPI */
5717#ifdef FEATURE_WLAN_BTAMP_UT_RF
5718 //Reset counter so no join retry is needed.
5719 pSession->maxRetryCount = 0;
5720 csrRoamStopJoinRetryTimer(pMac, sessionId);
5721#endif
5722 /* This creates problem since we have not saved the connected profile.
5723 So moving this after saving the profile
5724 */
5725 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305726
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305727 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305728 * by last failed secured connection.
5729 * It should be set only for secured connection.
5730 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305731 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5733 {
5734 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5735 }
5736 else
5737 {
5738 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 //Use the last connected bssdesc for reassoc-ing to the same AP.
5741 //NOTE: What to do when reassoc to a different AP???
5742 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5743 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5744 {
5745 pSirBssDesc = pSession->pConnectBssDesc;
5746 if(pSirBssDesc)
5747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305748 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5749 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 }
5751 }
5752 else
5753 {
5754
5755 if(pCommand->u.roamCmd.pRoamBssEntry)
5756 {
5757 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5758 if(pScanResult != NULL)
5759 {
5760 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5761 //this can be NULL
5762 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305763 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5764 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 }
5766 }
5767 }
5768 if( pSirBssDesc )
5769 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5772 //Save WPA/RSN IE
5773 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005774#ifdef FEATURE_WLAN_ESE
5775 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005776#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305777#ifdef WLAN_FEATURE_VOWIFI_11R
5778 if (pSirBssDesc->mdiePresent)
5779 {
5780 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5781#ifdef FEATURE_WLAN_ESE
5782 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5783 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5784#endif
5785 )
5786 {
5787 // is11Rconnection;
5788 roamInfo.is11rAssoc = VOS_TRUE;
5789 }
5790 else
5791 {
5792 // is11Rconnection;
5793 roamInfo.is11rAssoc = VOS_FALSE;
5794 }
5795 }
5796#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5798 // substate change.
5799 // Moving even save profile above so that below mentioned conditon is also met.
5800 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5801 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5803 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5804 // will be dropped for the security context may not be set properly.
5805 //
5806 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5807 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5808 //
5809 // this reordering was done on titan_prod_usb branch and is being replicated here.
5810 //
5811
5812 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5813 !pProfile->bWPSAssociation)
5814 {
5815 // Issue the set Context request to LIM to establish the Unicast STA context
5816 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5817 pProfile->negotiatedUCEncryptionType,
5818 pSirBssDesc, &(pSirBssDesc->bssId),
5819 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005821 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5823 }
5824 // Issue the set Context request to LIM to establish the Broadcast STA context
5825 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5826 pSirBssDesc, &BroadcastMac,
5827 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5828 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305829 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 {
5831 //Need to wait for supplicant authtication
5832 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 //Set the subestate to WaitForKey in case authentiation is needed
5834 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5835
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 if(pProfile->bWPSAssociation)
5837 {
5838 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5839 }
5840 else
5841 {
5842 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5843 }
5844
5845 //Save sessionId in case of timeout
5846 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5847 //This time should be long enough for the rest of the process plus setting key
5848 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5849 {
5850 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005851 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5853 }
5854 }
5855
5856 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5857 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 if(Context)
5859 {
5860 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5861 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5863 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5864#ifdef WLAN_FEATURE_VOWIFI_11R
5865 len += pJoinRsp->parsedRicRspLen;
5866#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005867#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 len += pJoinRsp->tspecIeLen;
5869#endif
5870 if(len)
5871 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305872 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5873 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305875 vos_mem_copy(pSession->connectedInfo.pbFrames,
5876 pJoinRsp->frames, len);
5877 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5878 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5879 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005880#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305881 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005882#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005883#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305884 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305886 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5887 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5888 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5889 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 }
5891 }
5892 if(pCommand->u.roamCmd.fReassoc)
5893 {
5894 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5895 }
5896 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5897 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5898 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5899 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305900 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305901 roamInfo.vht_caps = pJoinRsp->vht_caps;
5902 roamInfo.ht_caps = pJoinRsp->ht_caps;
5903 roamInfo.hs20vendor_ie = pJoinRsp->hs20vendor_ie;
5904 roamInfo.ht_operation = pJoinRsp->ht_operation;
5905 roamInfo.vht_operation = pJoinRsp->vht_operation;
5906
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 }
5908 else
5909 {
5910 if(pCommand->u.roamCmd.fReassoc)
5911 {
5912 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5913 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5914 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5915 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5916 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5917 }
5918 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305919 /* Update the staId from the previous connected profile info
5920 as the reassociation is triggred at SME/HDD */
5921 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5922 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5923 {
5924 roamInfo.staId = pSession->connectedInfo.staId;
5925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005926#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5927 // Indicate SME-QOS with reassoc success event, only after
5928 // copying the frames
5929 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 roamInfo.pBssDesc = pSirBssDesc;
5932 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5933 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5934#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5935 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5936#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5937 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5939 //It may be better to let QoS do this????
5940 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005942 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5944 pmcStartUapsd( pMac, NULL, NULL );
5945 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305946 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5948 if( pSession->bRefAssocStartCnt > 0 )
5949 {
5950 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005951 //Remove this code once SLM_Sessionization is supported
5952 //BMPS_WORKAROUND_NOT_NEEDED
5953 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005954 {
5955 pMac->roam.configParam.doBMPSWorkaround = 1;
5956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5958 }
5959
5960 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 // reset the PMKID candidate list
5962 csrResetPMKIDCandidateList( pMac, sessionId );
5963 //Update TL's AC weight base on the current EDCA parameters
5964 //These parameters may change in the course of the connection, that sictuation
5965 //is not taken care here. This change is mainly to address a WIFI WMM test where
5966 //BE has a equal or higher TX priority than VI.
5967 //We only do this for infra link
5968 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5969 {
5970 csrCheckAndUpdateACWeight(pMac, pIes);
5971 }
5972#ifdef FEATURE_WLAN_WAPI
5973 // reset the BKID candidate list
5974 csrResetBKIDCandidateList( pMac, sessionId );
5975#endif /* FEATURE_WLAN_WAPI */
5976 }
5977 else
5978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005979 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 csrScanCancelIdleScan(pMac);
5982 //Not to signal link up because keys are yet to be set.
5983 //The linkup function will overwrite the sub-state that we need to keep at this point.
5984 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5985 {
5986 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5989 //enough to let security and DHCP handshake succeed before entry into BMPS
5990 if (pmcShouldBmpsTimerRun(pMac))
5991 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305992 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05305993 * until keys are set before going into BMPS.
5994 */
5995 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5996 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305997 pMac->pmc.full_power_till_set_key = true;
5998 smsLog(pMac, LOG1,
5999 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 +05306000 }
6001
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
6003 != eHAL_STATUS_SUCCESS)
6004 {
6005 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
6006 }
6007 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
6008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 break;
6010
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 case eCsrStartBssSuccess:
6012 // on the StartBss Response, LIM is returning the Bss Description that we
6013 // are beaconing. Add this Bss Description to our scan results and
6014 // chain the Profile to this Bss Description. On a Start BSS, there was no
6015 // detected Bss description (no partner) so we issued the Start Bss to
6016 // start the Ibss without any Bss description. Lim was kind enough to return
6017 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006018 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05306021 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 if( CSR_IS_IBSS( pProfile ) )
6023 {
6024 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 else if (CSR_IS_INFRA_AP(pProfile))
6027 {
6028 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 else
6031 {
6032 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6033 }
6034 if( !CSR_IS_WDS_STA( pProfile ) )
6035 {
6036 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
6039 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306040 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 roamInfo.pBssDesc = pSirBssDesc;
6042 //We need to associate_complete it first, becasue Associate_start already indicated.
6043 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6044 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
6045 break;
6046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07006049 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 }
6051 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6052 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6053 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6054 if(pSirBssDesc)
6055 {
6056 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306057 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6058 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 }
6060 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306061 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006062#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6063 {
6064 vos_log_ibss_pkt_type *pIbssLog;
6065 tANI_U32 bi;
6066
6067 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6068 if(pIbssLog)
6069 {
6070 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6071 {
6072 //We start the IBSS (didn't find any matched IBSS out there)
6073 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6074 }
6075 else
6076 {
6077 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6078 }
6079 if(pSirBssDesc)
6080 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306081 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6083 }
6084 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6085 {
6086 //***U8 is not enough for beacon interval
6087 pIbssLog->beaconInterval = (v_U8_t)bi;
6088 }
6089 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6090 }
6091 }
6092#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6093 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6094 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6096 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6098 csrRoamIssueSetContextReq( pMac, sessionId,
6099 pProfile->negotiatedMCEncryptionType,
6100 pSirBssDesc, &BroadcastMac,
6101 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6102 }
6103 }
6104 else
6105 {
6106 //Keep the state to eCSR_ROAMING_STATE_JOINING
6107 //Need to send join_req.
6108 if(pCommand->u.roamCmd.pRoamBssEntry)
6109 {
6110 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6111 {
6112 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6113 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6114 // Set the roaming substate to 'join attempt'...
6115 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006116 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 }
6118 }
6119 else
6120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006121 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 VOS_ASSERT( 0 );
6123 }
6124 }
6125 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6126 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6127 //trigger the connection start indication in Vista
6128 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6129 {
6130 roamStatus = eCSR_ROAM_IBSS_IND;
6131 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6132 if( CSR_IS_WDS( pProfile ) )
6133 {
6134 roamStatus = eCSR_ROAM_WDS_IND;
6135 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 if( CSR_IS_INFRA_AP( pProfile ) )
6138 {
6139 roamStatus = eCSR_ROAM_INFRA_IND;
6140 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006142
6143 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6144 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6145 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306146 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6148 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006149 //We start the IBSS (didn't find any matched IBSS out there)
6150 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306152 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6153 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006154 //Remove this code once SLM_Sessionization is supported
6155 //BMPS_WORKAROUND_NOT_NEEDED
6156 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006157 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006158 {
6159 pMac->roam.configParam.doBMPSWorkaround = 1;
6160 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006161
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6163 }
6164
6165 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006166
6167 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 {
6169 //need to send stop BSS because we fail to send join_req
6170 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6171 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6172 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 case eCsrStartBssFailure:
6176#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6177 {
6178 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6180 if(pIbssLog)
6181 {
6182 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6183 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6184 }
6185 }
6186#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 roamStatus = eCSR_ROAM_IBSS_IND;
6188 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6189 if( CSR_IS_WDS( pProfile ) )
6190 {
6191 roamStatus = eCSR_ROAM_WDS_IND;
6192 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 if( CSR_IS_INFRA_AP( pProfile ) )
6195 {
6196 roamStatus = eCSR_ROAM_INFRA_IND;
6197 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 if(Context)
6200 {
6201 pSirBssDesc = (tSirBssDescription *)Context;
6202 }
6203 else
6204 {
6205 pSirBssDesc = NULL;
6206 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306207 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 roamInfo.pBssDesc = pSirBssDesc;
6209 //We need to associate_complete it first, becasue Associate_start already indicated.
6210 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6211 csrSetDefaultDot11Mode( pMac );
6212 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 case eCsrSilentlyStopRoaming:
6214 // We are here because we try to start the same IBSS
6215 //No message to PE
6216 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006217 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6219 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306220 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6222 if( roamInfo.pBssDesc )
6223 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306224 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6225 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 }
6227 //Since there is no change in the current state, simply pass back no result otherwise
6228 //HDD may be mistakenly mark to disconnected state.
6229 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6230 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 case eCsrSilentlyStopRoamingSaveState:
6233 //We are here because we try to connect to the same AP
6234 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006235 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306236 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006237
6238 //to aviod resetting the substate to NONE
6239 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6240 //No need to change substate to wai_for_key because there is no state change
6241 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6242 if( roamInfo.pBssDesc )
6243 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306244 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6245 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6248 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6249 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6250 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6251 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6252 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6253 roamInfo.staId = pSession->connectedInfo.staId;
6254 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 pSession->bRefAssocStartCnt--;
6257 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6258 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6259 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 case eCsrReassocFailure:
6262#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6263 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6264#endif
6265 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006266 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 csrFreeConnectBssDesc(pMac, sessionId);
6268 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6269 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306270 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6272 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6273 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6274 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6275 eCSR_ROAM_WDS_IND,
6276 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6277 //Need to issue stop_bss
6278 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 case eCsrJoinFailure:
6280 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006281 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 default:
6283 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006284 smsLog(pMac, LOGW, FL("receives no association indication"));
6285 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006286 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6288 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6289 {
6290 //do not free for the other profiles as we need to send down stop BSS later
6291 csrFreeConnectBssDesc(pMac, sessionId);
6292 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6293 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6294 csrSetDefaultDot11Mode( pMac );
6295 }
6296
6297 switch( pCommand->u.roamCmd.roamReason )
6298 {
6299 // If this transition is because of an 802.11 OID, then we transition
6300 // back to INIT state so we sit waiting for more OIDs to be issued and
6301 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006302 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 case eCsrSmeIssuedAssocToSimilarAP:
6304 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006305 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306307 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6309 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6310 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306311 vos_mem_copy(&roamInfo.bssid,
6312 &pSession->joinFailStatusCode.bssId,
6313 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006314
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 /* Defeaturize this later if needed */
6316#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6317 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6318 if (csrRoamIsHandoffInProgress(pMac))
6319 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 /* Should indicate neighbor roam algorithm about the connect failure here */
6321 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 if(pSession->bRefAssocStartCnt > 0)
6325 {
6326 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006327 if(eCsrJoinFailureDueToConcurrency == Result)
6328 {
6329 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6330 eCSR_ROAM_ASSOCIATION_COMPLETION,
6331 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6332 }
6333 else
6334 {
6335 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 eCSR_ROAM_ASSOCIATION_COMPLETION,
6337 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006340 else
6341 {
6342 /* bRefAssocStartCnt is not incremented when
6343 * eRoamState == eCsrStopRoamingDueToConcurrency
6344 * in csrRoamJoinNextBss API. so handle this in
6345 * else case by sending assoc failure
6346 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006347 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006348 pCommand->u.scanCmd.roamId,
6349 eCSR_ROAM_ASSOCIATION_FAILURE,
6350 eCSR_ROAM_RESULT_FAILURE);
6351 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006352 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306354 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6356#endif
6357 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6358 csrScanStartIdleScan(pMac);
6359#ifdef FEATURE_WLAN_BTAMP_UT_RF
6360 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6361 //BT activity and not able to recevie WLAN traffic. Retry the join
6362 if( CSR_IS_WDS_STA(pProfile) )
6363 {
6364 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6365 }
6366#endif
6367 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 case eCsrHddIssuedReassocToSameAP:
6369 case eCsrSmeIssuedReassocToSameAP:
6370 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6371
6372 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6373#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6374 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6375#endif
6376 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6377 csrScanStartIdleScan(pMac);
6378 break;
6379 case eCsrForcedDisassoc:
6380 case eCsrForcedDeauth:
6381 case eCsrSmeIssuedIbssJoinFailure:
6382 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6383
6384 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6385 {
6386 // Notify HDD that IBSS join failed
6387 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6388 }
6389 else
6390 {
6391 csrRoamCallCallback(pMac, sessionId, NULL,
6392 pCommand->u.roamCmd.roamId,
6393 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6394 }
6395#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6396 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6397#endif
6398 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006399 /*
6400 *DelSta not done FW still in conneced state so dont
6401 *issue IMPS req
6402 */
6403 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6404 {
6405 smsLog(pMac, LOGW, FL("FW still in connected state "));
6406 break;
6407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 csrScanStartIdleScan(pMac);
6409 break;
6410 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306411 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 csrRoamCallCallback(pMac, sessionId, NULL,
6413 pCommand->u.roamCmd.roamId,
6414 eCSR_ROAM_IBSS_LEAVE,
6415 eCSR_ROAM_RESULT_IBSS_STOP);
6416 break;
6417 case eCsrForcedDisassocMICFailure:
6418 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6419
6420 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6421#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6422 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6423#endif
6424 csrScanStartIdleScan(pMac);
6425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 case eCsrStopBss:
6427 csrRoamCallCallback(pMac, sessionId, NULL,
6428 pCommand->u.roamCmd.roamId,
6429 eCSR_ROAM_INFRA_IND,
6430 eCSR_ROAM_RESULT_INFRA_STOPPED);
6431 break;
6432 case eCsrForcedDisassocSta:
6433 case eCsrForcedDeauthSta:
6434 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306435 pSession = CSR_GET_SESSION(pMac, sessionId);
6436 if (pSession)
6437 {
6438 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306440 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6441 {
6442 roamInfo.u.pConnectedProfile =
6443 &pSession->connectedProfile;
6444 vos_mem_copy(roamInfo.peerMac,
6445 pCommand->u.roamCmd.peerMac,
6446 sizeof(tSirMacAddr));
6447 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6448 roamInfo.statusCode = eSIR_SME_SUCCESS;
6449 status = csrRoamCallCallback(pMac, sessionId,
6450 &roamInfo, pCommand->u.roamCmd.roamId,
6451 eCSR_ROAM_LOSTLINK,
6452 eCSR_ROAM_RESULT_FORCED);
6453 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306454 }
6455 else
6456 {
6457 smsLog(pMac, LOGE, FL("Inactive session %d"),
6458 sessionId);
6459 return eHAL_STATUS_FAILURE;
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306462 else
6463 {
6464 smsLog(pMac, LOGE, FL("Invalid session"));
6465 return eHAL_STATUS_FAILURE;
6466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 case eCsrLostLink1:
6469 // if lost link roam1 failed, then issue lost link Scan2 ...
6470 csrScanRequestLostLink2(pMac, sessionId);
6471 break;
6472 case eCsrLostLink2:
6473 // if lost link roam2 failed, then issue lost link scan3 ...
6474 csrScanRequestLostLink3(pMac, sessionId);
6475 break;
6476 case eCsrLostLink3:
6477 default:
6478 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6479
6480 //We are done with one round of lostlink roaming here
6481 csrScanHandleFailedLostlink3(pMac, sessionId);
6482 break;
6483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 break;
6485 }
6486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 return ( fReleaseCommand );
6488}
6489
Jeff Johnson295189b2012-06-20 16:38:30 -07006490eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6491{
6492 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 return (status);
6494}
6495
Jeff Johnson295189b2012-06-20 16:38:30 -07006496eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6497{
6498 eHalStatus status = eHAL_STATUS_SUCCESS;
6499 tANI_U32 size = 0;
6500
6501 do
6502 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306503 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6505 {
6506 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306507 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6508 if ( NULL == pDstProfile->BSSIDs.bssid )
6509 status = eHAL_STATUS_FAILURE;
6510 else
6511 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 if(!HAL_STATUS_SUCCESS(status))
6513 {
6514 break;
6515 }
6516 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306517 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6518 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 }
6520 if(pSrcProfile->SSIDs.numOfSSIDs)
6521 {
6522 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306523 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6524 if ( NULL == pDstProfile->SSIDs.SSIDList )
6525 status = eHAL_STATUS_FAILURE;
6526 else
6527 status = eHAL_STATUS_SUCCESS;
6528 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 {
6530 break;
6531 }
6532 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306533 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6534 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 }
6536 if(pSrcProfile->nWPAReqIELength)
6537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306538 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6539 if ( NULL == pDstProfile->pWPAReqIE )
6540 status = eHAL_STATUS_FAILURE;
6541 else
6542 status = eHAL_STATUS_SUCCESS;
6543
6544 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 {
6546 break;
6547 }
6548 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306549 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6550 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 }
6552 if(pSrcProfile->nRSNReqIELength)
6553 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306554 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6555 if ( NULL == pDstProfile->pRSNReqIE )
6556 status = eHAL_STATUS_FAILURE;
6557 else
6558 status = eHAL_STATUS_SUCCESS;
6559
6560 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 {
6562 break;
6563 }
6564 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306565 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6566 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 }
6568#ifdef FEATURE_WLAN_WAPI
6569 if(pSrcProfile->nWAPIReqIELength)
6570 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306571 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6572 if ( NULL == pDstProfile->pWAPIReqIE )
6573 status = eHAL_STATUS_FAILURE;
6574 else
6575 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 if(!HAL_STATUS_SUCCESS(status))
6577 {
6578 break;
6579 }
6580 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306581 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6582 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 }
6584#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 if(pSrcProfile->nAddIEScanLength)
6586 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306587 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6588 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306590 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306591 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306592 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6593 }
6594 else
6595 {
6596 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6597 FL(" AddIEScanLength is not valid %u"),
6598 pSrcProfile->nAddIEScanLength);
6599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 if(pSrcProfile->nAddIEAssocLength)
6602 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306603 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6604 if ( NULL == pDstProfile->pAddIEAssoc )
6605 status = eHAL_STATUS_FAILURE;
6606 else
6607 status = eHAL_STATUS_SUCCESS;
6608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 if(!HAL_STATUS_SUCCESS(status))
6610 {
6611 break;
6612 }
6613 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306614 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6615 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 if(pSrcProfile->ChannelInfo.ChannelList)
6618 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306619 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6620 pSrcProfile->ChannelInfo.numOfChannels);
6621 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6622 status = eHAL_STATUS_FAILURE;
6623 else
6624 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 if(!HAL_STATUS_SUCCESS(status))
6626 {
6627 break;
6628 }
6629 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306630 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6631 pSrcProfile->ChannelInfo.ChannelList,
6632 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 pDstProfile->AuthType = pSrcProfile->AuthType;
6635 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6636 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6637 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6638 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6639 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006640#ifdef WLAN_FEATURE_11W
6641 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6642 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6643 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 pDstProfile->BSSType = pSrcProfile->BSSType;
6646 pDstProfile->phyMode = pSrcProfile->phyMode;
6647 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6648
6649#ifdef FEATURE_WLAN_WAPI
6650 if(csrIsProfileWapi(pSrcProfile))
6651 {
6652 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6653 {
6654 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6655 }
6656 }
6657#endif /* FEATURE_WLAN_WAPI */
6658 pDstProfile->CBMode = pSrcProfile->CBMode;
6659 /*Save the WPS info*/
6660 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006661 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 pDstProfile->privacy = pSrcProfile->privacy;
6665 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6666 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6667 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6668 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6669 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6670 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6671 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6672 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6673 pDstProfile->wps_state = pSrcProfile->wps_state;
6674 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Abhishek Singhe3beee22017-07-31 15:35:40 +05306675 pDstProfile->force_24ghz_in_ht20 =
6676 pSrcProfile->force_24ghz_in_ht20;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05306677 pDstProfile->force_rsne_override = pSrcProfile->force_rsne_override;
Kiet Lam64c1b492013-07-12 13:56:44 +05306678 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6679 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006680#ifdef WLAN_FEATURE_VOWIFI_11R
6681 if (pSrcProfile->MDID.mdiePresent)
6682 {
6683 pDstProfile->MDID.mdiePresent = 1;
6684 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6685 }
6686#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 }while(0);
6688
6689 if(!HAL_STATUS_SUCCESS(status))
6690 {
6691 csrReleaseProfile(pMac, pDstProfile);
6692 pDstProfile = NULL;
6693 }
6694
6695 return (status);
6696}
Jeff Johnson295189b2012-06-20 16:38:30 -07006697eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6698{
6699 eHalStatus status = eHAL_STATUS_SUCCESS;
6700 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6701 do
6702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306703 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 if(pSrcProfile->bssid)
6705 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306706 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6707 if ( NULL == pDstProfile->BSSIDs.bssid )
6708 status = eHAL_STATUS_FAILURE;
6709 else
6710 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 if(!HAL_STATUS_SUCCESS(status))
6712 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306713 smsLog( pMac, LOGE,
6714 FL("failed to allocate memory for BSSID"
6715 "%02x:%02x:%02x:%02x:%02x:%02x"),
6716 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6717 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 break;
6719 }
6720 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306721 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6722 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 }
6724 if(pSrcProfile->SSID.ssId)
6725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306726 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6727 if ( NULL == pDstProfile->SSIDs.SSIDList )
6728 status = eHAL_STATUS_FAILURE;
6729 else
6730 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 if(!HAL_STATUS_SUCCESS(status))
6732 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306733 smsLog( pMac, LOGE,
6734 FL("failed to allocate memory for SSIDList"
6735 "%02x:%02x:%02x:%02x:%02x:%02x"),
6736 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6737 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 break;
6739 }
6740 pDstProfile->SSIDs.numOfSSIDs = 1;
6741 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6742 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306743 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6744 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006746 if(pSrcProfile->nAddIEAssocLength)
6747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306748 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6749 if ( NULL == pDstProfile->pAddIEAssoc)
6750 status = eHAL_STATUS_FAILURE;
6751 else
6752 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006753 if(!HAL_STATUS_SUCCESS(status))
6754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006755 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006756 break;
6757 }
6758 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306759 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6760 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006761 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306762 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6763 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6764 status = eHAL_STATUS_FAILURE;
6765 else
6766 status = eHAL_STATUS_SUCCESS;
6767
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 if(!HAL_STATUS_SUCCESS(status))
6769 {
6770 break;
6771 }
6772 pDstProfile->ChannelInfo.numOfChannels = 1;
6773 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 pDstProfile->AuthType.numEntries = 1;
6775 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6776 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6777 pDstProfile->EncryptionType.numEntries = 1;
6778 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6779 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6780 pDstProfile->mcEncryptionType.numEntries = 1;
6781 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6782 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6783 pDstProfile->BSSType = pSrcProfile->BSSType;
6784 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306785 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6786 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306787#ifdef WLAN_FEATURE_11W
6788 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6789 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6790 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6791#endif
6792
Jeff Johnson295189b2012-06-20 16:38:30 -07006793#ifdef WLAN_FEATURE_VOWIFI_11R
6794 if (pSrcProfile->MDID.mdiePresent)
6795 {
6796 pDstProfile->MDID.mdiePresent = 1;
6797 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6798 }
6799#endif
6800
6801 }while(0);
6802
6803 if(!HAL_STATUS_SUCCESS(status))
6804 {
6805 csrReleaseProfile(pMac, pDstProfile);
6806 pDstProfile = NULL;
6807 }
6808
6809 return (status);
6810}
6811
Jeff Johnson295189b2012-06-20 16:38:30 -07006812eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6813 tScanResultHandle hBSSList,
6814 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6815 tANI_BOOLEAN fClearScan)
6816{
6817 eHalStatus status = eHAL_STATUS_SUCCESS;
6818 tSmeCmd *pCommand;
6819
6820 pCommand = csrGetCommandBuffer(pMac);
6821 if(NULL == pCommand)
6822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006823 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 status = eHAL_STATUS_RESOURCES;
6825 }
6826 else
6827 {
6828 if( fClearScan )
6829 {
6830 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306831 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 }
6833 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6834 if(NULL == pProfile)
6835 {
6836 //We can roam now
6837 //Since pProfile is NULL, we need to build our own profile, set everything to default
6838 //We can only support open and no encryption
6839 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6840 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6841 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6842 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6843 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6844 }
6845 else
6846 {
6847 //make a copy of the profile
6848 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6849 if(HAL_STATUS_SUCCESS(status))
6850 {
6851 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6852 }
6853 }
6854 pCommand->command = eSmeCommandRoam;
6855 pCommand->sessionId = (tANI_U8)sessionId;
6856 pCommand->u.roamCmd.hBSSList = hBSSList;
6857 pCommand->u.roamCmd.roamId = roamId;
6858 pCommand->u.roamCmd.roamReason = reason;
6859 //We need to free the BssList when the command is done
6860 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6861 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6863 FL("CSR PERSONA=%d"),
6864 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6866 if( !HAL_STATUS_SUCCESS( status ) )
6867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006868 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 csrReleaseCommandRoam( pMac, pCommand );
6870 }
6871 }
6872
6873 return (status);
6874}
Jeff Johnson295189b2012-06-20 16:38:30 -07006875eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6876 tCsrRoamModifyProfileFields *pMmodProfileFields,
6877 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6878{
6879 eHalStatus status = eHAL_STATUS_SUCCESS;
6880 tSmeCmd *pCommand;
6881
6882 pCommand = csrGetCommandBuffer(pMac);
6883 if(NULL == pCommand)
6884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006885 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 status = eHAL_STATUS_RESOURCES;
6887 }
6888 else
6889 {
6890 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306891 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006892 if(pProfile)
6893 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 //This is likely trying to reassoc to different profile
6895 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6896 //make a copy of the profile
6897 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6898 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 }
6900 else
6901 {
6902 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6903 //how to update WPA/WPA2 info in roamProfile??
6904 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 if(HAL_STATUS_SUCCESS(status))
6907 {
6908 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6909 }
6910 pCommand->command = eSmeCommandRoam;
6911 pCommand->sessionId = (tANI_U8)sessionId;
6912 pCommand->u.roamCmd.roamId = roamId;
6913 pCommand->u.roamCmd.roamReason = reason;
6914 //We need to free the BssList when the command is done
6915 //For reassoc there is no BSS list, so the boolean set to false
6916 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6917 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6918 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6920 if( !HAL_STATUS_SUCCESS( status ) )
6921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006922 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6924 csrReleaseCommandRoam( pMac, pCommand );
6925 }
6926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 return (status);
6928}
6929
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006930eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6931 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306932// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006933{
6934 eHalStatus status = eHAL_STATUS_SUCCESS;
6935 tSmeCmd *pCommand;
6936
6937 pCommand = csrGetCommandBuffer(pMac);
6938 if(NULL == pCommand)
6939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006940 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006941 status = eHAL_STATUS_RESOURCES;
6942 }
6943 else
6944 {
6945 if(pBssDescription)
6946 {
6947 //copy over the parameters we need later
6948 pCommand->command = eSmeCommandRoam;
6949 pCommand->sessionId = (tANI_U8)sessionId;
6950 pCommand->u.roamCmd.roamReason = reason;
6951 //this is the important parameter
6952 //in this case we are using this field for the "next" BSS
6953 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6954 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6955 if( !HAL_STATUS_SUCCESS( status ) )
6956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006957 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006958 csrReleaseCommandPreauth( pMac, pCommand );
6959 }
6960 }
6961 else
6962 {
6963 //Return failure
6964 status = eHAL_STATUS_RESOURCES;
6965 }
6966 }
6967 return (status);
6968}
6969
6970eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6971{
6972 tListElem *pEntry;
6973 tSmeCmd *pCommand;
6974 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6975 if ( pEntry )
6976 {
6977 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6978 if ( (eSmeCommandRoam == pCommand->command) &&
6979 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6980 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006981 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006982 pCommand->command, pCommand->u.roamCmd.roamReason);
6983 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6984 csrReleaseCommandPreauth( pMac, pCommand );
6985 }
6986 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006987 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006988 pCommand->command, pCommand->u.roamCmd.roamReason);
6989 }
6990 }
6991 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006992 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006993 }
6994 smeProcessPendingQueue( pMac );
6995 return eHAL_STATUS_SUCCESS;
6996}
6997
Jeff Johnson295189b2012-06-20 16:38:30 -07006998eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6999 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7000{
7001 eHalStatus status = eHAL_STATUS_FAILURE;
7002 tScanResultHandle hBSSList;
7003 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
7005 if(HAL_STATUS_SUCCESS(status))
7006 {
7007 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7008 if(pRoamId)
7009 {
7010 *pRoamId = roamId;
7011 }
7012 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7013 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7014 if(!HAL_STATUS_SUCCESS(status))
7015 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007016 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 csrScanResultPurge(pMac, hBSSList);
7018 }
7019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 return (status);
7021}
7022
Jeff Johnson295189b2012-06-20 16:38:30 -07007023eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7024 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7025{
7026 eHalStatus status = eHAL_STATUS_SUCCESS;
7027 tScanResultHandle hBSSList;
7028 tCsrScanResultFilter *pScanFilter;
7029 tANI_U32 roamId = 0;
7030 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
7031 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 if (NULL == pProfile)
7033 {
7034 smsLog(pMac, LOGP, FL("No profile specified"));
7035 return eHAL_STATUS_FAILURE;
7036 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307037 if(!pSession)
7038 {
7039 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7040 return eHAL_STATUS_FAILURE;
7041 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307042 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7043 "encryType = %d"),
7044 lim_BssTypetoString(pProfile->BSSType),
7045 pProfile->BSSType,
7046 pProfile->AuthType.authType[0],
7047 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 if( CSR_IS_WDS( pProfile ) &&
7049 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
7050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007051 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007052 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 return status;
7054 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307055 /* Reset abortConnection for the fresh connection */
7056 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 csrRoamCancelRoaming(pMac, sessionId);
7058 csrScanRemoveFreshScanCommand(pMac, sessionId);
7059 csrScanCancelIdleScan(pMac);
7060 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307061 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307062
7063 if (!vos_concurrent_open_sessions_running() &&
7064 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307066 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 csrScanDisable(pMac);
7068 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307069
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7071 //Check whether ssid changes
7072 if(csrIsConnStateConnected(pMac, sessionId))
7073 {
7074 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7075 {
7076 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7077 }
7078 }
7079#ifdef FEATURE_WLAN_BTAMP_UT_RF
7080 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7081#endif
Abhishek Singh5de9efd2017-06-15 10:22:39 +05307082
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007085 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7087 if(pRoamId)
7088 {
7089 roamId = *pRoamId;
7090 }
7091 if(!HAL_STATUS_SUCCESS(status))
7092 {
7093 fCallCallback = eANI_BOOLEAN_TRUE;
7094 }
7095 }
7096 else
7097 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307098 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7099 if ( NULL == pScanFilter )
7100 status = eHAL_STATUS_FAILURE;
7101 else
7102 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 if(HAL_STATUS_SUCCESS(status))
7104 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307105 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 //Try to connect to any BSS
7107 if(NULL == pProfile)
7108 {
7109 //No encryption
7110 pScanFilter->EncryptionType.numEntries = 1;
7111 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7112 }//we don't have a profile
7113 else
7114 {
7115 //Here is the profile we need to connect to
7116 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7117 }//We have a profile
7118 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7119 if(pRoamId)
7120 {
7121 *pRoamId = roamId;
7122 }
7123
7124 if(HAL_STATUS_SUCCESS(status))
7125 {
7126 /*Save the WPS info*/
7127 if(NULL != pProfile)
7128 {
7129 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007130 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 }
7132 else
7133 {
7134 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007135 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 do
7138 {
7139 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 )
7142 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007143 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7145 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7146 if(!HAL_STATUS_SUCCESS(status))
7147 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007148 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 fCallCallback = eANI_BOOLEAN_TRUE;
7150 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007151 else
7152 {
7153 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 break;
7156 }
7157 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007158 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 if(HAL_STATUS_SUCCESS(status))
7160 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7162 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7163 if(!HAL_STATUS_SUCCESS(status))
7164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007165 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 csrScanResultPurge(pMac, hBSSList);
7167 fCallCallback = eANI_BOOLEAN_TRUE;
7168 }
7169 }//Have scan result
7170 else if(NULL != pProfile)
7171 {
7172 //Check whether it is for start ibss
7173 if(CSR_IS_START_IBSS(pProfile))
7174 {
7175 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7176 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7177 if(!HAL_STATUS_SUCCESS(status))
7178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007179 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 fCallCallback = eANI_BOOLEAN_TRUE;
7181 }
7182 }
7183 else
7184 {
7185 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007186 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 if(!HAL_STATUS_SUCCESS(status))
7188 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007189 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 fCallCallback = eANI_BOOLEAN_TRUE;
7191 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007192 else
7193 {
7194 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 }
7197 }
7198 else
7199 {
7200 fCallCallback = eANI_BOOLEAN_TRUE;
7201 }
7202 } while (0);
7203 if(NULL != pProfile)
7204 {
7205 //we need to free memory for filter if profile exists
7206 csrFreeScanFilter(pMac, pScanFilter);
7207 }
7208 }//Got the scan filter from profile
7209
Kiet Lam64c1b492013-07-12 13:56:44 +05307210 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 }//allocated memory for pScanFilter
7212 }//No Bsslist coming in
7213 //tell the caller if we fail to trigger a join request
7214 if( fCallCallback )
7215 {
7216 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7217 }
7218
7219 return (status);
7220}
Jeff Johnson295189b2012-06-20 16:38:30 -07007221eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7222 tCsrRoamModifyProfileFields modProfileFields,
7223 tANI_U32 *pRoamId)
7224{
7225 eHalStatus status = eHAL_STATUS_SUCCESS;
7226 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7227 tANI_U32 roamId = 0;
7228 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 if (NULL == pProfile)
7230 {
7231 smsLog(pMac, LOGP, FL("No profile specified"));
7232 return eHAL_STATUS_FAILURE;
7233 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307234 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7235 "encryType = %d"),
7236 lim_BssTypetoString(pProfile->BSSType),
7237 pProfile->BSSType,
7238 pProfile->AuthType.authType[0],
7239 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 csrRoamCancelRoaming(pMac, sessionId);
7241 csrScanRemoveFreshScanCommand(pMac, sessionId);
7242 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307243 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 if(csrIsConnStateConnected(pMac, sessionId))
7246 {
7247 if(pProfile)
7248 {
7249 if(pProfile->SSIDs.numOfSSIDs &&
7250 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7251 {
7252 fCallCallback = eANI_BOOLEAN_FALSE;
7253 }
7254 else
7255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007256 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 }
7258 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307259 else if (!vos_mem_compare(&modProfileFields,
7260 &pSession->connectedProfile.modifyProfileFields,
7261 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 {
7263 fCallCallback = eANI_BOOLEAN_FALSE;
7264 }
7265 else
7266 {
7267 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007268 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 }
7270 }
7271 else
7272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007273 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 if(!fCallCallback)
7276 {
7277 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7278 if(pRoamId)
7279 {
7280 *pRoamId = roamId;
7281 }
7282
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7284 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 }
7286 else
7287 {
7288 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7289 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 return status;
7292}
Jeff Johnson295189b2012-06-20 16:38:30 -07007293eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7294{
7295 eHalStatus status = eHAL_STATUS_FAILURE;
7296 tScanResultHandle hBSSList = NULL;
7297 tCsrScanResultFilter *pScanFilter = NULL;
7298 tANI_U32 roamId;
7299 tCsrRoamProfile *pProfile = NULL;
7300 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007301
7302 if(!pSession)
7303 {
7304 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7305 return eHAL_STATUS_FAILURE;
7306 }
7307
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 do
7309 {
7310 if(pSession->pCurRoamProfile)
7311 {
7312 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307313 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307315 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7316 if ( NULL == pProfile )
7317 status = eHAL_STATUS_FAILURE;
7318 else
7319 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 if(!HAL_STATUS_SUCCESS(status))
7321 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307322 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307324 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007325 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307326 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7327 if ( NULL == pScanFilter )
7328 status = eHAL_STATUS_FAILURE;
7329 else
7330 status = eHAL_STATUS_SUCCESS;
7331
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 if(!HAL_STATUS_SUCCESS(status))
7333 {
7334 break;
7335 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307336 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7338 if(!HAL_STATUS_SUCCESS(status))
7339 {
7340 break;
7341 }
7342 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7343 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7344 if(HAL_STATUS_SUCCESS(status))
7345 {
7346 //we want to put the last connected BSS to the very beginning, if possible
7347 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7348 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7349 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7350 if(!HAL_STATUS_SUCCESS(status))
7351 {
7352 csrScanResultPurge(pMac, hBSSList);
7353 break;
7354 }
7355 }
7356 else
7357 {
7358 //Do a scan on this profile
7359 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007360 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 if(!HAL_STATUS_SUCCESS(status))
7362 {
7363 break;
7364 }
7365 }
7366 }//We have a profile
7367 else
7368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007369 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 break;
7371 }
7372 }while(0);
7373 if(pScanFilter)
7374 {
7375 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307376 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 }
7378 if(NULL != pProfile)
7379 {
7380 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307381 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 return (status);
7384}
Jeff Johnson295189b2012-06-20 16:38:30 -07007385eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7386{
7387 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 if(csrIsConnStateConnected(pMac, sessionId))
7389 {
7390 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7391 if(HAL_STATUS_SUCCESS(status))
7392 {
7393 status = csrRoamJoinLastProfile(pMac, sessionId);
7394 }
7395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 return (status);
7397}
7398
Jeff Johnson295189b2012-06-20 16:38:30 -07007399eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7400{
7401 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007402 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 csrRoamCancelRoaming(pMac, sessionId);
7404 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7405 if(csrIsConnStateDisconnected(pMac, sessionId))
7406 {
7407 status = csrRoamJoinLastProfile(pMac, sessionId);
7408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 return (status);
7410}
7411
Jeff Johnson295189b2012-06-20 16:38:30 -07007412eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7413{
7414 eHalStatus status = eHAL_STATUS_SUCCESS;
7415 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7416 eCsrRoamSubState NewSubstate;
7417 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307418
7419 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7420 {
7421 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7422 " eCSR_ROAM_SUBSTATE_NONE"));
7423 csrRoamStopWaitForKeyTimer( pMac );
7424 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 // change state to 'Roaming'...
7427 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7428
7429 if ( csrIsConnStateIbss( pMac, sessionId ) )
7430 {
7431 // If we are in an IBSS, then stop the IBSS...
7432 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7433 fComplete = (!HAL_STATUS_SUCCESS(status));
7434 }
7435 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007437 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 -07007438 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7439 //Restore AC weight in case we change it
7440 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7441 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7442 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7443 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7444 {
7445 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7446 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307447 else
7448 {
7449 // If we are in neighbor preauth done state then on receiving
7450 // disassoc or deauth we dont roam instead we just disassoc
7451 // from current ap and then go to disconnected state
7452 // This happens for ESE and 11r FT connections ONLY.
7453#ifdef WLAN_FEATURE_VOWIFI_11R
7454 if (csrRoamIs11rAssoc(pMac) &&
7455 (csrNeighborRoamStatePreauthDone(pMac)))
7456 {
7457 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7458 }
7459#endif
7460#ifdef FEATURE_WLAN_ESE
7461 if (csrRoamIsESEAssoc(pMac) &&
7462 (csrNeighborRoamStatePreauthDone(pMac)))
7463 {
7464 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7465 }
7466#endif
7467#ifdef FEATURE_WLAN_LFR
7468 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7469 (csrNeighborRoamStatePreauthDone(pMac)))
7470 {
7471 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7472 }
7473#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307474#ifdef WLAN_FEATURE_LFR_MBB
7475 csr_stop_preauth_reassoc_mbb_timer(pMac);
7476#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307477 }
7478
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 if( fDisassoc )
7480 {
7481 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307482 if (pMac->roam.configParam.roamDelayStatsEnabled)
7483 {
7484 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 }
7487 else
7488 {
7489 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7490 }
7491 fComplete = (!HAL_STATUS_SUCCESS(status));
7492 }
7493 else if ( csrIsConnStateWds( pMac, sessionId ) )
7494 {
7495 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7496 {
7497 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7498 fComplete = (!HAL_STATUS_SUCCESS(status));
7499 }
7500 //This has to be WDS station
7501 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7502 {
7503
7504 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7505 if( fDisassoc )
7506 {
7507 status = csrRoamIssueDisassociate( pMac, sessionId,
7508 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7509 fComplete = (!HAL_STATUS_SUCCESS(status));
7510 }
7511 }
7512 } else {
7513 // we got a dis-assoc request while not connected to any peer
7514 // just complete the command
7515 fComplete = eANI_BOOLEAN_TRUE;
7516 status = eHAL_STATUS_FAILURE;
7517 }
7518 if(fComplete)
7519 {
7520 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7521 }
7522
7523 if(HAL_STATUS_SUCCESS(status))
7524 {
7525 if ( csrIsConnStateInfra( pMac, sessionId ) )
7526 {
7527 //Set the state to disconnect here
7528 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307529#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7530 //we don't need to run this timer any more
7531 if (VOS_TIMER_STATE_RUNNING ==
7532 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7533 {
7534 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7535 if (status != eHAL_STATUS_SUCCESS)
7536 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7537 }
7538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 }
7540 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007541 else
7542 {
7543 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 return (status);
7546}
7547
Jeff Johnson295189b2012-06-20 16:38:30 -07007548/* This is been removed from latest code base */
7549/*
7550static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7551{
7552 eHalStatus status;
7553 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7555 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 return ( status );
7557}
7558*/
7559
Jeff Johnson295189b2012-06-20 16:38:30 -07007560eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7561{
7562 eHalStatus status = eHAL_STATUS_SUCCESS;
7563 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307564
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 do
7566 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 pCommand = csrGetCommandBuffer( pMac );
7568 if ( !pCommand )
7569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007570 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 status = eHAL_STATUS_RESOURCES;
7572 break;
7573 }
7574 //Change the substate in case it is wait-for-key
7575 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7576 {
7577 csrRoamStopWaitForKeyTimer( pMac );
7578 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7579 }
7580 pCommand->command = eSmeCommandRoam;
7581 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307582 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7583 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 switch ( reason )
7585 {
7586 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7587 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 case eCSR_DISCONNECT_REASON_DEAUTH:
7590 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7594 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7596 case eCSR_DISCONNECT_REASON_DISASSOC:
7597 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7598 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7600 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7601 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7603 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 default:
7606 break;
7607 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307608 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 if( !HAL_STATUS_SUCCESS( status ) )
7610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007611 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 csrReleaseCommandRoam( pMac, pCommand );
7613 }
7614 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 return( status );
7616}
7617
Jeff Johnson295189b2012-06-20 16:38:30 -07007618eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7619{
7620 eHalStatus status = eHAL_STATUS_SUCCESS;
7621 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 pCommand = csrGetCommandBuffer( pMac );
7623 if ( NULL != pCommand )
7624 {
7625 //Change the substate in case it is wait-for-key
7626 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7627 {
7628 csrRoamStopWaitForKeyTimer( pMac );
7629 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7630 }
7631 pCommand->command = eSmeCommandRoam;
7632 pCommand->sessionId = (tANI_U8)sessionId;
7633 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7634 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7635 if( !HAL_STATUS_SUCCESS( status ) )
7636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007637 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 csrReleaseCommandRoam( pMac, pCommand );
7639 }
7640 }
7641 else
7642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007643 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 status = eHAL_STATUS_RESOURCES;
7645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 return ( status );
7647}
7648
Jeff Johnson295189b2012-06-20 16:38:30 -07007649eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7650{
7651 eHalStatus status = eHAL_STATUS_SUCCESS;
7652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007653
7654 if(!pSession)
7655 {
7656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7657 return eHAL_STATUS_FAILURE;
7658 }
7659
Jeff Johnson295189b2012-06-20 16:38:30 -07007660#ifdef FEATURE_WLAN_BTAMP_UT_RF
7661 //Stop te retry
7662 pSession->maxRetryCount = 0;
7663 csrRoamStopJoinRetryTimer(pMac, sessionId);
7664#endif
7665 //Not to call cancel roaming here
7666 //Only issue disconnect when necessary
7667 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7668 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7669 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7670
7671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007672 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7674 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307675 else
7676 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307677 csrScanAbortScanForSSID(pMac, sessionId);
Mukul Sharma11841b42017-07-05 13:10:09 +05307678 csrScanStartIdleScan(pMac);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307679 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307680 smsLog(pMac, LOGE,
7681 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 return (status);
7684}
7685
Jeff Johnson295189b2012-06-20 16:38:30 -07007686eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7687{
7688 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007689
7690 if(!pSession)
7691 {
7692 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7693 return eHAL_STATUS_FAILURE;
7694 }
7695
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7698
7699 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7700}
7701
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307702void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7703{
7704 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7705 if(!pSession)
7706 {
7707 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7708 return;
7709 }
7710 pSession->abortConnection = TRUE;
7711 return;
7712}
7713
Jeff Johnson295189b2012-06-20 16:38:30 -07007714eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7715 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7716{
7717 eHalStatus status = eHAL_STATUS_SUCCESS;
7718 tDot11fBeaconIEs *pIesTemp = pIes;
7719 tANI_U8 index;
7720 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7721 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007722
7723 if(!pSession)
7724 {
7725 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7726 return eHAL_STATUS_FAILURE;
7727 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007728 if(pConnectProfile->pAddIEAssoc)
7729 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307730 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007731 pConnectProfile->pAddIEAssoc = NULL;
7732 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307733 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007734 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7735 pConnectProfile->AuthInfo = pProfile->AuthType;
7736 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7737 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7738 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7739 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7740 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7741 pConnectProfile->BSSType = pProfile->BSSType;
7742 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7743 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007744 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307745 if (!pConnectProfile->beaconInterval)
7746 {
7747 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7748 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307749 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007750 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7751 if(pProfile->nAddIEAssocLength)
7752 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307753 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7754 if ( NULL == pConnectProfile->pAddIEAssoc )
7755 status = eHAL_STATUS_FAILURE;
7756 else
7757 status = eHAL_STATUS_SUCCESS;
7758 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007759 {
7760 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7761 return eHAL_STATUS_FAILURE;
7762 }
7763 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307764 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7765 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007766 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307767
7768#ifdef WLAN_FEATURE_11W
7769 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7770 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7771 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7772#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007773
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 //Save bssid
7775 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7776#ifdef WLAN_FEATURE_VOWIFI_11R
7777 if (pSirBssDesc->mdiePresent)
7778 {
7779 pConnectProfile->MDID.mdiePresent = 1;
7780 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7781 }
7782#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007783 if( NULL == pIesTemp )
7784 {
7785 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7786 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007787#ifdef FEATURE_WLAN_ESE
7788 if ((csrIsProfileESE(pProfile) ||
7789 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307790 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7791 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7792 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7793 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7794#ifdef WLAN_FEATURE_11W
7795 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307796 || (pProfile->negotiatedAuthType ==
7797 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307798#endif
7799 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007800 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007802 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 }
7804#endif
7805 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 if(HAL_STATUS_SUCCESS(status))
7807 {
7808 if(pIesTemp->SSID.present)
7809 {
7810 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307811 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7812 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007813 }
7814
7815 //Save the bss desc
7816 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307817
7818 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307820 //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 -07007821 pConnectProfile->qap = TRUE;
7822 }
7823 else
7824 {
7825 pConnectProfile->qap = FALSE;
7826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 if ( NULL == pIes )
7828 {
7829 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307830 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 }
7832 }
7833 //Save Qos connection
7834 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7835
7836 if(!HAL_STATUS_SUCCESS(status))
7837 {
7838 csrFreeConnectBssDesc(pMac, sessionId);
7839 }
7840 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7841 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307842 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7843 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7844 pConnectProfile->SSID.ssId,
7845 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 {
7847 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7848 break;
7849 }
7850 pConnectProfile->handoffPermitted = FALSE;
7851 }
7852
7853 return (status);
7854}
7855
Jeff Johnson295189b2012-06-20 16:38:30 -07007856static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7857{
7858 tListElem *pEntry = NULL;
7859 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307860 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 //The head of the active list is the request we sent
7862 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7863 if(pEntry)
7864 {
7865 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7866 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307867 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7869 {
7870 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7871 {
7872#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7873 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7874#endif
7875 }
7876 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307877 if(!pSession)
7878 {
7879 smsLog(pMac, LOGE, FL(" session %d not found "),
7880 pSmeJoinRsp->sessionId);
7881 return;
7882 }
7883 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 }
7885 else
7886 {
7887 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007888 if(!pSession)
7889 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307890 smsLog(pMac, LOGE, FL(" session %d not found "),
7891 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007892 return;
7893 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307894 if (pSession->abortConnection)
7895 {
Abhinav Kumare548f1e2018-07-12 16:40:43 +05307896 smsLog(pMac, LOG1, FL("Disconnection in progess abort Join request"));
7897
7898 if (pSession->bRefAssocStartCnt)
7899 pSession->bRefAssocStartCnt--;
7900 csrRoamCallCallback(pMac, pSession->sessionId,
7901 NULL, roamId,
7902 eCSR_ROAM_ASSOCIATION_COMPLETION,
7903 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307904 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7905 pSession->abortConnection = FALSE;
7906 return;
7907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 //The head of the active list is the request we sent
7909 //Try to get back the same profile and roam again
7910 if(pCommand)
7911 {
7912 roamId = pCommand->u.roamCmd.roamId;
7913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7915 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007916 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007917#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7918 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7919 if (csrRoamIsHandoffInProgress(pMac))
7920 {
7921 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7922 /* Should indicate neighbor roam algorithm about the connect failure here */
7923 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7924 }
7925#endif
7926 if (pCommand)
7927 {
7928 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7929 {
7930 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7931 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7932 csrRoamReissueRoamCommand(pMac);
7933 }
7934 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7935 {
7936 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7937 }
7938 else
7939 {
7940 csrRoam(pMac, pCommand);
7941 }
7942 }
7943 else
7944 {
7945 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7946 }
7947 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7948}
7949
Jeff Johnson295189b2012-06-20 16:38:30 -07007950eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7951 tDot11fBeaconIEs *pIes,
7952 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7953{
7954 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007955 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7956 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007957
7958 // Set the roaming substate to 'join attempt'...
7959 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007961 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 return (status);
7963}
7964
Jeff Johnson295189b2012-06-20 16:38:30 -07007965static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7966 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7967{
7968 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 // Set the roaming substate to 'join attempt'...
7970 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7971
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307972 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7973 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307974 if (pMac->roam.configParam.roamDelayStatsEnabled)
7975 {
7976 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7977 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007980 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007981}
7982
Jeff Johnson295189b2012-06-20 16:38:30 -07007983void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7984{
7985 tListElem *pEntry;
7986 tSmeCmd *pCommand;
7987 tCsrRoamInfo roamInfo;
7988 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307989 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007990
7991 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7992 if(pEntry)
7993 {
7994 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7995 if ( eSmeCommandRoam == pCommand->command )
7996 {
7997 sessionId = pCommand->sessionId;
7998 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007999
8000 if(!pSession)
8001 {
8002 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8003 return;
8004 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05308005 /* While switching between two AP, csr will reissue roam command again
8006 to the nextbss if it was interrupted by the dissconnect req for the
8007 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
8008 so reset the bRefAssocStartCnt.
8009 */
8010 if(pSession->bRefAssocStartCnt > 0)
8011 {
8012 pSession->bRefAssocStartCnt--;
8013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 if( pCommand->u.roamCmd.fStopWds )
8015 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308016 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8018 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8019 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008020 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
8022 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8023 eCSR_ROAM_WDS_IND,
8024 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
8026 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8027 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8028 eCSR_ROAM_INFRA_IND,
8029 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
8030 }
8031
Jeff Johnson295189b2012-06-20 16:38:30 -07008032
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
8034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008035 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008036 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8037 }
8038 }
8039 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
8040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008041 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8043 }
8044 }
8045 else
8046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008047 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 }
8049 }
8050 else
8051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008052 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 }
8054}
8055
Jeff Johnson295189b2012-06-20 16:38:30 -07008056tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
8057{
8058 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8059 tListElem *pEntry;
8060 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 //alwasy lock active list before locking pending list
8062 csrLLLock( &pMac->sme.smeCmdActiveList );
8063 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8064 if(pEntry)
8065 {
8066 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8067 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8068 {
8069 fRet = eANI_BOOLEAN_TRUE;
8070 }
8071 }
8072 if(eANI_BOOLEAN_FALSE == fRet)
8073 {
8074 csrLLLock(&pMac->sme.smeCmdPendingList);
8075 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8076 while(pEntry)
8077 {
8078 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8079 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8080 {
8081 fRet = eANI_BOOLEAN_TRUE;
8082 break;
8083 }
8084 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8085 }
8086 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8087 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308088 if (eANI_BOOLEAN_FALSE == fRet)
8089 {
8090 csrLLLock(&pMac->roam.roamCmdPendingList);
8091 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8092 while (pEntry)
8093 {
8094 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8095 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8096 {
8097 fRet = eANI_BOOLEAN_TRUE;
8098 break;
8099 }
8100 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8101 }
8102 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 return (fRet);
8106}
8107
Jeff Johnson295189b2012-06-20 16:38:30 -07008108tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8109{
8110 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8111 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8113 {
8114 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8115 {
8116 break;
8117 }
8118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 return ( fRet );
8120}
8121
Jeff Johnson295189b2012-06-20 16:38:30 -07008122tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8123{
8124 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 //alwasy lock active list before locking pending list
8126 csrLLLock( &pMac->sme.smeCmdActiveList );
8127 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8128 if(eANI_BOOLEAN_FALSE == fRet)
8129 {
8130 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8131 }
8132 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 return (fRet);
8134}
8135
Jeff Johnson295189b2012-06-20 16:38:30 -07008136tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8137{
8138 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8139 tListElem *pEntry;
8140 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 //alwasy lock active list before locking pending list
8142 csrLLLock( &pMac->sme.smeCmdActiveList );
8143 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8144 if( pEntry )
8145 {
8146 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8147 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8148 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8149 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8150 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8151 {
8152 fRet = eANI_BOOLEAN_TRUE;
8153 }
8154 }
8155 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 return (fRet);
8157}
Jeff Johnson295189b2012-06-20 16:38:30 -07008158eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8159{
8160 eHalStatus status = eHAL_STATUS_SUCCESS;
8161 tSmeCmd *pCommand = NULL;
8162 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8163 tANI_BOOLEAN fRemoveCmd = FALSE;
8164 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 // Delete the old assoc command. All is setup for reassoc to be serialized
8166 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8167 if ( pEntry )
8168 {
8169 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8170 if ( !pCommand )
8171 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008172 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 return eHAL_STATUS_RESOURCES;
8174 }
8175 if ( eSmeCommandRoam == pCommand->command )
8176 {
8177 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8178 {
8179 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8180 }
8181 else
8182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008183 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 }
8185 if (fRemoveCmd == FALSE)
8186 {
8187 // Implies we did not get the serialized assoc command we
8188 // were expecting
8189 pCommand = NULL;
8190 }
8191 }
8192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 if(NULL == pCommand)
8194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008195 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 return eHAL_STATUS_RESOURCES;
8197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 do
8199 {
8200 //Change the substate in case it is wait-for-key
8201 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8202 {
8203 csrRoamStopWaitForKeyTimer( pMac );
8204 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8205 }
8206 pCommand->command = eSmeCommandRoam;
8207 pCommand->sessionId = (tANI_U8)sessionId;
8208 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8210 if( !HAL_STATUS_SUCCESS( status ) )
8211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008212 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 csrReleaseCommandRoam( pMac, pCommand );
8214 }
8215 } while( 0 );
8216
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 return( status );
8218}
8219static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8220{
8221 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8222 tCsrScanResult *pScanResult = NULL;
8223 tSirBssDescription *pBssDesc = NULL;
8224 tSmeCmd *pCommand = NULL;
8225 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308226 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 if(NULL == pEntry)
8228 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308229 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 return;
8231 }
8232 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8233 sessionId = pCommand->sessionId;
8234 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008235
8236 if(!pSession)
8237 {
8238 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8239 return;
8240 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308241 smsLog(pMac, LOG1, FL("CFG return value is %d "
8242 " current state is : %d substate is : %d "),
8243 result, pMac->roam.curState[sessionId],
8244 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8246 {
8247 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008248 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8250 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008251 /* If the roaming has stopped, not to continue the roaming command*/
8252 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8253 {
8254 //No need to complete roaming here as it already completes
8255 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8256 pCommand->u.roamCmd.roamReason);
8257 csrSetAbortRoamingCommand( pMac, pCommand );
8258 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 else
8261 {
8262 if ( CCM_IS_RESULT_SUCCESS(result) )
8263 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308264 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 // Successfully set the configuration parameters for the new Bss. Attempt to
8266 // join the roaming Bss.
8267 if(pCommand->u.roamCmd.pRoamBssEntry)
8268 {
8269 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308270 if (!pScanResult)
8271 {
8272 smsLog(pMac, LOGE,
8273 FL("Failed to get base address for pScanResult"));
8274 return;
8275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 pBssDesc = &pScanResult->Result.BssDescriptor;
8277 }
8278 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8279 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 )
8282 {
8283 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8284 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8285 pBssDesc, pCommand->u.roamCmd.roamId )))
8286 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308287 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 //We need to complete the command
8289 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8290 }
8291 }
8292 else
8293 {
8294 if (!pCommand->u.roamCmd.pRoamBssEntry)
8295 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308296 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 //We need to complete the command
8298 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8299 return;
8300 }
8301 // If we are roaming TO an Infrastructure BSS...
8302 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308303 if( !pScanResult->Result.pvIes )
8304 {
8305 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8306 return;
8307 }
8308
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 if ( csrIsInfraBssDesc( pBssDesc ) )
8310 {
8311 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308312 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8314 {
8315 // ..and currently in an Infrastructure connection....
8316 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8317 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308318 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 // ...and the SSIDs are equal, then we Reassoc.
8320 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8321 pIesLocal ) )
8322 // ..and currently in an infrastructure connection
8323 {
8324 // then issue a Reassoc.
8325 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8326 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8327 &pCommand->u.roamCmd.roamProfile );
8328 }
8329 else
8330 {
8331
8332 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8333 // previously associated AP.
8334 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8335 pIesLocal,
8336 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8337 {
8338 //try something else
8339 csrRoam( pMac, pCommand );
8340 }
8341 }
8342 }
8343 else
8344 {
8345 eHalStatus status = eHAL_STATUS_SUCCESS;
8346
8347 /* We need to come with other way to figure out that this is because of HO in BMP
8348 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008349 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 * use join request */
8351#ifdef WLAN_FEATURE_VOWIFI_11R
8352 if (csrRoamIsHandoffInProgress(pMac) &&
8353 csrRoamIs11rAssoc(pMac))
8354 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308355 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8357 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8358 }
8359 else
8360#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008361#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008363 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308365 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 // Now serialize the reassoc command.
8367 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8368 }
8369 else
8370#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008371#ifdef FEATURE_WLAN_LFR
8372 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308373 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008374 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308375 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008376 // Now serialize the reassoc command.
8377 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8378 }
8379 else
8380#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 // else we are not connected and attempting to Join. Issue the
8382 // Join request.
8383 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308384 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8386 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8387 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8388 }
8389 if(!HAL_STATUS_SUCCESS(status))
8390 {
8391 //try something else
8392 csrRoam( pMac, pCommand );
8393 }
8394 }
8395 if( !pScanResult->Result.pvIes )
8396 {
8397 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308398 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 }
8400 }
8401 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8402 else
8403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008404 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 }
8406 }//else
8407 }//if ( WNI_CFG_SUCCESS == result )
8408 else
8409 {
8410 // In the event the configuration failed, for infra let the roam processor
8411 //attempt to join something else...
8412 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8413 {
8414 csrRoam(pMac, pCommand);
8415 }
8416 else
8417 {
8418 //We need to complete the command
8419 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8420 {
8421 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8422 }
8423 else
8424 {
8425 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8426 }
8427 }
8428 }
8429 }//we have active entry
8430}
8431
Jeff Johnson295189b2012-06-20 16:38:30 -07008432static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8433{
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008436 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8438 // join the new one...
8439 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8441 }
8442 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008443 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 /***profHandleLostLinkAfterReset(pAdapter);
8445 // In the event the authenticate fails, let the roam processor attempt to join something else...
8446 roamRoam( pAdapter );***/
8447 }
8448}
8449
Jeff Johnson295189b2012-06-20 16:38:30 -07008450static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8451{
8452 eCsrRoamCompleteResult result;
8453 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8454 tCsrRoamInfo roamInfo;
8455 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308456 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308457 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308458 tANI_U8 nilMac[6] = {0};
8459
8460 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008462 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 /* Defeaturize this part later if needed */
8465#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8466 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8467 * we need the response contents while processing the result in csrRoamProcessResults() */
8468 if (csrRoamIsHandoffInProgress(pMac))
8469 {
8470 /* Need to dig more on indicating events to SME QoS module */
8471 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8472 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308473#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8474 /* Add previous BSSID to blacklist ; this will be in blacklised for
8475 * some period and score of this AP will be reduced if black listed
8476 * to avoid ping pong */
8477 if (pMac->PERroamCandidatesCnt)
8478 {
8479 current_timestamp = jiffies_to_msecs(jiffies);
8480 for (candidateApCnt = 0; candidateApCnt <
8481 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8482 {
8483 /* Find one blank entry */
8484 if (sirCompareMacAddr(nilMac,
8485 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8486 {
8487 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8488 bssAddr,
8489 pNeighborRoamInfo->prevConnProfile.bssid,
8490 sizeof(tSirMacAddr));
8491 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8492 current_timestamp;
8493 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8494 MAC_ADDR_ARRAY(
8495 pNeighborRoamInfo->prevConnProfile.bssid),
8496 candidateApCnt);
8497 break;
8498 }
8499 /* if already in the list */
8500 if (sirCompareMacAddr(pMac->previousRoamApInfo
8501 [candidateApCnt].bssAddr,
8502 pNeighborRoamInfo->prevConnProfile.bssid) &&
8503 ((current_timestamp -
8504 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8505 pMac->PERroamTimeout))
8506 {
8507 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8508 bssAddr,
8509 pNeighborRoamInfo->prevConnProfile.bssid,
8510 sizeof(tSirMacAddr));
8511 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8512 current_timestamp;
8513 break;
8514 } else
8515 {
8516 /* find oldest BSSID entry in the blacklist */
8517 if (max_time <
8518 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8519 {
8520 max_time =
8521 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8522 oldestIndex = candidateApCnt;
8523 }
8524 }
8525 }
8526 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8527 {
8528 smsLog(pMac, LOGW,
8529 "%s: Clearing out oldest roam results bssid="
8530 MAC_ADDRESS_STR,
8531 __func__,
8532 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8533 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8534 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8535 pNeighborRoamInfo->prevConnProfile.bssid,
8536 sizeof(tSirMacAddr));
8537 }
8538 }
8539#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 }
8541 else
8542#endif
8543 {
8544 csrRoamComplete( pMac, result, NULL );
8545 }
8546 }
8547 /* Should we handle this similar to handling the join failure? Is it ok
8548 * to call csrRoamComplete() with state as CsrJoinFailure */
8549 else
8550 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008551 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308553 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8554 WLAN_LOG_INDICATOR_HOST_DRIVER,
8555 WLAN_LOG_REASON_ROAM_FAIL,
8556 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008557#ifdef WLAN_FEATURE_VOWIFI_11R
8558 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308559 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8560 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008561 {
8562 // Inform HDD to turn off FT flag in HDD
8563 if (pNeighborRoamInfo)
8564 {
8565 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8566 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8567 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008568 /*
8569 * Since the above callback sends a disconnect
8570 * to HDD, we should clean-up our state
8571 * machine as well to be in sync with the upper
8572 * layers. There is no need to send a disassoc
8573 * since: 1) we will never reassoc to the current
8574 * AP in LFR, and 2) there is no need to issue a
8575 * disassoc to the AP with which we were trying
8576 * to reassoc.
8577 */
8578 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8579 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 }
8581 }
8582#endif
8583 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8584 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8585 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8586 //The disassoc rsp message will remove the command from active list
8587 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8588 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8589 {
8590 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8591 }
8592 }
8593}
8594
Jeff Johnson295189b2012-06-20 16:38:30 -07008595static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8596{
Jeff Johnson295189b2012-06-20 16:38:30 -07008597#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8598 {
8599 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8601 if(pIbssLog)
8602 {
8603 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8604 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8605 {
8606 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8607 }
8608 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8609 }
8610 }
8611#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008612 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8613 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8614 {
8615 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8616 }
8617 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8618 {
8619 csrRoamReissueRoamCommand(pMac);
8620 }
8621}
8622
Jeff Johnson295189b2012-06-20 16:38:30 -07008623void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8624{
8625 tSirResultCodes statusCode;
8626#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8627 tScanResultHandle hBSSList;
8628 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8629 eHalStatus status;
8630 tCsrRoamInfo roamInfo;
8631 tCsrScanResultFilter *pScanFilter = NULL;
8632 tANI_U32 roamId = 0;
8633 tCsrRoamProfile *pCurRoamProfile = NULL;
8634 tListElem *pEntry = NULL;
8635 tSmeCmd *pCommand = NULL;
8636#endif
8637 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308638 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008639
Jeff Johnson295189b2012-06-20 16:38:30 -07008640 tSirSmeDisassocRsp SmeDisassocRsp;
8641
8642 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8643 sessionId = SmeDisassocRsp.sessionId;
8644 statusCode = SmeDisassocRsp.statusCode;
8645
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008646 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008647
8648 if ( csrIsConnStateInfra( pMac, sessionId ) )
8649 {
8650 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008653
8654 if(!pSession)
8655 {
8656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8657 return;
8658 }
8659
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8661 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308662 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8664 }
8665 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8666 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8667 {
8668 if ( eSIR_SME_SUCCESS == statusCode )
8669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008670 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8672 }
8673 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008675 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8676 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308677 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8678 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008679#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008680 /*
8681 * First ensure if the roam profile is in the scan cache.
8682 * If not, post a reassoc failure and disconnect.
8683 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308684 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8685 if ( NULL == pScanFilter )
8686 status = eHAL_STATUS_FAILURE;
8687 else
8688 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008689 if(HAL_STATUS_SUCCESS(status))
8690 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308691 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008692 status = csrRoamPrepareFilterFromProfile(pMac,
8693 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8694 if(!HAL_STATUS_SUCCESS(status))
8695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008696 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008697 __func__, status);
8698 goto POST_ROAM_FAILURE;
8699 }
8700 else
8701 {
8702 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8703 if (!HAL_STATUS_SUCCESS(status))
8704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008705 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008706 __func__, status);
8707 goto POST_ROAM_FAILURE;
8708 }
8709 }
8710 }
8711 else
8712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008713 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008714 __func__, status);
8715 goto POST_ROAM_FAILURE;
8716 }
8717
8718 /*
8719 * After ensuring that the roam profile is in the scan result list,
8720 * dequeue the command from the active list.
8721 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8723 if ( pEntry )
8724 {
8725 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008726 /* If the head of the queue is Active and it is a ROAM command, remove
8727 * and put this on the Free queue.
8728 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 if ( eSmeCommandRoam == pCommand->command )
8730 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008731
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008732 /*
8733 * we need to process the result first before removing it from active list
8734 * because state changes still happening insides roamQProcessRoamResults so
8735 * no other roam command should be issued.
8736 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8738 if(pCommand->u.roamCmd.fReleaseProfile)
8739 {
8740 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8741 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 else
8746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008747 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008748 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 }
8750 }
8751 else
8752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008753 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 }
8755 }
8756 else
8757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008758 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008760
8761 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8763
Kiet Lam64c1b492013-07-12 13:56:44 +05308764 vos_mem_copy(roamInfo.bssid,
8765 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8766 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008767
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008768 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8769 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008770
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008771 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308772 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8773 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308775 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008776 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8777 //make sure to put it at the head of the cmd queue
8778 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8779 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8780 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8781
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 if(!HAL_STATUS_SUCCESS(status))
8783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008784 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008785 __func__, status);
8786 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 }
8788
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008789 /* Notify sub-modules like QoS etc. that handoff happening */
8790 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308791 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008792 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308793 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008794 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308795 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008796 return;
8797 }
8798
8799POST_ROAM_FAILURE:
8800 if (pScanFilter)
8801 {
8802 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308803 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008804 }
8805 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308806 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008807
8808 /* Inform the upper layers that the reassoc failed */
8809 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8810 csrRoamCallCallback(pMac, sessionId,
8811 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8812
8813 /*
8814 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8815 * Upon success, we would re-enter this routine after receiving the disassoc
8816 * response and will fall into the reassoc fail sub-state. And, eventually
8817 * call csrRoamComplete which would remove the roam command from SME active
8818 * queue.
8819 */
8820 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8821 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008823 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008824 __func__, status);
8825 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008827#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008828
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8830 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8831 {
8832 // Disassoc due to Reassoc failure falls into this codepath....
8833 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8834 }
8835 else
8836 {
8837 if ( eSIR_SME_SUCCESS == statusCode )
8838 {
8839 // Successfully disassociated from the 'old' Bss...
8840 //
8841 // We get Disassociate response in three conditions.
8842 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8843 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8844 // Infrastructure network.
8845 // - Third is where we are doing an Infra to Infra roam between networks with different
8846 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8847
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008848 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 }
8850 else
8851 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008852 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 }
8854 //We are not done yet. Get the data and continue roaming
8855 csrRoamReissueRoamCommand(pMac);
8856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008857}
8858
Jeff Johnson295189b2012-06-20 16:38:30 -07008859static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8860{
8861 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008863 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8865 {
8866 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8867 }
8868 else
8869 {
8870 if ( eSIR_SME_SUCCESS == statusCode )
8871 {
8872 // Successfully deauth from the 'old' Bss...
8873 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008874 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 }
8876 else
8877 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008878 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 }
8880 //We are not done yet. Get the data and continue roaming
8881 csrRoamReissueRoamCommand(pMac);
8882 }
8883}
8884
Jeff Johnson295189b2012-06-20 16:38:30 -07008885static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8886{
8887 eCsrRoamCompleteResult result;
8888
8889 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008891 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 result = eCsrStartBssSuccess;
8893 }
8894 else
8895 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008896 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 //Let csrRoamComplete decide what to do
8898 result = eCsrStartBssFailure;
8899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008901}
8902
Jeff Johnson295189b2012-06-20 16:38:30 -07008903/*
8904 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8905 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8906 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8907 For the messages where sender allocates memory for specific structures, then it can be
8908 cast accordingly.
8909*/
8910void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8911{
8912 tSirSmeRsp *pSmeRsp;
8913 tSmeIbssPeerInd *pIbssPeerInd;
8914 tCsrRoamInfo roamInfo;
8915 // TODO Session Id need to be acquired in this function
8916 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308918 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8919 pSmeRsp->messageType, pSmeRsp->messageType,
8920 macTraceGetcsrRoamSubState(
8921 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 pSmeRsp->messageType = (pSmeRsp->messageType);
8923 pSmeRsp->length = (pSmeRsp->length);
8924 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 switch (pSmeRsp->messageType)
8926 {
8927
8928 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8929 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8930 {
8931 //We sent a JOIN_REQ
8932 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8933 }
8934 break;
8935
8936 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8937 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8938 {
8939 //We sent a AUTH_REQ
8940 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8941 }
8942 break;
8943
8944 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8945 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8946 {
8947 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8948 }
8949 break;
8950
8951 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8952 {
8953 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8954 }
8955 break;
8956
8957 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8958 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8959 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8960 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8961 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8962 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8963//HO
8964 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8965 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308966 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8967 macTraceGetcsrRoamSubState(
8968 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008969 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308970 if (pMac->roam.configParam.roamDelayStatsEnabled)
8971 {
8972 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 }
8975 break;
8976
8977 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8978 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8979 {
8980 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8981 }
8982 break;
8983
8984 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8985 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8986 {
8987 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8988 }
8989 break;
8990
8991 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8992 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8993 {
8994 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8998 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8999 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009000 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05309001 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9002 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9004 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309005 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9006 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9008 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9009 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9010 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05309011 case eWNI_SME_LOST_LINK_PARAMS_IND:
9012 {
9013 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
9014 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9015 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9016 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9017 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
9018 pRoamInfo = &roamInfo;
9019 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
9020 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
9021 break;
9022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009023 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309024 smsLog(pMac, LOG1,
9025 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9026 pSmeRsp->messageType, pSmeRsp->messageType,
9027 macTraceGetcsrRoamSubState(
9028 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009029
9030 //If we are connected, check the link status change
9031 if(!csrIsConnStateDisconnected(pMac, sessionId))
9032 {
9033 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
9034 }
9035 break;
9036 }
9037}
9038
Jeff Johnson295189b2012-06-20 16:38:30 -07009039void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
9040{
9041 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 switch (pSirMsg->messageType)
9043 {
9044 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009045 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 csrRoamStatsRspProcessor( pMac, pSirMsg );
9047 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9049 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309050 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9052 tCsrRoamInfo roamInfo;
9053 tCsrRoamInfo *pRoamInfo = NULL;
9054 tANI_U32 sessionId;
9055 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009056 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05309057 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
9060 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9061 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009062
9063 if(!pSession)
9064 {
9065 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9066 return;
9067 }
9068
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9070 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9072 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9073 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9075 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309076 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9077 sizeof(tSirMacAddr));
9078 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9079 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309081#ifdef WLAN_FEATURE_AP_HT40_24G
9082 pRoamInfo->HT40MHzIntoEnabledSta =
9083 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9084 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9085 pRoamInfo->HT40MHzIntoEnabledSta);
9086#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309087 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309088 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9089 pRoamInfo->chan_info = pUpperLayerAssocCnf->chan_info;
9090 if (pUpperLayerAssocCnf->HTCaps.present)
9091 pRoamInfo->ht_caps = pUpperLayerAssocCnf->HTCaps;
9092 if (pUpperLayerAssocCnf->VHTCaps.present)
9093 pRoamInfo->vht_caps = pUpperLayerAssocCnf->VHTCaps;
9094
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9096 {
9097 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9098 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9099 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9100 }
9101 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9102 {
9103 vos_sleep( 100 );
9104 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9105 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9106 }
9107
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 }
9109 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 default:
9111 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9112 break;
9113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009114}
9115
Jeff Johnson295189b2012-06-20 16:38:30 -07009116eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9117 tSirBssDescription *pBssDescription,
9118 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9119 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9120 tANI_U8 keyId, tANI_U16 keyLength,
9121 tANI_U8 *pKey, tANI_U8 paeRole )
9122{
9123 eHalStatus status = eHAL_STATUS_SUCCESS;
9124 tAniEdType edType;
9125
9126 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9127 {
9128 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9129 }
9130
9131 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9132
9133 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9134 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9135 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9136 addKey )
9137 {
9138 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 setKey.encType = EncryptType;
9140 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309141 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 setKey.paeRole = paeRole; //0 for supplicant
9143 setKey.keyId = keyId; // Kye index
9144 setKey.keyLength = keyLength;
9145 if( keyLength )
9146 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309147 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 }
9149 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 return (status);
9152}
9153
Jeff Johnson295189b2012-06-20 16:38:30 -07009154static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9155 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9156{
9157 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9158 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009159#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009161#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009162
9163 do
9164 {
9165 pCommand = csrGetCommandBuffer(pMac);
9166 if(NULL == pCommand)
9167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009168 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 status = eHAL_STATUS_RESOURCES;
9170 break;
9171 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309172 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 pCommand->command = eSmeCommandSetKey;
9174 pCommand->sessionId = (tANI_U8)sessionId;
9175 // validate the key length, Adjust if too long...
9176 // for static WEP the keys are not set thru' SetContextReq
9177 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9178 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9179 {
9180 //KeyLength maybe 0 for static WEP
9181 if( pSetKey->keyLength )
9182 {
9183 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009185 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 break;
9187 }
9188
9189 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309190 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9191 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 }
9193 }
9194 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9195 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9196 {
9197 //KeyLength maybe 0 for static WEP
9198 if( pSetKey->keyLength )
9199 {
9200 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009202 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 break;
9204 }
9205
9206 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309207 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9208 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 }
9210 }
9211 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9212 {
9213 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009215 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009216 break;
9217 }
9218 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309219 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9220 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 }
9222 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9223 {
9224 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009226 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 break;
9228 }
9229 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309230 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9231 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 }
9233#ifdef FEATURE_WLAN_WAPI
9234 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9235 {
9236 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009238 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 break;
9240 }
9241 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309242 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9243 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 }
9245#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009246#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9248 {
9249 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009251 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 break;
9253 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009254 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309255 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009256 pSession->eseCckmInfo.reassoc_req_num=1;
9257 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 status = eHAL_STATUS_SUCCESS;
9259 break;
9260 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009261#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009262
Jeff Johnson295189b2012-06-20 16:38:30 -07009263#ifdef WLAN_FEATURE_11W
9264 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009265 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009267 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009268 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009269 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 break;
9271 }
9272 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309273 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009274 }
9275#endif
9276 status = eHAL_STATUS_SUCCESS;
9277 pCommand->u.setKeyCmd.roamId = roamId;
9278 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9279 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309280 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9281 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9283 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309284 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 //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
9286
9287 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9288 if( !HAL_STATUS_SUCCESS( status ) )
9289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009290 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 }
9292 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009293 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009294 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009295 if ( ( NULL != pCommand ) &&
9296 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009297#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009299#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009300 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 {
9302 csrReleaseCommandSetKey( pMac, pCommand );
9303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 return( status );
9305}
9306
Jeff Johnson295189b2012-06-20 16:38:30 -07009307eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9308 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9309{
9310 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9311 tSmeCmd *pCommand = NULL;
9312 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 do
9314 {
9315 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009317 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 status = eHAL_STATUS_CSR_WRONG_STATE;
9319 break;
9320 }
9321 pCommand = csrGetCommandBuffer(pMac);
9322 if(NULL == pCommand)
9323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009324 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009325 status = eHAL_STATUS_RESOURCES;
9326 break;
9327 }
9328 pCommand->command = eSmeCommandRemoveKey;
9329 pCommand->sessionId = (tANI_U8)sessionId;
9330 pCommand->u.removeKeyCmd.roamId = roamId;
9331 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309332 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9333 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9335 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9336 {
9337 //in this case, put it to the end of the Q incase there is a set key pending.
9338 fImediate = eANI_BOOLEAN_FALSE;
9339 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009340 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009342 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9344 if( !HAL_STATUS_SUCCESS( status ) )
9345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009346 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 break;
9348 }
9349 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9351 {
9352 csrReleaseCommandRemoveKey( pMac, pCommand );
9353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 return (status );
9355}
9356
Jeff Johnson295189b2012-06-20 16:38:30 -07009357eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9358{
9359 eHalStatus status;
9360 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9361 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9362 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9363 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009364#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9365 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9366 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309367 if(!pSession)
9368 {
9369 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9370 return eHAL_STATUS_FAILURE;
9371 }
lukez3c809222013-05-03 10:23:02 -07009372 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009373 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309374 vos_mem_set(&setKeyEvent,
9375 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009376 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9377 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309378 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9380 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9381 }
9382 else
9383 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309384 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9386 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9387 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309388 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009389 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009390 {
9391 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 //It has to be static WEP here
9393 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9394 {
9395 setKeyEvent.keyId = (v_U8_t)defKeyId;
9396 }
9397 }
9398 else
9399 {
9400 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9401 }
9402 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9403 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9404 }
9405#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 if( csrIsSetKeyAllowed(pMac, sessionId) )
9407 {
9408 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9409 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9410 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9411 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9412 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9413 pCommand->u.setKeyCmd.keyRsc);
9414 }
9415 else
9416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009417 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 //Set this status so the error handling take care of the case.
9419 status = eHAL_STATUS_CSR_WRONG_STATE;
9420 }
9421 if( !HAL_STATUS_SUCCESS(status) )
9422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009423 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009425#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009426 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 {
9428 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9429 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309430 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 }
9432 else
9433 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309434 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 }
9436 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9437 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9438 }
9439#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 return ( status );
9442}
9443
Jeff Johnson295189b2012-06-20 16:38:30 -07009444eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9445{
9446 eHalStatus status;
9447 tpSirSmeRemoveKeyReq pMsg = NULL;
9448 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9449 tANI_U8 *p;
9450 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009451#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9452 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9453 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309454 if(!pSession)
9455 {
9456 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9457 return eHAL_STATUS_FAILURE;
9458 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309459 vos_mem_set(&removeKeyEvent,
9460 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9462 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9463 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309464 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9466 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9467 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9468#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 if( csrIsSetKeyAllowed(pMac, sessionId) )
9470 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309471 pMsg = vos_mem_malloc(wMsgLen);
9472 if ( NULL == pMsg )
9473 status = eHAL_STATUS_FAILURE;
9474 else
9475 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 }
9477 else
9478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009479 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 //Set the error status so error handling kicks in below
9481 status = eHAL_STATUS_CSR_WRONG_STATE;
9482 }
9483 if( HAL_STATUS_SUCCESS( status ) )
9484 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309485 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9487 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 pMsg->sessionId = (tANI_U8)sessionId;
9489 pMsg->transactionId = 0;
9490 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9491 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9492 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309493 vos_mem_copy(p,
9494 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9495 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 p += sizeof(tSirMacAddr);
9497 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309498 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 p += sizeof(tSirMacAddr);
9500 // edType
9501 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9502 p++;
9503 // weptype
9504 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9505 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9506 {
9507 *p = (tANI_U8)eSIR_WEP_STATIC;
9508 }
9509 else
9510 {
9511 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9512 }
9513 p++;
9514 //keyid
9515 *p = pCommand->u.removeKeyCmd.keyId;
9516 p++;
9517 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009518 status = palSendMBMessage(pMac->hHdd, pMsg);
9519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 if( !HAL_STATUS_SUCCESS( status ) )
9521 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009522 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009523#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9524 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009525 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9527#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 return ( status );
9531}
9532
Jeff Johnson295189b2012-06-20 16:38:30 -07009533eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9534{
9535 eHalStatus status;
9536
9537 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9538 {
9539 status = eHAL_STATUS_CSR_WRONG_STATE;
9540 }
9541 else
9542 {
9543 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 return ( status );
9546}
9547
Jeff Johnson295189b2012-06-20 16:38:30 -07009548/*
9549 Prepare a filter base on a profile for parsing the scan results.
9550 Upon successful return, caller MUST call csrFreeScanFilter on
9551 pScanFilter when it is done with the filter.
9552*/
9553eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9554 tCsrScanResultFilter *pScanFilter)
9555{
9556 eHalStatus status = eHAL_STATUS_SUCCESS;
9557 tANI_U32 size = 0;
9558 tANI_U8 index = 0;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309559 uint8_t i;
Jeff Johnson295189b2012-06-20 16:38:30 -07009560
9561 do
9562 {
9563 if(pProfile->BSSIDs.numOfBSSIDs)
9564 {
9565 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309566 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9567 if ( NULL == pScanFilter->BSSIDs.bssid )
9568 status = eHAL_STATUS_FAILURE;
9569 else
9570 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 if(!HAL_STATUS_SUCCESS(status))
9572 {
9573 break;
9574 }
9575 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309576 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 }
9578 if(pProfile->SSIDs.numOfSSIDs)
9579 {
9580 if( !CSR_IS_WDS_STA( pProfile ) )
9581 {
9582 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9583 }
9584 else
9585 {
9586 //For WDS station
9587 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9588 pScanFilter->SSIDs.numOfSSIDs = 1;
9589 }
9590 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309591 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9592 if ( NULL == pScanFilter->SSIDs.SSIDList )
9593 status = eHAL_STATUS_FAILURE;
9594 else
9595 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 if(!HAL_STATUS_SUCCESS(status))
9597 {
9598 break;
9599 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309600 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9601 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 }
9603 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9604 {
9605 pScanFilter->ChannelInfo.numOfChannels = 0;
9606 pScanFilter->ChannelInfo.ChannelList = NULL;
9607 }
9608 else if(pProfile->ChannelInfo.numOfChannels)
9609 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309610 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9611 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9612 pProfile->ChannelInfo.numOfChannels);
9613 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9614 status = eHAL_STATUS_FAILURE;
9615 else
9616 status = eHAL_STATUS_SUCCESS;
9617
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 pScanFilter->ChannelInfo.numOfChannels = 0;
9619 if(HAL_STATUS_SUCCESS(status))
9620 {
9621 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9622 {
9623 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9624 {
9625 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9626 = pProfile->ChannelInfo.ChannelList[index];
9627 pScanFilter->ChannelInfo.numOfChannels++;
9628 }
9629 else
9630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009631 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 }
9634 }
9635 else
9636 {
9637 break;
9638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 }
9640 else
9641 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309642 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 status = eHAL_STATUS_FAILURE;
9644 break;
9645 }
9646 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309647 if (pProfile->force_rsne_override) {
9648 smsLog(pMac, LOG1, FL("force_rsne_override enabled fill all auth type and enctype"));
9649
9650 pScanFilter->authType.numEntries = eCSR_NUM_OF_SUPPORT_AUTH_TYPE;
9651 for (i = 0; i < pScanFilter->authType.numEntries; i++)
9652 pScanFilter->authType.authType[i] = i;
9653 index = 0;
9654 for (i = 0; i < eCSR_NUM_OF_ENCRYPT_TYPE; i++) {
9655 if (i == eCSR_ENCRYPT_TYPE_TKIP ||
9656 i == eCSR_ENCRYPT_TYPE_AES) {
9657 pScanFilter->
9658 EncryptionType.encryptionType[index] = i;
9659 pScanFilter->
9660 mcEncryptionType.encryptionType[index] = i;
9661 index++;
9662 }
9663 }
9664 pScanFilter->EncryptionType.numEntries = index;
9665 pScanFilter->mcEncryptionType.numEntries = index;
9666 pScanFilter->ignore_pmf_cap = true;
9667 } else {
9668 pScanFilter->authType = pProfile->AuthType;
9669 pScanFilter->EncryptionType = pProfile->EncryptionType;
9670 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 pScanFilter->BSSType = pProfile->BSSType;
9673 pScanFilter->phyMode = pProfile->phyMode;
9674#ifdef FEATURE_WLAN_WAPI
9675 //check if user asked for WAPI with 11n or auto mode, in that case modify
9676 //the phymode to 11g
9677 if(csrIsProfileWapi(pProfile))
9678 {
9679 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9680 {
9681 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9682 }
9683 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9684 {
9685 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9686 }
9687 if(!pScanFilter->phyMode)
9688 {
9689 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9690 }
9691 }
9692#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 /*Save the WPS info*/
9694 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009695 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 if( pProfile->countryCode[0] )
9697 {
9698 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309699 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9700 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 }
9702#ifdef WLAN_FEATURE_VOWIFI_11R
9703 if (pProfile->MDID.mdiePresent)
9704 {
9705 pScanFilter->MDID.mdiePresent = 1;
9706 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9707 }
9708#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309709 vos_mem_copy(pScanFilter->bssid_hint,
9710 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309711
9712#ifdef WLAN_FEATURE_11W
9713 // Management Frame Protection
9714 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9715 pScanFilter->MFPRequired = pProfile->MFPRequired;
9716 pScanFilter->MFPCapable = pProfile->MFPCapable;
9717#endif
9718
Jeff Johnson295189b2012-06-20 16:38:30 -07009719 }while(0);
9720
9721 if(!HAL_STATUS_SUCCESS(status))
9722 {
9723 csrFreeScanFilter(pMac, pScanFilter);
9724 }
9725
9726 return(status);
9727}
9728
Jeff Johnson295189b2012-06-20 16:38:30 -07009729tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9730 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9731{
9732 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9733 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009734 do
9735 {
9736 // Validate the type is ok...
9737 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9738 pCommand = csrGetCommandBuffer( pMac );
9739 if ( !pCommand )
9740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009741 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 break;
9743 }
9744 //Change the substate in case it is waiting for key
9745 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9746 {
9747 csrRoamStopWaitForKeyTimer( pMac );
9748 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9749 }
9750 pCommand->command = eSmeCommandWmStatusChange;
9751 pCommand->sessionId = (tANI_U8)sessionId;
9752 pCommand->u.wmStatusChangeCmd.Type = Type;
9753 if ( eCsrDisassociated == Type )
9754 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309755 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9756 pSmeRsp,
9757 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 }
9759 else
9760 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309761 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9762 pSmeRsp,
9763 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 }
9765 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9766 {
9767 fCommandQueued = eANI_BOOLEAN_TRUE;
9768 }
9769 else
9770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009771 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 csrReleaseCommandWmStatusChange( pMac, pCommand );
9773 }
9774
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9776 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 return( fCommandQueued );
9779}
9780
Jeff Johnson295189b2012-06-20 16:38:30 -07009781static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9782{
9783 v_S7_t rssi = 0;
9784 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9785 if(pGetRssiReq)
9786 {
9787 if(NULL != pGetRssiReq->pVosContext)
9788 {
9789 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9790 }
9791 else
9792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009793 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 return;
9795 }
9796
9797 if(NULL != pGetRssiReq->rssiCallback)
9798 {
9799 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9800 }
9801 else
9802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009803 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 return;
9805 }
9806 }
9807 else
9808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009809 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 }
9811 return;
9812}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309813
9814static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9815{
9816 tANI_S8 snr = 0;
9817 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9818
9819 if (pGetSnrReq)
9820 {
9821 if (VOS_STATUS_SUCCESS !=
9822 WDA_GetSnr(pGetSnrReq->staId, &snr))
9823 {
9824 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9825 return;
9826 }
9827
9828 if (pGetSnrReq->snrCallback)
9829 {
9830 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9831 pGetSnrReq->pDevContext);
9832 }
9833 else
9834 {
9835 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9836 return;
9837 }
9838 }
9839 else
9840 {
9841 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9842 }
9843 return;
9844}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009845#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009846void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9847{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009848 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9849
Jeff Johnson36d483b2013-04-08 11:08:53 -07009850 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009851 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009852 /* Get roam Rssi request is backed up and passed back to the response,
9853 Extract the request message to fetch callback */
9854 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9855 v_S7_t rssi = pRoamRssiRsp->rssi;
9856
9857 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009858 {
9859 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9860 reqBkp->rssiCallback = NULL;
9861 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009862 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009863 }
9864 else
9865 {
9866 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9867 if (NULL != reqBkp)
9868 {
9869 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009870 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009871 }
9872 }
9873 }
9874 else
9875 {
9876 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9877 }
9878 return;
9879}
9880#endif
9881
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009882
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009883#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009884void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9885{
9886 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9887
9888 if (NULL != pTsmStatsRsp)
9889 {
9890 /* Get roam Rssi request is backed up and passed back to the response,
9891 Extract the request message to fetch callback */
9892 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9893
9894 if (NULL != reqBkp)
9895 {
9896 if (NULL != reqBkp->tsmStatsCallback)
9897 {
9898 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9899 pTsmStatsRsp->staId, reqBkp->pDevContext);
9900 reqBkp->tsmStatsCallback = NULL;
9901 }
9902 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009903 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009904 }
9905 else
9906 {
9907 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9908 if (NULL != reqBkp)
9909 {
9910 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009911 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009912 }
9913 }
9914 }
9915 else
9916 {
9917 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9918 }
9919 return;
9920}
9921
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009922void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009923{
9924 tANI_U32 roamTS2 = 0;
9925 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009926 tpPESession pSessionEntry = NULL;
9927 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009928
9929 if (NULL == pSession)
9930 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009931 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009932 return;
9933 }
9934
9935 roamTS2 = vos_timer_get_system_time();
9936 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009937 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9938 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009939 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009940
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009941 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9942 if (NULL == pSessionEntry)
9943 {
9944 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9945 return;
9946 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009947 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009948 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009949 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009950}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009951#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009952
Jeff Johnsone7245742012-09-05 17:12:55 -07009953static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9954{
9955 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9956 if(pTlRssiInd)
9957 {
9958 if(NULL != pTlRssiInd->tlCallback)
9959 {
9960 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009961 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009962 }
9963 else
9964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009965 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009966 }
9967 }
9968 else
9969 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009970 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009971 }
9972 return;
9973}
Jeff Johnson295189b2012-06-20 16:38:30 -07009974
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309975eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9976{
9977 tpSirResetAPCapsChange pMsg;
9978 tANI_U16 len;
9979 eHalStatus status = eHAL_STATUS_SUCCESS;
9980
9981 /* Create the message and send to lim */
9982 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309983 pMsg = vos_mem_malloc(len);
9984 if ( NULL == pMsg )
9985 status = eHAL_STATUS_FAILURE;
9986 else
9987 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309988 if (HAL_STATUS_SUCCESS(status))
9989 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309990 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309991 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9992 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309993 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009994 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9995 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309996 status = palSendMBMessage(pMac->hHdd, pMsg);
9997 }
9998 else
9999 {
10000 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
10001 }
10002 return status;
10003}
10004
Jeff Johnson295189b2012-06-20 16:38:30 -070010005void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
10006{
10007 tSirSmeAssocInd *pAssocInd;
10008 tSirSmeDisassocInd *pDisassocInd;
10009 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010010 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
10012 tSirSmeNewBssInfo *pNewBss;
10013 tSmeIbssPeerInd *pIbssPeerInd;
10014 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10015 tSirSmeApNewCaps *pApNewCaps;
10016 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10017 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
10018 tCsrRoamInfo *pRoamInfo = NULL;
10019 tCsrRoamInfo roamInfo;
10020 eHalStatus status;
10021 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
10022 tCsrRoamSession *pSession = NULL;
10023 tpSirSmeSwitchChannelInd pSwitchChnInd;
10024 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +053010025 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -080010026
10027
10028 if (NULL == pSirMsg)
10029 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
10030 return;
10031 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 switch( pSirMsg->messageType )
10033 {
10034 case eWNI_SME_ASSOC_IND:
10035 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053010036 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053010037 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
10039 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
10040 if( HAL_STATUS_SUCCESS( status ) )
10041 {
10042 pSession = CSR_GET_SESSION(pMac, sessionId);
10043
Jeff Johnson32d95a32012-09-10 13:15:23 -070010044 if(!pSession)
10045 {
10046 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10047 return;
10048 }
10049
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 pRoamInfo = &roamInfo;
10051
10052 // Required for indicating the frames to upper layer
10053 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
10054 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
10055
10056 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
10057 pRoamInfo->beaconLength = pAssocInd->beaconLength;
10058 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
10059 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10060
10061 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
10062 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
10063 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10064
10065 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
10066 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +053010067 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
10068 sizeof(tSirMacAddr));
10069 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
10070 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +053010072 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053010073#ifdef WLAN_FEATURE_AP_HT40_24G
10074 pRoamInfo->HT40MHzIntoEnabledSta =
10075 pAssocInd->HT40MHzIntoEnabledSta;
10076 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
10077 pRoamInfo->HT40MHzIntoEnabledSta);
10078#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -070010081 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
10082 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010083#ifdef SAP_AUTH_OFFLOAD
10084 if (pMac->sap_auth_offload)
10085 {
10086 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
10087 pRoamInfo->fAuthRequired = FALSE;
10088 }
10089 else
10090 {
10091#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10093 {
10094 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10095 pSession->pConnectBssDesc,
10096 &(pRoamInfo->peerMac),
10097 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10098 pRoamInfo->fAuthRequired = FALSE;
10099 }
10100 else
10101 {
10102 pRoamInfo->fAuthRequired = TRUE;
10103 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010104#ifdef SAP_AUTH_OFFLOAD
10105 }
10106#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10108 if (!HAL_STATUS_SUCCESS(status))
10109 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 /* Send Association completion message to PE */
10112 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10113
10114 /* send a message to CSR itself just to avoid the EAPOL frames going
10115 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10117 {
10118 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10121 {
10122 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10123 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10124 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 }
10127 }
10128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010131 // Check if AP dis-associated us because of MIC failure. If so,
10132 // then we need to take action immediately and not wait till the
10133 // the WmStatusChange requests is pushed and processed
10134 tSmeCmd *pCommand;
10135
10136 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10137 status = csrRoamGetSessionIdFromBSSID( pMac,
10138 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10139 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010141 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10142 " for session %d "), sessionId);
10143 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10144 MAC_ADDRESS_STR " "
10145 " reason = %d status = %d "),
10146 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10147 pDisassocInd->reasonCode,
10148 pDisassocInd->statusCode);
10149 // If we are in neighbor preauth done state then on receiving
10150 // disassoc or deauth we dont roam instead we just disassoc
10151 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010152 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010153#ifdef WLAN_FEATURE_VOWIFI_11R
10154 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10155 {
10156 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010158#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010159#ifdef FEATURE_WLAN_ESE
10160 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010161 {
10162 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010164#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010165#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010166 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10167 {
10168 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10169 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010170#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010171#ifdef WLAN_FEATURE_LFR_MBB
10172 csr_stop_preauth_reassoc_mbb_timer(pMac);
10173#endif
10174
Agarwal Ashish4f616132013-12-30 23:32:50 +053010175 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010176
Agarwal Ashish4f616132013-12-30 23:32:50 +053010177 if (!pSession)
10178 {
10179 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10180 return;
10181 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010182
Agarwal Ashish4f616132013-12-30 23:32:50 +053010183 if ( csrIsConnStateInfra( pMac, sessionId ) )
10184 {
10185 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010187#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010188 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010189#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010190 csrRoamLinkDown(pMac, sessionId);
10191 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10192 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10193 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010194 /*
10195 * STA/P2P client got disassociated so remove any pending deauth
10196 * commands in sme pending list
10197 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010198 pCommand = csrGetCommandBuffer(pMac);
10199 if (NULL == pCommand)
10200 {
10201 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10202 status = eHAL_STATUS_RESOURCES;
10203 return;
10204 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010205 pCommand->command = eSmeCommandRoam;
10206 pCommand->sessionId = (tANI_U8)sessionId;
10207 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10208 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10209 pDisassocInd->peerMacAddr,
10210 sizeof(tSirMacAddr));
10211 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10212 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010213
Agarwal Ashish4f616132013-12-30 23:32:50 +053010214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010216 else
10217 {
10218 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10219 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10220 }
Kiet Lam82004c62013-11-11 13:24:28 +053010221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010224 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10226 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10227 if( HAL_STATUS_SUCCESS( status ) )
10228 {
10229 // If we are in neighbor preauth done state then on receiving
10230 // disassoc or deauth we dont roam instead we just disassoc
10231 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010232 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010233#ifdef WLAN_FEATURE_VOWIFI_11R
10234 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10235 {
10236 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10237 }
10238#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010239#ifdef FEATURE_WLAN_ESE
10240 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 {
10242 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10243 }
10244#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010245#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010246 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010247 {
10248 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10249 }
10250#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010251#ifdef WLAN_FEATURE_LFR_MBB
10252 csr_stop_preauth_reassoc_mbb_timer(pMac);
10253#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 pSession = CSR_GET_SESSION( pMac, sessionId );
10255
Jeff Johnson32d95a32012-09-10 13:15:23 -070010256 if(!pSession)
10257 {
10258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10259 return;
10260 }
10261
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 if ( csrIsConnStateInfra( pMac, sessionId ) )
10263 {
10264 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010266#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10267 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10268#endif
Yeshwanth Sriram Guntuka381bfa82018-11-06 18:29:50 +053010269#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
10270 csrRemoveNeighbourRoamPreauthCommand(pMac);
10271#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010272 csrRoamLinkDown(pMac, sessionId);
10273 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 }
10275 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010276
10277 case eWNI_SME_DISCONNECT_DONE_IND:
10278 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10279 smsLog( pMac, LOG1,
10280 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10281 pDisConDoneInd->reasonCode);
10282 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10283 {
10284 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10285 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10286 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10287 sizeof(tSirMacAddr));
10288 status = csrRoamCallCallback(pMac,
10289 pDisConDoneInd->sessionId,
10290 &roamInfo, 0,
10291 eCSR_ROAM_LOSTLINK,
10292 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010293 pSession = CSR_GET_SESSION(pMac,
10294 pDisConDoneInd->sessionId);
10295 if (pSession &&
10296 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10297 csrRoamStateChange(pMac,
10298 eCSR_ROAMING_STATE_IDLE,
10299 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010300 }
10301 else
10302 {
10303 smsLog(pMac, LOGE, FL("Inactive session %d"),
10304 pDisConDoneInd->sessionId);
10305 }
10306 break;
10307
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 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 -080010309 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010310
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10312 //Update with the new channel id.
10313 //The channel id is hidden in the statusCode.
10314 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10315 if( HAL_STATUS_SUCCESS( status ) )
10316 {
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010317 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010319 if(!pSession)
10320 {
10321 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10322 return;
10323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10325 if(pSession->pConnectBssDesc)
10326 {
10327 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10328 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010329 pRoamInfo->chan_info.chan_id =
10330 (tANI_U8)pSwitchChnInd->newChannelId;
10331 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10332 eCSR_ROAM_STA_CHANNEL_SWITCH,
10333 eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 }
10335 break;
10336
10337 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010338 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 {
10340 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10341 sessionId = pDeauthRsp->sessionId;
10342 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10343 {
10344 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010345 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10346 {
10347 pRoamInfo = &roamInfo;
10348 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010349 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10350 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10352 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10353 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10354 }
10355 }
10356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 break;
10358
10359 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010360 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010361 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 {
10363 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10364 sessionId = pDisassocRsp->sessionId;
10365 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10366 {
10367 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10369 {
10370 pRoamInfo = &roamInfo;
10371 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010372 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10373 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10375 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10376 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10377 }
10378 }
10379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010380 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010381 case eWNI_SME_LOST_LINK_PARAMS_IND:
10382 {
10383 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10384 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10385 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10386 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10387 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10388 pRoamInfo = &roamInfo;
10389 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10390 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10391 break;
10392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010393 case eWNI_SME_MIC_FAILURE_IND:
10394 {
10395 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10396 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10397 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010398
10399 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10400 if( HAL_STATUS_SUCCESS( status ) )
10401 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010402 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010403 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10404 pRoamInfo = &roamInfo;
10405 if(pMicInd->info.multicast)
10406 {
10407 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10408 }
10409 else
10410 {
10411 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10412 }
10413 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10414 }
10415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10417 {
lukez3c809222013-05-03 10:23:02 -070010418 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010420 if(!pSession)
10421 {
10422 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10423 return;
10424 }
lukez3c809222013-05-03 10:23:02 -070010425
Kiet Lam64c1b492013-07-12 13:56:44 +053010426 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10428 secEvent.encryptionModeMulticast =
10429 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10430 secEvent.encryptionModeUnicast =
10431 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10432 secEvent.authMode =
10433 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010434 vos_mem_copy(secEvent.bssid,
10435 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10437 }
10438#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 }
10440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010441 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10442 {
10443 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10444 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010445 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010446
10447 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10448 if( HAL_STATUS_SUCCESS( status ) )
10449 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010450 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10452 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10453 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10454 }
10455 }
10456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010457
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10459 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10460 switch( pStatusChangeMsg->statusChangeCode )
10461 {
10462 case eSIR_SME_IBSS_ACTIVE:
10463 sessionId = csrFindIbssSession( pMac );
10464 if( CSR_SESSION_ID_INVALID != sessionId )
10465 {
10466 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010467 if(!pSession)
10468 {
10469 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10470 return;
10471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10473 if(pSession->pConnectBssDesc)
10474 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010475 vos_mem_copy(&roamInfo.bssid,
10476 pSession->pConnectBssDesc->bssId,
10477 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010478 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10479 pRoamInfo = &roamInfo;
10480 }
10481 else
10482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010483 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010484 }
10485 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10486 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10487 }
10488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 case eSIR_SME_IBSS_INACTIVE:
10490 sessionId = csrFindIbssSession( pMac );
10491 if( CSR_SESSION_ID_INVALID != sessionId )
10492 {
10493 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010494 if(!pSession)
10495 {
10496 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10497 return;
10498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10500 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10501 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10502 }
10503 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10505 sessionId = csrFindIbssSession( pMac );
10506 if( CSR_SESSION_ID_INVALID != sessionId )
10507 {
10508 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010509 if(!pSession)
10510 {
10511 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10512 return;
10513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 // update the connection state information
10515 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010516#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10517 {
10518 vos_log_ibss_pkt_type *pIbssLog;
10519 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10521 if(pIbssLog)
10522 {
10523 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10524 if(pNewBss)
10525 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010526 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Yeshwanth Sriram Guntuka7231db02018-08-10 15:18:21 +053010527 if(pNewBss->ssId.length >
10528 VOS_LOG_MAX_SSID_SIZE)
10529 pNewBss->ssId.length =
10530 VOS_LOG_MAX_SSID_SIZE;
10531
10532 vos_mem_copy(pIbssLog->ssid,
10533 pNewBss->ssId.ssId,
10534 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 pIbssLog->operatingChannel = pNewBss->channelNumber;
10536 }
10537 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10538 {
10539 //***U8 is not enough for beacon interval
10540 pIbssLog->beaconInterval = (v_U8_t)bi;
10541 }
10542 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10543 }
10544 }
10545#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010547
10548 if ((eCSR_ENCRYPT_TYPE_NONE ==
10549 pSession->connectedProfile.EncryptionType ))
10550 {
10551 csrRoamIssueSetContextReq( pMac, sessionId,
10552 pSession->connectedProfile.EncryptionType,
10553 pSession->pConnectBssDesc,
10554 &Broadcastaddr,
10555 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10558 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010559 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10560 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 pRoamInfo = &roamInfo;
10562 //This BSSID is th ereal BSSID, let's save it
10563 if(pSession->pConnectBssDesc)
10564 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010565 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10566 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010569 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 // detection by LIM that the capabilities of the associated AP have changed.
10572 case eSIR_SME_AP_CAPS_CHANGED:
10573 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010574 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10576 if( HAL_STATUS_SUCCESS( status ) )
10577 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010578 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10579 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010580 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010581 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10582 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10583 )
10584 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010585 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10586 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010587 }
10588 else
10589 {
10590 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010591 FL("Skipping csrScanForCapabilityChange as "
10592 "CSR is in state %s and sub-state %s"),
10593 macTraceGetcsrRoamState(
10594 pMac->roam.curState[sessionId]),
10595 macTraceGetcsrRoamSubState(
10596 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010597 /* We ignore the caps change event if CSR is not in full connected state.
10598 * Send one event to PE to reset limSentCapsChangeNtf
10599 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10600 * otherwise lim cannot send any CAPS change events to SME */
10601 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010602 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 }
10604 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010605
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 default:
10607 roamStatus = eCSR_ROAM_FAILED;
10608 result = eCSR_ROAM_RESULT_NONE;
10609 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 } // end switch on statusChangeCode
10611 if(eCSR_ROAM_RESULT_NONE != result)
10612 {
10613 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10614 }
10615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 case eWNI_SME_IBSS_NEW_PEER_IND:
10617 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010618#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10619 {
10620 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10622 if(pIbssLog)
10623 {
10624 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010625 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10627 }
10628 }
10629#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010630 sessionId = csrFindIbssSession( pMac );
10631 if( CSR_SESSION_ID_INVALID != sessionId )
10632 {
10633 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010634
10635 if(!pSession)
10636 {
10637 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10638 return;
10639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10641 if(pSession->pConnectBssDesc)
10642 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010643 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10644 sizeof(tCsrBssid));
10645 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10646 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10648 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010649 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10650 - sizeof(tSmeIbssPeerInd)));
10651 if ( NULL == roamInfo.pbFrames )
10652 status = eHAL_STATUS_FAILURE;
10653 else
10654 status = eHAL_STATUS_SUCCESS;
10655 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 {
10657 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010658 vos_mem_copy(roamInfo.pbFrames,
10659 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10660 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 }
10662 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10663 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10664 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010665 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10666 if ( NULL == roamInfo.pBssDesc )
10667 status = eHAL_STATUS_FAILURE;
10668 else
10669 status = eHAL_STATUS_SUCCESS;
10670 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010671 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010672 vos_mem_copy(roamInfo.pBssDesc,
10673 pSession->pConnectBssDesc,
10674 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010675 }
10676 if(HAL_STATUS_SUCCESS(status))
10677 {
10678 pRoamInfo = &roamInfo;
10679 }
10680 else
10681 {
10682 if(roamInfo.pbFrames)
10683 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010684 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010685 }
10686 if(roamInfo.pBssDesc)
10687 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010688 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 }
10690 }
10691 }
10692 else
10693 {
10694 pRoamInfo = &roamInfo;
10695 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010696 if ((eCSR_ENCRYPT_TYPE_NONE ==
10697 pSession->connectedProfile.EncryptionType ))
10698 {
10699 csrRoamIssueSetContextReq( pMac, sessionId,
10700 pSession->connectedProfile.EncryptionType,
10701 pSession->pConnectBssDesc,
10702 &(pIbssPeerInd->peerAddr),
10703 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10704 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010705 }
10706 else
10707 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010708 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 }
10710 //send up the sec type for the new peer
10711 if (pRoamInfo)
10712 {
10713 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10714 }
10715 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10716 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10717 if(pRoamInfo)
10718 {
10719 if(roamInfo.pbFrames)
10720 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010721 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 }
10723 if(roamInfo.pBssDesc)
10724 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010725 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010726 }
10727 }
10728 }
10729 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010730 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10731 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10732 sessionId = csrFindIbssSession( pMac );
10733 if( CSR_SESSION_ID_INVALID != sessionId )
10734 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010735#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10736 {
10737 vos_log_ibss_pkt_type *pIbssLog;
10738
10739 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10740 if(pIbssLog)
10741 {
10742 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10743 if(pIbssPeerInd)
10744 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010745 vos_mem_copy(pIbssLog->peerMacAddr,
10746 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010747 }
10748 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10749 }
10750 }
10751#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010752 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10754 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10755 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010756 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10757 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10759 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10760 }
10761 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 case eWNI_SME_SETCONTEXT_RSP:
10763 {
10764 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10765 tListElem *pEntry;
10766 tSmeCmd *pCommand;
10767
10768 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10769 if ( pEntry )
10770 {
10771 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10772 if ( eSmeCommandSetKey == pCommand->command )
10773 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010774 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010776
10777 if(!pSession)
10778 {
10779 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10780 return;
10781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010782
10783#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10784 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10785 {
10786 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010787 vos_mem_set(&setKeyEvent,
10788 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 if( pRsp->peerMacAddr[0] & 0x01 )
10790 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010791 setKeyEvent.eventId =
10792 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 }
10794 else
10795 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010796 setKeyEvent.eventId =
10797 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010798 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010799 if( pRsp->peerMacAddr[0] & 0x01 )
10800 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010801 pMac->pmc.full_power_till_set_key = false;
10802 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010804 setKeyEvent.encryptionModeMulticast =
10805 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10806 setKeyEvent.encryptionModeUnicast =
10807 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010808 vos_mem_copy(setKeyEvent.bssid,
10809 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 setKeyEvent.authMode =
10811 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010812 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010813 {
10814 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10815 }
10816 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10817 }
10818#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10819 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10820 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010821 csrRoamStopWaitForKeyTimer( pMac );
10822
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 //We are done with authentication, whethere succeed or not
10824 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 //We do it here because this linkup function is not called after association
10826 //when a key needs to be set.
10827 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10828 {
10829 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10830 }
10831 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010832 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010833 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010834 vos_mem_copy(&roamInfo.peerMac,
10835 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010836 //Make sure we install the GTK before indicating to HDD as authenticated
10837 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010838 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10839 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010840 {
Yathish9f22e662012-12-10 14:21:35 -080010841#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10842 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10843 {
10844 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010845 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010846 if (NULL == pMsg)
10847 {
10848 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10849 return;
10850 }
10851
Yathish9f22e662012-12-10 14:21:35 -080010852 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010853 pMsg->length = pal_cpu_to_be16(sizeof(
10854 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010855 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010856 vos_mem_copy(pMsg->bssid,
10857 pSession->connectedProfile.bssid,
10858 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010859 status = palSendMBMessage(pMac->hHdd, pMsg );
10860 }
10861#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010862 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010863 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010864 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010865 && (pSession->connectState ==
10866 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10867 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010868 && (VOS_P2P_GO_MODE !=
10869 pSession->pCurRoamProfile->csrPersona
10870 && VOS_STA_SAP_MODE !=
10871 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010872 {
10873 tpSirSmeHT40OBSSScanInd pMsg;
10874 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010875 if (NULL == pMsg)
10876 {
10877 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10878 return;
10879 }
10880
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010881 pMsg->messageType =
10882 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10883 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010884 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10885 vos_mem_copy(pMsg->peerMacAddr,
10886 pSession->connectedProfile.bssid,
10887 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010888 status = palSendMBMessage(pMac->hHdd,
10889 pMsg );
10890 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010891 else
10892 {
10893 smsLog( pMac, LOG1,FL("OBSS SCAN"
10894 "Indication not sent to FW"
10895 "channel %d OBSS_SCAN: %d"),
10896 pSession->connectedProfile.
10897 operationChannel,
10898 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10899 smsLog( pMac, LOG1,FL("connectState %d"
Jeff Johnson89477502017-09-19 08:35:23 -070010900 "pCurRoamProfile %pK"),
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010901 pSession->connectState,
10902 pSession->pCurRoamProfile);
10903 }
10904
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010905 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010906 }
10907 else
10908 {
10909 result = eCSR_ROAM_RESULT_NONE;
10910 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010911 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 }
10913 else
10914 {
10915 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010916 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10917 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10918 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010919 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010920 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10922 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010923 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10924 // can go ahead and initiate the TSPEC if any are pending
10925 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010926#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 //Send Adjacent AP repot to new AP.
10928 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10929 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010930 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010932#ifdef FEATURE_WLAN_ESE_UPLOAD
10933 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010934#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010935 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010936#endif
10937 pSession->isPrevApInfoValid = FALSE;
10938 }
10939#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10941 {
10942 csrReleaseCommandSetKey( pMac, pCommand );
10943 }
10944 }
10945 else
10946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010947 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 }
10949 }
10950 else
10951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010952 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 smeProcessPendingQueue( pMac );
10955 }
10956 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 case eWNI_SME_REMOVEKEY_RSP:
10958 {
10959 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10960 tListElem *pEntry;
10961 tSmeCmd *pCommand;
10962
10963 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10964 if ( pEntry )
10965 {
10966 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10967 if ( eSmeCommandRemoveKey == pCommand->command )
10968 {
10969 sessionId = pCommand->sessionId;
10970 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010971
10972 if(!pSession)
10973 {
10974 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10975 return;
10976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010977#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10978 {
10979 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010980 vos_mem_set(&removeKeyEvent,
10981 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010982 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10983 removeKeyEvent.encryptionModeMulticast =
10984 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10985 removeKeyEvent.encryptionModeUnicast =
10986 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010987 vos_mem_copy( removeKeyEvent.bssid,
10988 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 removeKeyEvent.authMode =
10990 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010991 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 {
10993 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10994 }
10995 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10996 }
10997#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010998 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010999 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011000 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
11001 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 result = eCSR_ROAM_RESULT_NONE;
11003 pRoamInfo = &roamInfo;
11004 }
11005 else
11006 {
11007 result = eCSR_ROAM_RESULT_FAILURE;
11008 }
11009 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
11010 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
11011 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11012 {
11013 csrReleaseCommandRemoveKey( pMac, pCommand );
11014 }
11015 }
11016 else
11017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011018 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 }
11020 }
11021 else
11022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011023 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011025 smeProcessPendingQueue( pMac );
11026 }
11027 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011028 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011029 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011030 csrRoamStatsRspProcessor( pMac, pSirMsg );
11031 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011032#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011033 case eWNI_SME_GET_ROAM_RSSI_RSP:
11034 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
11035 csrRoamRssiRspProcessor( pMac, pSirMsg );
11036 break;
11037#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011038#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011039 case eWNI_SME_GET_TSM_STATS_RSP:
11040 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
11041 csrTsmStatsRspProcessor( pMac, pSirMsg );
11042 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011043#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070011044 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011045 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011046 csrUpdateRssi( pMac, pSirMsg );
11047 break;
11048
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011049 case eWNI_SME_GET_SNR_REQ:
11050 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
11051 csrUpdateSnr(pMac, pSirMsg);
11052 break;
11053
Jeff Johnson295189b2012-06-20 16:38:30 -070011054#ifdef WLAN_FEATURE_VOWIFI_11R
11055 case eWNI_SME_FT_PRE_AUTH_RSP:
11056 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
11057 break;
11058#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053011059#ifdef WLAN_FEATURE_LFR_MBB
11060 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
11061 csr_roam_preauth_rsp_mbb_processor(pMac,
11062 (tpSirFTPreAuthRsp)pSirMsg);
11063 break;
11064#endif
11065
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11067 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011068 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 -070011069 sessionId = pSmeMaxAssocInd->sessionId;
11070 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011071 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
11072 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011073 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11074 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11075 break;
11076
11077 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011078 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011079#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011080 btampEstablishLogLinkHdlr( pSirMsg );
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011081#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070011083 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011084 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011085 csrRoamRssiIndHdlr( pMac, pSirMsg );
11086 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011087#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11088 case eWNI_SME_CANDIDATE_FOUND_IND:
11089 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
11090 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
11091 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070011092 case eWNI_SME_HANDOFF_REQ:
11093 smsLog( pMac, LOG2, FL("Handoff Req from self"));
11094 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
11095 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011096#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011097
11098 default:
11099 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070011101}
11102
Jeff Johnson295189b2012-06-20 16:38:30 -070011103void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
11104 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
11105{
11106 if(pSession)
11107 {
11108 if(pSession->bRefAssocStartCnt)
11109 {
11110 pSession->bRefAssocStartCnt--;
11111 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11112 //Need to call association_completion because there is an assoc_start pending.
11113 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11114 eCSR_ROAM_ASSOCIATION_COMPLETION,
11115 eCSR_ROAM_RESULT_FAILURE);
11116 }
11117 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11118 }
11119 else
11120 {
11121 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11122 }
11123}
11124
11125
11126eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11127{
11128 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11130 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11131 {
11132 status = csrScanRequestLostLink1( pMac, sessionId );
11133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 return(status);
11135}
11136
Jeff Johnson295189b2012-06-20 16:38:30 -070011137//return a boolean to indicate whether roaming completed or continue.
11138tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11139 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11140{
11141 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11142 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11143 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11144 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011145 if(!pSession)
11146 {
11147 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11148 return eANI_BOOLEAN_FALSE;
11149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 //Check whether time is up
11151 if(pSession->fCancelRoaming || fForce ||
11152 ((curTime - pSession->roamingStartTime) > roamTime) ||
11153 eCsrReassocRoaming == pSession->roamingReason ||
11154 eCsrDynamicRoaming == pSession->roamingReason)
11155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011156 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011157 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11158 {
11159 //roaming is cancelled, tell HDD to indicate disconnect
11160 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11161 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11162 //to be eSIR_BEACON_MISSED
11163 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11164 {
11165 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11166 }
11167 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11168 {
11169 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11170 }
11171 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11172 {
11173 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11174 }
11175 else
11176 {
11177 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11178 }
11179 }
11180 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11181 pSession->roamingReason = eCsrNotRoaming;
11182 }
11183 else
11184 {
11185 pSession->roamResult = roamResult;
11186 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11187 {
11188 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11189 pSession->roamingReason = eCsrNotRoaming;
11190 }
11191 else
11192 {
11193 fCompleted = eANI_BOOLEAN_FALSE;
11194 }
11195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 return(fCompleted);
11197}
11198
Jeff Johnson295189b2012-06-20 16:38:30 -070011199void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11200{
11201 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011202
11203 if(!pSession)
11204 {
11205 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11206 return;
11207 }
11208
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 if(CSR_IS_ROAMING(pSession))
11210 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011211 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11213 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11214 {
11215 //No need to do anything in here because the handler takes care of it
11216 }
11217 else
11218 {
11219 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11220 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11221 //Roaming is stopped after here
11222 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11223 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011224 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 csrRoamStopRoamingTimer(pMac, sessionId);
11226 }
11227 }
11228}
11229
Jeff Johnson295189b2012-06-20 16:38:30 -070011230void csrRoamRoamingTimerHandler(void *pv)
11231{
11232 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11233 tpAniSirGlobal pMac = pInfo->pMac;
11234 tANI_U32 sessionId = pInfo->sessionId;
11235 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011236
11237 if(!pSession)
11238 {
11239 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11240 return;
11241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011242
11243 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11244 {
11245 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11246 {
11247 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11248 pSession->roamingReason = eCsrNotRoaming;
11249 }
11250 }
11251}
11252
Jeff Johnson295189b2012-06-20 16:38:30 -070011253eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11254{
11255 eHalStatus status;
11256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011257
11258 if(!pSession)
11259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011260 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011261 return eHAL_STATUS_FAILURE;
11262 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011263
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011264 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011266 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011267
11268 return (status);
11269}
11270
Jeff Johnson295189b2012-06-20 16:38:30 -070011271eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11272{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011273 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011274}
11275
Jeff Johnson295189b2012-06-20 16:38:30 -070011276void csrRoamWaitForKeyTimeOutHandler(void *pv)
11277{
11278 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11279 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011280 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011281 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011282
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011283 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011284 macTraceGetNeighbourRoamState(
11285 pMac->roam.neighborRoamInfo.neighborRoamState),
11286 macTraceGetcsrRoamSubState(
11287 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011288
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011289 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011290 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011291 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011292 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11293 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011294 //Change the substate so command queue is unblocked.
11295 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11296 pMac->roam.curSubState[pInfo->sessionId] =
11297 eCSR_ROAM_SUBSTATE_NONE;
11298 vos_spin_lock_release(&pMac->roam.roam_state_lock);
11299
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011300#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011301 if (csrNeighborRoamIsHandoffInProgress(pMac))
11302 {
11303 /*
11304 * Enable heartbeat timer when hand-off is in progress
11305 * and Key Wait timer expired.
11306 */
11307 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11308 " (nHBCount=%d)",
11309 pMac->roam.configParam.HeartbeatThresh24);
11310 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11311 pMac->roam.configParam.HeartbeatThresh24,
11312 NULL, eANI_BOOLEAN_FALSE);
11313 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011314#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011315
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011316 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011317
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011318 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011319 {
11320 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11321 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011322 status = sme_AcquireGlobalLock(&pMac->sme);
11323 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011324 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011325 csrRoamDisconnect(pMac, pInfo->sessionId,
11326 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11327 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011328 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011329 }
11330 else
11331 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011332 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11333 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011334 }
11335 }
11336 else
11337 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011338 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011339 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 }
11342
11343}
11344
Jeff Johnson295189b2012-06-20 16:38:30 -070011345eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11346{
11347 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011348#ifdef FEATURE_WLAN_LFR
11349 if (csrNeighborRoamIsHandoffInProgress(pMac))
11350 {
11351 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011352 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11353 macTraceGetNeighbourRoamState(
11354 pMac->roam.neighborRoamInfo.neighborRoamState),
11355 macTraceGetcsrRoamSubState(
11356 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11357 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011358 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11359 }
11360#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011361 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011362 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011363
11364 return (status);
11365}
11366
Jeff Johnson295189b2012-06-20 16:38:30 -070011367eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11368{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011369 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11370 macTraceGetNeighbourRoamState(
11371 pMac->roam.neighborRoamInfo.neighborRoamState),
11372 macTraceGetcsrRoamSubState(
11373 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011374#ifdef FEATURE_WLAN_LFR
11375 if (csrNeighborRoamIsHandoffInProgress(pMac))
11376 {
11377 /*
11378 * Enable heartbeat timer when hand-off is in progress
11379 * and Key Wait timer got stopped for some reason
11380 */
11381 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011382 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011383 pMac->roam.configParam.HeartbeatThresh24);
11384 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11385 pMac->roam.configParam.HeartbeatThresh24,
11386 NULL, eANI_BOOLEAN_FALSE);
11387 }
11388#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011389 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011390}
11391
Jeff Johnson295189b2012-06-20 16:38:30 -070011392void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11393 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11394{
11395 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11396 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011397 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11398 /* To silence the KW tool Null chaeck is added */
11399 if(!pSession)
11400 {
11401 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11402 return;
11403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011404
11405 if(pCommand)
11406 {
11407 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11411 {
11412 //if success, force roaming completion
11413 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11414 }
11415 else
11416 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011417 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011418 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11420 }
11421}
11422
Jeff Johnson295189b2012-06-20 16:38:30 -070011423eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11424{
11425 eHalStatus status = eHAL_STATUS_SUCCESS;
11426 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11427 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11428 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 tCsrRoamInfo roamInfo;
11430 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011431 /* To silence the KW tool Null chaeck is added */
11432 if(!pSession)
11433 {
11434 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11435 return eHAL_STATUS_FAILURE;
11436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011438 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 if ( eWNI_SME_DISASSOC_IND == type )
11440 {
11441 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11442 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11443 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011444 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011445 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11446 sizeof(tSirMacAddr));
11447 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 }
11449 else if ( eWNI_SME_DEAUTH_IND == type )
11450 {
11451 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11452 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11453 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011454 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011455 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11456 sizeof(tSirMacAddr));
11457 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 }
11459 else
11460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011461 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011463 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011465 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11466 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11467 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
11468
11469 if (type == eWNI_SME_DEAUTH_IND || type == eWNI_SME_DISASSOC_IND) {
11470 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11471 eCSR_ROAM_LOSTLINK_DETECTED, result);
11472 } else if(!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11473 csrRoamCallCallback(pMac, sessionId, NULL, 0,
11474 eCSR_ROAM_LOSTLINK_DETECTED, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 }
11476
11477 if ( eWNI_SME_DISASSOC_IND == type )
11478 {
11479 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11480 }
11481 else if ( eWNI_SME_DEAUTH_IND == type )
11482 {
11483 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011485
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011486 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11487 {
Jingxiang Ge6298d0a2018-10-18 16:12:54 +080011488 //remove the connected BSS in infrastructure mode
11489 csrRoamRemoveConnectedBssFromScanCache(pMac,
11490 &pSession->connectedProfile);
11491
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011492 csrScanStartIdleScan(pMac);
11493 }
11494
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 return (status);
11496}
11497
Jeff Johnson295189b2012-06-20 16:38:30 -070011498eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11499{
11500 eHalStatus status = eHAL_STATUS_SUCCESS;
11501 tListElem *pEntry = NULL;
11502 tSmeCmd *pCommand = NULL;
11503 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011504
11505 if(!pSession)
11506 {
11507 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11508 return eHAL_STATUS_FAILURE;
11509 }
11510
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 //Only remove the connected BSS in infrastructure mode
11513 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11514 if(pMac->roam.configParam.nRoamingTime)
11515 {
11516 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11517 {
11518 //before starting the lost link logic release the roam command for handoff
11519 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11520 if(pEntry)
11521 {
11522 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11523 }
11524 if(pCommand)
11525 {
11526 if (( eSmeCommandRoam == pCommand->command ) &&
11527 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11528 {
11529 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11530 {
11531 csrReleaseCommandRoam( pMac, pCommand );
11532 }
11533 }
11534 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011535 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 }
11537 }
11538 else
11539 {
11540 //We are told not to roam, indicate lostlink
11541 status = eHAL_STATUS_FAILURE;
11542 }
11543
11544 return (status);
11545}
Jeff Johnson295189b2012-06-20 16:38:30 -070011546void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11547{
11548 tListElem *pEntry;
11549 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11551 if ( pEntry )
11552 {
11553 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11554 if ( eSmeCommandWmStatusChange == pCommand->command )
11555 {
11556 // Nothing to process in a Lost Link completion.... It just kicks off a
11557 // roaming sequence.
11558 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11559 {
11560 csrReleaseCommandWmStatusChange( pMac, pCommand );
11561 }
11562 else
11563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011564 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 }
11566
11567 }
11568 else
11569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011570 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 }
11572 }
11573 else
11574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011575 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 smeProcessPendingQueue( pMac );
11578}
11579
Jeff Johnson295189b2012-06-20 16:38:30 -070011580void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11581{
11582 eHalStatus status = eHAL_STATUS_FAILURE;
11583 tSirSmeRsp *pSirSmeMsg;
11584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011585
11586 if(!pSession)
11587 {
11588 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11589 return;
11590 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011591 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11592 pCommand->sessionId,
11593 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 switch ( pCommand->u.wmStatusChangeCmd.Type )
11595 {
11596 case eCsrDisassociated:
11597 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11598 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 case eCsrDeauthenticated:
11601 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11602 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11603 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011605 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 break;
11607 }
11608 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11609 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11610 {
11611 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11612 {
11613 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011614 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 }
11616 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011617 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11618 // command here since there is nothing else to do.
11619 csrRoamWmStatusChangeComplete( pMac );
11620}
11621
Jeff Johnson295189b2012-06-20 16:38:30 -070011622//This function returns band and mode information.
11623//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11624//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011625static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11626 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011627{
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11629 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11630 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011632
Jeff Johnson295189b2012-06-20 16:38:30 -070011633 //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 -070011634 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11635 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11636 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11637 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 {
11639 switch( pMac->roam.configParam.uCfgDot11Mode )
11640 {
11641 case eCSR_CFG_DOT11_MODE_11A:
11642 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11643 eBand = eCSR_BAND_5G;
11644 break;
11645 case eCSR_CFG_DOT11_MODE_11B:
11646 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11647 eBand = eCSR_BAND_24;
11648 break;
11649 case eCSR_CFG_DOT11_MODE_11G:
11650 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11651 eBand = eCSR_BAND_24;
11652 break;
11653 case eCSR_CFG_DOT11_MODE_11N:
11654 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011655 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11656 break;
11657#ifdef WLAN_FEATURE_11AC
11658 case eCSR_CFG_DOT11_MODE_11AC:
11659 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11660 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011661 /* If the operating channel is in 2.4 GHz band, check for
11662 * INI item to disable VHT operation in 2.4 GHz band
11663 */
11664 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11665 !pMac->roam.configParam.enableVhtFor24GHz)
11666 {
11667 /* Disable 11AC operation */
11668 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11669 }
11670 else
11671 {
11672 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11673 }
11674 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011675 }
11676 else
11677 {
11678 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11679 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11680 }
11681 break;
11682 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11683 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11684 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011685 /* If the operating channel is in 2.4 GHz band, check for
11686 * INI item to disable VHT operation in 2.4 GHz band
11687 */
11688 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11689 !pMac->roam.configParam.enableVhtFor24GHz)
11690 {
11691 /* Disable 11AC operation */
11692 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11693 }
11694 else
11695 {
11696 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11697 }
11698 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011699 }
11700 else
11701 {
11702 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11703 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11704 }
11705 break;
11706#endif
11707 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011708#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011709 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11710 {
11711 /* If the operating channel is in 2.4 GHz band, check for
11712 * INI item to disable VHT operation in 2.4 GHz band
11713 */
11714 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11715 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011716 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011717 /* Disable 11AC operation */
11718 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011719 }
11720 else
11721 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011722 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11723 }
11724 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11725 }
11726 else
11727 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011728 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11729 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011730 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011731#else
11732 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11733 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11734#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 default:
11737 // Global dot11 Mode setting is 11a/b/g.
11738 // use the channel number to determine the Mode setting.
11739 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11740 {
11741 eBand = pMac->roam.configParam.eBand;
11742 if(eCSR_BAND_24 == eBand)
11743 {
11744 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11745 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11746 }
11747 else
11748 {
11749 //prefer 5GHz
11750 eBand = eCSR_BAND_5G;
11751 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11752 }
11753 }
11754 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11755 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011756 // WiFi tests require IBSS networks to start in 11b mode
11757 // without any change to the default parameter settings
11758 // on the adapter. We use ACU to start an IBSS through
11759 // creation of a startIBSS profile. This startIBSS profile
11760 // has Auto MACProtocol and the adapter property setting
11761 // for dot11Mode is also AUTO. So in this case, let's
11762 // start the IBSS network in 11b mode instead of 11g mode.
11763 // So this is for Auto=profile->MacProtocol && Auto=Global.
11764 // dot11Mode && profile->channel is < 14, then start the IBSS
11765 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011767 // Note: we used to have this start as an 11g IBSS for best
11768 // performance... now to specify that the user will have to
11769 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11771 eBand = eCSR_BAND_24;
11772 }
11773 else
11774 {
11775 // else, it's a 5.0GHz channel. Set mode to 11a.
11776 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11777 eBand = eCSR_BAND_5G;
11778 }
11779 break;
11780 }//switch
11781 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11782 else
11783 {
11784 //dot11 mode is set, lets pick the band
11785 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11786 {
11787 // channel is Auto also.
11788 eBand = pMac->roam.configParam.eBand;
11789 if(eCSR_BAND_ALL == eBand)
11790 {
11791 //prefer 5GHz
11792 eBand = eCSR_BAND_5G;
11793 }
11794 }
11795 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11796 {
11797 eBand = eCSR_BAND_24;
11798 }
11799 else
11800 {
11801 eBand = eCSR_BAND_5G;
11802 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 if(pBand)
11805 {
11806 *pBand = eBand;
11807 }
11808
11809 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011810 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11812 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011813
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011814 /* 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 +053011815 if (
11816#ifdef SAP_AUTH_OFFLOAD
11817 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11818#endif
11819 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11820 ((pProfile->privacy == 1) &&
11821 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011822 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011823#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011824 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011825#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011826 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11827 {
11828 //We cannot do 11n here
11829 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11830 {
11831 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11832 }
11833 else
11834 {
11835 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11836 }
11837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 return( cfgDot11Mode );
11839}
11840
Jeff Johnson295189b2012-06-20 16:38:30 -070011841eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11842{
11843 eHalStatus status;
11844 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011845
11846 if(!pSession)
11847 {
11848 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11849 return eHAL_STATUS_FAILURE;
11850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011851
11852#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11853 {
11854 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11856 if(pIbssLog)
11857 {
11858 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11859 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11860 }
11861 }
11862#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 // Set the roaming substate to 'stop Bss request'...
11864 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11865
11866 // attempt to stop the Bss (reason code is ignored...)
11867 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011868 if(!HAL_STATUS_SUCCESS(status))
11869 {
11870 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 return (status);
11873}
11874
Jeff Johnson295189b2012-06-20 16:38:30 -070011875//pNumChan is a caller allocated space with the sizeof pChannels
11876eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11877{
11878
11879 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11880 (tANI_U8 *)pChannels,
11881 pNumChan));
11882}
11883
Kiran4a17ebe2013-01-31 10:43:43 -080011884tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11885{
11886 tANI_U32 cfgLength = 0;
11887 tANI_U16 cfgId = 0;
11888 tPowerdBm maxTxPwr = 0;
11889 tANI_U8 *pCountryInfo = NULL;
11890 eHalStatus status;
11891 tANI_U8 count = 0;
11892 tANI_U8 firstChannel;
11893 tANI_U8 maxChannels;
11894
11895 if (CSR_IS_CHANNEL_5GHZ(channel))
11896 {
11897 cfgId = WNI_CFG_MAX_TX_POWER_5;
11898 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11899 }
11900 else if (CSR_IS_CHANNEL_24GHZ(channel))
11901 {
11902 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11903 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11904 }
11905 else
11906 return maxTxPwr;
11907
Kiet Lam64c1b492013-07-12 13:56:44 +053011908 pCountryInfo = vos_mem_malloc(cfgLength);
11909 if ( NULL == pCountryInfo )
11910 status = eHAL_STATUS_FAILURE;
11911 else
11912 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011913 if (status != eHAL_STATUS_SUCCESS)
11914 {
11915 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011916 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011917 __FUNCTION__, status);
11918 goto error;
11919 }
11920 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11921 if (status != eHAL_STATUS_SUCCESS)
11922 {
11923 goto error;
11924 }
11925 /* Identify the channel and maxtxpower */
11926 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11927 {
11928 firstChannel = pCountryInfo[count++];
11929 maxChannels = pCountryInfo[count++];
11930 maxTxPwr = pCountryInfo[count++];
11931
11932 if ((channel >= firstChannel) &&
11933 (channel < (firstChannel + maxChannels)))
11934 {
11935 break;
11936 }
11937 }
11938
11939error:
11940 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011941 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011942
11943 return maxTxPwr;
11944}
11945
11946
Jeff Johnson295189b2012-06-20 16:38:30 -070011947tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11948{
11949 tANI_BOOLEAN fValid = FALSE;
11950 tANI_U32 idxValidChannels;
11951 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11952
11953 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11954 {
11955 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11956 {
11957 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11958 {
11959 fValid = TRUE;
11960 break;
11961 }
11962 }
11963 }
11964 pMac->roam.numValidChannels = len;
11965 return fValid;
11966}
11967
Jeff Johnson295189b2012-06-20 16:38:30 -070011968tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11969{
11970 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11971 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11973 {
11974 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11975 {
11976 fValid = eANI_BOOLEAN_TRUE;
11977 break;
11978 }
11979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011980 return (fValid);
11981}
11982
Jeff Johnson295189b2012-06-20 16:38:30 -070011983//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011984 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011985{
Jeff Johnsone7245742012-09-05 17:12:55 -070011986 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 tANI_U8 centerChn;
11988 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011989
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11991 {
11992 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11993 }
11994 else
11995 {
11996 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11997 }
11998 //Figure what the other side's CB mode
11999 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
12000 {
12001 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
12002 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053012003 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
12004 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
12005 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
12006 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012007 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
12008 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053012009 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012010 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053012011
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080012012 {
12013 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
12014 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12015 }
12016
12017 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012019 /* This is called during INFRA STA/CLIENT and should use the merged value of
12020 * supported channel width and recommended tx width as per standard
12021 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012022 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070012023 pIes->HTCaps.supportedChannelWidthSet,
12024 pIes->HTInfo.recommendedTxWidthSet,
12025 pIes->HTInfo.secondaryChannelOffset);
12026
12027 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12028 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 else
Jeff Johnsone7245742012-09-05 17:12:55 -070012030 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12031 switch (eRet) {
12032 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12033 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12034 break;
12035 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12036 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12037 break;
12038 case PHY_SINGLE_CHANNEL_CENTERED:
12039 default:
12040 centerChn = primaryChn;
12041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012043 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012045 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012046 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012048 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12049 {
12050 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12051 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12052 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 }
12054 }
12055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 return eRet;
12057}
Jeff Johnson295189b2012-06-20 16:38:30 -070012058tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12059{
12060 tANI_BOOLEAN fFound = FALSE;
12061 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12063 {
12064 if( pCipherList->encryptionType[idx] == encryptionType )
12065 {
12066 fFound = TRUE;
12067 break;
12068 }
12069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 return fFound;
12071}
Jeff Johnson295189b2012-06-20 16:38:30 -070012072tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12073{
12074 tANI_BOOLEAN fFound = FALSE;
12075 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12077 {
12078 if( pAuthList->authType[idx] == authType )
12079 {
12080 fFound = TRUE;
12081 break;
12082 }
12083 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 return fFound;
12085}
Jeff Johnson295189b2012-06-20 16:38:30 -070012086tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12087{
12088 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12089 tCsrScanResultFilter *pScanFilter = NULL;
12090 eHalStatus status = eHAL_STATUS_SUCCESS;
12091
12092 if(pProfile1 && pProfile2)
12093 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012094 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12095 if ( NULL == pScanFilter )
12096 status = eHAL_STATUS_FAILURE;
12097 else
12098 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 if(HAL_STATUS_SUCCESS(status))
12100 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012101 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12103 if(HAL_STATUS_SUCCESS(status))
12104 {
12105 fCheck = eANI_BOOLEAN_FALSE;
12106 do
12107 {
12108 tANI_U32 i;
12109 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12110 {
12111 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12112 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12113 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12114 if ( fCheck ) break;
12115 }
12116 if(!fCheck)
12117 {
12118 break;
12119 }
12120 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12121 || pProfile2->BSSType != pProfile1->BSSType
12122 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12123 )
12124 {
12125 fCheck = eANI_BOOLEAN_FALSE;
12126 break;
12127 }
12128#ifdef WLAN_FEATURE_VOWIFI_11R
12129 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12130 {
12131 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12132 {
12133 fCheck = eANI_BOOLEAN_FALSE;
12134 break;
12135 }
12136 }
12137#endif
12138 //Match found
12139 fCheck = eANI_BOOLEAN_TRUE;
12140 }while(0);
12141 csrFreeScanFilter(pMac, pScanFilter);
12142 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012143 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 }
12145 }
12146
12147 return (fCheck);
12148}
12149
Jeff Johnson295189b2012-06-20 16:38:30 -070012150tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12151{
12152 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12153 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012154 do
12155 {
12156 //Only check for static WEP
12157 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12158 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12159 {
12160 fCheck = eANI_BOOLEAN_TRUE;
12161 break;
12162 }
12163 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12164 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12165 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12166 {
12167 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012168 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12169 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 {
12171 break;
12172 }
12173 }
12174 if( i == CSR_MAX_NUM_KEY)
12175 {
12176 fCheck = eANI_BOOLEAN_TRUE;
12177 }
12178 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 return (fCheck);
12180}
12181
Jeff Johnson295189b2012-06-20 16:38:30 -070012182//IBSS
12183
Jeff Johnson295189b2012-06-20 16:38:30 -070012184tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12185{
12186 tANI_U8 channel = 0;
12187 tANI_U32 idx;
12188 tANI_U32 idxValidChannels;
12189 tANI_BOOLEAN fFound = FALSE;
12190 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12191
12192 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12193 {
12194 channel = pMac->roam.configParam.AdHocChannel5G;
12195 if(!csrRoamIsChannelValid(pMac, channel))
12196 {
12197 channel = 0;
12198 }
12199 }
12200 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12201 {
12202 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12203 {
12204 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12205 {
12206 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12207 {
12208 fFound = TRUE;
12209 channel = csrStartIbssChannels50[ idx ];
12210 }
12211 }
12212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12214 if (!fFound)
12215 {
12216 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12217 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012218 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012220 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012221 break;
12222 }
12223 }
12224 }
12225 }//if
12226
12227 return( channel );
12228}
12229
Jeff Johnson295189b2012-06-20 16:38:30 -070012230tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12231{
12232 tANI_U8 channel = 1;
12233 tANI_U32 idx;
12234 tANI_U32 idxValidChannels;
12235 tANI_BOOLEAN fFound = FALSE;
12236 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12237
12238 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12239 {
12240 channel = pMac->roam.configParam.AdHocChannel24;
12241 if(!csrRoamIsChannelValid(pMac, channel))
12242 {
12243 channel = 0;
12244 }
12245 }
12246
12247 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12248 {
12249 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12250 {
12251 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12252 {
12253 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12254 {
12255 fFound = TRUE;
12256 channel = csrStartIbssChannels24[ idx ];
12257 }
12258 }
12259 }
12260 }
12261
12262 return( channel );
12263}
12264
Jeff Johnson295189b2012-06-20 16:38:30 -070012265static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12266 tCsrRoamStartBssParams *pParam )
12267{
12268 eCsrCfgDot11Mode cfgDot11Mode;
12269 eCsrBand eBand;
12270 tANI_U8 channel = 0;
12271 tSirNwType nwType;
12272 tANI_U8 operationChannel = 0;
12273
12274 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12275 {
12276 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12277 }
12278
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012280
Jeff Johnson295189b2012-06-20 16:38:30 -070012281 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12282 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12283 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12284 )
12285 {
12286 /* This should never happen */
12287 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012288 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 pProfile->csrPersona);
12290 VOS_ASSERT(0);
12291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 switch( cfgDot11Mode )
12293 {
12294 case eCSR_CFG_DOT11_MODE_11G:
12295 nwType = eSIR_11G_NW_TYPE;
12296 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 case eCSR_CFG_DOT11_MODE_11B:
12298 nwType = eSIR_11B_NW_TYPE;
12299 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 case eCSR_CFG_DOT11_MODE_11A:
12301 nwType = eSIR_11A_NW_TYPE;
12302 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012303 default:
12304 case eCSR_CFG_DOT11_MODE_11N:
12305 case eCSR_CFG_DOT11_MODE_TAURUS:
12306 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12307 if(eCSR_BAND_24 == eBand)
12308 {
12309 nwType = eSIR_11G_NW_TYPE;
12310 }
12311 else
12312 {
12313 nwType = eSIR_11A_NW_TYPE;
12314 }
12315 break;
12316 }
12317
12318 pParam->extendedRateSet.numRates = 0;
12319
12320 switch ( nwType )
12321 {
12322 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012323 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 case eSIR_11A_NW_TYPE:
12325
12326 pParam->operationalRateSet.numRates = 8;
12327
12328 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12329 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12330 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12331 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12332 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12333 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12334 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12335 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12336
12337 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12338 {
12339 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12340 if( 0 == channel &&
12341 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12342 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12343 )
12344 {
12345 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12346 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12347 nwType = eSIR_11B_NW_TYPE;
12348 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12349 pParam->operationalRateSet.numRates = 4;
12350 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12351 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12352 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12353 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12354 }
12355 }
12356 else
12357 {
12358 channel = operationChannel;
12359 }
12360 break;
12361
12362 case eSIR_11B_NW_TYPE:
12363 pParam->operationalRateSet.numRates = 4;
12364 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12365 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12366 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12367 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12369 {
12370 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12371 }
12372 else
12373 {
12374 channel = operationChannel;
12375 }
12376
12377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 /* For P2P Client and P2P GO, disable 11b rates */
12380 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12381 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12382 )
12383 {
12384 pParam->operationalRateSet.numRates = 8;
12385
12386 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12387 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12388 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12389 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12390 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12391 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12392 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12393 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12394 }
12395 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 {
12397 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12399 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12400 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12401 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12402
12403 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12405 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12406 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12407 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12408 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12409 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12410 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12411 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12412 }
12413
12414 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12415 {
12416 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12417 }
12418 else
12419 {
12420 channel = operationChannel;
12421 }
12422
12423 break;
12424 }
12425 pParam->operationChn = channel;
12426 pParam->sirNwType = nwType;
12427}
12428
Jeff Johnson295189b2012-06-20 16:38:30 -070012429static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12430 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12431{
12432
12433 if( pParam )
12434 {
12435 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012436 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012438 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012439
12440 if( pIes )
12441 {
12442 if(pIes->SuppRates.present)
12443 {
12444 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12445 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012447 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 -070012448 pIes->SuppRates.num_rates);
12449 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12450 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012451 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12452 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012453 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012454 if (pIes->ExtSuppRates.present)
12455 {
12456 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012457 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012458 {
12459 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12460 SIR_MAC_RATESET_EID_MAX, resetting to \
12461 SIR_MAC_RATESET_EID_MAX"),
12462 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012463 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012464 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012465 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012466 pIes->ExtSuppRates.rates,
12467 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 if( pIes->SSID.present )
12470 {
12471 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012472 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12473 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012474 }
12475 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 }
12477 else
12478 {
12479 pParam->ssId.length = 0;
12480 pParam->operationalRateSet.numRates = 0;
12481 }
12482 }
12483}
12484
Jeff Johnson295189b2012-06-20 16:38:30 -070012485static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12486{
12487 tANI_U8 MaxRate = 0;
12488 tANI_U32 i;
12489 tANI_U8 *pRate;
12490
12491 pRate = pSirRateSet->rate;
12492 for ( i = 0; i < pSirRateSet->numRates; i++ )
12493 {
12494 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12495 }
12496
12497 // Save the max rate in the connected state information...
12498
12499 // modify LastRates variable as well
12500
12501 return;
12502}
12503
Jeff Johnson295189b2012-06-20 16:38:30 -070012504eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12505 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12506{
12507 eHalStatus status = eHAL_STATUS_SUCCESS;
12508 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012509 // Set the roaming substate to 'Start BSS attempt'...
12510 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012511#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12512 //Need to figure out whether we need to log WDS???
12513 if( CSR_IS_IBSS( pProfile ) )
12514 {
12515 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12517 if(pIbssLog)
12518 {
12519 if(pBssDesc)
12520 {
12521 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012522 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 }
12524 else
12525 {
12526 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12527 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012528 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 if(pProfile->ChannelInfo.numOfChannels == 0)
12530 {
12531 pIbssLog->channelSetting = AUTO_PICK;
12532 }
12533 else
12534 {
12535 pIbssLog->channelSetting = SPECIFIED;
12536 }
12537 pIbssLog->operatingChannel = pParam->operationChn;
12538 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12539 }
12540 }
12541#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12542 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012543 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12544 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012545
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 pParam->privacy = pProfile->privacy;
12547 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12548 pParam->authType = pProfile->csr80211AuthType;
12549 pParam->beaconInterval = pProfile->beaconInterval;
12550 pParam->dtimPeriod = pProfile->dtimPeriod;
12551 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12552 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12553 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12554 {
12555 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12556 {
12557 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12558 }
12559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012560 pParam->protEnabled = pProfile->protEnabled;
12561 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12562 pParam->ht_protection = pProfile->cfg_protection;
12563 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012564
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12566 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012568
12569#ifdef WLAN_FEATURE_11W
12570 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12571 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12572#endif
12573
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 // When starting an IBSS, start on the channel from the Profile.
12575 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 return (status);
12577}
12578
Jeff Johnson295189b2012-06-20 16:38:30 -070012579static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012580 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012581{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012582 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012583 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012585
12586 if(!pSession)
12587 {
12588 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12589 return;
12590 }
12591
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 if( pBssDesc )
12593 {
12594 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12595 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12596 //The following code has to be do after that.
12597 //For WDS station, use selfMac as the self BSSID
12598 if( CSR_IS_WDS_STA( pProfile ) )
12599 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012600 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12601 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 }
12603 }
12604 else
12605 {
12606 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 //Use the first SSID
12608 if(pProfile->SSIDs.numOfSSIDs)
12609 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012610 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12611 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 }
12613 //For WDS station, use selfMac as the self BSSID
12614 if( CSR_IS_WDS_STA( pProfile ) )
12615 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012616 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12617 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 }
12619 //Use the first BSSID
12620 else if( pProfile->BSSIDs.numOfBSSIDs )
12621 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012622 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12623 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 }
12625 else
12626 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012627 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 }
12629 }
12630 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 //Set operating channel in pProfile which will be used
12632 //in csrRoamSetBssConfigCfg() to determine channel bonding
12633 //mode and will be configured in CFG later
12634 pProfile->operationChannel = Channel;
12635
12636 if(Channel == 0)
12637 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012638 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 }
12640 else
12641 {
12642
12643 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012644 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012645 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012646 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012647 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012648#ifdef WLAN_FEATURE_AP_HT40_24G
12649 if (CSR_IS_INFRA_AP(pProfile))
12650 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12651 else
12652 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12653#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012654 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012655#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012656 }
12657 else
12658 {
12659 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12660 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012661 pBssConfig->cbMode = cbMode;
12662 pSession->bssParams.cbMode = cbMode;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012663 if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
12664 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
12665 else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
12666 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
12667 else
12668 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
12669 smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
12670 pSession->bssParams.orig_ch_width);
Jeff Johnsone7245742012-09-05 17:12:55 -070012671 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 }
12673}
12674
Jeff Johnson295189b2012-06-20 16:38:30 -070012675static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12676 tANI_BOOLEAN *pfSameIbss )
12677{
12678 eHalStatus status = eHAL_STATUS_SUCCESS;
12679 tANI_BOOLEAN fSameIbss = FALSE;
12680
12681 if ( csrIsConnStateIbss( pMac, sessionId ) )
12682 {
12683 // Check if any profile parameter has changed ? If any profile parameter
12684 // has changed then stop old BSS and start a new one with new parameters
12685 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12686 {
12687 fSameIbss = TRUE;
12688 }
12689 else
12690 {
12691 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12692 }
12693 }
12694 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12695 {
12696 // Disassociate from the connected Infrastructure network...
12697 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12698 }
12699 else
12700 {
12701 tBssConfigParam *pBssConfig;
12702
Kiet Lam64c1b492013-07-12 13:56:44 +053012703 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12704 if ( NULL == pBssConfig )
12705 status = eHAL_STATUS_FAILURE;
12706 else
12707 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 if(HAL_STATUS_SUCCESS(status))
12709 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012710 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 // there is no Bss description before we start an IBSS so we need to adopt
12712 // all Bss configuration parameters from the Profile.
12713 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12714 if(HAL_STATUS_SUCCESS(status))
12715 {
12716 //save dotMode
12717 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12718 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012719 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012720 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12721 NULL, pBssConfig,
12722 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012724
12725 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 }//Allocate memory
12727 }
12728
12729 if(pfSameIbss)
12730 {
12731 *pfSameIbss = fSameIbss;
12732 }
12733 return( status );
12734}
12735
Jeff Johnson295189b2012-06-20 16:38:30 -070012736static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12737 tSirSmeNewBssInfo *pNewBss )
12738{
12739 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012740
12741 if(!pSession)
12742 {
12743 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12744 return;
12745 }
12746
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 if( pNewBss )
12748 {
12749 // Set the operating channel.
12750 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12751 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012752 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12753 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 return;
12756}
12757
Jeff Johnson295189b2012-06-20 16:38:30 -070012758#ifdef FEATURE_WLAN_WAPI
12759eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12760 tANI_U32 numItems )
12761{
12762 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012763 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012766 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 return status;
12768 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012769 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 pSession = CSR_GET_SESSION( pMac, sessionId );
12771 if(numItems <= CSR_MAX_BKID_ALLOWED)
12772 {
12773 status = eHAL_STATUS_SUCCESS;
12774 //numItems may be 0 to clear the cache
12775 pSession->NumBkidCache = (tANI_U16)numItems;
12776 if(numItems && pBKIDCache)
12777 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012778 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12779 sizeof(tBkidCacheInfo) * numItems);
12780 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 }
12782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 return (status);
12784}
Jeff Johnson295189b2012-06-20 16:38:30 -070012785eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12786 tBkidCacheInfo *pBkidCache)
12787{
12788 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012789 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012792 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 return status;
12794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 pSession = CSR_GET_SESSION( pMac, sessionId );
12796 if(pNum && pBkidCache)
12797 {
12798 if(pSession->NumBkidCache == 0)
12799 {
12800 *pNum = 0;
12801 status = eHAL_STATUS_SUCCESS;
12802 }
12803 else if(*pNum >= pSession->NumBkidCache)
12804 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012805 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012807 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 -070012808 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012809 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012811 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12812 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 *pNum = pSession->NumBkidCache;
12814 status = eHAL_STATUS_SUCCESS;
12815 }
12816 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012818}
Jeff Johnson295189b2012-06-20 16:38:30 -070012819tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12820{
12821 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012822}
12823#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012824eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012825 tPmkidCacheInfo *pPMKIDCache,
12826 tANI_U32 numItems,
12827 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012828{
12829 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12830 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012831
12832 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012833 {
12834 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12835 return eHAL_STATUS_FAILURE;
12836 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012837
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012838 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012839
12840 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 {
12842#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12843 {
12844 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012845 vos_mem_set(&secEvent,
12846 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12848 secEvent.encryptionModeMulticast =
12849 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12850 secEvent.encryptionModeUnicast =
12851 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012852 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 secEvent.authMode =
12854 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12855 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12856 }
12857#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012859 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012860 if (numItems && pPMKIDCache)
12861 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012862 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012863 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12864 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012865 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012866 }
12867 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012868 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012869 tPmkidCacheInfo *pmksa;
12870
12871 for (i = 0; i < numItems; i++) {
12872 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012873
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012874 /* Delete the entry if present */
12875 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12876
12877 /* Add entry to the cache */
12878 vos_mem_copy(
12879 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12880 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12881 vos_mem_copy(
12882 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12883 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12884
12885 /* Increment the CSR local cache index */
12886 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12887 pSession->CurCacheIndex++;
12888 else
12889 pSession->CurCacheIndex = 0;
12890
12891 pSession->NumPmkidCache++;
12892 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12893 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 }
12896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012897 return (status);
12898}
12899
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012900eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012901#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12902 const tANI_U8 *pBSSId,
12903#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012904 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012905#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012906 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012907{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012908 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12909 tANI_BOOLEAN fMatchFound = FALSE;
12910 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012911 tANI_U32 CurIndex;
12912 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012913
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012914 if(!pSession)
12915 {
12916 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12917 return eHAL_STATUS_FAILURE;
12918 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012919
12920 /* Check if there are no entries to delete */
12921 if (0 == pSession->NumPmkidCache) {
12922 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12923 return eHAL_STATUS_SUCCESS;
12924 }
12925
12926 if (!flush_cache) {
12927 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12928 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12929 pBSSId, VOS_MAC_ADDR_SIZE)) {
12930 fMatchFound = 1;
12931
12932 /* Clear this - the matched entry */
12933 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12934 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012935 break;
12936 }
12937 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012938
12939 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12940 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12941 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012942 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012943 else {
12944 /* Match Found */
12945 CurIndex = pSession->CurCacheIndex;
12946 if(Index < CurIndex) {
12947 for(i = Index; i < (CurIndex-1); i++) {
12948 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12949 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12950 }
12951 pSession->CurCacheIndex--;
12952 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12953 sizeof(tPmkidCacheInfo));
12954 } else if(Index > CurIndex) {
12955 for(i = Index; i > (CurIndex); i--) {
12956 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12957 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12958 }
12959 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12960 sizeof(tPmkidCacheInfo));
12961 }
12962 pSession->NumPmkidCache--;
12963 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012964 } else {
12965 /* Flush the entire cache */
12966 vos_mem_zero(pSession->PmkidCacheInfo,
12967 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12968 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012969 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012970 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012971
12972 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012973}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012974
Jeff Johnson295189b2012-06-20 16:38:30 -070012975tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12976{
12977 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12978}
12979
Jeff Johnson295189b2012-06-20 16:38:30 -070012980eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12981{
12982 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12983 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012984 tPmkidCacheInfo *pmksa;
12985 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012986
12987 if(!pSession)
12988 {
12989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12990 return eHAL_STATUS_FAILURE;
12991 }
12992
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 if(pNum && pPmkidCache)
12994 {
12995 if(pSession->NumPmkidCache == 0)
12996 {
12997 *pNum = 0;
12998 status = eHAL_STATUS_SUCCESS;
12999 }
13000 else if(*pNum >= pSession->NumPmkidCache)
13001 {
13002 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
13003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013004 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 -070013005 pSession->NumPmkidCache);
13006 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13007 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013008
13009 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
13010 pmksa = &pSession->PmkidCacheInfo[i];
13011 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
13012 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
13013 pPmkidCache++;
13014 j++;
13015 }
13016 }
13017
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 *pNum = pSession->NumPmkidCache;
13019 status = eHAL_STATUS_SUCCESS;
13020 }
13021 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013022 return (status);
13023}
13024
Jeff Johnson295189b2012-06-20 16:38:30 -070013025eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13026{
13027 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13028 tANI_U32 len;
13029 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013030
13031 if(!pSession)
13032 {
13033 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13034 return eHAL_STATUS_FAILURE;
13035 }
13036
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 if(pLen)
13038 {
13039 len = *pLen;
13040 *pLen = pSession->nWpaRsnReqIeLength;
13041 if(pBuf)
13042 {
13043 if(len >= pSession->nWpaRsnReqIeLength)
13044 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013045 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13046 pSession->nWpaRsnReqIeLength);
13047 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 }
13049 }
13050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 return (status);
13052}
13053
Jeff Johnson295189b2012-06-20 16:38:30 -070013054eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13055{
13056 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13057 tANI_U32 len;
13058 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013059
13060 if(!pSession)
13061 {
13062 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13063 return eHAL_STATUS_FAILURE;
13064 }
13065
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 if(pLen)
13067 {
13068 len = *pLen;
13069 *pLen = pSession->nWpaRsnRspIeLength;
13070 if(pBuf)
13071 {
13072 if(len >= pSession->nWpaRsnRspIeLength)
13073 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013074 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13075 pSession->nWpaRsnRspIeLength);
13076 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 }
13078 }
13079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 return (status);
13081}
Jeff Johnson295189b2012-06-20 16:38:30 -070013082#ifdef FEATURE_WLAN_WAPI
13083eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13084{
13085 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13086 tANI_U32 len;
13087 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013088
13089 if(!pSession)
13090 {
13091 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13092 return eHAL_STATUS_FAILURE;
13093 }
13094
Jeff Johnson295189b2012-06-20 16:38:30 -070013095 if(pLen)
13096 {
13097 len = *pLen;
13098 *pLen = pSession->nWapiReqIeLength;
13099 if(pBuf)
13100 {
13101 if(len >= pSession->nWapiReqIeLength)
13102 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013103 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13104 pSession->nWapiReqIeLength);
13105 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 }
13107 }
13108 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 return (status);
13110}
Jeff Johnson295189b2012-06-20 16:38:30 -070013111eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13112{
13113 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13114 tANI_U32 len;
13115 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013116
13117 if(!pSession)
13118 {
13119 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13120 return eHAL_STATUS_FAILURE;
13121 }
13122
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 if(pLen)
13124 {
13125 len = *pLen;
13126 *pLen = pSession->nWapiRspIeLength;
13127 if(pBuf)
13128 {
13129 if(len >= pSession->nWapiRspIeLength)
13130 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013131 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13132 pSession->nWapiRspIeLength);
13133 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 }
13135 }
13136 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 return (status);
13138}
13139#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013140eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13141{
13142 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13143 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013144
13145 if(!pSession)
13146 {
13147 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13148 return (retStatus);
13149 }
13150
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 if(CSR_IS_ROAMING(pSession))
13152 {
13153 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13154 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13155 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 return (retStatus);
13157}
13158
Jeff Johnson295189b2012-06-20 16:38:30 -070013159//This function remove the connected BSS from te cached scan result
13160eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13161 tCsrRoamConnectedProfile *pConnProfile)
13162{
13163 eHalStatus status = eHAL_STATUS_FAILURE;
13164 tCsrScanResultFilter *pScanFilter = NULL;
13165 tListElem *pEntry;
13166 tCsrScanResult *pResult;
13167 tDot11fBeaconIEs *pIes;
13168 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13170 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13171 {
13172 do
13173 {
13174 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013175 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13176 if ( NULL == pScanFilter )
13177 status = eHAL_STATUS_FAILURE;
13178 else
13179 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013181 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13182 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13183 if ( NULL == pScanFilter->BSSIDs.bssid )
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_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13189 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13191 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13192 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013193 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13194 if ( NULL == pScanFilter->SSIDs.SSIDList )
13195 status = eHAL_STATUS_FAILURE;
13196 else
13197 status = eHAL_STATUS_SUCCESS;
13198 if (!HAL_STATUS_SUCCESS(status)) break;
13199 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13200 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 }
13202 pScanFilter->authType.numEntries = 1;
13203 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13204 pScanFilter->BSSType = pConnProfile->BSSType;
13205 pScanFilter->EncryptionType.numEntries = 1;
13206 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13207 pScanFilter->mcEncryptionType.numEntries = 1;
13208 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13209 //We ignore the channel for now, BSSID should be enough
13210 pScanFilter->ChannelInfo.numOfChannels = 0;
13211 //Also ignore the following fields
13212 pScanFilter->uapsd_mask = 0;
13213 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013214 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 pScanFilter->countryCode[0] = 0;
13216 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 csrLLLock(&pMac->scan.scanResultList);
13218 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13219 while( pEntry )
13220 {
13221 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13222 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13223 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13224 pScanFilter, NULL, NULL, NULL, &pIes);
13225 //Release the IEs allocated by csrMatchBSS is needed
13226 if( !pResult->Result.pvIes )
13227 {
13228 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013229 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 }
13231 if(fMatch)
13232 {
13233 //We found the one
13234 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13235 {
13236 //Free the memory
13237 csrFreeScanResultEntry( pMac, pResult );
13238 }
13239 break;
13240 }
13241 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13242 }//while
13243 csrLLUnlock(&pMac->scan.scanResultList);
13244 }while(0);
13245 if(pScanFilter)
13246 {
13247 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013248 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 }
13250 }
13251 return (status);
13252}
13253
Jeff Johnson295189b2012-06-20 16:38:30 -070013254//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013255eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13256{
13257 eHalStatus status = eHAL_STATUS_SUCCESS;
13258 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13260 {
13261 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13262 {
13263 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13264 {
13265 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013266 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 status = eHAL_STATUS_CSR_WRONG_STATE;
13268 break;
13269 }
13270 if( csrIsConnStateInfra( pMac, sessionId ) )
13271 {
13272 if( chnId &&
13273 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013275 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13277 status = eHAL_STATUS_CSR_WRONG_STATE;
13278 break;
13279 }
13280 }
13281 }
13282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 return ( status );
13284}
13285
Jeff Johnson295189b2012-06-20 16:38:30 -070013286static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13287{
13288 eHalStatus status = eHAL_STATUS_SUCCESS;
13289 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13290 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013291
13292 if(!pSession)
13293 {
13294 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13295 return eHAL_STATUS_FAILURE;
13296 }
13297
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 if ( csrIsConnStateIbss( pMac, sessionId ) )
13299 {
13300 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13301 }
13302 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13303 {
13304 // Disassociate from the connected Infrastructure network...
13305 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13306 }
13307 else
13308 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13310 //Otherwise we need to add code to handle the
13311 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13312 //send stop_bss to PE, before we can continue.
13313 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013314 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013316 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13317 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 // there is no Bss description before we start an WDS so we need
13319 // to adopt all Bss configuration parameters from the Profile.
13320 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13321 if(HAL_STATUS_SUCCESS(status))
13322 {
13323 //Save profile for late use
13324 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13326 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013328 vos_mem_set(pSession->pCurRoamProfile,
13329 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013333 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013334 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13335 NULL, &bssConfig,
13336 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 }
13338 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013339
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 return( status );
13341}
13342
Jeff Johnson295189b2012-06-20 16:38:30 -070013343////////////////////Mail box
13344
Jeff Johnson295189b2012-06-20 16:38:30 -070013345//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13346//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013347static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13348 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13350{
13351 tCsrChannelSet channelGroup;
13352 tSirMacCapabilityInfo *pAP_capabilityInfo;
13353 tAniBool fTmp;
13354 tANI_BOOLEAN found = FALSE;
13355 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013356 tANI_S8 pwrLimit = 0;
13357 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13359 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13360 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13361 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 // 802.11h
13363 //We can do this because it is in HOST CPU order for now.
13364 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013365 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13366 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13367 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 fTmp = (tAniBool)pal_cpu_to_be32(1);
13369 }
13370 else
13371 fTmp = (tAniBool)0;
13372
13373 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013374 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013376 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013377 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 // This is required for 11k test VoWiFi Ent: Test 2.
13379 // We need the power capabilities for Assoc Req.
13380 // This macro is provided by the halPhyCfg.h. We pick our
13381 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013382 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13383 if (0 != pwrLimit)
13384 {
13385 *pBuf++ = pwrLimit;
13386 }
13387 else
13388 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013389 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 size = sizeof(pMac->roam.validChannelList);
13392 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013393 {
13394 tANI_U8 *actualSize = pBuf++;
13395 *actualSize = 0;
13396
13397 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013399 /* Only add 5ghz channels*/
13400 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13401 {
13402 *actualSize +=1;
13403 *pBuf++ = pMac->roam.validChannelList[ i ];
13404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 }
13406 }
13407 else
13408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013409 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 *pBuf++ = 0; //tSirSupChnl->numChnl
13411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 //Check whether it is ok to enter UAPSD
13413#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13414 if( btcIsReadyForUapsd(pMac) )
13415#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13416 {
13417 *pBuf++ = uapsdMask;
13418 }
13419#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13420 else
13421 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013422 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 *pBuf++ = 0;
13424 }
13425#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13426
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013428 vos_mem_copy(pBuf, pBssDescription,
13429 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13431}
13432
Jeff Johnson295189b2012-06-20 16:38:30 -070013433/*
13434 * The communication between HDD and LIM is thru mailbox (MB).
13435 * Both sides will access the data structure "tSirSmeJoinReq".
13436 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13437 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13438 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13439 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13440 */
13441eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013442 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013443{
13444 eHalStatus status = eHAL_STATUS_SUCCESS;
13445 tSirSmeJoinReq *pMsg;
13446 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013447 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 tANI_U16 msgLen, wTmp, ieLen;
13449 tSirMacRateSet OpRateSet;
13450 tSirMacRateSet ExRateSet;
13451 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13452 tANI_U32 dwTmp;
13453 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013454 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013455 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013456 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013457
13458 if(!pSession)
13459 {
13460 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13461 return eHAL_STATUS_FAILURE;
13462 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013463 /* To satisfy klockworks */
13464 if (NULL == pBssDescription)
13465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013466 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013467 return eHAL_STATUS_FAILURE;
13468 }
13469
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 do {
13471 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13472 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013473 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13475 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13476 // IE fields, but the length field in the bssDescription needs to be interpreted to
13477 // determine length of the IE fields.
13478 //
13479 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13480 // add in the length from the bssDescription (then add the size of the 'length' field
13481 // itself because that is NOT included in the length field).
13482 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13483 pBssDescription->length + sizeof( pBssDescription->length ) +
13484 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 +053013485 pMsg = vos_mem_malloc(msgLen);
13486 if (NULL == pMsg)
13487 status = eHAL_STATUS_FAILURE;
13488 else
13489 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013491 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013492 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 pMsg->length = pal_cpu_to_be16(msgLen);
13494 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 // sessionId
13496 *pBuf = (tANI_U8)sessionId;
13497 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 // transactionId
13499 *pBuf = 0;
13500 *( pBuf + 1 ) = 0;
13501 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 // ssId
13503 if( pIes->SSID.present && pIes->SSID.num_ssid )
13504 {
13505 // ssId len
13506 *pBuf = pIes->SSID.num_ssid;
13507 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013508 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 pBuf += pIes->SSID.num_ssid;
13510 }
13511 else
13512 {
13513 *pBuf = 0;
13514 pBuf++;
13515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013517 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13518 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013519 pBuf += sizeof(tSirMacAddr);
13520 // bsstype
13521 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13522 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013523 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 pBuf += sizeof(tSirBssType);
13525 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013526 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13527 if (pBssDescription->channelId <= 14 &&
13528 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13529 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13530 {
13531 //Need to disable VHT operation in 2.4 GHz band
13532 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13533 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013534 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13535 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13536
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013537 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 //Persona
13540 *pBuf = (tANI_U8)pProfile->csrPersona;
13541 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013542 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13543 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013544 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13545 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013546 //CBMode
13547 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13548 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013549 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13550 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013551
13552 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013553 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13554 pProfile->csrPersona, pSession->bssParams.cbMode,
13555 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013556
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 // uapsdPerAcBitmask
13558 *pBuf = pProfile->uapsd_mask;
13559 pBuf++;
13560
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013561
13562
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013563 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013564 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 {
13566 // OperationalRateSet
13567 if (OpRateSet.numRates) {
13568 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013569 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 pBuf += OpRateSet.numRates;
13571 } else *pBuf++ = 0;
13572 // ExtendedRateSet
13573 if (ExRateSet.numRates) {
13574 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013575 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pBuf += ExRateSet.numRates;
13577 } else *pBuf++ = 0;
13578 }
13579 else
13580 {
13581 *pBuf++ = 0;
13582 *pBuf++ = 0;
13583 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013584
13585 //rateBitmap
13586 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13587 pBuf += sizeof(tANI_U16);
13588
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 // rsnIE
13590 if ( csrIsProfileWpa( pProfile ) )
13591 {
13592 // Insert the Wpa IE into the join request
13593 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13594 (tCsrWpaIe *)( wpaRsnIE ) );
13595 }
13596 else if( csrIsProfileRSN( pProfile ) )
13597 {
13598 // Insert the RSN IE into the join request
13599 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13600 (tCsrRSNIe *)( wpaRsnIE ) );
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +053013601 pMsg->force_rsne_override =
13602 pProfile->force_rsne_override;
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 }
13604#ifdef FEATURE_WLAN_WAPI
13605 else if( csrIsProfileWapi( pProfile ) )
13606 {
13607 // Insert the WAPI IE into the join request
13608 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13609 (tCsrWapiIe *)( wpaRsnIE ) );
13610 }
13611#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 else
13613 {
13614 ieLen = 0;
13615 }
13616 //remember the IE for future use
13617 if( ieLen )
13618 {
13619 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13620 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013621 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 -070013622 ieLen = DOT11F_IE_RSN_MAX_LEN;
13623 }
13624#ifdef FEATURE_WLAN_WAPI
13625 if( csrIsProfileWapi( pProfile ) )
13626 {
13627 //Check whether we need to allocate more memory
13628 if(ieLen > pSession->nWapiReqIeLength)
13629 {
13630 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13631 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013634 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13635 if (NULL == pSession->pWapiReqIE)
13636 status = eHAL_STATUS_FAILURE;
13637 else
13638 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 if(!HAL_STATUS_SUCCESS(status)) break;
13640 }
13641 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013642 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013644 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pBuf += ieLen;
13648 }
13649 else//should be WPA/WPA2 otherwise
13650#endif /* FEATURE_WLAN_WAPI */
13651 {
13652 //Check whether we need to allocate more memory
13653 if(ieLen > pSession->nWpaRsnReqIeLength)
13654 {
13655 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13656 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013657 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013659 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13660 if (NULL == pSession->pWpaRsnReqIE)
13661 status = eHAL_STATUS_FAILURE;
13662 else
13663 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 if(!HAL_STATUS_SUCCESS(status)) break;
13665 }
13666 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013667 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013669 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013671 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 pBuf += ieLen;
13673 }
13674 }
13675 else
13676 {
13677 //free whatever old info
13678 pSession->nWpaRsnReqIeLength = 0;
13679 if(pSession->pWpaRsnReqIE)
13680 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013681 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 pSession->pWpaRsnReqIE = NULL;
13683 }
13684#ifdef FEATURE_WLAN_WAPI
13685 pSession->nWapiReqIeLength = 0;
13686 if(pSession->pWapiReqIE)
13687 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013688 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 pSession->pWapiReqIE = NULL;
13690 }
13691#endif /* FEATURE_WLAN_WAPI */
13692 //length is two bytes
13693 *pBuf = 0;
13694 *(pBuf + 1) = 0;
13695 pBuf += 2;
13696 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013697#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013698 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013700 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 //length is two bytes
13702 *pBuf = 0;
13703 *(pBuf + 1) = 0;
13704 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013705 }
13706 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013708 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013709 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013710 {
13711 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013712#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013713 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013714 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013715 pSession->suppCckmIeInfo.cckmIe, ieLen);
13716#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013717 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013718 pSession,
13719 pProfile,
13720 pBssDescription,
13721 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pSession->nWpaRsnReqIeLength,
13723 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013724#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013725 }
13726 else
13727 {
13728 ieLen = 0;
13729 }
13730 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13731 if( ieLen )
13732 {
13733 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13734 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013735 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013736 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013737 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013738 pBuf += ieLen;
13739 }
13740 else
13741 {
13742 //Indicate you have no CCKM IE
13743 //length is two bytes
13744 *pBuf = 0;
13745 *(pBuf + 1) = 0;
13746 pBuf += 2;
13747 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013749#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013751 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 {
13753 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013754 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013756 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013758 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013760 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 pBuf += ieLen;
13762 }
13763 else
13764 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013765 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 *pBuf = 0;
13768 *(pBuf + 1) = 0;
13769 pBuf += 2;
13770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 // addIEAssoc
13772 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13773 {
13774 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 if(ieLen > pSession->nAddIEAssocLength)
13776 {
13777 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 {
13779 vos_mem_free(pSession->pAddIEAssoc);
13780 }
13781 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13782 if (NULL == pSession->pAddIEAssoc)
13783 status = eHAL_STATUS_FAILURE;
13784 else
13785 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013789 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013791 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013792 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 pBuf += ieLen;
13795 }
13796 else
13797 {
13798 pSession->nAddIEAssocLength = 0;
13799 if(pSession->pAddIEAssoc)
13800 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013801 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 pSession->pAddIEAssoc = NULL;
13803 }
13804 *pBuf = 0;
13805 *(pBuf + 1) = 0;
13806 pBuf += 2;
13807 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013808
13809 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013811 //Unmask any AC in reassoc that is ACM-set
13812 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13813 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013815 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13816 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013817#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013818 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013819#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013820 }
13821 else
13822 {
13823 uapsd_mask = 0;
13824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 }
13826 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013827
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013829 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013830 pBuf += sizeof(tANI_U32);
13831
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013833 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013834 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013835#ifdef WLAN_FEATURE_11W
13836 //MgmtEncryption
13837 if (pProfile->MFPEnabled)
13838 {
13839 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13840 }
13841 else
13842 {
13843 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13844 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013845 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013846 pBuf += sizeof(tANI_U32);
13847#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013848#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013849 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013850 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013851#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013852 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013853 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013854#endif
13855 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013856 {
13857 // is11Rconnection;
13858 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013859 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013860 pBuf += sizeof(tAniBool);
13861 }
13862 else
13863 {
13864 // is11Rconnection;
13865 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013866 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013867 pBuf += sizeof(tAniBool);
13868 }
13869#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013870#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013871
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013872 // isESEFeatureIniEnabled
13873 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013874 {
13875 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013876 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013877 pBuf += sizeof(tAniBool);
13878 }
13879 else
13880 {
13881 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013882 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013883 pBuf += sizeof(tAniBool);
13884 }
13885
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013886 /* A profile can not be both ESE and 11R. But an 802.11R AP
13887 * may be advertising support for ESE as well. So if we are
13888 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013889 * If we are associating explictly 11R only then we will get
13890 * 11R.
13891 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013892 if ((csrIsProfileESE(pProfile) ||
13893 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013894 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13895 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13896 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13897 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13898#ifdef WLAN_FEATURE_11W
13899 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013900 || (pProfile->negotiatedAuthType ==
13901 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013902#endif
13903 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013904 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013905 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013906 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013907 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013908 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013909 pBuf += sizeof(tAniBool);
13910 }
13911 else
13912 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013913 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013914 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013915 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013916 pBuf += sizeof(tAniBool);
13917 }
13918
13919 if (eWNI_SME_JOIN_REQ == messageType)
13920 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013921 tESETspecInfo eseTspec;
13922 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013923 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013924 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13925 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13926 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013927 }
13928 else if (eWNI_SME_REASSOC_REQ == messageType)
13929 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013930 if ((csrIsProfileESE(pProfile) ||
13931 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013932 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13933 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13934 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13935 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13936#ifdef WLAN_FEATURE_11W
13937 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013938 || (pProfile->negotiatedAuthType ==
13939 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013940#endif
13941 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013942 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013944 tESETspecInfo eseTspec;
13945 // ESE Tspec information
13946 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13947 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13948 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013951 if (eseTspec.numTspecs) {
13952 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13953 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013955 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013957 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013959 tESETspecInfo eseTspec;
13960 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013962 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13963 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13964 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 }
13966 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013967#endif // FEATURE_WLAN_ESE
13968#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013970 if (pMac->roam.configParam.isFastTransitionEnabled
13971#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013972 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013973#endif
13974 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013976 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013977 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013978 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 }
13980 else
13981 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013982 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013983 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013984 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 }
13986#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013987#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013988 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013989 {
13990 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013991 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013992 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013993 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013994 }
13995 else
13996 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013997 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013998 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013999 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014000 }
14001#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014002
14003 // txLdpcIniFeatureEnabled
14004 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
14005 pBuf++;
14006
Kiran4a17ebe2013-01-31 10:43:43 -080014007 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
14008 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
14009 {
14010 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
14011 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
14012 csrApplyPower2Current(pMac);
14013 }
14014
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014015#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014016 // txBFIniFeatureEnabled
14017 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14018 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014019
14020 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014021 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014022 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014023 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14024 if (pIes->VHTCaps.numSoundingDim)
14025 txBFCsnValue = CSR_ROAM_MIN
14026 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014027 }
14028 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014029 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014030
14031 /* Only enable MuBf if no other MuBF session exist
14032 * and FW and HOST is MuBF capable.
14033 */
14034 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14035 {
14036 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14037 pBuf++;
14038 }
14039 else
14040 {
14041 *pBuf = 0;
14042 pBuf++;
14043 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014044#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014045 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14046 pBuf++;
14047
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014048 // WME
14049 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14050 {
14051 //WME enabled
14052 dwTmp = pal_cpu_to_be32(TRUE);
14053 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14054 pBuf += sizeof(tAniBool);
14055 }
14056 else
14057 {
14058 dwTmp = pal_cpu_to_be32(FALSE);
14059 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14060 pBuf += sizeof(tAniBool);
14061 }
14062
14063 // QOS
14064 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14065 {
14066 //QOS enabled
14067 dwTmp = pal_cpu_to_be32(TRUE);
14068 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14069 pBuf += sizeof(tAniBool);
14070 }
14071 else
14072 {
14073 dwTmp = pal_cpu_to_be32(FALSE);
14074 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14075 pBuf += sizeof(tAniBool);
14076 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014077 //BssDesc
14078 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14079 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014080
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014081 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014082 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14083 pMsg = NULL;
14084
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014085 if(!HAL_STATUS_SUCCESS(status))
14086 {
14087 break;
14088 }
14089 else
14090 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014091#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014092 if (eWNI_SME_JOIN_REQ == messageType)
14093 {
14094 //Tush-QoS: notify QoS module that join happening
14095 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14096 }
14097 else if (eWNI_SME_REASSOC_REQ == messageType)
14098 {
14099 //Tush-QoS: notify QoS module that reassoc happening
14100 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14101 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014102#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014105
14106 if (pMsg != NULL)
14107 {
14108 vos_mem_free( pMsg );
14109 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014110 pMac->roam.roamSession[sessionId].connect_req_start_time =
14111 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014112
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014114}
14115
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014116#ifdef WLAN_FEATURE_LFR_MBB
14117/**
14118 * csr_prepare_reassoc_req () - Prepares reassoc request
14119 * @mac: MAC context
14120 * @session_id: session id
14121 * @pbss_description: bss description
14122 * @ies: pointer to beacon IE's
14123 * @reassoc_req: pointer to reassociation request
14124 *
14125 *Return: None
14126 */
14127eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14128 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14129 tSirSmeJoinReq **reassoc_req)
14130{
14131 eHalStatus status = eHAL_STATUS_SUCCESS;
14132 tSirSmeJoinReq *csr_join_req;
14133 tANI_U8 *buf;
14134 v_U8_t acm_mask = 0, uapsd_mask;
14135 tANI_U16 msg_len, w_tmp, ie_len;
14136 tSirMacRateSet op_rate_set;
14137 tSirMacRateSet ex_rate_set;
14138 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14139 tANI_U32 dw_tmp;
14140 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14141 tANI_U32 uc_dot11_mode = 0;
14142 tANI_U8 tx_bf_csn_value = 0;
14143 tANI_U16 rate_bitmap = 0;
14144 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014145 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014146
14147 if(!session) {
14148 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14149 return eHAL_STATUS_FAILURE;
14150 }
14151
14152 if (NULL == bss_description) {
14153 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14154 return eHAL_STATUS_FAILURE;
14155 }
14156
14157 smsLog(mac, LOG1,
14158 FL("session_id %d"), session_id);
14159
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014160 profile = vos_mem_malloc(sizeof(*profile));
14161 if (NULL == profile) {
14162 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14163 return eHAL_STATUS_RESOURCES;
14164 }
14165
14166 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014167 if(!HAL_STATUS_SUCCESS(status)) {
14168 smsLog(mac, LOGE, FL("Profile copy failed"));
14169 return eHAL_STATUS_FAILURE;
14170 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014171
14172 do {
14173 /*
14174 * There are a number of variable length fields to consider.
14175 * First, the tSirSmeJoinReq includes a single bssDescription.
14176 * bssDescription includes a single tANI_U32 for the IE fields,
14177 * but the length field in the bssDescription needs to be
14178 * interpreted to determine length of the IE fields.
14179 * So, take the size of the JoinReq, subtract the size of the
14180 * bssDescription and add in the length from the bssDescription
14181 * (then add the size of the 'length' field itself because that is
14182 * NOT included in the length field). msgLen =
14183 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14184 * pBssDescription->length + sizeof( pBssDescription->length ) +
14185 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14186 * add in the size of the WPA IE that we may build.
14187 */
14188
14189 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14190 bss_description->length + sizeof(bss_description->length) +
14191 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14192
14193 csr_join_req = vos_mem_malloc(msg_len);
14194 if (NULL == csr_join_req)
14195 status = eHAL_STATUS_FAILURE;
14196 else
14197 status = eHAL_STATUS_SUCCESS;
14198 if (!HAL_STATUS_SUCCESS(status)) break;
14199
14200 vos_mem_set(csr_join_req, msg_len, 0);
14201 *reassoc_req = csr_join_req;
14202
14203 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14204 csr_join_req->length = pal_cpu_to_be16(msg_len);
14205 buf = &csr_join_req->sessionId;
14206
14207 /* session_id */
14208 *buf = (tANI_U8)session_id;
14209 buf++;
14210
14211 /* transactionId */
14212 *buf = 0;
14213 *(buf + 1) = 0;
14214 buf += sizeof(tANI_U16);
14215
14216 /* ssId */
14217 if(ies->SSID.present && ies->SSID.num_ssid)
14218 {
14219 /* ssId len */
14220 *buf = ies->SSID.num_ssid;
14221 buf++;
14222 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14223 buf += ies->SSID.num_ssid;
14224 }
14225 else
14226 {
14227 *buf = 0;
14228 buf++;
14229 }
14230
14231 /* selfMacAddr */
14232 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14233 sizeof(tSirMacAddr));
14234 buf += sizeof(tSirMacAddr);
14235
14236 /* bsstype */
14237 dw_tmp =
14238 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14239 /* Override BssType for BTAMP */
14240 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14241 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14242 buf += sizeof(tSirBssType);
14243
14244 /* dot11mode */
14245 uc_dot11_mode =
14246 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14247 if (bss_description->channelId <= 14 &&
14248 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14249 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14250 {
14251 /* Need to disable VHT operation in 2.4 GHz band */
14252 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14253 }
14254 *buf = (tANI_U8)uc_dot11_mode;
14255 buf++;
14256
14257 /* Persona */
14258 *buf = (tANI_U8)profile->csrPersona;
14259 buf++;
14260 *buf = (tANI_U8)profile->bOSENAssociation;
14261 buf++;
14262 *buf = (tANI_U8)profile->bWPSAssociation;
14263 buf++;
14264
14265 /* CBMode */
14266 *buf = (tANI_U8)session->bssParams.cbMode;
14267 buf++;
14268
14269 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14270 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14271 session->bssParams.cbMode);
14272
14273 /* uapsdPerAcBitmask */
14274 *buf = profile->uapsd_mask;
14275 buf++;
14276
14277
14278 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14279 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14280 if (HAL_STATUS_SUCCESS(status))
14281 {
14282 /* OperationalRateSet */
14283 if (op_rate_set.numRates) {
14284 *buf++ = op_rate_set.numRates;
14285 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14286 buf += op_rate_set.numRates;
14287 } else *buf++ = 0;
14288
14289 /* ExtendedRateSet */
14290 if (ex_rate_set.numRates) {
14291 *buf++ = ex_rate_set.numRates;
14292 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14293 buf += ex_rate_set.numRates;
14294 } else *buf++ = 0;
14295 }
14296 else
14297 {
14298 *buf++ = 0;
14299 *buf++ = 0;
14300 }
14301
14302 /* rateBitmap */
14303 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14304 buf += sizeof(tANI_U16);
14305
14306 profile->negotiatedAuthType =
14307 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14308 profile->negotiatedUCEncryptionType =
14309 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14310
14311 /* rsnIE */
14312 if ( csrIsProfileWpa(profile))
14313 {
14314 /* Insert the Wpa IE into the join request */
14315 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14316 (tCsrWpaIe *)(wpa_rsn_ie));
14317 }
14318 else if( csrIsProfileRSN(profile))
14319 {
14320 /* Insert the RSN IE into the join request */
14321 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14322 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14323 }
14324#ifdef FEATURE_WLAN_WAPI
14325 else if( csrIsProfileWapi(profile))
14326 {
14327 /* Insert the WAPI IE into the join request */
14328 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14329 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14330 }
14331#endif
14332 else
14333 {
14334 ie_len = 0;
14335 }
14336 /* remember the IE for future use */
14337 if(ie_len)
14338 {
14339 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14340 {
14341 smsLog(mac, LOGE,
14342 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14343 ie_len, DOT11F_IE_RSN_MAX_LEN);
14344 ie_len = DOT11F_IE_RSN_MAX_LEN;
14345 }
14346#ifdef FEATURE_WLAN_WAPI
14347 if( csrIsProfileWapi(profile))
14348 {
14349 /* Check whether we need to allocate more memory */
14350 if(ie_len > session->nWapiReqIeLength)
14351 {
14352 if(session->pWapiReqIE && session->nWapiReqIeLength)
14353 {
14354 vos_mem_free(session->pWapiReqIE);
14355 }
14356 session->pWapiReqIE = vos_mem_malloc(ie_len);
14357 if (NULL == session->pWapiReqIE)
14358 status = eHAL_STATUS_FAILURE;
14359 else
14360 status = eHAL_STATUS_SUCCESS;
14361 if(!HAL_STATUS_SUCCESS(status)) break;
14362 }
14363 session->nWapiReqIeLength = ie_len;
14364 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14365 w_tmp = pal_cpu_to_be16(ie_len);
14366 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14367 buf += sizeof(tANI_U16);
14368 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14369 buf += ie_len;
14370 }
14371 else /* should be WPA/WPA2 otherwise */
14372#endif
14373 {
14374 /* Check whether we need to allocate more memory */
14375 if(ie_len > session->nWpaRsnReqIeLength)
14376 {
14377 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14378 {
14379 vos_mem_free(session->pWpaRsnReqIE);
14380 }
14381 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14382 if (NULL == session->pWpaRsnReqIE)
14383 status = eHAL_STATUS_FAILURE;
14384 else
14385 status = eHAL_STATUS_SUCCESS;
14386 if(!HAL_STATUS_SUCCESS(status)) break;
14387 }
14388 session->nWpaRsnReqIeLength = ie_len;
14389 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14390 w_tmp = pal_cpu_to_be16(ie_len);
14391 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14392 buf += sizeof(tANI_U16);
14393 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14394 buf += ie_len;
14395 }
14396 }
14397 else
14398 {
14399 /* free whatever old info */
14400 session->nWpaRsnReqIeLength = 0;
14401 if(session->pWpaRsnReqIE)
14402 {
14403 vos_mem_free(session->pWpaRsnReqIE);
14404 session->pWpaRsnReqIE = NULL;
14405 }
14406#ifdef FEATURE_WLAN_WAPI
14407 session->nWapiReqIeLength = 0;
14408 if(session->pWapiReqIE)
14409 {
14410 vos_mem_free(session->pWapiReqIE);
14411 session->pWapiReqIE = NULL;
14412 }
14413#endif
14414 /* length is two bytes */
14415 *buf = 0;
14416 *(buf + 1) = 0;
14417 buf += 2;
14418 }
14419#ifdef FEATURE_WLAN_ESE
14420 if(eWNI_SME_JOIN_REQ == message_type)
14421 {
14422 /*
14423 * Never include the cckmIE in an Join Request
14424 * length is two bytes
14425 */
14426 *buf = 0;
14427 *(buf + 1) = 0;
14428 buf += 2;
14429 }
14430 else if(eWNI_SME_REASSOC_REQ == message_type)
14431 {
14432 /* cckmIE */
14433 if( csrIsProfileESE(profile))
14434 {
14435 /* Insert the CCKM IE into the join request */
14436#ifdef FEATURE_WLAN_ESE_UPLOAD
14437 ie_len = session->suppCckmIeInfo.cckmIeLen;
14438 vos_mem_copy((void *) (wpa_rsn_ie),
14439 session->suppCckmIeInfo.cckmIe, ie_len);
14440#else
14441 ie_len = csrConstructEseCckmIe(mac,
14442 session,
14443 profile,
14444 bss_description,
14445 session->pWpaRsnReqIE,
14446 session->nWpaRsnReqIeLength,
14447 (void *)(wpa_rsn_ie));
14448#endif
14449 }
14450 else
14451 {
14452 ie_len = 0;
14453 }
14454 /*
14455 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14456 * message buffer
14457 */
14458 if(ie_len)
14459 {
14460 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14461 w_tmp = pal_cpu_to_be16(ie_len);
14462 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14463 buf += sizeof(tANI_U16);
14464 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14465 buf += ie_len;
14466 }
14467 else
14468 {
14469 /* Indicate you have no CCKM IE length is two bytes */
14470 *buf = 0;
14471 *(buf + 1) = 0;
14472 buf += 2;
14473 }
14474 }
14475#endif
14476 /* addIEScan */
14477 if (profile->nAddIEScanLength)
14478 {
14479 ie_len = profile->nAddIEScanLength;
14480 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14481 session->nAddIEScanLength = ie_len;
14482 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14483 w_tmp = pal_cpu_to_be16(ie_len);
14484 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14485 buf += sizeof(tANI_U16);
14486 vos_mem_copy(buf, profile->addIEScan, ie_len);
14487 buf += ie_len;
14488 }
14489 else
14490 {
14491 memset(session->addIEScan, 0, session->nAddIEScanLength);
14492 session->nAddIEScanLength = 0;
14493 *buf = 0;
14494 *(buf + 1) = 0;
14495 buf += 2;
14496 }
14497 /* addIEAssoc */
14498 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14499 {
14500 ie_len = profile->nAddIEAssocLength;
14501 if(ie_len > session->nAddIEAssocLength)
14502 {
14503 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14504 {
14505 vos_mem_free(session->pAddIEAssoc);
14506 }
14507 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14508 if (NULL == session->pAddIEAssoc)
14509 status = eHAL_STATUS_FAILURE;
14510 else
14511 status = eHAL_STATUS_SUCCESS;
14512 if(!HAL_STATUS_SUCCESS(status)) break;
14513 }
14514 session->nAddIEAssocLength = ie_len;
14515 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14516 w_tmp = pal_cpu_to_be16(ie_len);
14517 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14518 buf += sizeof(tANI_U16);
14519 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14520 buf += ie_len;
14521 }
14522 else
14523 {
14524 session->nAddIEAssocLength = 0;
14525 if(session->pAddIEAssoc)
14526 {
14527 vos_mem_free(session->pAddIEAssoc);
14528 session->pAddIEAssoc = NULL;
14529 }
14530 *buf = 0;
14531 *(buf + 1) = 0;
14532 buf += 2;
14533 }
14534
14535 if(eWNI_SME_REASSOC_REQ == message_type )
14536 {
14537 /*Unmask any AC in reassoc that is ACM-set */
14538 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14539 if( uapsd_mask && (NULL != bss_description))
14540 {
14541 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14542 {
14543#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14544 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14545#endif
14546 }
14547 else
14548 {
14549 uapsd_mask = 0;
14550 }
14551 }
14552 }
14553
14554 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14555 profile->negotiatedUCEncryptionType));
14556 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14557 buf += sizeof(tANI_U32);
14558
14559 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14560 profile->negotiatedMCEncryptionType));
14561 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14562 buf += sizeof(tANI_U32);
14563#ifdef WLAN_FEATURE_11W
14564 /* MgmtEncryption */
14565 if (profile->MFPEnabled)
14566 {
14567 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14568 }
14569 else
14570 {
14571 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14572 }
14573 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14574 buf += sizeof(tANI_U32);
14575#endif
14576#ifdef WLAN_FEATURE_VOWIFI_11R
14577 profile->MDID.mdiePresent = bss_description->mdiePresent;
14578 if (csrIsProfile11r(profile)
14579#ifdef FEATURE_WLAN_ESE
14580 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14581 (ies->ESEVersion.present) &&
14582 (mac->roam.configParam.isEseIniFeatureEnabled))
14583#endif
14584 )
14585 {
14586 /* is11Rconnection */
14587 dw_tmp = pal_cpu_to_be32(TRUE);
14588 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14589 buf += sizeof(tAniBool);
14590 }
14591 else
14592 {
14593 /* is11Rconnection */
14594 dw_tmp = pal_cpu_to_be32(FALSE);
14595 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14596 buf += sizeof(tAniBool);
14597 }
14598#endif
14599#ifdef FEATURE_WLAN_ESE
14600
14601 /* isESEFeatureIniEnabled */
14602 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14603 {
14604 dw_tmp = pal_cpu_to_be32(TRUE);
14605 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14606 buf += sizeof(tAniBool);
14607 }
14608 else
14609 {
14610 dw_tmp = pal_cpu_to_be32(FALSE);
14611 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14612 buf += sizeof(tAniBool);
14613 }
14614
14615 /* A profile can not be both ESE and 11R. But an 802.11R AP
14616 * may be advertising support for ESE as well. So if we are
14617 * associating Open or explicitly ESE then we will get ESE.
14618 * If we are associating explictly 11R only then we will get
14619 * 11R.
14620 */
14621 if ((csrIsProfileESE(profile) ||
14622 ((ies->ESEVersion.present)
14623 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14624 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14625 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14626 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14627#ifdef WLAN_FEATURE_11W
14628 || (profile->negotiatedAuthType ==
14629 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14630 || (profile->negotiatedAuthType ==
14631 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14632#endif
14633 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14634 && (mac->roam.configParam.isEseIniFeatureEnabled))
14635 {
14636 /* isESEconnection */
14637 dw_tmp = pal_cpu_to_be32(TRUE);
14638 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14639 buf += sizeof(tAniBool);
14640 }
14641 else
14642 {
14643 /* isESEconnection */
14644 dw_tmp = pal_cpu_to_be32(FALSE);
14645 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14646 buf += sizeof(tAniBool);
14647 }
14648
14649 if (eWNI_SME_JOIN_REQ == message_type)
14650 {
14651 tESETspecInfo eseTspec;
14652 /*
14653 * ESE-Tspec IEs in the ASSOC request is presently not supported
14654 * so nullify the TSPEC parameters
14655 */
14656 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14657 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14658 buf += sizeof(tESETspecInfo);
14659 }
14660 else if (eWNI_SME_REASSOC_REQ == message_type)
14661 {
14662 if ((csrIsProfileESE(profile) ||
14663 ((ies->ESEVersion.present)
14664 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14665 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14666 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14667 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14668#ifdef WLAN_FEATURE_11W
14669 || (profile->negotiatedAuthType ==
14670 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14671 || (profile->negotiatedAuthType ==
14672 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14673#endif
14674 || (profile->negotiatedAuthType ==
14675 eCSR_AUTH_TYPE_RSN_PSK))))
14676 && (mac->roam.configParam.isEseIniFeatureEnabled))
14677 {
14678 tESETspecInfo eseTspec;
14679 /* ESE Tspec information */
14680 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14681 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14682 (tTspecInfo *) &eseTspec.tspec[0]);
14683 *buf = eseTspec.numTspecs;
14684 buf += sizeof(tANI_U8);
14685 // Copy the TSPEC information only if present
14686 if (eseTspec.numTspecs) {
14687 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14688 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14689 }
14690 buf += sizeof(eseTspec.tspec);
14691 }
14692 else
14693 {
14694 tESETspecInfo eseTspec;
14695 /*
14696 * ESE-Tspec IEs in the ASSOC request is presently
14697 * not supported so nullify the TSPEC parameters
14698 */
14699 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14700 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14701 buf += sizeof(tESETspecInfo);
14702 }
14703 }
14704#endif
14705#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14706 /* Fill in isFastTransitionEnabled */
14707 if (mac->roam.configParam.isFastTransitionEnabled
14708#ifdef FEATURE_WLAN_LFR
14709 || csrRoamIsFastRoamEnabled(mac, session_id)
14710#endif
14711 )
14712 {
14713 dw_tmp = pal_cpu_to_be32(TRUE);
14714 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14715 buf += sizeof(tAniBool);
14716 }
14717 else
14718 {
14719 dw_tmp = pal_cpu_to_be32(FALSE);
14720 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14721 buf += sizeof(tAniBool);
14722 }
14723#endif
14724#ifdef FEATURE_WLAN_LFR
14725 if(csrRoamIsFastRoamEnabled(mac, session_id))
14726 {
14727 /* legacy fast roaming enabled */
14728 dw_tmp = pal_cpu_to_be32(TRUE);
14729 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14730 buf += sizeof(tAniBool);
14731 }
14732 else
14733 {
14734 dw_tmp = pal_cpu_to_be32(FALSE);
14735 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14736 buf += sizeof(tAniBool);
14737 }
14738#endif
14739
14740 /* txLdpcIniFeatureEnabled */
14741 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14742 buf++;
14743
14744 if ((csrIs11hSupported(mac)) &&
14745 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14746 (ies->Country.present) &&\
14747 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14748 {
14749 csrSaveToChannelPower2G_5G(mac,
14750 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14751 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14752 csrApplyPower2Current(mac);
14753 }
14754
14755#ifdef WLAN_FEATURE_11AC
14756 /* txBFIniFeatureEnabled */
14757 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14758 buf++;
14759
14760 /* txBFCsnValue */
14761 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14762 {
14763 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14764 if (ies->VHTCaps.numSoundingDim)
14765 tx_bf_csn_value = CSR_ROAM_MIN
14766 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14767 }
14768 *buf = tx_bf_csn_value;
14769 buf++;
14770
14771 /* Only enable MuBf if no other MuBF session exist
14772 * and FW and HOST is MuBF capable.
14773 */
14774 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14775 {
14776 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14777 buf++;
14778 }
14779 else
14780 {
14781 *buf = 0;
14782 buf++;
14783 }
14784#endif
14785 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14786 buf++;
14787
14788 /* WME */
14789 if(mac->roam.roamSession[session_id].fWMMConnection)
14790 {
14791 /* WME enabled */
14792 dw_tmp = pal_cpu_to_be32(TRUE);
14793 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14794 buf += sizeof(tAniBool);
14795 }
14796 else
14797 {
14798 dw_tmp = pal_cpu_to_be32(FALSE);
14799 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14800 buf += sizeof(tAniBool);
14801 }
14802
14803 /* QOS */
14804 if(mac->roam.roamSession[session_id].fQOSConnection)
14805 {
14806 /* QOS enabled */
14807 dw_tmp = pal_cpu_to_be32(TRUE);
14808 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14809 buf += sizeof(tAniBool);
14810 }
14811 else
14812 {
14813 dw_tmp = pal_cpu_to_be32(FALSE);
14814 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14815 buf += sizeof(tAniBool);
14816 }
14817 /* BssDesc */
14818 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14819 (tANI_U8)profile->uapsd_mask);
14820 } while( 0 );
14821
14822 smsLog(mac, LOG1, FL("status %d"), status);
14823
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014824 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014825 return status;
14826}
14827#endif
14828
Jeff Johnson295189b2012-06-20 16:38:30 -070014829//
14830eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14831{
14832 eHalStatus status = eHAL_STATUS_SUCCESS;
14833 tSirSmeDisassocReq *pMsg;
14834 tANI_U8 *pBuf;
14835 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14837 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14838 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014840 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14841 if (NULL == pMsg)
14842 status = eHAL_STATUS_FAILURE;
14843 else
14844 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014846 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14848 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 pBuf = &pMsg->sessionId;
14850 // sessionId
14851 *pBuf++ = (tANI_U8)sessionId;
14852 // transactionId
14853 *pBuf = 0;
14854 *( pBuf + 1 ) = 0;
14855 pBuf += sizeof(tANI_U16);
14856
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014857 if ( (pSession->pCurRoamProfile != NULL) &&
14858 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14859 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 {
14861 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014862 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14863 sizeof( tSirMacAddr ));
14864 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014867 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14868 //perMacAddr is passed as bssId for softAP
14869 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014870 pBuf = pBuf + sizeof ( tSirMacAddr );
14871 }
14872 else
14873 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014875 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14876 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014877 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053014878 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
14879 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 if(!HAL_STATUS_SUCCESS(status))
14883 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014884 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 break;
14886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014887 // reasonCode
14888 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014889 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
14890 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 if(!HAL_STATUS_SUCCESS(status))
14892 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014893 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 break;
14895 }
14896 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14898 Here we should not send the disassoc over the air to the AP */
14899 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14900#ifdef WLAN_FEATURE_VOWIFI_11R
14901 && csrRoamIs11rAssoc(pMac)
14902#endif
14903 )
14904 {
14905 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14906 }
14907 pBuf += sizeof(tANI_U8);
14908 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 return( status );
14911}
Jeff Johnson295189b2012-06-20 16:38:30 -070014912eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14913{
14914 eHalStatus status = eHAL_STATUS_SUCCESS;
14915 tSirSmeTkipCntrMeasReq *pMsg;
14916 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 do
14918 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014919 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14920 if ( NULL == pMsg )
14921 status = eHAL_STATUS_FAILURE;
14922 else
14923 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014925 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14927 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 pBuf = &pMsg->sessionId;
14929 // sessionId
14930 *pBuf++ = (tANI_U8)sessionId;
14931 // transactionId
14932 *pBuf = 0;
14933 *( pBuf + 1 ) = 0;
14934 pBuf += sizeof(tANI_U16);
14935 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014936 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14937 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014938 pBuf = pBuf + sizeof ( tSirMacAddr );
14939 // bEnable
14940 *pBuf = (tANI_BOOLEAN)bEnable;
14941 if(!HAL_STATUS_SUCCESS(status))
14942 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014943 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 break;
14945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 return( status );
14949}
Jeff Johnson295189b2012-06-20 16:38:30 -070014950eHalStatus
14951csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
14952 VOS_MODULE_ID modId, tSirMacAddr bssId,
14953 void *pUsrContext, void *pfnSapEventCallback,
14954 tANI_U8 *pAssocStasBuf )
14955{
14956 eHalStatus status = eHAL_STATUS_SUCCESS;
14957 tSirSmeGetAssocSTAsReq *pMsg;
14958 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14959 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 do
14961 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014962 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
14963 if ( NULL == pMsg )
14964 status = eHAL_STATUS_FAILURE;
14965 else
14966 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014968 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 pBuf = (tANI_U8 *)&pMsg->bssId;
14971 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014973 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 // modId
14976 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014977 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014980 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
14981 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014983 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
14984 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080014986 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
14987 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 status = palSendMBMessage( pMac->hHdd, pMsg );
14990 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 return( status );
14992 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014993eHalStatus
14994csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
14995 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
14996 {
14997 eHalStatus status = eHAL_STATUS_SUCCESS;
14998 tSirSmeGetWPSPBCSessionsReq *pMsg;
14999 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080015000
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 do
15002 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015003 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
15004 if ( NULL == pMsg )
15005 status = eHAL_STATUS_FAILURE;
15006 else
15007 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015009 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070015012 VOS_ASSERT(pBuf);
15013
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015016 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15017 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015019 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15020 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015021 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015022 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015024 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015025 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015026 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015030 return( status );
15031}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015032
15033eHalStatus
15034csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15035{
15036 tpSirChangeBIParams pMsg;
15037 tANI_U16 len = 0;
15038 eHalStatus status = eHAL_STATUS_SUCCESS;
15039 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15040
15041 if(!pSession)
15042 {
15043 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15044 return eHAL_STATUS_FAILURE;
15045 }
15046
15047 //NO need to update the Beacon Params if update beacon parameter flag is not set
15048 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15049 return eHAL_STATUS_SUCCESS;
15050
15051 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15052
15053 /* Create the message and send to lim */
15054 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015055 pMsg = vos_mem_malloc(len);
15056 if ( NULL == pMsg )
15057 status = eHAL_STATUS_FAILURE;
15058 else
15059 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015060 if(HAL_STATUS_SUCCESS(status))
15061 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015062 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015063 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15064 pMsg->length = len;
15065
15066 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015067 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15068 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015069 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15070 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015071 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015072 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015073 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15074 status = palSendMBMessage(pMac->hHdd, pMsg);
15075 }
15076 return status;
15077}
15078
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015079#ifdef WLAN_FEATURE_AP_HT40_24G
15080eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15081{
15082 tpSirSetHT2040Mode pMsg;
15083 tANI_U16 len = 0;
15084 eHalStatus status = eHAL_STATUS_SUCCESS;
15085 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15086
15087 if(!pSession)
15088 {
15089 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15090 return eHAL_STATUS_FAILURE;
15091 }
15092
15093 /* Create the message and send to lim */
15094 len = sizeof(tSirSetHT2040Mode);
15095 pMsg = vos_mem_malloc(len);
15096
15097 if ( NULL == pMsg )
15098 {
15099 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15100 status = eHAL_STATUS_FAILURE;
15101 }
15102 else
15103 status = eHAL_STATUS_SUCCESS;
15104
15105 if(HAL_STATUS_SUCCESS(status))
15106 {
15107 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15108 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15109 pMsg->length = len;
15110
15111 // bssId
15112 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15113 sizeof(tSirMacAddr));
15114
15115 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15116 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15117 MAC_ADDR_ARRAY(pMsg->bssId));
15118
15119 pMsg->sessionId = sessionId;
15120 pMsg->cbMode = cbMode;
15121
15122 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15123 sessionId, cbMode);
15124
15125 status = palSendMBMessage(pMac->hHdd, pMsg);
15126 }
15127 return status;
15128}
15129#endif
15130
Jeff Johnson295189b2012-06-20 16:38:30 -070015131eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15132{
15133 eHalStatus status = eHAL_STATUS_SUCCESS;
15134 tSirSmeDeauthReq *pMsg;
15135 tANI_U8 *pBuf;
15136 tANI_U16 wTmp;
15137 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15138 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15139 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015141 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15142 if ( NULL == pMsg )
15143 status = eHAL_STATUS_FAILURE;
15144 else
15145 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015147 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15149 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15150 //sessionId
15151 pBuf = &pMsg->sessionId;
15152 *pBuf++ = (tANI_U8)sessionId;
15153
15154 //tansactionId
15155 *pBuf = 0;
15156 *(pBuf + 1 ) = 0;
15157 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015158 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15161 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015162 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15163 sizeof( pMsg->peerMacAddr ) );
15164 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 pBuf = pBuf + sizeof(tSirMacAddr);
15166 }
15167 else
15168 {
15169 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015170 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15171 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015172 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015173 }
15174 if(!HAL_STATUS_SUCCESS(status))
15175 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015176 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 break;
15178 }
15179 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015180 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15181 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 pBuf = pBuf + sizeof(tSirMacAddr);
15183 if(!HAL_STATUS_SUCCESS(status))
15184 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015185 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015186 break;
15187 }
15188 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015189 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15190 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 if(!HAL_STATUS_SUCCESS(status))
15192 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015193 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 break;
15195 }
15196 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015198 return( status );
15199}
15200
Jeff Johnson295189b2012-06-20 16:38:30 -070015201eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15202{
15203 eHalStatus status = eHAL_STATUS_SUCCESS;
15204 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015206 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15207 if ( NULL == pMsg )
15208 status = eHAL_STATUS_FAILURE;
15209 else
15210 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015212 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15214 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15215 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015216 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015217 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15218 sizeof(pMsg->peerMacAddr));
15219 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 if(!HAL_STATUS_SUCCESS(status))
15221 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015222 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015223 break;
15224 }
15225//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015226 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15227 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 if(!HAL_STATUS_SUCCESS(status))
15229 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015230 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015231 break;
15232 }
15233//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 return( status );
15237}
15238
Jeff Johnson295189b2012-06-20 16:38:30 -070015239eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15240{
15241 eHalStatus status = eHAL_STATUS_SUCCESS;
15242 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015244 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15245 if ( NULL == pMsg )
15246 status = eHAL_STATUS_FAILURE;
15247 else
15248 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015249 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015250 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15252 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15253 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015254 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015255 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15256 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 if(!HAL_STATUS_SUCCESS(status))
15258 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015259 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015260 break;
15261 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015262 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15263 sizeof(pMsg->peerMacAddr));
15264 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 if(!HAL_STATUS_SUCCESS(status))
15266 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015267 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015268 break;
15269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015271 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 return( status );
15273}
Jeff Johnson295189b2012-06-20 16:38:30 -070015274eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15275{
15276 eHalStatus status = eHAL_STATUS_SUCCESS;
15277 tSirSmeAssocCnf *pMsg;
15278 tANI_U8 *pBuf;
15279 tSirResultCodes statusCode;
15280 tANI_U16 wTmp;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015281 vos_msg_t msg;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015282
15283 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15284 "HalStatus : %d"),
15285 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015287 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15288 if ( NULL == pMsg )
15289 status = eHAL_STATUS_FAILURE;
15290 else
15291 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015292 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015293 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15295 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015296 pBuf = (tANI_U8 *)&pMsg->statusCode;
15297 if(HAL_STATUS_SUCCESS(Halstatus))
15298 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15299 else
15300 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015301 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 pBuf += sizeof(tSirResultCodes);
15303 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015304 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15305 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 pBuf += sizeof (tSirMacAddr);
15307 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015308 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15309 sizeof(tSirMacAddr));
15310 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 pBuf += sizeof (tSirMacAddr);
15312 // aid
15313 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015314 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 pBuf += sizeof (tANI_U16);
15316 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015317 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15318 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 pBuf += sizeof (tSirMacAddr);
15320 // alternateChannelId
15321 *pBuf = 11;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015322 msg.type = pMsg->messageType;
15323 msg.bodyval = 0;
15324 msg.bodyptr = pMsg;
15325 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015326 if(!HAL_STATUS_SUCCESS(status))
15327 {
15328 //pMsg is freed by palSendMBMessage
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015329 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 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;
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015433 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015434 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 );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015439 vos_msg_t msg;
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015440 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15441 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15445 // key set. Since we only support upto one key, we always allocate memory for 1 key
15446 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15447 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15448 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15449 ( sizeof( pMsg->keyMaterial.key ) );
15450
Kiet Lam64c1b492013-07-12 13:56:44 +053015451 pMsg = vos_mem_malloc(msgLen);
15452 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15453 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15455 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 //sessionId
15457 pBuf = &pMsg->sessionId;
15458 *pBuf = (tANI_U8)sessionId;
15459 pBuf++;
15460 // transactionId
15461 *pBuf = 0;
15462 *(pBuf + 1) = 0;
15463 pBuf += sizeof(tANI_U16);
15464 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015465 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015466
15467 pBuf += sizeof(tSirMacAddr);
15468
15469 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015470 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15471 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015472
15473 pBuf += sizeof(tSirMacAddr);
15474
15475 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15477 // in the tSirKeyMaterial keyMaterial; field).
15478 //
15479 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15480 // shorter than this max size. Is LIM interpreting this ok ?
15481 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 -070015482 // set pMsg->keyMaterial.edType
15483 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015484 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 // set the pMsg->keyMaterial.numKeys field
15487 *p = numKeys;
15488 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 // set pSirKey->keyId = keyId;
15490 *p = keyId;
15491 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015492 // set pSirKey->unicast = (tANI_U8)fUnicast;
15493 *p = (tANI_U8)fUnicast;
15494 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 // set pSirKey->keyDirection = aniKeyDirection;
15496 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015497 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015498 p += sizeof(tAniKeyDirection);
15499 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015500 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015502 // set pSirKey->paeRole
15503 *p = paeRole; // 0 is Supplicant
15504 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 // set pSirKey->keyLength = keyLength;
15506 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015507 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015508 vos_mem_copy(p, pKey, keyLength);
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015509 msg.type = pMsg->messageType;
15510 msg.bodyptr = pMsg;
15511 msg.bodyval = 0;
15512 if (fUnicast)
15513 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
15514 else
15515 status = vos_mq_post_message(VOS_MQ_ID_PE, &msg);
15516 if (!VOS_IS_STATUS_SUCCESS(status)) {
15517 vos_mem_free(pMsg);
15518 return eHAL_STATUS_FAILURE;
15519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015520 } while( 0 );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015521 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015522}
15523
Jeff Johnson295189b2012-06-20 16:38:30 -070015524eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15525 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15526{
15527 eHalStatus status;
15528 tSirSmeStartBssReq *pMsg;
15529 tANI_U8 *pBuf = NULL;
15530 tANI_U8 *wTmpBuf = NULL;
15531 tANI_U16 msgLen, wTmp;
15532 tANI_U32 dwTmp;
15533 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015534 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015535 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015536 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015537
15538 if(!pSession)
15539 {
15540 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15541 return eHAL_STATUS_FAILURE;
15542 }
15543
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 do {
15545 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15546 pSession->joinFailStatusCode.reasonCode = 0;
15547 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015548 pMsg = vos_mem_malloc(msgLen);
15549 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15550 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 //sessionId
15555 *pBuf = (tANI_U8)sessionId;
15556 pBuf++;
15557 // transactionId
15558 *pBuf = 0;
15559 *(pBuf + 1) = 0;
15560 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015561 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015562 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015563 pBuf += sizeof(tSirMacAddr);
15564 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015565 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015566 pBuf += sizeof(tSirMacAddr);
15567 // beaconInterval
15568 if( pBssDesc && pBssDesc->beaconInterval )
15569 {
15570 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015572 else if(pParam->beaconInterval)
15573 {
15574 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015576 else
15577 {
15578 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15579 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015580 if(csrIsconcurrentsessionValid (pMac, sessionId,
15581 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015582 == eHAL_STATUS_SUCCESS )
15583 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015584 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015585 pParam->bssPersona);
15586 //Update the beacon Interval
15587 pParam->beaconInterval = wTmp;
15588 }
15589 else
15590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015591 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015592 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015593 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015594 return status;
15595 }
15596
Kiet Lam64c1b492013-07-12 13:56:44 +053015597 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 pBuf += sizeof(tANI_U16);
15599 // dot11mode
15600 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15601 pBuf += 1;
15602 // bssType
15603 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015604 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015605 pBuf += sizeof(tSirBssType);
15606 // ssId
15607 if( pParam->ssId.length )
15608 {
15609 // ssId len
15610 *pBuf = pParam->ssId.length;
15611 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015612 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015613 pBuf += pParam->ssId.length;
15614 }
15615 else
15616 {
15617 *pBuf = 0;
15618 pBuf++;
15619 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 // set the channel Id
15621 *pBuf = pParam->operationChn;
15622 pBuf++;
15623 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015624 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015625 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015626 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015627
Jeff Johnson295189b2012-06-20 16:38:30 -070015628 // Set privacy
15629 *pBuf = pParam->privacy;
15630 pBuf++;
15631
15632 //Set Uapsd
15633 *pBuf = pParam->ApUapsdEnable;
15634 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015635 //Set SSID hidden
15636 *pBuf = pParam->ssidHidden;
15637 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015638 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15639 pBuf++;
15640
15641 //Ht protection Enable/Disable
15642 *pBuf = (tANI_U8)pParam->protEnabled;
15643 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 //Enable Beacons to Receive for OBSS protection Enable/Disable
15645 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15646 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 //set cfg related to protection
15648 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015649 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 // Set Auth type
15652 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015653 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015654 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 // Set DTIM
15656 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015657 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015658 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015659 // Set wps_state
15660 *pBuf = pParam->wps_state;
15661 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015662 // set isCoalesingInIBSSAllowed
15663 *pBuf = pMac->isCoalesingInIBSSAllowed;
15664 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015665 //Persona
15666 *pBuf = (tANI_U8)pParam->bssPersona;
15667 pBuf++;
15668
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015669 //txLdpcIniFeatureEnabled
15670 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15671 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015672
Chet Lanctot8cecea22014-02-11 19:09:36 -080015673#ifdef WLAN_FEATURE_11W
15674 // Set MFP capable/required
15675 *pBuf = (tANI_U8)pParam->mfpCapable;
15676 pBuf++;
15677 *pBuf = (tANI_U8)pParam->mfpRequired;
15678 pBuf++;
15679#endif
15680
krunal soni4f087d22013-07-29 16:32:26 -070015681 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015682 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15683 {
15684 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015685 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 break;
15687 }
15688 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015689 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015690 pBuf += sizeof(tANI_U16);
15691 if( wTmp )
15692 {
15693 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015694 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 pBuf += wTmp;
15696 }
15697 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015698 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15701 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015702 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15703 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015704 pBuf += pParam->operationalRateSet.numRates ;
15705 *pBuf++ = pParam->extendedRateSet.numRates;
15706 if(0 != pParam->extendedRateSet.numRates)
15707 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015708 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15709 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015710 pBuf += pParam->extendedRateSet.numRates;
15711 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015712#ifdef WLAN_FEATURE_AP_HT40_24G
15713 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15714#endif
krunal sonie9002db2013-11-25 14:24:17 -080015715
Jeff Johnson295189b2012-06-20 16:38:30 -070015716 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15717 pMsg->length = pal_cpu_to_be16(msgLen);
15718
15719 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015720 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015721 return( status );
15722}
15723
Jeff Johnson295189b2012-06-20 16:38:30 -070015724eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15725{
15726 eHalStatus status = eHAL_STATUS_FAILURE;
15727 tSirSmeStopBssReq *pMsg;
15728 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15729 tANI_U8 *pBuf;
15730 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015731
15732 if(!pSession)
15733 {
15734 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15735 return eHAL_STATUS_FAILURE;
15736 }
15737
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015738 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15739 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15740 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15741 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15742 pBuf = &pMsg->sessionId;
15743 //sessionId
15744 *pBuf = (tANI_U8)sessionId;
15745 pBuf++;
15746 // transactionId
15747 *pBuf = 0;
15748 pBuf += sizeof(tANI_U16);
15749 //reason code
15750 *pBuf = 0;
15751 pBuf += sizeof(tSirResultCodes);
15752 // bssid
15753 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15754 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15755 {
15756 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15757 sizeof(tSirMacAddr));
15758 }
15759 else
15760 {
15761 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15762 sizeof(tSirMacAddr));
15763 }
15764 pBuf += sizeof(tSirMacAddr);
15765 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15766 pMsg->length = pal_cpu_to_be16(msgLen);
15767 status = palSendMBMessage( pMac->hHdd, pMsg );
15768
Jeff Johnson295189b2012-06-20 16:38:30 -070015769 return( status );
15770}
15771
Jeff Johnson295189b2012-06-20 16:38:30 -070015772eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15773 tCsrRoamModifyProfileFields *pModProfileFields,
15774 tANI_U32 *pRoamId, v_BOOL_t fForce)
15775{
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 eHalStatus status = eHAL_STATUS_FAILURE;
15777 tANI_U32 roamId = 0;
15778 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015780 (fForce || (!vos_mem_compare( &pModProfileFields,
15781 &pSession->connectedProfile.modifyProfileFields,
15782 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 {
15784 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15785 if(pRoamId)
15786 {
15787 *pRoamId = roamId;
15788 }
15789
Jeff Johnson295189b2012-06-20 16:38:30 -070015790 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15791 eCsrSmeIssuedReassocToSameAP, roamId,
15792 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015794 return status;
15795}
Jeff Johnson295189b2012-06-20 16:38:30 -070015796static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15797{
15798 eHalStatus status = eHAL_STATUS_SUCCESS;
15799 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015800 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015801 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15802 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15803 return (status);
15804}
Jeff Johnson295189b2012-06-20 16:38:30 -070015805eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15806{
15807 eHalStatus status = eHAL_STATUS_SUCCESS;
15808 tListElem *pEntry = NULL;
15809 tSmeCmd *pCommand = NULL;
15810 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015811 do
15812 {
15813 if(pMsg == NULL)
15814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015815 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 status = eHAL_STATUS_FAILURE;
15817 break;
15818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15820 if(pEntry)
15821 {
15822 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15823 if(eSmeCommandAddStaSession == pCommand->command)
15824 {
15825 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015826 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015827 if (pRsp->status == eSIR_FAILURE) {
15828 VOS_ASSERT( 0 );
15829 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015830 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015831 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015832 //Remove this command out of the active list
15833 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15834 {
15835 //Now put this command back on the avilable command list
15836 csrReleaseCommand(pMac, pCommand);
15837 }
15838 smeProcessPendingQueue( pMac );
15839 }
15840 else
15841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015842 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 -070015843 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 status = eHAL_STATUS_FAILURE;
15845 break;
15846 }
15847 }
15848 else
15849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015850 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 -070015851 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015852 status = eHAL_STATUS_FAILURE;
15853 break;
15854 }
15855 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015857}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015858eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15859 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015860{
15861 tSirSmeAddStaSelfReq *pMsg;
15862 tANI_U16 msgLen;
15863 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015865 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015866 pMsg = vos_mem_malloc(msgLen);
15867 if ( NULL == pMsg ) break;
15868 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15870 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015872 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015873 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15874
15875 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
15876
Arif Hussain24bafea2013-11-15 15:10:03 -080015877 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
15878 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015879 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015881 return( status );
15882}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015883eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
15884 tANI_U32 sessionId,
15885 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070015886{
15887 eHalStatus status = eHAL_STATUS_SUCCESS;
15888 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015889 pCommand = csrGetCommandBuffer(pMac);
15890 if(NULL == pCommand)
15891 {
15892 status = eHAL_STATUS_RESOURCES;
15893 }
15894 else
15895 {
15896 pCommand->command = eSmeCommandAddStaSession;
15897 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053015898 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
15899 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015900 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
15902 if( !HAL_STATUS_SUCCESS( status ) )
15903 {
15904 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015905 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015906 }
15907 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015908 return (status);
15909}
Jeff Johnson295189b2012-06-20 16:38:30 -070015910eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15911{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015912 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070015913}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015914eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
15915 csrRoamCompleteCallback callback,
15916 void *pContext, tANI_U8 *pSelfMacAddr,
15917 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070015918{
15919 eHalStatus status = eHAL_STATUS_SUCCESS;
15920 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053015921 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 *pbSessionId = CSR_SESSION_ID_INVALID;
15923 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15924 {
15925 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15926 {
15927 pSession = CSR_GET_SESSION( pMac, i );
15928 status = eHAL_STATUS_SUCCESS;
15929 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15930 pSession->sessionId = (tANI_U8)i;
15931 pSession->callback = callback;
15932 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015933 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015934 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015935 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15936 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015938 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015940 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 break;
15942 }
15943#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015944 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15945 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015946 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015947 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015949 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015950 break;
15951 }
15952#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015953 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 break;
15955 }
15956 }
15957 if( CSR_ROAM_SESSION_MAX == i )
15958 {
15959 //No session is available
15960 status = eHAL_STATUS_RESOURCES;
15961 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015962 return ( status );
15963}
Jeff Johnson295189b2012-06-20 16:38:30 -070015964eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15965{
15966 eHalStatus status = eHAL_STATUS_SUCCESS;
15967 tListElem *pEntry = NULL;
15968 tSmeCmd *pCommand = NULL;
15969 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015970 do
15971 {
15972 if(pMsg == NULL)
15973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015974 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015975 status = eHAL_STATUS_FAILURE;
15976 break;
15977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15979 if(pEntry)
15980 {
15981 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15982 if(eSmeCommandDelStaSession == pCommand->command)
15983 {
15984 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015986 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015987 //This session is done.
15988 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 if(pCommand->u.delStaSessionCmd.callback)
15990 {
15991
15992 status = sme_ReleaseGlobalLock( &pMac->sme );
15993 if ( HAL_STATUS_SUCCESS( status ) )
15994 {
15995 pCommand->u.delStaSessionCmd.callback(
15996 pCommand->u.delStaSessionCmd.pContext);
15997 status = sme_AcquireGlobalLock( &pMac->sme );
15998 if (! HAL_STATUS_SUCCESS( status ) )
15999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016000 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 return status;
16002 }
16003 }
16004 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016005 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016006 }
16007 }
16008
16009 //Remove this command out of the active list
16010 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
16011 {
16012 //Now put this command back on the avilable command list
16013 csrReleaseCommand(pMac, pCommand);
16014 }
16015 smeProcessPendingQueue( pMac );
16016 }
16017 else
16018 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016019 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 -070016020 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016021 status = eHAL_STATUS_FAILURE;
16022 break;
16023 }
16024 }
16025 else
16026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016027 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 -070016028 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 status = eHAL_STATUS_FAILURE;
16030 break;
16031 }
16032 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016034}
Jeff Johnson295189b2012-06-20 16:38:30 -070016035eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16036{
16037 tSirSmeDelStaSelfReq *pMsg;
16038 tANI_U16 msgLen;
16039 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16042 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016043 pMsg = vos_mem_malloc(msgLen);
16044 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16045 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16047 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016048 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016049 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16050 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016052 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016053 return( status );
16054}
Jeff Johnson295189b2012-06-20 16:38:30 -070016055eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016056 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016057 tSirMacAddr sessionMacAddr,
16058 csrRoamSessionCloseCallback callback,
16059 void *pContext)
16060{
16061 eHalStatus status = eHAL_STATUS_SUCCESS;
16062 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016063 pCommand = csrGetCommandBuffer(pMac);
16064 if(NULL == pCommand)
16065 {
16066 status = eHAL_STATUS_RESOURCES;
16067 }
16068 else
16069 {
16070 pCommand->command = eSmeCommandDelStaSession;
16071 pCommand->sessionId = (tANI_U8)sessionId;
16072 pCommand->u.delStaSessionCmd.callback = callback;
16073 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016074 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16075 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016076 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 if( !HAL_STATUS_SUCCESS( status ) )
16078 {
16079 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016080 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016081 }
16082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016083 return (status);
16084}
Jeff Johnson295189b2012-06-20 16:38:30 -070016085eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16086{
16087 return csrSendMBDelSelfStaReqMsg( pMac,
16088 pCommand->u.delStaSessionCmd.selfMacAddr );
16089}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016090static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16091 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016092{
16093 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16094 tListElem *pEntry, *pNext;
16095 tSmeCmd *pCommand;
16096 tDblLinkList localList;
16097
16098 vos_mem_zero(&localList, sizeof(tDblLinkList));
16099 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16100 {
16101 smsLog(pMac, LOGE, FL(" failed to open list"));
16102 return;
16103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 csrLLLock(pList);
16105 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16106 while(pEntry != NULL)
16107 {
16108 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16109 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016110
16111 if (!flush_all &&
16112 csr_is_disconnect_full_power_cmd(pCommand)) {
16113 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16114 pEntry = pNext;
16115 continue;
16116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016117 if(pCommand->sessionId == sessionId)
16118 {
16119 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16120 {
16121 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16122 }
16123 }
16124 pEntry = pNext;
16125 }
16126 csrLLUnlock(pList);
16127
16128 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16129 {
16130 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16131 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16132 }
16133 csrLLClose(&localList);
16134}
16135
Jeff Johnson295189b2012-06-20 16:38:30 -070016136void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16137{
16138 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16139 {
16140 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016141 csrRoamStop(pMac, sessionId);
16142 csrFreeConnectBssDesc(pMac, sessionId);
16143 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16144 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016145 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016146#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016147 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016148#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016149 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016150 csrInitSession(pMac, sessionId);
16151 }
16152}
16153
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016154void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16155 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016156{
16157 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016158 &pMac->sme.smeCmdPendingList,
16159 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016160 if (pMac->fScanOffload)
16161 {
16162 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016163 &pMac->sme.smeScanCmdPendingList,
16164 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016165 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016166 purgeCsrSessionCmdList(pMac, sessionId,
16167 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016168}
16169
Jeff Johnson295189b2012-06-20 16:38:30 -070016170eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016171 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016172 csrRoamSessionCloseCallback callback,
16173 void *pContext )
16174{
16175 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016176 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16177 {
16178 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16179 if(fSync)
16180 {
16181 csrCleanupSession(pMac, sessionId);
16182 }
16183 else
mukul sharmabab477d2015-06-11 17:14:55 +053016184 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016185 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016186 /* If bPurgeList is FALSE, it means HDD already free all the
16187 * cmd and later queue few essential cmd. Now sme should process
16188 * the cmd in pending queue order only.Hence we should
16189 * avoid DEL_SELF_STA as high priority cmd.
16190 */
16191 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016192 pSession->selfMacAddr, callback, pContext);
16193 }
16194 }
16195 else
16196 {
16197 status = eHAL_STATUS_INVALID_PARAMETER;
16198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 return ( status );
16200}
16201
Jeff Johnson295189b2012-06-20 16:38:30 -070016202static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16203{
16204 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016205
16206 if(!pSession)
16207 {
16208 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16209 return;
16210 }
16211
Jeff Johnson295189b2012-06-20 16:38:30 -070016212 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16213 pSession->sessionId = CSR_SESSION_ID_INVALID;
16214 pSession->callback = NULL;
16215 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016216 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16217 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16218 csrFreeRoamProfile( pMac, sessionId );
16219 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16220 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16221 csrFreeConnectBssDesc(pMac, sessionId);
16222 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016223 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16224 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016225 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016226 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 pSession->pWpaRsnReqIE = NULL;
16228 }
16229 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016230 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016232 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016233 pSession->pWpaRsnRspIE = NULL;
16234 }
16235 pSession->nWpaRsnRspIeLength = 0;
16236#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016237 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016238 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016239 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016240 pSession->pWapiReqIE = NULL;
16241 }
16242 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016243 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016244 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016245 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016246 pSession->pWapiRspIE = NULL;
16247 }
16248 pSession->nWapiRspIeLength = 0;
16249#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016250 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016251 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016252 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016253 }
16254 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016255
Kiet Lam64c1b492013-07-12 13:56:44 +053016256 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016257 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016258 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016259 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016260 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016261 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016262}
16263
Jeff Johnson295189b2012-06-20 16:38:30 -070016264eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16265{
16266 eHalStatus status = eHAL_STATUS_FAILURE;
16267 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016268 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16269 {
16270 if( CSR_IS_SESSION_VALID( pMac, i ) )
16271 {
16272 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16273 {
16274 //Found it
16275 status = eHAL_STATUS_SUCCESS;
16276 *pSessionId = i;
16277 break;
16278 }
16279 }
16280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 return( status );
16282}
16283
Jeff Johnson295189b2012-06-20 16:38:30 -070016284//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16285//session because for IBSS, the bssid changes.
16286static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16287{
16288 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16289 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016290 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16291 {
16292 if( CSR_IS_SESSION_VALID( pMac, i ) )
16293 {
16294 pSession = CSR_GET_SESSION( pMac, i );
16295 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16296 {
16297 //Found it
16298 nRet = i;
16299 break;
16300 }
16301 }
16302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 return (nRet);
16304}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016305void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016306{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016307 VOS_STATUS status = VOS_STATUS_SUCCESS;
16308
16309 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 profile info from pmac global structure */
16311
Arif Hussain24bafea2013-11-15 15:10:03 -080016312 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16313 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016314 /* Check for user misconfig of RSSI trigger threshold */
16315 pMac->roam.configParam.vccRssiThreshold =
16316 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16317 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16318 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016319 /* Check for user misconfig of UL MAC Loss trigger threshold */
16320 pMac->roam.configParam.vccUlMacLossThreshold =
16321 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16322 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016323#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16324 {
16325 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016326 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 /* Indicate the neighbor roal algorithm about the connect indication */
16328 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16329 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016330
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016331 /* Making sure we are roaming force fully to 5GHz AP only once and
16332 * only when we connected to 2.4GH AP only during initial association.
16333 */
16334 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16335 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16336 SIR_BAND_2_4_GHZ)
16337 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016338 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016339 status = vos_timer_start(
16340 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16341 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016342 if ( status != VOS_STATUS_SUCCESS )
16343 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016344 smsLog(pMac, LOGE,
16345 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16346 status);
16347 //Send RSO start because in case 5G roaming
16348 //host have not enabled at initial connection
16349 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016350 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016351 else
16352 {
16353 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16354 __func__);
16355 }
16356 }
16357 /*
16358 * Making ini value to false here only so we just roam to
16359 * only once for whole driver load to unload tenure
16360 * This feature is only applicable for first connection only
16361 */
16362 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16363 {
16364 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16365 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016367 }
16368#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016369}
16370
Jeff Johnson295189b2012-06-20 16:38:30 -070016371static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16372{
16373 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016374
16375 if(!pSession)
16376 {
16377 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16378 return;
16379 }
16380
Jeff Johnson295189b2012-06-20 16:38:30 -070016381 //Only to handle the case for Handover on infra link
16382 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16383 {
16384 return;
16385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016386 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16387 csrRoamDeregStatisticsReq(pMac);
16388 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16389#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16390 /* Indicate the neighbor roal algorithm about the disconnect indication */
16391 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16392#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016393
16394 //Remove this code once SLM_Sessionization is supported
16395 //BMPS_WORKAROUND_NOT_NEEDED
16396 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016397 csrIsInfraApStarted( pMac ) &&
16398 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016399 {
16400 pMac->roam.configParam.doBMPSWorkaround = 0;
16401 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016402}
16403
Jeff Johnson295189b2012-06-20 16:38:30 -070016404void csrRoamTlStatsTimerHandler(void *pv)
16405{
16406 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16407 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16409
Jeff Johnsone7245742012-09-05 17:12:55 -070016410 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16411
Jeff Johnson295189b2012-06-20 16:38:30 -070016412#if 0
16413 // TODO Persession .???
16414 //req TL for stats
16415 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016417 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016418 }
16419 else
16420 {
16421 //save in SME
16422 csrRoamSaveStatsFromTl(pMac, tlStats);
16423 }
16424#endif
16425 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16426 {
16427 if(pMac->roam.tlStatsReqInfo.periodicity)
16428 {
16429 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016430 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16431 pMac->roam.tlStatsReqInfo.periodicity);
16432 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016434 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 return;
16436 }
16437 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16438 }
16439 }
16440}
Jeff Johnson295189b2012-06-20 16:38:30 -070016441void csrRoamPeStatsTimerHandler(void *pv)
16442{
16443 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16444 eHalStatus status;
16445 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16446 VOS_STATUS vosStatus;
16447 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 pPeStatsReqListEntry->timerRunning = FALSE;
16449 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16450 {
16451 // If we entered here, meaning the timer could not be successfully
16452 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16453
16454 /* Destroy the timer */
16455 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16456 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016458 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016459 }
16460
16461 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016462 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 pPeStatsReqListEntry = NULL;
16464 }
16465 else
16466 {
16467 if(!pPeStatsReqListEntry->rspPending)
16468 {
16469 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16470 pPeStatsReqListEntry->staId);
16471 if(!HAL_STATUS_SUCCESS(status))
16472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016473 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016474 }
16475 else
16476 {
16477 pPeStatsReqListEntry->rspPending = TRUE;
16478 }
16479 }
16480
16481 //send down a req
16482 if(pPeStatsReqListEntry->periodicity &&
16483 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16484 {
16485 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16486 if(ePMC_FULL_POWER == powerState)
16487 {
16488 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16489 {
16490 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16491 }
16492 }
16493 else
16494 {
16495 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16496 {
16497 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16498 }
16499 }
16500 //start timer
16501 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16502 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016504 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 return;
16506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 pPeStatsReqListEntry->timerRunning = TRUE;
16508
16509 }
16510
16511 }
16512}
Jeff Johnson295189b2012-06-20 16:38:30 -070016513void csrRoamStatsClientTimerHandler(void *pv)
16514{
16515 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16517 {
16518#if 0
16519 // TODO Stats fix for multisession
16520 //start the timer
16521 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16522
16523 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016525 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016526 }
16527#endif
16528 }
16529#if 0
16530 //send up the stats report
16531 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16532 pStaEntry->staId, pStaEntry->pContext);
16533#endif
16534}
16535
16536
16537
Jeff Johnson295189b2012-06-20 16:38:30 -070016538eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16539{
16540 tAniGetPEStatsReq *pMsg;
16541 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016542 tSirMsgQ msgQ;
16543
Kiet Lam64c1b492013-07-12 13:56:44 +053016544 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16545 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016547 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016548 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016549 }
16550 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016551 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016552 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16553 pMsg->staId = staId;
16554 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016555
16556 msgQ.type = WDA_GET_STATISTICS_REQ;
16557 msgQ.reserved = 0;
16558 msgQ.bodyptr = pMsg;
16559 msgQ.bodyval = 0;
16560 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 if(!HAL_STATUS_SUCCESS(status))
16562 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016563 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016564 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016566 return status;
16567}
Jeff Johnson295189b2012-06-20 16:38:30 -070016568void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16569{
16570 tAniGetPEStatsRsp *pSmeStatsRsp;
16571 eHalStatus status = eHAL_STATUS_FAILURE;
16572 tListElem *pEntry = NULL;
16573 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16574 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16575 tANI_U32 tempMask = 0;
16576 tANI_U8 counter = 0;
16577 tANI_U8 *pStats = NULL;
16578 tANI_U32 length = 0;
16579 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016580 v_S7_t rssi = 0, snr = 0;
16581 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016582 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016583 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16585 if(pSmeStatsRsp->rc)
16586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016587 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016588 goto post_update;
16589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016590 tempMask = pSmeStatsRsp->statsMask;
16591 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016592 /* subtract all statistics from this length, and after processing the entire
16593 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16594 * in this 'stats' message.
16595 */
16596 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 //new stats info from PE, fill up the stats strucutres in PMAC
16598 while(tempMask)
16599 {
16600 if(tempMask & 1)
16601 {
16602 switch(counter)
16603 {
16604 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016605 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016606 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16607 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016608 pStats += sizeof(tCsrSummaryStatsInfo);
16609 length -= sizeof(tCsrSummaryStatsInfo);
16610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016611 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016612 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016613 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16614 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016615 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16616 length -= sizeof(tCsrGlobalClassAStatsInfo);
16617 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016618 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016619 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016620 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16621 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016622 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16623 length -= sizeof(tCsrGlobalClassBStatsInfo);
16624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016625 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016626 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016627 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16628 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016629 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16630 length -= sizeof(tCsrGlobalClassCStatsInfo);
16631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016632 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016633 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016634 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16635 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016636 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016637 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16638 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 }
16640 else
16641 {
16642 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016643 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016644 VOS_ASSERT( 0 );
16645 }
16646 if(!HAL_STATUS_SUCCESS(status))
16647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016648 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016649 }
16650 pStats += sizeof(tCsrPerStaStatsInfo);
16651 length -= sizeof(tCsrPerStaStatsInfo);
16652 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016653 case eCsrPerPktStats:
16654 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16655 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16656 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16657 {
16658 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16659 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16660 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016661 /* for reserved bytes */
16662 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16663 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016664 }
16665 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016666 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016667 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016669 }
16670 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016671 tempMask >>=1;
16672 counter++;
16673 }
16674 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16675 if (length != 0)
16676 {
16677 pRssi = (tANI_U32*)pStats;
16678 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016679 pStats += sizeof(tANI_U32);
16680 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016681 }
16682 else
16683 {
16684 /* If riva is not sending rssi, continue to use the hack */
16685 rssi = RSSI_HACK_BMPS;
16686 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016687 /* send positive value of rssi to wifi_hal */
16688 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016689 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016690 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016691
16692 if (length != 0)
16693 {
16694 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016695 pStats += sizeof(tANI_U32);
16696 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016697 }
16698 else
16699 {
16700 linkCapacity = 0;
16701 }
16702
16703 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016704
16705 if (length != 0)
16706 {
16707 pSnr = (tANI_U32*)pStats;
16708 snr = (v_S7_t)*pSnr;
16709 }
16710 else
16711 {
16712 snr = SNR_HACK_BMPS;
16713 }
16714
16715 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016716post_update:
16717 //make sure to update the pe stats req list
16718 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16719 if(pEntry)
16720 {
16721 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16722 pPeStaEntry->rspPending = FALSE;
16723
16724 }
16725 //check the one timer cases
16726 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16727 if(pEntry)
16728 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016729 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 if(pTempStaEntry->timerExpired)
16731 {
16732 //send up the stats report
16733 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16734 pTempStaEntry->staId, pTempStaEntry->pContext);
16735 //also remove from the client list
16736 csrRoamRemoveStatListEntry(pMac, pEntry);
16737 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 }
16739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016740}
Jeff Johnson295189b2012-06-20 16:38:30 -070016741tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16742{
16743 tListElem *pEntry = NULL;
16744 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016745 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 if(!pEntry)
16747 {
16748 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016749 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016750 return NULL;
16751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 while( pEntry )
16753 {
16754 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016755 if(pTempStaEntry->statsMask == statsMask)
16756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016757 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 break;
16759 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016760 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016762 return pEntry;
16763}
16764
Jeff Johnson295189b2012-06-20 16:38:30 -070016765tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16766 tANI_BOOLEAN update)
16767{
16768 tListElem *pEntry;
16769 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016771 if(!pEntry)
16772 {
16773 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016774 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016775 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 return NULL;
16777 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016778 while( pEntry )
16779 {
16780 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016781 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16782 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016784 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016785 if(update)
16786 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016787 pTempStaEntry->periodicity = pStaEntry->periodicity;
16788 pTempStaEntry->callback = pStaEntry->callback;
16789 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016790 }
16791 break;
16792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016793 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 return pEntry;
16796}
Jeff Johnson295189b2012-06-20 16:38:30 -070016797tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16798{
16799 tListElem *pEntry;
16800 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016801 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 if(!pEntry)
16803 {
16804 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016805 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016806 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 return NULL;
16808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016809 while( pEntry )
16810 {
16811 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016812 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016814 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016815 break;
16816 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 return pEntry;
16820}
Jeff Johnson295189b2012-06-20 16:38:30 -070016821eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16822 csrRoamLinkQualityIndCallback callback,
16823 void *pContext)
16824{
16825 pMac->roam.linkQualityIndInfo.callback = callback;
16826 pMac->roam.linkQualityIndInfo.context = pContext;
16827 if( NULL == callback )
16828 {
16829 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16830 }
16831 else
16832 {
16833 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016834 /* do we need to invoke the callback to notify client of initial value ?? */
16835 }
16836 return eHAL_STATUS_SUCCESS;
16837}
Jeff Johnson295189b2012-06-20 16:38:30 -070016838void csrRoamVccTrigger(tpAniSirGlobal pMac)
16839{
16840 eCsrRoamLinkQualityInd newVccLinkQuality;
16841 tANI_U32 ul_mac_loss = 0;
16842 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16844 /*-------------------------------------------------------------------------
16845 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016846 Check for a change in link quality and notify client if necessary
16847 -------------------------------------------------------------------------*/
16848 ul_mac_loss_trigger_threshold =
16849 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016851 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016853 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016855 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016856 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16857 }
16858 else
16859 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016860 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016861 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16862 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016863 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16864 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016867 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016868 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016870 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 newVccLinkQuality );
16872
16873 /* we now invoke the callback once to notify client of initial value */
16874 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16875 pMac->roam.linkQualityIndInfo.context );
16876 //event: EVENT_WLAN_VCC
16877 }
16878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 pMac->roam.vccLinkQuality = newVccLinkQuality;
16880
Jeff Johnson295189b2012-06-20 16:38:30 -070016881}
Jeff Johnson295189b2012-06-20 16:38:30 -070016882VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
16883 v_U8_t rssiNotification,
16884 void * context)
16885{
16886 tpAniSirGlobal pMac = PMAC_STRUCT( context );
16887 eCsrRoamLinkQualityInd newVccLinkQuality;
16888 // TODO : Session info unavailable
16889 tANI_U32 sessionId = 0;
16890 VOS_STATUS status = VOS_STATUS_SUCCESS;
16891 /*-------------------------------------------------------------------------
16892 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 Check for a change in link quality and notify client if necessary
16894 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016895 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 pMac->roam.configParam.vccRssiThreshold);
16897 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
16898 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016899 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070016900 return VOS_STATUS_SUCCESS;
16901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016902 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
16903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016904 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070016905 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16906 }
16907 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
16908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016909 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016910 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16911 }
16912 else
16913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016914 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 //Set to this so the code below won't do anything
16916 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 VOS_ASSERT(0);
16918 }
16919
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016922 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016923 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16924 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016925 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016926 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 /* we now invoke the callback once to notify client of initial value */
16928 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16929 pMac->roam.linkQualityIndInfo.context );
16930 //event: EVENT_WLAN_VCC
16931 }
16932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016934 return status;
16935}
Jeff Johnson295189b2012-06-20 16:38:30 -070016936tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16937 tDblLinkList *pStaList,
16938 tCsrStatsClientReqInfo *pStaEntry)
16939{
16940 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 //if same entity requested for same set of stats with different periodicity &
16942 // callback update it
16943 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16944 {
16945
Kiet Lam64c1b492013-07-12 13:56:44 +053016946 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16947 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016948 {
16949 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016950 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016951 return NULL;
16952 }
16953
Jeff Johnson295189b2012-06-20 16:38:30 -070016954 pNewStaEntry->callback = pStaEntry->callback;
16955 pNewStaEntry->pContext = pStaEntry->pContext;
16956 pNewStaEntry->periodicity = pStaEntry->periodicity;
16957 pNewStaEntry->requesterId = pStaEntry->requesterId;
16958 pNewStaEntry->statsMask = pStaEntry->statsMask;
16959 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16960 pNewStaEntry->pMac = pStaEntry->pMac;
16961 pNewStaEntry->staId = pStaEntry->staId;
16962 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16963
16964 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
16965 }
16966 return pNewStaEntry;
16967}
16968
Jeff Johnson295189b2012-06-20 16:38:30 -070016969tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
16970 tDblLinkList *pStaList,
16971 tCsrPeStatsReqInfo *pStaEntry)
16972{
16973 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016974 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
16975 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016976 {
16977 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016978 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016979 return NULL;
16980 }
16981
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
16983 pNewStaEntry->numClient = pStaEntry->numClient;
16984 pNewStaEntry->periodicity = pStaEntry->periodicity;
16985 pNewStaEntry->statsMask = pStaEntry->statsMask;
16986 pNewStaEntry->pMac = pStaEntry->pMac;
16987 pNewStaEntry->staId = pStaEntry->staId;
16988 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
16989 pNewStaEntry->rspPending = pStaEntry->rspPending;
16990
16991 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016992 return pNewStaEntry;
16993}
Jeff Johnson295189b2012-06-20 16:38:30 -070016994eHalStatus csrGetRssi(tpAniSirGlobal pMac,
16995 tCsrRssiCallback callback,
16996 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16997{
16998 eHalStatus status = eHAL_STATUS_SUCCESS;
16999 vos_msg_t msg;
17000 tANI_U32 sessionId;
17001
17002 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017003 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017004 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17005 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070017006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017007 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017008 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017010 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17011
17012 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
17013 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17014 pMsg->sessionId = sessionId;
17015 pMsg->staId = staId;
17016 pMsg->rssiCallback = callback;
17017 pMsg->pDevContext = pContext;
17018 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070017019 msg.type = eWNI_SME_GET_RSSI_REQ;
17020 msg.bodyptr = pMsg;
17021 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017024 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017025 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017026 status = eHAL_STATUS_FAILURE;
17027 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017028 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017029 return status;
17030}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017031
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017032eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17033 tCsrSnrCallback callback,
17034 tANI_U8 staId, tCsrBssid bssId,
17035 void *pContext)
17036{
17037 eHalStatus status = eHAL_STATUS_SUCCESS;
17038 vos_msg_t msg;
17039 tANI_U32 sessionId;
17040
17041 tAniGetSnrReq *pMsg;
17042
17043 smsLog(pMac, LOG2, FL("called"));
17044
17045 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17046 if (NULL == pMsg )
17047 {
17048 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17049 return status;
17050 }
17051
17052 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17053
17054 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17055 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17056 pMsg->sessionId = sessionId;
17057 pMsg->staId = staId;
17058 pMsg->snrCallback = callback;
17059 pMsg->pDevContext = pContext;
17060 msg.type = eWNI_SME_GET_SNR_REQ;
17061 msg.bodyptr = pMsg;
17062 msg.reserved = 0;
17063
17064 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17065 {
17066 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17067 vos_mem_free((v_VOID_t *)pMsg);
17068 status = eHAL_STATUS_FAILURE;
17069 }
17070
17071 smsLog(pMac, LOG2, FL("returned"));
17072 return status;
17073}
17074
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017075#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017076eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17077 tCsrRssiCallback callback,
17078 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17079{
17080 eHalStatus status = eHAL_STATUS_SUCCESS;
17081 tAniGetRssiReq *pMsg;
17082
Kiet Lam64c1b492013-07-12 13:56:44 +053017083 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17084 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017085 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017086 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017087 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017088 }
17089 // need to initiate a stats request to PE
17090 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17091 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17092 pMsg->staId = staId;
17093 pMsg->rssiCallback = callback;
17094 pMsg->pDevContext = pContext;
17095 pMsg->pVosContext = pVosContext;
17096 status = palSendMBMessage(pMac->hHdd, pMsg );
17097 if(!HAL_STATUS_SUCCESS(status))
17098 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017099 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017100 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017101 status = eHAL_STATUS_FAILURE;
17102 }
17103 return status;
17104}
17105#endif
17106
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017107
17108
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017109#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017110eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17111 tCsrTsmStatsCallback callback,
17112 tANI_U8 staId,
17113 tCsrBssid bssId,
17114 void *pContext,
17115 void* pVosContext,
17116 tANI_U8 tid)
17117{
17118 eHalStatus status = eHAL_STATUS_SUCCESS;
17119 tAniGetTsmStatsReq *pMsg = NULL;
17120
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017121 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17122 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017123 {
17124 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017125 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017126 }
17127 // need to initiate a stats request to PE
17128 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17129 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17130 pMsg->staId = staId;
17131 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017132 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017133 pMsg->tsmStatsCallback = callback;
17134 pMsg->pDevContext = pContext;
17135 pMsg->pVosContext = pVosContext;
17136 status = palSendMBMessage(pMac->hHdd, pMsg );
17137 if(!HAL_STATUS_SUCCESS(status))
17138 {
17139 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17140 //pMsg is freed by palSendMBMessage
17141 status = eHAL_STATUS_FAILURE;
17142 }
17143 return status;
17144}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017145#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017146
17147
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017148/* ---------------------------------------------------------------------------
17149 \fn csrGetTLSTAState
17150 \helper function to get teh TL STA State whenever the function is called.
17151
17152 \param staId - The staID to be passed to the TL
17153 to get the relevant TL STA State
17154 \return the state as tANI_U16
17155 ---------------------------------------------------------------------------*/
17156tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17157{
17158 WLANTL_STAStateType tlSTAState;
17159 tlSTAState = WLANTL_STA_INIT;
17160
17161 //request TL for STA State
17162 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17163 {
17164 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17165 }
17166
17167 return tlSTAState;
17168}
17169
Jeff Johnson295189b2012-06-20 16:38:30 -070017170eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17171 tANI_U32 statsMask,
17172 tCsrStatsCallback callback,
17173 tANI_U32 periodicity, tANI_BOOLEAN cache,
17174 tANI_U8 staId, void *pContext)
17175{
17176 tCsrStatsClientReqInfo staEntry;
17177 tCsrStatsClientReqInfo *pStaEntry = NULL;
17178 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17179 tListElem *pEntry = NULL;
17180 tANI_BOOLEAN found = FALSE;
17181 eHalStatus status = eHAL_STATUS_SUCCESS;
17182 tANI_BOOLEAN insertInClientList = FALSE;
17183 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017184 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017185
17186 if( csrIsAllSessionDisconnected(pMac) )
17187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017188 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017189 return eHAL_STATUS_FAILURE;
17190 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017191
17192 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17193 {
17194 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17195 return eHAL_STATUS_FAILURE;
17196 }
17197
Jeff Johnson295189b2012-06-20 16:38:30 -070017198 if((!statsMask) && (!callback))
17199 {
17200 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017201 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017202 return eHAL_STATUS_FAILURE;
17203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017204 //for the search list method for deregister
17205 staEntry.requesterId = requesterId;
17206 staEntry.statsMask = statsMask;
17207 //requester wants to deregister or just an error
17208 if((statsMask) && (!callback))
17209 {
17210 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17211 if(!pEntry)
17212 {
17213 //msg
17214 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017215 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 return eHAL_STATUS_FAILURE;
17217 }
17218 else
17219 {
17220 //clean up & return
17221 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017222 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017223 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017224 pStaEntry->pPeStaEntry->numClient--;
17225 //check if we need to delete the entry from peStatsReqList too
17226 if(!pStaEntry->pPeStaEntry->numClient)
17227 {
17228 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017230 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017231
Jeff Johnson295189b2012-06-20 16:38:30 -070017232 //check if we need to stop the tl stats timer too
17233 pMac->roam.tlStatsReqInfo.numClient--;
17234 if(!pMac->roam.tlStatsReqInfo.numClient)
17235 {
17236 if(pMac->roam.tlStatsReqInfo.timerRunning)
17237 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017238 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17239 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017241 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017242 return eHAL_STATUS_FAILURE;
17243 }
17244 }
17245 pMac->roam.tlStatsReqInfo.periodicity = 0;
17246 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17247 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017248 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017249 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017250 vos_timer_stop(&pStaEntry->timer);
17251 // Destroy the vos timer
17252 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17253 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17254 {
17255 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017258 csrRoamRemoveStatListEntry(pMac, pEntry);
17259 pStaEntry = NULL;
17260 return eHAL_STATUS_SUCCESS;
17261 }
17262 }
17263
17264 if(cache && !periodicity)
17265 {
17266 //return the cached stats
17267 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17268 }
17269 else
17270 {
17271 //add the request in the client req list
17272 staEntry.callback = callback;
17273 staEntry.pContext = pContext;
17274 staEntry.periodicity = periodicity;
17275 staEntry.pPeStaEntry = NULL;
17276 staEntry.staId = staId;
17277 staEntry.pMac = pMac;
17278 staEntry.timerExpired = FALSE;
17279
17280
Jeff Johnson295189b2012-06-20 16:38:30 -070017281 //if periodic report requested with non cached result from PE/TL
17282 if(periodicity)
17283 {
17284
17285 //if looking for stats from PE
17286 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17287 {
17288
17289 //check if same request made already & waiting for rsp
17290 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17291 periodicity, &found, staId);
17292 if(!pPeStaEntry)
17293 {
17294 //bail out, maxed out on number of req for PE
17295 return eHAL_STATUS_FAILURE;
17296 }
17297 else
17298 {
17299 staEntry.pPeStaEntry = pPeStaEntry;
17300 }
17301
17302 }
17303 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17304 if(statsMask & (1 << eCsrGlobalClassDStats))
17305 {
17306 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17307 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017308 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017309 }
17310 else
17311 {
17312
17313 //update periodicity
17314 if(pMac->roam.tlStatsReqInfo.periodicity)
17315 {
17316 pMac->roam.tlStatsReqInfo.periodicity =
17317 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17318 }
17319 else
17320 {
17321 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17322 }
17323 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17324 {
17325 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17326 }
17327
17328 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17329 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017330 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017331 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017332 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017333 //req TL for class D stats
17334 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017336 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017337 }
17338 else
17339 {
17340 //save in SME
17341 csrRoamSaveStatsFromTl(pMac, pTlStats);
17342 }
17343 vos_mem_free(pTlStats);
17344 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017345 }
17346 else
17347 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017348 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017349 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017350
Jeff Johnson295189b2012-06-20 16:38:30 -070017351 if(pMac->roam.tlStatsReqInfo.periodicity)
17352 {
17353 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017354 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17355 pMac->roam.tlStatsReqInfo.periodicity);
17356 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017358 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017359 return eHAL_STATUS_FAILURE;
17360 }
17361 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17362 }
17363 }
17364 }
17365 pMac->roam.tlStatsReqInfo.numClient++;
17366 }
17367
17368 insertInClientList = TRUE;
17369 }
17370 //if one time report requested with non cached result from PE/TL
17371 else if(!cache && !periodicity)
17372 {
17373 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17374 {
17375 //send down a req
17376 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17377 if(!HAL_STATUS_SUCCESS(status))
17378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017379 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017380 }
17381 //so that when the stats rsp comes back from PE we respond to upper layer
17382 //right away
17383 staEntry.timerExpired = TRUE;
17384 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017385 }
17386 if(statsMask & (1 << eCsrGlobalClassDStats))
17387 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017388 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017389 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017390 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017391 //req TL for class D stats
17392 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017394 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017395 }
17396 else
17397 {
17398 //save in SME
17399 csrRoamSaveStatsFromTl(pMac, pTlStats);
17400 }
17401 vos_mem_free(pTlStats);
17402 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017403 }
17404 else
17405 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017406 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017408
17409 }
17410 //if looking for stats from TL only
17411 if(!insertInClientList)
17412 {
17413 //return the stats
17414 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17415 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017417 if(insertInClientList)
17418 {
17419 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17420 if(!pStaEntry)
17421 {
17422 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017423 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017424 return eHAL_STATUS_FAILURE;
17425 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017426 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017427 //Init & start timer if needed
17428 if(periodicity)
17429 {
17430 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17431 csrRoamStatsClientTimerHandler, pStaEntry );
17432 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017434 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017435 return eHAL_STATUS_FAILURE;
17436 }
17437 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17438 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017440 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017441 return eHAL_STATUS_FAILURE;
17442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017443 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017445 }
17446 return eHAL_STATUS_SUCCESS;
17447}
17448
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017449#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17450
17451static tSirRetStatus
17452csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17453 tANI_U8* pBD,
17454 tANI_U8 type,
17455 tANI_U8 subType,
17456 tSirMacAddr peerAddr,
17457 tSirMacAddr selfMacAddr)
17458{
17459 tSirRetStatus statusCode = eSIR_SUCCESS;
17460 tpSirMacMgmtHdr pMacHdr;
17461
17462 /* Prepare MAC management header */
17463 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17464
17465 /* Prepare FC */
17466 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17467 pMacHdr->fc.type = type;
17468 pMacHdr->fc.subType = subType;
17469
17470 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017471 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17472 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017473
17474 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17475
17476 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017477 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17478 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017479 return statusCode;
17480} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17481
17482static tSirRetStatus
17483csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17484 tANI_U8 nChannelNum,
17485 tANI_U32 dot11mode,
17486 tSirMacAddr selfMacAddr,
17487 tANI_U8 *pFrame,
17488 tANI_U16 *pusLen)
17489{
17490 tDot11fProbeRequest pr;
17491 tANI_U32 nStatus, nBytes, nPayload;
17492 tSirRetStatus nSirStatus;
17493 /*Bcast tx*/
17494 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17495 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17496
17497
Kiet Lam64c1b492013-07-12 13:56:44 +053017498 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017499
17500 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17501
17502 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17503 {
17504 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17505 }
17506
17507
17508 if (IS_DOT11_MODE_HT(dot11mode))
17509 {
17510 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17511 }
17512
17513
17514 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17515 if ( DOT11F_FAILED( nStatus ) )
17516 {
17517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17518 "Failed to calculate the packed size f"
17519 "or a Probe Request (0x%08x).\n", nStatus );
17520
17521
17522 nPayload = sizeof( tDot11fProbeRequest );
17523 }
17524 else if ( DOT11F_WARNED( nStatus ) )
17525 {
17526 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17527 "There were warnings while calculating"
17528 "the packed size for a Probe Request ("
17529 "0x%08x).\n", nStatus );
17530 }
17531
17532 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17533
17534 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017535 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017536
17537
17538 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017539 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017540
17541 if ( eSIR_SUCCESS != nSirStatus )
17542 {
17543 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17544 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17545 nSirStatus );
17546 return nSirStatus;
17547 }
17548
17549
17550 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17551 sizeof( tSirMacMgmtHdr ),
17552 nPayload, &nPayload );
17553 if ( DOT11F_FAILED( nStatus ) )
17554 {
17555 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17556 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17557 return eSIR_FAILURE;
17558 }
17559 else if ( DOT11F_WARNED( nStatus ) )
17560 {
17561 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017562 "There were warnings while packing a Probe Request (0x%08x).\n",
17563 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017564 }
17565
17566 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17567 return eSIR_SUCCESS;
17568}
17569
Mukul Sharmad68cda62015-03-20 21:25:41 +053017570/*
17571 * Below Table describe whether RSO command can be send down to fimrware or not.
17572 * Host check it on the basis of previous RSO command sent down to firmware.
17573||===========================================================================||
17574|| New cmd | LAST SENT COMMAND ---> ||
17575||====|======================================================================||
17576|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17577|| --------------------------------------------------------------------------||
17578|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017579|| RSO_STOP | YES | NO | YES | YES ||
17580|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017581|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17582||===========================================================================||
17583*/
17584
17585#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17586#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17587#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17588#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17589
17590#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17591#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017592 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017593#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17594 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017595#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017596 RSO_START_BIT)
17597
17598tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17599{
17600 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17601 tANI_U8 desiredMask = 0;
17602 switch(command)
17603 {
17604 case ROAM_SCAN_OFFLOAD_START:
17605 desiredMask = RSO_START_ALLOW_MASK;
17606 break;
17607 case ROAM_SCAN_OFFLOAD_STOP:
17608 desiredMask = RSO_STOP_ALLOW_MASK;
17609 break;
17610 case ROAM_SCAN_OFFLOAD_RESTART:
17611 desiredMask = RSO_RESTART_ALLOW_MASK;
17612 break;
17613 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17614 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17615 break;
17616 default:
17617 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17618 FL("Wrong RSO command %d, not allowed"), command);
17619 return 0;/*Cmd Not allowed*/
17620 }
17621 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17622}
17623
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017624eCsrBand GetCurrentBand(tANI_U8 channel)
17625{
17626 tSirRFBand Rfband;
17627 eCsrBand band;
17628
17629 Rfband = GetRFBand(channel);
17630
17631 if (Rfband == SIR_BAND_5_GHZ)
17632 band = eCSR_BAND_5G;
17633 else if (Rfband == SIR_BAND_2_4_GHZ)
17634 band = eCSR_BAND_24;
17635 else if (Rfband == SIR_BAND_UNKNOWN)
17636 band = eCSR_BAND_MAX;
17637
17638 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17639 "channel %d Rfband %d band %d", channel, Rfband, band);
17640
17641 return band;
17642}
17643
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017644eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17645{
17646 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017647 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017648 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017649 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017650 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017651 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017652 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017653 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017654 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017655 eHalStatus status = eHAL_STATUS_SUCCESS;
17656 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017657 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017658 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017659 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017660 tSirBssDescription *pBssDesc = NULL;
17661 tDot11fBeaconIEs *pIes = NULL;
17662 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017663 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017664
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017665 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17666
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017667 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017668 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017669 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017670 return eHAL_STATUS_FAILURE;
17671 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017672
17673 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17674 {
17675 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17676 return eHAL_STATUS_FAILURE;
17677 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017678
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017679 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17680 * It is important to ensure that the command is passed down to the FW only
17681 * if the Infra Station is in a connected state.A connected station could also be
17682 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17683 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17684 * irrespective of whichever state we are in.*/
17685 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17686 (command != ROAM_SCAN_OFFLOAD_STOP))
17687 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017688 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17689 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17690 macTraceGetNeighbourRoamState(
17691 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017692 return eHAL_STATUS_FAILURE;
17693 }
17694
Mukul Sharmad68cda62015-03-20 21:25:41 +053017695 if (!CsrIsRSOCommandAllowed(pMac, command))
17696 {
17697 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17698 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17699 command, pNeighborRoamInfo->lastSentCmd);
17700 return eHAL_STATUS_FAILURE;
17701 }
17702
Abhishek Singh3e915632014-11-01 17:14:50 +053017703 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17704 * Also there are cases where pNeighborRoamInfo->currAPbssid
17705 * is set to 0 during disconnect and so we might return without stopping
17706 * the roam scan. So no need to find the session if command is
17707 * ROAM_SCAN_OFFLOAD_STOP.
17708 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017709 status = csrRoamGetSessionIdFromBSSID(pMac,
17710 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17711 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017712 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017713 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017714 if ( !HAL_STATUS_SUCCESS( status ) )
17715 {
17716 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17717 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17718 return eHAL_STATUS_FAILURE;
17719 }
17720 pSession = CSR_GET_SESSION( pMac, sessionId );
17721 if (NULL == pSession)
17722 {
17723 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080017724 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053017725 return eHAL_STATUS_FAILURE;
17726 }
17727 pBssDesc = pSession->pConnectBssDesc;
17728 if (pBssDesc == NULL)
17729 {
17730 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17731 "%s: pBssDesc not found for current session", __func__);
17732 return eHAL_STATUS_FAILURE;
17733 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017734
17735 operationChannel = pSession->connectedProfile.operationChannel;
17736 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17737 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017738 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017739 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17740 if (NULL == pRequestBuf)
17741 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017742 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17743 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17744 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017745 }
17746
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017747#ifdef FEATURE_WLAN_DIAG_SUPPORT
17748 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17749 eSIR_SUCCESS, eSIR_SUCCESS);
17750#endif
17751
Abhishek Singh3e915632014-11-01 17:14:50 +053017752 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17753 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17754 * host driver reloads, but Riva still up and running*/
17755 pRequestBuf->Command = command;
17756 if(command == ROAM_SCAN_OFFLOAD_STOP)
17757 {
17758 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017759 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017760 /*For a STOP Command, there is no need to
17761 * go through filling up all the below parameters
17762 * since they are not required for the STOP command*/
17763 goto send_roam_scan_offload_cmd;
17764 }
17765 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017766 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017767 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17768 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017769 sizeof(tCsrBssid));
17770 pRequestBuf->ConnectedNetwork.ssId.length =
17771 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17772 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17773 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17774 pRequestBuf->ConnectedNetwork.ssId.length);
17775 pRequestBuf->ConnectedNetwork.authentication =
17776 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17777 pRequestBuf->ConnectedNetwork.encryption =
17778 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17779 pRequestBuf->ConnectedNetwork.mcencryption =
17780 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017781 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17782 {
17783 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017784 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017785 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17786 }
17787 else
17788 {
17789 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017790
17791 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17792 {
17793 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17794 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17795 vos_mem_free(pRequestBuf);
17796 return eHAL_STATUS_FAILURE;
17797 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017798 if(NULL == pIes)
17799 {
17800 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17801 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017802 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017803 return eHAL_STATUS_FAILURE;
17804 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017805 if (pIes->SuppRates.present)
17806 {
17807 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17808 /*Check for both basic rates and extended rates.*/
17809 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17810 {
17811 /*Check if the Rate is Mandatory or Not*/
17812 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17813 && (pIes->SuppRates.rates[i] & 0x80))
17814 {
17815 /*Retrieve the actual data rate*/
17816 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17817 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17818 if (minRate == 0)
17819 minRate = dataRate;
17820 else
17821 minRate = (minRate < dataRate) ? minRate:dataRate;
17822 }
17823 }
17824
17825 if (pIes->ExtSuppRates.present)
17826 {
17827 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17828 {
17829 /*Check if the Rate is Mandatory or Not*/
17830 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17831 && (pIes->ExtSuppRates.rates[i] & 0x80))
17832 {
17833 /*Retrieve the actual data rate*/
17834 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17836 if (minRate == 0)
17837 minRate = dataRate;
17838 else
17839 minRate = (minRate < dataRate) ? minRate:dataRate;
17840 }
17841 }
17842 }
17843 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17844 }
17845 else
17846 {
17847 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17848 "%s: Supp Rates not present in pIes", __func__);
17849 vos_mem_free(pRequestBuf);
17850 return eHAL_STATUS_FAILURE;
17851 }
17852 if (NULL != pIes)
17853 {
17854 vos_mem_free(pIes);
17855 pIes = NULL;
17856 }
17857 switch (minRate)
17858 {
17859 case 1:
17860 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
17861 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
17862 break;
17863 case 2:
17864 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
17865 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
17866 break;
17867 case 5:
17868 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
17869 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
17870 break;
17871 case 6:
17872 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17873 {
17874 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
17875 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
17876 }
17877 else
17878 {
17879 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
17880 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
17881 }
17882 break;
17883 case 11:
17884 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
17885 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
17886 break;
17887 case 12:
17888 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17889 {
17890 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
17891 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
17892 }
17893 else
17894 {
17895 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
17896 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
17897 }
17898 break;
17899 case 24:
17900 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17901 {
17902 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
17903 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
17904 }
17905 else
17906 {
17907 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
17908 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
17909 }
17910 break;
17911 default:
17912 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
17913 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17914 break;
17915 }
17916 }
17917 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17918 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
17919 operationChannel, minRate,
17920 pRequestBuf->RxSensitivityThreshold,
17921 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017922 pRequestBuf->RoamRssiDiff =
17923 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017924 pRequestBuf->StartScanReason = reason;
17925 pRequestBuf->NeighborScanTimerPeriod =
17926 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
17927 pRequestBuf->NeighborRoamScanRefreshPeriod =
17928 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
17929 pRequestBuf->NeighborScanChannelMinTime =
17930 pNeighborRoamInfo->cfgParams.minChannelScanTime;
17931 pRequestBuf->NeighborScanChannelMaxTime =
17932 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
17933 pRequestBuf->EmptyRefreshScanPeriod =
17934 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080017935 /* MAWC feature */
17936 pRequestBuf->MAWCEnabled =
17937 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017938
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017939#ifdef FEATURE_WLAN_ESE
17940 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017941#endif
17942 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017943#ifdef FEATURE_WLAN_ESE
17944 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017945 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17946 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017947 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17948#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017949 currChannelListInfo->numOfChannels == 0)
17950 {
17951
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017952 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
17953 * Give Preference to INI Channels.*/
17954 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
17955 {
17956 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
17957 /*The INI channels need to be filtered with respect to the current
17958 * band that is supported.*/
17959 eBand = pMac->roam.configParam.bandCapability;
17960 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017961 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017962 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17963 "Invalid band, No operation carried out (Band %d)", eBand);
17964 vos_mem_free(pRequestBuf);
17965 return eHAL_STATUS_FAILURE;
17966 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017967
17968 if (pMac->roam.configParam.nRoamIntraBand)
17969 {
17970 eBand = GetCurrentBand(operationChannel);
17971 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17972 "Current Band %d", eBand);
17973 }
17974
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017975 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
17976 {
17977 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17978 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
17979 (eCSR_BAND_ALL == eBand))
17980 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017981 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
17982 ((pMac->roam.configParam.allowDFSChannelRoam) ||
17983 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
17984 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017985 {
17986 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
17987 }
17988 }
17989 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017990 }
17991 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17992 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017993 }
17994 else
17995 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017996 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017997
17998 if (pMac->roam.configParam.nRoamIntraBand)
17999 {
18000 Rfband = GetCurrentBand(operationChannel);
18001 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18002 "Current Band %d", Rfband);
18003 }
18004
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018005 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
18006 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018007 if(((eCSR_BAND_24 == Rfband) &&
18008 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18009 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18010 || (eCSR_BAND_ALL == Rfband))
18011 {
18012 /* Allow DFS channels only if the DFS channel roam flag is
18013 * enabled
18014 */
18015 if(*ChannelList && ((pMac->roam.configParam.
18016 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
18017 && (num_channels < SIR_ROAM_MAX_CHANNELS))
18018 {
18019 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
18020 = *ChannelList;
18021 }
18022 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018023 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018024 }
18025 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18026 /* If the profile changes as to what it was earlier, inform the FW through
18027 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
18028 * for the earlier profile and try to learn them afresh.*/
18029 if (reason == REASON_FLUSH_CHANNEL_LIST)
18030 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18031 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018032 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18033 (pMac->roam.configParam.nRoamIntraBand))
18034 pRequestBuf->ChannelCacheType =
18035 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018036 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018037 pRequestBuf->ChannelCacheType =
18038 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018039 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018040 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018041 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018042#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018043 else
18044 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018045 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018046 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018047 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018048 if (currChannelListInfo->numOfChannels != 0)
18049 {
18050 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018051
18052 if (pMac->roam.configParam.nRoamIntraBand)
18053 {
18054 Rfband = GetCurrentBand(operationChannel);
18055 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18056 "Current Band %d", Rfband);
18057 }
18058
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018059 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018060 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018061 if(((eCSR_BAND_24 == Rfband) &&
18062 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18063 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18064 || (eCSR_BAND_ALL == Rfband))
18065 {
18066 if(*ChannelList && ((pMac->roam.configParam.
18067 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18068 {
18069 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018070 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018071 }
18072 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018073 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018074 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018075 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018076 if (pMac->roam.configParam.nRoamIntraBand)
18077 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18078 else
18079 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018080 }
18081 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018082#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018083 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18084 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018085 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018086 if (j < sizeof(ChannelCacheStr))
18087 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018088 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18089 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018090 }
18091 else
18092 {
18093 break;
18094 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018095 }
18096 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18097 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18098 pRequestBuf->ChannelCacheType,
18099 pRequestBuf->ConnectedNetwork.ChannelCount,
18100 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018101 num_channels = 0;
18102 ChannelList = NULL;
18103
18104 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018105 host_channels = sizeof(pMac->roam.validChannelList);
18106 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018107 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018108 ChannelList = pMac->roam.validChannelList;
18109 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018110 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018111 else
18112 {
18113 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18114 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018115 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018116 return eHAL_STATUS_FAILURE;
18117 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018118
18119 if (pMac->roam.configParam.nRoamIntraBand)
18120 {
18121 Rfband = GetCurrentBand(operationChannel);
18122 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18123 Rfband);
18124 }
18125
Srinivas Girigowda56076852013-08-20 14:00:50 -070018126 for(i=0; i<pMac->roam.numValidChannels; i++)
18127 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018128 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18129 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18130 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018131 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018132 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18133 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18134 {
18135 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18136 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018137 }
18138 ChannelList++;
18139 }
18140 pRequestBuf->ValidChannelCount = num_channels;
18141
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018142 pRequestBuf->MDID.mdiePresent =
18143 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18144 pRequestBuf->MDID.mobilityDomain =
18145 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018146 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18147
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018148 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018149 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18150 * where RFS is the RF Switching time. It is twice RFS to consider the
18151 * time to go off channel and return to the home channel. */
18152 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18153 {
18154 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18155 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18156 " Hence enforcing home away time to disable (0)",
18157 __func__, pRequestBuf->HomeAwayTime,
18158 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18159 pRequestBuf->HomeAwayTime = 0;
18160 }
18161 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018162
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018163 pRequestBuf->WeakZoneRssiThresholdForRoam =
18164 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018165 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18166 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18167 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18168 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18169 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18170
18171 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18172 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018173send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018174 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018175 msg.reserved = 0;
18176 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018177 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18178 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018179 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18180 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018181 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18182 vos_mem_free(pRequestBuf);
18183 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018184 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018185 else
18186 {
18187 if (ROAM_SCAN_OFFLOAD_START == command)
18188 bRoamScanOffloadStarted = VOS_TRUE;
18189 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18190 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018191
18192 /*update the last sent cmd*/
18193 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018194 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018195
18196 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 +053018197
18198 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018199 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18200 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018201 {
18202
18203 /* PER ROAM SCAN */
18204 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18205 if (!PERRoamReqBuf)
18206 {
18207 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18208 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18209 return eHAL_STATUS_FAILURE;
18210 }
18211 /* PER Roam Config */
18212 PERRoamReqBuf->rateUpThreshold =
18213 pMac->roam.configParam.rateUpThreshold;
18214 PERRoamReqBuf->rateDownThreshold =
18215 pMac->roam.configParam.rateDownThreshold;
18216 PERRoamReqBuf->waitPeriodForNextPERScan =
18217 pMac->roam.configParam.waitPeriodForNextPERScan;
18218 PERRoamReqBuf->PERtimerThreshold =
18219 pMac->roam.configParam.PERtimerThreshold;
18220 PERRoamReqBuf->isPERRoamCCAEnabled =
18221 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018222 PERRoamReqBuf->PERRoamFullScanThreshold =
18223 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018224 PERRoamReqBuf->PERroamTriggerPercent =
18225 pMac->roam.configParam.PERroamTriggerPercent;
18226 PERRoamReqBuf->sessionId = sessionId;
18227
18228 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18229 PERroamScanConfigMsg.reserved = 0;
18230 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18231 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18232 &PERroamScanConfigMsg))) {
18233 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18234 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18235 vos_mem_free(PERRoamReqBuf);
18236 return eHAL_STATUS_FAILURE;
18237 }
18238 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18239 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18240 PERRoamReqBuf->rateUpThreshold,
18241 PERRoamReqBuf->rateDownThreshold,
18242 PERRoamReqBuf->waitPeriodForNextPERScan,
18243 PERRoamReqBuf->PERtimerThreshold);
18244 }
18245
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018246 return status;
18247}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018248
18249eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18250{
18251 switch(reason)
18252 {
18253 case 0:
18254 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18255 break;
18256 case REASON_OS_REQUESTED_ROAMING_NOW:
18257 csrNeighborRoamProceedWithHandoffReq(pMac);
18258 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018259 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18260 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18261 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018262 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018263 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 -070018264 }
18265 return eHAL_STATUS_SUCCESS;
18266}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018267#endif
18268
Jeff Johnson295189b2012-06-20 16:38:30 -070018269tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18270 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18271{
18272 tANI_BOOLEAN found = FALSE;
18273 eHalStatus status = eHAL_STATUS_SUCCESS;
18274 tCsrPeStatsReqInfo staEntry;
18275 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18276 tListElem *pStaEntry = NULL;
18277 VOS_STATUS vosStatus;
18278 tPmcPowerState powerState;
18279 *pFound = FALSE;
18280
18281 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18282 if(pStaEntry)
18283 {
18284 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18285 if(pTempStaEntry->periodicity)
18286 {
18287 pTempStaEntry->periodicity =
18288 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18289 }
18290 else
18291 {
18292 pTempStaEntry->periodicity = periodicity;
18293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018294 pTempStaEntry->numClient++;
18295 found = TRUE;
18296 }
18297 else
18298 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018299 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018300 staEntry.numClient = 1;
18301 staEntry.periodicity = periodicity;
18302 staEntry.pMac = pMac;
18303 staEntry.rspPending = FALSE;
18304 staEntry.staId = staId;
18305 staEntry.statsMask = statsMask;
18306 staEntry.timerRunning = FALSE;
18307 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18308 if(!pTempStaEntry)
18309 {
18310 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018311 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018312 return NULL;
18313 }
18314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018315 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18316 if(ePMC_FULL_POWER == powerState)
18317 {
18318 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18319 {
18320 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18321 }
18322 }
18323 else
18324 {
18325 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18326 {
18327 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18328 }
18329 }
18330 if(!pTempStaEntry->timerRunning)
18331 {
18332 //send down a req in case of one time req, for periodic ones wait for timer to expire
18333 if(!pTempStaEntry->rspPending &&
18334 !pTempStaEntry->periodicity)
18335 {
18336 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18337 if(!HAL_STATUS_SUCCESS(status))
18338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018339 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018340 }
18341 else
18342 {
18343 pTempStaEntry->rspPending = TRUE;
18344 }
18345 }
18346 if(pTempStaEntry->periodicity)
18347 {
18348 if(!found)
18349 {
18350
18351 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18352 csrRoamPeStatsTimerHandler, pTempStaEntry );
18353 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018355 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018356 return NULL;
18357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018358 }
18359 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018360 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018361 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18362 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018364 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018365 return NULL;
18366 }
18367 pTempStaEntry->timerRunning = TRUE;
18368 }
18369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018370 *pFound = found;
18371 return pTempStaEntry;
18372}
18373
Jeff Johnson295189b2012-06-20 16:38:30 -070018374/*
18375 pStaEntry is no longer invalid upon the return of this function.
18376*/
18377static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18378{
18379 if(pEntry)
18380 {
18381 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18382 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018383 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018385 }
18386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018387
18388void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18389{
18390 tListElem *pEntry;
18391 tCsrPeStatsReqInfo *pTempStaEntry;
18392 VOS_STATUS vosStatus;
18393 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018394 if(!pEntry)
18395 {
18396 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018397 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018398 return;
18399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018400 while( pEntry )
18401 {
18402 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018403 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18404 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018405 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018406 if(pTempStaEntry->timerRunning)
18407 {
18408 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18409 /* If we are not able to stop the timer here, just remove
18410 * the entry from the linked list. Destroy the timer object
18411 * and free the memory in the timer CB
18412 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018413 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018414 {
18415 /* the timer is successfully stopped */
18416 pTempStaEntry->timerRunning = FALSE;
18417
18418 /* Destroy the timer */
18419 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18420 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18421 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018422 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018423 }
18424 }
18425 else
18426 {
18427 // the timer could not be stopped. Hence destroy and free the
18428 // memory for the PE stat entry in the timer CB.
18429 pTempStaEntry->timerStopFailed = TRUE;
18430 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018432
18433 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18434 {
18435 // Only free the memory if we could stop the timer successfully
18436 if(!pTempStaEntry->timerStopFailed)
18437 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018438 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018439 pTempStaEntry = NULL;
18440 }
18441 break;
18442 }
18443
18444 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18445 }
18446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018447 return;
18448}
18449
18450
Jeff Johnsone7245742012-09-05 17:12:55 -070018451void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018452{
18453
Jeff Johnsone7245742012-09-05 17:12:55 -070018454 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18455 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18456 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18457 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18458 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18459 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18460 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018461 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018462 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18463 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18464 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18465 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18466 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18467 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018468 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018469 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18470 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018471
18472}
18473
Jeff Johnson295189b2012-06-20 16:38:30 -070018474void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18475 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18476{
18477 tANI_U8 stats[500];
18478 tANI_U8 *pStats = NULL;
18479 tANI_U32 tempMask = 0;
18480 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018481 if(!callback)
18482 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018483 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018484 return;
18485 }
18486 if(!statsMask)
18487 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018488 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018489 return;
18490 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018491 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018492 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018493 while(tempMask)
18494 {
18495 if(tempMask & 1)
18496 {
18497 //new stats info from PE, fill up the stats strucutres in PMAC
18498 switch(counter)
18499 {
18500 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018501 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018502 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18503 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018504 pStats += sizeof(tCsrSummaryStatsInfo);
18505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018506 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018507 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018508 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18509 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018510 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018511 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018512 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018513 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018514 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18515 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018516 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018517 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018518 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018519 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018520 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18521 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018522 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018523 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018524 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018525 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018526 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18527 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018528 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018530 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018531 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018532 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18533 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018534 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018535 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018536 case eCsrPerPktStats:
18537 smsLog( pMac, LOG2, FL("PerPkt stats"));
18538 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18539 sizeof(tPerTxPacketFrmFw));
18540 pStats += sizeof(tPerTxPacketFrmFw);
18541 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018542 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018543 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018544 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018545 }
18546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018547 tempMask >>=1;
18548 counter++;
18549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018550 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018551}
18552
Jeff Johnson295189b2012-06-20 16:38:30 -070018553eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18554{
18555 tListElem *pEntry = NULL;
18556 tListElem *pPrevEntry = NULL;
18557 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18558 eHalStatus status = eHAL_STATUS_SUCCESS;
18559 VOS_STATUS vosStatus;
18560 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018561 if(!pEntry)
18562 {
18563 //list empty
18564 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018565 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018566 return status;
18567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018568 while( pEntry )
18569 {
18570 if(pPrevEntry)
18571 {
18572 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18573 //send up the stats report
18574 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18575 pTempStaEntry->staId, pTempStaEntry->pContext);
18576 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018578 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018579 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18580 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018581 pTempStaEntry->pPeStaEntry->numClient--;
18582 //check if we need to delete the entry from peStatsReqList too
18583 if(!pTempStaEntry->pPeStaEntry->numClient)
18584 {
18585 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18586 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018588 //check if we need to stop the tl stats timer too
18589 pMac->roam.tlStatsReqInfo.numClient--;
18590 if(!pMac->roam.tlStatsReqInfo.numClient)
18591 {
18592 if(pMac->roam.tlStatsReqInfo.timerRunning)
18593 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018594 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18595 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018597 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018598 //we will continue
18599 }
18600 }
18601 pMac->roam.tlStatsReqInfo.periodicity = 0;
18602 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018604 if (pTempStaEntry->periodicity)
18605 {
18606 //While creating StaEntry in csrGetStatistics,
18607 //Initializing and starting timer only when periodicity is set.
18608 //So Stop and Destroy timer only when periodicity is set.
18609
Jeff Johnsone7245742012-09-05 17:12:55 -070018610 vos_timer_stop( &pTempStaEntry->timer );
18611 // Destroy the vos timer...
18612 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18613 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18614 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018615 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018616 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018617 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018618
Jeff Johnson295189b2012-06-20 16:38:30 -070018619
18620 pPrevEntry = pEntry;
18621 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18622 }
18623 //the last one
18624 if(pPrevEntry)
18625 {
18626 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18627 //send up the stats report
18628 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18629 pTempStaEntry->staId, pTempStaEntry->pContext);
18630 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018632 return status;
18633
18634}
18635
Jeff Johnson295189b2012-06-20 16:38:30 -070018636eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18637 tRequestFullPowerReason *pReason,
18638 tANI_BOOLEAN *pfNeedPower )
18639{
18640 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18641 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18642 tPmcState pmcState;
18643 eHalStatus status = eHAL_STATUS_SUCCESS;
18644 // TODO : Session info unavailable
18645 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018646 if( pfNeedPower )
18647 {
18648 *pfNeedPower = eANI_BOOLEAN_FALSE;
18649 }
18650 //We only handle CSR commands
18651 if( !(eSmeCsrCommandMask & pCommand->command) )
18652 {
18653 return eHAL_STATUS_SUCCESS;
18654 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018655 //Check PMC state first
18656 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018657 switch( pmcState )
18658 {
18659 case REQUEST_IMPS:
18660 case IMPS:
18661 if( eSmeCommandScan == pCommand->command )
18662 {
18663 switch( pCommand->u.scanCmd.reason )
18664 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018665#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18666 case eCsrScanGetLfrResult:
18667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018668 case eCsrScanGetResult:
18669 case eCsrScanBGScanAbort:
18670 case eCsrScanBGScanEnable:
18671 case eCsrScanGetScanChnInfo:
18672 //Internal process, no need for full power
18673 fNeedFullPower = eANI_BOOLEAN_FALSE;
18674 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018675 default:
18676 //Other scans are real scan, ask for power
18677 fNeedFullPower = eANI_BOOLEAN_TRUE;
18678 break;
18679 } //switch
18680 }
18681 else
18682 {
18683 //ask for power for roam and status change
18684 fNeedFullPower = eANI_BOOLEAN_TRUE;
18685 }
18686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018687 case REQUEST_BMPS:
18688 case BMPS:
18689 case REQUEST_START_UAPSD:
18690 case UAPSD:
18691 //We treat WOWL same as BMPS
18692 case REQUEST_ENTER_WOWL:
18693 case WOWL:
18694 if( eSmeCommandRoam == pCommand->command )
18695 {
18696 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18697 tCsrScanResult *pScanResult;
18698 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018699 switch ( pCommand->u.roamCmd.roamReason )
18700 {
18701 case eCsrForcedDisassoc:
18702 case eCsrForcedDisassocMICFailure:
18703 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18704 fNeedFullPower = eANI_BOOLEAN_TRUE;
18705 break;
18706 case eCsrSmeIssuedDisassocForHandoff:
18707 case eCsrForcedDeauth:
18708 case eCsrHddIssuedReassocToSameAP:
18709 case eCsrSmeIssuedReassocToSameAP:
18710 fNeedFullPower = eANI_BOOLEAN_TRUE;
18711 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018712 case eCsrCapsChange:
18713 fNeedFullPower = eANI_BOOLEAN_TRUE;
18714 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018715 case eCsrForcedDisassocSta:
18716 case eCsrForcedDeauthSta:
18717 fNeedFullPower = eANI_BOOLEAN_FALSE;
18718 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018719 default:
18720 //Check whether the profile is already connected. If so, no need for full power
18721 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18722 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18723 {
18724 //Only need to check the first one
18725 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18726 if( pEntry )
18727 {
18728 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18729#if 0
18730 // TODO : Session Specific info pConnectBssDesc
18731 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18732 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18733 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18734 {
18735 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18736 // with Authenticating first. To force this, stop the current association (Disassociate) and
18737 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18738 // a new Association.
18739 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18740 {
18741 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18742 {
18743 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18744 //No need for full power
18745 //Set the flag so the code later can avoid to do the above
18746 //check again.
18747 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18748 break;
18749 }
18750 }
18751 }
18752#endif
18753 }
18754 }
18755 //If we are here, full power is needed
18756 fNeedFullPower = eANI_BOOLEAN_TRUE;
18757 break;
18758 }
18759 }
18760 else if( eSmeCommandWmStatusChange == pCommand->command )
18761 {
18762 //need full power for all
18763 fNeedFullPower = eANI_BOOLEAN_TRUE;
18764 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18765 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018766#ifdef FEATURE_WLAN_TDLS
18767 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18768 {
18769 //TDLS link is getting established. need full power
18770 fNeedFullPower = eANI_BOOLEAN_TRUE;
18771 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18772 }
18773#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018774 else if (eSmeCommandDelStaSession == pCommand->command)
18775 {
18776 //need full power for all
18777 fNeedFullPower = eANI_BOOLEAN_TRUE;
18778 }
18779
Jeff Johnson295189b2012-06-20 16:38:30 -070018780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018781 case REQUEST_STOP_UAPSD:
18782 case REQUEST_EXIT_WOWL:
18783 if( eSmeCommandRoam == pCommand->command )
18784 {
18785 fNeedFullPower = eANI_BOOLEAN_TRUE;
18786 switch ( pCommand->u.roamCmd.roamReason )
18787 {
18788 case eCsrForcedDisassoc:
18789 case eCsrForcedDisassocMICFailure:
18790 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18791 break;
18792 default:
18793 break;
18794 }
18795 }
18796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018797 case STOPPED:
18798 case REQUEST_STANDBY:
18799 case STANDBY:
18800 case LOW_POWER:
18801 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018802 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18803 " stopped/standby state %s (%d)" ),
18804 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018805 status = eHAL_STATUS_FAILURE;
18806 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018807 case FULL_POWER:
18808 case REQUEST_FULL_POWER:
18809 default:
18810 //No need to ask for full power. This has to be FULL_POWER state
18811 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018812 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018813 if( pReason )
18814 {
18815 *pReason = reason;
18816 }
18817 if( pfNeedPower )
18818 {
18819 *pfNeedPower = fNeedFullPower;
18820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018821 return ( status );
18822}
18823
Jeff Johnson295189b2012-06-20 16:38:30 -070018824static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18825{
18826 eHalStatus status = eHAL_STATUS_SUCCESS;
18827 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18828 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018829 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018830 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18831 {
18832 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18833 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018834 return ( status );
18835}
18836
Jeff Johnson295189b2012-06-20 16:38:30 -070018837tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18838{
18839 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018840 if( pCmd )
18841 {
18842 pMac->roam.sPendingCommands++;
18843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018844 return ( pCmd );
18845}
18846
Jeff Johnson295189b2012-06-20 16:38:30 -070018847void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18848{
18849 if (pMac->roam.sPendingCommands > 0)
18850 {
18851 //All command allocated through csrGetCommandBuffer need to
18852 //decrement the pending count when releasing.
18853 pMac->roam.sPendingCommands--;
18854 smeReleaseCommand( pMac, pCommand );
18855 }
18856 else
18857 {
18858 smsLog(pMac, LOGE, FL( "no pending commands"));
18859 VOS_ASSERT(0);
18860 }
18861}
18862
Jeff Johnson295189b2012-06-20 16:38:30 -070018863//Return SUCCESS is the command is queued, failed
18864eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
18865{
18866 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053018867
18868 if (!SME_IS_START(pMac))
18869 {
18870 smsLog( pMac, LOGE, FL("Sme in stop state"));
18871 return eHAL_STATUS_FAILURE;
18872 }
18873
Jeff Johnson295189b2012-06-20 16:38:30 -070018874 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
18875 {
18876 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
18877 pCommand->u.scanCmd.reason);
18878 return eHAL_STATUS_CSR_WRONG_STATE;
18879 }
18880
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018881 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
18882 {
18883 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
18884 &pCommand->Link, LL_ACCESS_LOCK);
18885 // process the command queue...
18886 smeProcessPendingQueue(pMac);
18887 status = eHAL_STATUS_SUCCESS;
18888 goto end;
18889 }
18890
Jeff Johnson295189b2012-06-20 16:38:30 -070018891 //We can call request full power first before putting the command into pending Q
18892 //because we are holding SME lock at this point.
18893 status = csrRequestFullPower( pMac, pCommand );
18894 if( HAL_STATUS_SUCCESS( status ) )
18895 {
18896 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070018897 //make sure roamCmdPendingList is not empty first
18898 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
18899 if( fNoCmdPending )
18900 {
18901 smePushCommand( pMac, pCommand, fHighPriority );
18902 }
18903 else
18904 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018905 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070018906 //no list lock is needed since SME lock is held
18907 if( !fHighPriority )
18908 {
18909 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18910 }
18911 else {
18912 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18913 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018914 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018915 }
18916 else if( eHAL_STATUS_PMC_PENDING == status )
18917 {
18918 //no list lock is needed since SME lock is held
18919 if( !fHighPriority )
18920 {
18921 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18922 }
18923 else {
18924 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18925 }
18926 //Let caller know the command is queue
18927 status = eHAL_STATUS_SUCCESS;
18928 }
18929 else
18930 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018931 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070018932 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018933 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070018934 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018935end:
Jeff Johnson295189b2012-06-20 16:38:30 -070018936 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070018937}
Jeff Johnson295189b2012-06-20 16:38:30 -070018938eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
18939{
18940 eHalStatus status = eHAL_STATUS_SUCCESS;
18941 tSirUpdateAPWPSIEsReq *pMsg;
18942 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
18943
18944 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18945 if (NULL == pSession)
18946 {
18947 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18948 return eHAL_STATUS_FAILURE;
18949 }
18950
Jeff Johnson295189b2012-06-20 16:38:30 -070018951 do
18952 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018953 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
18954 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18955 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018956 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
18957
18958 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070018959 VOS_ASSERT(pBuf);
18960
Jeff Johnson295189b2012-06-20 16:38:30 -070018961 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018962 // transactionId
18963 *pBuf = 0;
18964 *( pBuf + 1 ) = 0;
18965 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070018966 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018967 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18968 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070018969 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018970 //sessionId
18971 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018972 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018973 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070018974 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070018975 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018976 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018977 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018978 return ( status );
18979}
Jeff Johnson295189b2012-06-20 16:38:30 -070018980eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
18981{
18982 eHalStatus status = eHAL_STATUS_SUCCESS;
18983 tSirUpdateAPWPARSNIEsReq *pMsg;
18984 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018985 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18986 if (NULL == pSession)
18987 {
18988 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18989 return eHAL_STATUS_FAILURE;
18990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018991 do
18992 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018993 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
18994 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18995 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018996 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070018997 pBuf = (tANI_U8 *)&pMsg->transactionId;
18998 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018999 // transactionId
19000 *pBuf = 0;
19001 *( pBuf + 1 ) = 0;
19002 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070019003 VOS_ASSERT(pBuf);
19004
Jeff Johnson295189b2012-06-20 16:38:30 -070019005 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019006 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19007 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019008 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019009 // sessionId
19010 *pBuf++ = (tANI_U8)sessionId;
19011
19012 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019013 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070019014 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070019015 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019016 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019017 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019018 return ( status );
19019}
Jeff Johnson295189b2012-06-20 16:38:30 -070019020
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019021tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
19022 tpSirBssDescription pBssDescription)
19023{
19024 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19025 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19026 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
19027 eHalStatus status;
19028 tDot11fBeaconIEs *ies_local = NULL;
19029 tANI_U32 dot11mode = 0;
19030
19031 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19032
19033 /* Get IE's */
19034 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19035 if (!HAL_STATUS_SUCCESS(status)) {
19036 smsLog(pMac, LOGE,
19037 FL("csrGetParsedBssDescriptionIEs failed"));
19038 return 0;
19039 }
19040 if(ies_local == NULL) {
19041 smsLog(pMac, LOGE,
19042 FL("ies_local is NULL"));
19043 return 0;
19044 }
19045
19046 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19047 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19048 uCfgDot11Mode = cfgDot11Mode;
19049 else
19050 {
19051 smsLog(pMac, LOGE, "Can not find match phy mode");
19052 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19053 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19054 else
19055 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19056 }
19057
19058 /* dot11mode */
19059 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19060 smsLog(pMac, LOG1,
19061 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19062
19063 if (pBssDescription->channelId <= 14 &&
19064 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19065 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19066 {
19067 /* Need to disable VHT operation in 2.4 GHz band */
19068 dot11mode = WNI_CFG_DOT11_MODE_11N;
19069 }
19070 vos_mem_free(ies_local);
19071 return dot11mode;
19072}
19073
Jeff Johnson295189b2012-06-20 16:38:30 -070019074#ifdef WLAN_FEATURE_VOWIFI_11R
19075//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19076eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19077{
19078 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19079 tpSirFTPreAuthReq pftPreAuthReq;
19080 tANI_U16 auth_req_len = 0;
19081 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019082 auth_req_len = sizeof(tSirFTPreAuthReq);
19083 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019084 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019085 {
19086 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19087 return eHAL_STATUS_RESOURCES;
19088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019089 // Save the SME Session ID here. We need it while processing the preauth response
19090 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019091 vos_mem_zero(pftPreAuthReq, auth_req_len);
19092
19093 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19094 sizeof(pBssDescription->length) + pBssDescription->length);
19095
19096 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19097
19098 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019099 pftPreAuthReq->dot11mode =
19100 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19101 if (!pftPreAuthReq->dot11mode)
19102 {
19103 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19104 vos_mem_free(pftPreAuthReq);
19105 return eHAL_STATUS_FAILURE;
19106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019107
Kiet Lam64c1b492013-07-12 13:56:44 +053019108 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19109 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19110 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19111 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019112
Jeff Johnson295189b2012-06-20 16:38:30 -070019113#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019114 if (csrRoamIs11rAssoc(pMac) &&
19115 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019116 {
19117 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019118 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19119 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019120 }
19121 else
19122#endif
19123 {
19124 pftPreAuthReq->ft_ies_length = 0;
19125 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019126 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19127 sizeof(pBssDescription->length) + pBssDescription->length);
19128 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019129 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19130}
Jeff Johnson295189b2012-06-20 16:38:30 -070019131/*--------------------------------------------------------------------------
19132 * This will receive and process the FT Pre Auth Rsp from the current
19133 * associated ap.
19134 *
19135 * This will invoke the hdd call back. This is so that hdd can now
19136 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19137 ------------------------------------------------------------------------*/
19138void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19139{
19140 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19141 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019142#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019143 tCsrRoamInfo roamInfo;
19144#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019145 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019146
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019147#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019148 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019149 if (status != eHAL_STATUS_SUCCESS) {
19150 /*
19151 * Bail out if pre-auth was not even processed.
19152 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019153 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19154 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019155 return;
19156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019157#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019158 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19159 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19160 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019161 // Implies a success
19162 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019163 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19164 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019165 /* No need to notify qos module if this is a non 11r & ESE roam*/
19166 if (csrRoamIs11rAssoc(pMac)
19167#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19168 || csrRoamIsESEAssoc(pMac)
19169#endif
19170 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019171 {
19172 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19173 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019174 if (pMac->roam.configParam.roamDelayStatsEnabled)
19175 {
19176 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19177 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019178 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19179 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019180 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19181 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019182 if (pMac->roam.configParam.roamDelayStatsEnabled)
19183 {
19184 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19185 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019186 if (eHAL_STATUS_SUCCESS != status)
19187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019188 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019189 return;
19190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019191 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019192 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19193 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019194 if (csrRoamIs11rAssoc(pMac))
19195 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19196 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19197
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019198#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19199 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019200 {
19201 /* read TSF */
19202 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19203
19204 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019205 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019206 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19207 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019208#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019209#ifdef FEATURE_WLAN_LFR
19210 // If Legacy Fast Roaming is enabled, signal the supplicant
19211 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019212 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019213 {
19214 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019215 vos_mem_copy((void *)&roamInfo.bssid,
19216 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019217 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19218 }
19219
19220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019221
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019222 // If its an Open Auth, FT IEs are not provided by supplicant
19223 // Hence populate them here
19224 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19225 pMac->ft.ftSmeContext.addMDIE = FALSE;
19226 if( csrRoamIs11rAssoc(pMac) &&
19227 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19228 {
19229 tANI_U16 ft_ies_length;
19230 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19231
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019232 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19233 connectedProfile.MDID.mdiePresent)
19234 pMac->ft.ftSmeContext.addMDIE = TRUE;
19235
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019236 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19237 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19238 {
19239 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19240 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19241 }
19242
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019243 if (!ft_ies_length)
19244 {
19245 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19246 return;
19247 }
19248
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019249 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19250 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19251 {
19252 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19253 }
19254 else
19255 {
19256 // Copy the RIC IEs to reassoc IEs
19257 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19258 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19259 pFTPreAuthRsp->ric_ies_length);
19260 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19261 pMac->ft.ftSmeContext.addMDIE = TRUE;
19262 }
19263 }
19264
Jeff Johnson295189b2012-06-20 16:38:30 -070019265 // Done with it, init it.
19266 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19267}
19268#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019269
Jeff Johnson295189b2012-06-20 16:38:30 -070019270#ifdef FEATURE_WLAN_BTAMP_UT_RF
19271void csrRoamJoinRetryTimerHandler(void *pv)
19272{
19273 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19274 tpAniSirGlobal pMac = pInfo->pMac;
19275 tANI_U32 sessionId = pInfo->sessionId;
19276 tCsrRoamSession *pSession;
19277
19278 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019280 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019281 pSession = CSR_GET_SESSION( pMac, sessionId );
19282 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19283 {
19284 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019286 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019287 }
19288 }
19289 }
19290}
Jeff Johnson295189b2012-06-20 16:38:30 -070019291eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19292{
19293 eHalStatus status = eHAL_STATUS_FAILURE;
19294 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19295
19296 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019298 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019299 pSession->maxRetryCount--;
19300 pSession->joinRetryTimerInfo.pMac = pMac;
19301 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019302 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19303 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019305 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019306 }
19307 }
19308 else
19309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019310 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019311 pSession->maxRetryCount);
19312 }
19313
19314 return (status);
19315}
Jeff Johnson295189b2012-06-20 16:38:30 -070019316eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19317{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019318 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019319 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19320 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019321 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019322 }
19323
19324 return eHAL_STATUS_SUCCESS;
19325}
19326#endif
19327
19328
19329/*
19330 pBuf points to the beginning of the message
19331 LIM packs disassoc rsp as below,
19332 messageType - 2 bytes
19333 messageLength - 2 bytes
19334 sessionId - 1 byte
19335 transactionId - 2 bytes (tANI_U16)
19336 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19337 peerMacAddr - 6 bytes
19338 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19339*/
19340static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19341{
19342 if(pBuf && pRsp)
19343 {
19344 pBuf += 4; //skip type and length
19345 pRsp->sessionId = *pBuf++;
19346 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19347 pBuf += 2;
19348 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19349 pBuf += 4;
19350 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19351 }
19352}
19353
Jeff Johnsond13512a2012-07-17 11:42:19 -070019354eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19355{
19356 static uNvTables nvTables;
19357 eHalStatus status = eHAL_STATUS_SUCCESS;
19358 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19359
19360 /* read the country code from NV and use it */
19361 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19362 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019363 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19364 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019365 return status;
19366 }
19367 else
19368 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019369 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019370 status = eHAL_STATUS_FAILURE;
19371 return status;
19372 }
19373}
19374
19375eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19376{
Kiet Lam64c1b492013-07-12 13:56:44 +053019377 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019378 return eHAL_STATUS_SUCCESS;
19379}
schang86c22c42013-03-13 18:41:24 -070019380
19381eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19382{
19383 tSirSetTxPowerReq *pMsg = NULL;
19384 eHalStatus status = eHAL_STATUS_SUCCESS;
19385 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19386
19387 if (!pSession)
19388 {
19389 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19390 return eHAL_STATUS_FAILURE;
19391 }
19392
Kiet Lam64c1b492013-07-12 13:56:44 +053019393 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19394 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19395 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19396 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19397 pMsg->length = sizeof(tSirSetTxPowerReq);
19398 pMsg->mwPower = mW;
19399 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19400 sizeof(tSirMacAddr));
19401 status = palSendMBMessage(pMac->hHdd, pMsg);
19402 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019403 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019404 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19405 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019406 }
19407 return status;
19408}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019409
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019410eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19411{
19412 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19413 eHalStatus status = eHAL_STATUS_SUCCESS;
19414 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19415
19416 if (!pSession)
19417 {
19418 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19419 return eHAL_STATUS_FAILURE;
19420 }
19421 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19422 {
19423 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019424
19425 if( NULL == pMsg )
19426 {
19427 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19428 return eHAL_STATUS_FAILURE;
19429 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019430 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19431 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019432 pMsg->length =
19433 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019434 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019435 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19436 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019437 status = palSendMBMessage(pMac->hHdd, pMsg);
19438 if (!HAL_STATUS_SUCCESS(status))
19439 {
19440 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19441 //pMsg is freed by palSendMBMessage
19442 }
19443 }
19444 else
19445 {
19446 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19447 status = eHAL_STATUS_FAILURE;
19448 }
19449 return status;
19450}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019451/* Returns whether a session is in VOS_STA_MODE...or not */
19452tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19453{
19454 tCsrRoamSession *pSession = NULL;
19455 pSession = CSR_GET_SESSION ( pMac, sessionId );
19456 if(!pSession)
19457 {
19458 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19459 return eANI_BOOLEAN_FALSE;
19460 }
19461 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19462 {
19463 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19464 return eANI_BOOLEAN_FALSE;
19465 }
19466 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19467 {
19468 return eANI_BOOLEAN_FALSE;
19469 }
19470 /* There is a possibility that the above check may fail,because
19471 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19472 * when it is connected.So,we may sneak through the above check even
19473 * if we are not a STA mode INFRA station. So, if we sneak through
19474 * the above condition, we can use the following check if we are
19475 * really in STA Mode.*/
19476
19477 if ( NULL != pSession->pCurRoamProfile )
19478 {
19479 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19480 {
19481 return eANI_BOOLEAN_TRUE;
19482 } else {
19483 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19484 return eANI_BOOLEAN_FALSE;
19485 }
19486 }
19487
19488 return eANI_BOOLEAN_FALSE;
19489}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019490
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019491/**
19492 * csr_set_src_handoff_request() - Set handoff source to
19493 * SME handoff request
19494 * @pHandoffInfo: Pointer to Handoff info
19495 * @pMsg: Pointer to SME handoff request message
19496 *
19497 * Return: None
19498 */
19499#ifndef QCA_WIFI_ISOC
19500static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19501 tCsrHandoffRequest *pHandoffInfo)
19502{
19503 pMsg->handoff_src = pHandoffInfo->src;
19504}
19505#else
19506static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19507 tCsrHandoffRequest *pHandoffInfo)
19508{
19509}
19510#endif
19511
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019512#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19513eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19514 tCsrHandoffRequest *pHandoffInfo)
19515{
19516 eHalStatus status = eHAL_STATUS_SUCCESS;
19517 vos_msg_t msg;
19518
19519 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019520 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19521 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019522 {
19523 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019524 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019525 }
19526 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19527 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19528 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19529 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019530 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019531 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019532 pHandoffInfo->bssid,
19533 6);
19534 msg.type = eWNI_SME_HANDOFF_REQ;
19535 msg.bodyptr = pMsg;
19536 msg.reserved = 0;
19537 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19538 {
19539 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019540 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019541 status = eHAL_STATUS_FAILURE;
19542 }
19543 return status;
19544}
19545#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019546
Abhishek Singh00b71972016-01-07 10:51:04 +053019547#ifdef WLAN_FEATURE_RMC
19548eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19549{
19550 tSirSetRMCReq *pMsg = NULL;
19551 eHalStatus status = eHAL_STATUS_SUCCESS;
19552 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19553
19554 if (!pSession)
19555 {
19556 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19557 return eHAL_STATUS_FAILURE;
19558 }
19559
19560 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19561 if (NULL != pMsg)
19562 {
19563 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19564 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19565 pMsg->msgLen = sizeof(tSirSetRMCReq);
19566 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19567 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19568
19569 status = palSendMBMessage(pMac->hHdd, pMsg);
19570 if (!HAL_STATUS_SUCCESS(status))
19571 {
19572 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19573 //pMsg is freed by palSendMBMessage
19574 }
19575 }
19576 else
19577 {
19578 return eHAL_STATUS_FAILURE;
19579 }
19580 return status;
19581}
19582
19583eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19584{
19585 tSirSetRMCReq *pMsg = NULL;
19586 eHalStatus status = eHAL_STATUS_SUCCESS;
19587 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19588
19589 if (!pSession)
19590 {
19591 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19592 return eHAL_STATUS_FAILURE;
19593 }
19594
19595 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19596 if (NULL != pMsg)
19597 {
19598 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19599 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19600 pMsg->msgLen = sizeof(tSirSetRMCReq);
19601 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19602 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19603
19604 status = palSendMBMessage(pMac->hHdd, pMsg);
19605 if (!HAL_STATUS_SUCCESS(status))
19606 {
19607 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19608 //pMsg is freed by palSendMBMessage
19609 }
19610 }
19611 else
19612 {
19613 return eHAL_STATUS_FAILURE;
19614 }
19615 return status;
19616}
19617
19618#endif /* WLAN_FEATURE_RMC */
19619
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019620
19621#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019622/* ---------------------------------------------------------------------------
19623 \fn csrSetCCKMIe
19624 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19625 data structure and this IE will be packed inside reassociation request
19626 \param pMac - pMac global structure
19627 \param sessionId - Current session id
19628 \param pCckmIe - pointer to CCKM IE data
19629 \param ccKmIeLen - length of the CCKM IE
19630 \- return Success or failure
19631 -------------------------------------------------------------------------*/
19632VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19633 const tANI_U8 *pCckmIe,
19634 const tANI_U8 ccKmIeLen)
19635{
19636 eHalStatus status = eHAL_STATUS_SUCCESS;
19637 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19638
19639 if (!pSession)
19640 {
19641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19642 return eHAL_STATUS_FAILURE;
19643 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019644 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019645 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19646 return status;
19647}
19648
19649/* ---------------------------------------------------------------------------
19650 \fn csrRoamReadTSF
19651 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19652 probe response reception from the hand off AP to arrive at the latest TSF value.
19653 \param pMac - pMac global structure
19654 \param pTimestamp - output TSF timestamp
19655 \- return Success or failure
19656 -------------------------------------------------------------------------*/
19657VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19658{
19659 eHalStatus status = eHAL_STATUS_SUCCESS;
19660 tCsrNeighborRoamBSSInfo handoffNode;
19661 tANI_U32 timer_diff = 0;
19662 tANI_U32 timeStamp[2];
19663 tpSirBssDescription pBssDescription = NULL;
19664
19665 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19666 pBssDescription = handoffNode.pBssDescription;
19667
19668 // Get the time diff in milli seconds
19669 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19670 // Convert msec to micro sec timer
19671 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19672
19673 timeStamp[0] = pBssDescription->timeStamp[0];
19674 timeStamp[1] = pBssDescription->timeStamp[1];
19675
19676 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19677
Kiet Lamf2f201e2013-11-16 21:24:16 +053019678 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019679 sizeof (tANI_U32) * 2);
19680 return status;
19681}
19682
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019683#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019684
Agarwal Ashish738843c2014-09-25 12:27:56 +053019685/* ---------------------------------------------------------------------------
19686 \fn csrDisableDfsChannel
19687 \brief This function will call csrApplyChannelPowerCountryInfo to
19688 \ to trim the list on basis of NO_DFS flag.
19689 \param pMac - pMac global structure
19690 \- return void
19691 -------------------------------------------------------------------------*/
19692void csrDisableDfsChannel(tpAniSirGlobal pMac)
19693{
19694 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19695 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19696}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019697
19698/* ---------------------------------------------------------------------------
19699 \fn csrGetStaticUapsdMask
19700 \brief This function will get the static uapsd settings for an existing
19701 \ Infra session.
19702 \param pMac - pMac global structure
19703 \- return void
19704 -------------------------------------------------------------------------*/
19705void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19706{
19707 tANI_S8 sessionId;
19708 tCsrRoamSession *pSession = NULL;
19709
19710 *staticUapsdMask = 0;
19711 sessionId = csrGetInfraSessionId(pMac);
19712 if(sessionId == -1)
19713 smsLog(pMac, LOGE, FL("Valid session not present."));
19714 else
19715 pSession = CSR_GET_SESSION(pMac, sessionId);
19716
19717 if(!pSession || !pSession->pCurRoamProfile)
19718 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019719 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019720 else
19721 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19722}
19723
Abhishek Singh02605092017-10-25 14:06:12 +053019724VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19725 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19726{
19727 VOS_STATUS status = VOS_STATUS_SUCCESS;
19728 struct sir_ecsa_ie_req *msg;
19729
19730 msg = vos_mem_malloc(sizeof(*msg));
19731 if (!msg) {
19732 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19733 return VOS_STATUS_E_NOMEM;
19734 }
19735
19736 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19737 msg->len = sizeof(*msg);
19738
19739 msg->new_chan = new_chan;
19740 msg->cb_mode = cb_mode;
19741 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19742
19743 status = palSendMBMessage(mac_ctx->hHdd, msg);
19744 if (!VOS_IS_STATUS_SUCCESS(status))
19745 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019746 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019747 return status;
19748}
19749
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019750VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19751 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19752{
19753 VOS_STATUS status = VOS_STATUS_SUCCESS;
19754 struct sir_channel_chanege_req *msg;
19755 tCsrRoamStartBssParams param;
19756
19757 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19758
19759 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19760
19761 msg = vos_mem_malloc(sizeof(*msg));
19762 if (!msg) {
19763 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19764 return VOS_STATUS_E_NOMEM;
19765 }
19766
19767 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19768 msg->len = sizeof(*msg);
19769
19770 msg->new_chan = new_chan;
19771 msg->cb_mode = cb_mode;
19772 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19773 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19774 mac_ctx->roam.configParam.uCfgDot11Mode);
19775 if (IS_24G_CH(msg->new_chan) &&
19776 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19777 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19778 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19779 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19780
19781 vos_mem_copy(&msg->operational_rateset,
19782 &param.operationalRateSet, sizeof(msg->operational_rateset));
19783 vos_mem_copy(&msg->extended_rateset,
19784 &param.extendedRateSet, sizeof(msg->extended_rateset));
19785
19786 status = palSendMBMessage(mac_ctx->hHdd, msg);
19787 if (!VOS_IS_STATUS_SUCCESS(status))
19788 smsLog(mac_ctx, LOGE,
19789 FL(" channel switch req fauiled status %d "), status);
19790 return status;
19791}