blob: 058915b5f8015f57174e418a95378a21781e80fa [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302 * Copyright (c) 2012-2018 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;
3363 }
3364 //short slot time
3365 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3366 {
3367 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3368 }
3369 else
3370 {
3371 pBssConfig->uShortSlotTime = 0;
3372 }
3373 if(pBssConfig->BssCap.ibss)
3374 {
3375 //We don't support 11h on IBSS
3376 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3377 }
3378 else
3379 {
3380 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3381 }
3382 //power constraint
3383 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3384 //heartbeat
3385 if ( CSR_IS_11A_BSS( pBssDesc ) )
3386 {
3387 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3388 }
3389 else
3390 {
3391 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3392 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303393 /*
3394 * Join timeout, if we find a BeaconInterval in the BssDescription,
3395 * then set the Join Timeout to be 3 BeaconInterval.
3396 */
3397 if (pBssDesc->beaconInterval)
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 {
3399 //Make sure it is bigger than the minimal
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303400 pBssConfig->uJoinTimeOut =
3401 CSR_ROAM_MAX(3 * pBssDesc->beaconInterval,
3402 CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303404 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 {
3406 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3407 }
3408 //validate CB
3409 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Abhishek Singhe3beee22017-07-31 15:35:40 +05303410 if (CSR_IS_CHANNEL_24GHZ(pBssDesc->channelId) &&
3411 pProfile->force_24ghz_in_ht20) {
3412 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
3413 smsLog(pMac, LOG1,
3414 FL("force_24ghz_in_ht20 is set so set cbmode to 0"));
3415 }
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303416 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3417 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 return (status);
3420}
3421
Jeff Johnson295189b2012-06-20 16:38:30 -07003422static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3423 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3424{
3425 eHalStatus status = eHAL_STATUS_SUCCESS;
3426 tANI_U8 operationChannel = 0;
3427 tANI_U8 qAPisEnabled = FALSE;
3428 //SSID
3429 pBssConfig->SSID.length = 0;
3430 if(pProfile->SSIDs.numOfSSIDs)
3431 {
3432 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303433 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3434 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 }
3436 else
3437 {
3438 //SSID must present
3439 return eHAL_STATUS_FAILURE;
3440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 //Settomg up the capabilities
3442 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3443 {
3444 pBssConfig->BssCap.ibss = 1;
3445 }
3446 else
3447 {
3448 pBssConfig->BssCap.ess = 1;
3449 }
3450 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3451 {
3452 pBssConfig->BssCap.privacy = 1;
3453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 pBssConfig->eBand = pMac->roam.configParam.eBand;
3455 //phymode
3456 if(pProfile->ChannelInfo.ChannelList)
3457 {
3458 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3461 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 //QOS
3463 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 if ( pBssConfig->BssCap.ess == 1 )
3465 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 /*For Softap case enable WMM*/
3467 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3468 qAPisEnabled = TRUE;
3469 }
3470 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3472 qAPisEnabled = TRUE;
3473 } else {
3474 qAPisEnabled = FALSE;
3475 }
3476 } else {
3477 qAPisEnabled = TRUE;
3478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3480 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3481 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3482 )
3483 {
3484 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3485 } else {
3486 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3487 }
3488
3489 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003490 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 {
3492 default:
3493 case eCSR_AUTH_TYPE_WPA:
3494 case eCSR_AUTH_TYPE_WPA_PSK:
3495 case eCSR_AUTH_TYPE_WPA_NONE:
3496 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3497 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3498 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 case eCSR_AUTH_TYPE_SHARED_KEY:
3500 pBssConfig->authType = eSIR_SHARED_KEY;
3501 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 case eCSR_AUTH_TYPE_AUTOSWITCH:
3503 pBssConfig->authType = eSIR_AUTO_SWITCH;
3504 break;
3505 }
3506 //short slot time
3507 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3508 {
3509 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3510 }
3511 else
3512 {
3513 pBssConfig->uShortSlotTime = 0;
3514 }
3515 //power constraint. We don't support 11h on IBSS
3516 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3517 pBssConfig->uPowerLimit = 0;
3518 //heartbeat
3519 if ( eCSR_BAND_5G == pBssConfig->eBand )
3520 {
3521 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3522 }
3523 else
3524 {
3525 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3526 }
3527 //Join timeout
3528 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003529
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 return (status);
3531}
Jeff Johnson295189b2012-06-20 16:38:30 -07003532static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3533{
3534 eHalStatus status = eHAL_STATUS_FAILURE;
3535 tDot11fBeaconIEs *pIes = NULL;
3536
3537 do
3538 {
3539 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3540 {
3541 //err msg
3542 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003543 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 break;
3545 }
3546 //check if the AP is QAP & it supports APSD
3547 if( CSR_IS_QOS_BSS(pIes) )
3548 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303549 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 }
3551 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303552
3553 if (NULL != pIes)
3554 {
3555 vos_mem_free(pIes);
3556 }
3557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 return status;
3559}
3560
Jeff Johnson295189b2012-06-20 16:38:30 -07003561void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3562{
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3564 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3565 // See !!Note: below in this function...
3566 tANI_U32 PrivacyEnabled = 0;
3567 tANI_U32 RsnEnabled = 0;
3568 tANI_U32 WepDefaultKeyId = 0;
3569 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3570 tANI_U32 Key0Length = 0;
3571 tANI_U32 Key1Length = 0;
3572 tANI_U32 Key2Length = 0;
3573 tANI_U32 Key3Length = 0;
3574
3575 // Reserve for the biggest key
3576 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3577 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3578 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3579 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3580
3581 switch ( pProfile->negotiatedUCEncryptionType )
3582 {
3583 case eCSR_ENCRYPT_TYPE_NONE:
3584
3585 // for NO encryption, turn off Privacy and Rsn.
3586 PrivacyEnabled = 0;
3587 RsnEnabled = 0;
3588
3589 // WEP key length and Wep Default Key ID don't matter in this case....
3590
3591 // clear out the WEP keys that may be hanging around.
3592 Key0Length = 0;
3593 Key1Length = 0;
3594 Key2Length = 0;
3595 Key3Length = 0;
3596
3597 break;
3598
3599 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303600 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003601
3602 // Privacy is ON. NO RSN for Wep40 static key.
3603 PrivacyEnabled = 1;
3604 RsnEnabled = 0;
3605
3606 // Set the Wep default key ID.
3607 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 // Wep key size if 5 bytes (40 bits).
3609 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3610
3611 // set encryption keys in the CFG database or clear those that are not present in this profile.
3612 if ( pProfile->Keys.KeyLength[0] )
3613 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303614 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3615 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3617 }
3618 else
3619 {
3620 Key0Length = 0;
3621 }
3622
3623 if ( pProfile->Keys.KeyLength[1] )
3624 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303625 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3626 WNI_CFG_WEP_KEY_LENGTH_5);
3627 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 }
3629 else
3630 {
3631 Key1Length = 0;
3632 }
3633
3634 if ( pProfile->Keys.KeyLength[2] )
3635 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303636 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3637 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3639 }
3640 else
3641 {
3642 Key2Length = 0;
3643 }
3644
3645 if ( pProfile->Keys.KeyLength[3] )
3646 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303647 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3648 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3650 }
3651 else
3652 {
3653 Key3Length = 0;
3654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 break;
3656
3657 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303658 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003659
3660 // Privacy is ON. NO RSN for Wep40 static key.
3661 PrivacyEnabled = 1;
3662 RsnEnabled = 0;
3663
3664 // Set the Wep default key ID.
3665 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3666
3667 // Wep key size if 13 bytes (104 bits).
3668 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3669
3670 // set encryption keys in the CFG database or clear those that are not present in this profile.
3671 if ( pProfile->Keys.KeyLength[0] )
3672 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303673 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3674 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3676 }
3677 else
3678 {
3679 Key0Length = 0;
3680 }
3681
3682 if ( pProfile->Keys.KeyLength[1] )
3683 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303684 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3685 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3687 }
3688 else
3689 {
3690 Key1Length = 0;
3691 }
3692
3693 if ( pProfile->Keys.KeyLength[2] )
3694 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303695 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3696 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3698 }
3699 else
3700 {
3701 Key2Length = 0;
3702 }
3703
3704 if ( pProfile->Keys.KeyLength[3] )
3705 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303706 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3707 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3709 }
3710 else
3711 {
3712 Key3Length = 0;
3713 }
3714
3715 break;
3716
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 case eCSR_ENCRYPT_TYPE_TKIP:
3718 case eCSR_ENCRYPT_TYPE_AES:
3719#ifdef FEATURE_WLAN_WAPI
3720 case eCSR_ENCRYPT_TYPE_WPI:
3721#endif /* FEATURE_WLAN_WAPI */
3722 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3723 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3724 PrivacyEnabled = (0 != fPrivacy);
3725
3726 // turn on RSN enabled for WPA associations
3727 RsnEnabled = 1;
3728
3729 // WEP key length and Wep Default Key ID don't matter in this case....
3730
3731 // clear out the static WEP keys that may be hanging around.
3732 Key0Length = 0;
3733 Key1Length = 0;
3734 Key2Length = 0;
3735 Key3Length = 0;
3736
3737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 default:
3739 PrivacyEnabled = 0;
3740 RsnEnabled = 0;
3741 break;
3742 }
3743
3744 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3745 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3746 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3747 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3748 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3749 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3750 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3751 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3752}
3753
Jeff Johnson295189b2012-06-20 16:38:30 -07003754static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3755{
3756 tANI_U32 len = 0;
3757 if(pSSID->length <= WNI_CFG_SSID_LEN)
3758 {
3759 len = pSSID->length;
3760 }
3761 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3762}
3763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3765{
3766 eHalStatus status = eHAL_STATUS_SUCCESS;
3767 tANI_U32 QoSEnabled;
3768 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 // set the CFG enable/disable variables based on the qosType being configured...
3770 switch( qosType )
3771 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3773 QoSEnabled = FALSE;
3774 WmeEnabled = TRUE;
3775 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3777 QoSEnabled = FALSE;
3778 WmeEnabled = TRUE;
3779 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3781 QoSEnabled = FALSE;
3782 WmeEnabled = TRUE;
3783 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3785 QoSEnabled = TRUE;
3786 WmeEnabled = FALSE;
3787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 case eCSR_MEDIUM_ACCESS_11e_HCF:
3789 QoSEnabled = TRUE;
3790 WmeEnabled = FALSE;
3791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 default:
3793 case eCSR_MEDIUM_ACCESS_DCF:
3794 QoSEnabled = FALSE;
3795 WmeEnabled = FALSE;
3796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 }
3798 //save the WMM setting for later use
3799 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303800 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 return (status);
3802}
Jeff Johnson295189b2012-06-20 16:38:30 -07003803static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303804 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003805{
3806 eHalStatus status = eHAL_STATUS_FAILURE;
3807 int i;
3808 eCsrCfgDot11Mode cfgDot11Mode;
3809 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303810 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303811 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3812 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003814
3815 if( NULL != pIes )
3816 {
3817 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 // Originally, we thought that for 11a networks, the 11a rates are always
3819 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3820 // appear in the Operational Rate set. Consequently, in either case, we
3821 // would blindly put the rates we support into our Operational Rate set
3822 // (including the basic rates, which we have already verified are
3823 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 // However, it turns out that this is not always the case. Some AP's
3825 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3826 // too. Now, we're a little more careful:
3827 pDstRate = pOpRateSet->rate;
3828 if(pIes->SuppRates.present)
3829 {
3830 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3831 {
3832 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3833 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003834 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3835 {
3836 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3837 *pDstRate++ = pIes->SuppRates.rates[ i ];
3838 pOpRateSet->numRates++;
3839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 }
3841 }
3842 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303843 /* If there are Extended Rates in the beacon, we will reflect those
3844 * extended rates that we support in out Extended Operational Rate
3845 * set*/
3846 pDstRate = pExRateSet->rate;
3847 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303849 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303851 if (csrRatesIsDot11RateSupported(pMac,
3852 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303854 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3855 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303857 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3858 &rateBitmap);
3859 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3860 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 }
3862 }
3863 }
3864 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303865 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 }//Parsing BSSDesc
3867 else
3868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003869 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 }
3871 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3872 return status;
3873}
3874
3875static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3876 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3877{
3878 int i;
3879 tANI_U8 *pDstRate;
3880 eCsrCfgDot11Mode cfgDot11Mode;
3881 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3882 tANI_U32 OperationalRatesLength = 0;
3883 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3884 tANI_U32 ExtendedOperationalRatesLength = 0;
3885 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3886 tANI_U32 ProprietaryOperationalRatesLength = 0;
3887 tANI_U32 PropRatesEnable = 0;
3888 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3889 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 if( NULL != pIes )
3892 {
3893 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 // Originally, we thought that for 11a networks, the 11a rates are always
3895 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3896 // appear in the Operational Rate set. Consequently, in either case, we
3897 // would blindly put the rates we support into our Operational Rate set
3898 // (including the basic rates, which we have already verified are
3899 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 // However, it turns out that this is not always the case. Some AP's
3901 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3902 // too. Now, we're a little more careful:
3903 pDstRate = OperationalRates;
3904 if(pIes->SuppRates.present)
3905 {
3906 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3907 {
3908 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3909 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3910 {
3911 *pDstRate++ = pIes->SuppRates.rates[ i ];
3912 OperationalRatesLength++;
3913 }
3914 }
3915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3917 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3918 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3919 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3920 {
3921 // If there are Extended Rates in the beacon, we will reflect those
3922 // extended rates that we support in out Extended Operational Rate
3923 // set:
3924 pDstRate = ExtendedOperationalRates;
3925 if(pIes->ExtSuppRates.present)
3926 {
3927 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3928 {
3929 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3930 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3931 {
3932 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3933 ExtendedOperationalRatesLength++;
3934 }
3935 }
3936 }
3937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 // Enable proprietary MAC features if peer node is Airgo node and STA
3939 // user wants to use them
3940 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3941 {
3942 PropRatesEnable = 1;
3943 }
3944 else
3945 {
3946 PropRatesEnable = 0;
3947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 // For ANI network companions, we need to populate the proprietary rate
3949 // set with any proprietary rates we found in the beacon, only if user
3950 // allows them...
3951 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3952 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3953 {
3954 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3955 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3956 {
3957 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3958 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303959 vos_mem_copy(ProprietaryOperationalRates,
3960 pIes->Airgo.PropSuppRates.rates,
3961 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 }
3963 else {
3964 // No proprietary modes...
3965 ProprietaryOperationalRatesLength = 0;
3966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 /* Get MCS Rate */
3968 pDstRate = MCSRateIdxSet;
3969 if ( pIes->HTCaps.present )
3970 {
3971 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3972 {
3973 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3974 {
3975 MCSRateLength++;
3976 *pDstRate++ = i;
3977 }
3978 }
3979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 // Set the operational rate set CFG variables...
3981 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3982 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3983 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3984 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3985 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3986 ProprietaryOperationalRates,
3987 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3988 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3989 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3990 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3991 }//Parsing BSSDesc
3992 else
3993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003994 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 }
3996}
3997
Jeff Johnson295189b2012-06-20 16:38:30 -07003998static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3999 tCsrRoamProfile *pProfile )
4000{
4001 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4002 { 8,
4003 { SIR_MAC_RATE_6,
4004 SIR_MAC_RATE_9,
4005 SIR_MAC_RATE_12,
4006 SIR_MAC_RATE_18,
4007 SIR_MAC_RATE_24,
4008 SIR_MAC_RATE_36,
4009 SIR_MAC_RATE_48,
4010 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4012 { 4,
4013 { SIR_MAC_RATE_1,
4014 SIR_MAC_RATE_2,
4015 SIR_MAC_RATE_5_5,
4016 SIR_MAC_RATE_11 } } };
4017
4018
4019 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4020 { SIR_MAC_RATE_72,
4021 SIR_MAC_RATE_96,
4022 SIR_MAC_RATE_108 } };
4023 eCsrCfgDot11Mode cfgDot11Mode;
4024 eCsrBand eBand;
4025 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4026 tANI_U32 OperationalRatesLength = 0;
4027 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4028 tANI_U32 ExtendedOperationalRatesLength = 0;
4029 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
4030 tANI_U32 ProprietaryOperationalRatesLength = 0;
4031 tANI_U32 PropRatesEnable = 0;
4032 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 if(pProfile->ChannelInfo.ChannelList)
4034 {
4035 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4039 // networks, the 11b rates appear in the Operational Rate set. In either case,
4040 // we can blindly put the rates we support into our Operational Rate set
4041 // (including the basic rates, which we have already verified are supported
4042 // earlier in the roaming decision).
4043 if ( eCSR_BAND_5G == eBand )
4044 {
4045 // 11a rates into the Operational Rate Set.
4046 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4047 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304048 vos_mem_copy(OperationalRates,
4049 DefaultSupportedRates11a.supportedRateSet.rate,
4050 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051
4052 // Nothing in the Extended rate set.
4053 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 // populate proprietary rates if user allows them
4055 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4056 {
4057 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4058 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304059 vos_mem_copy(ProprietaryOperationalRates,
4060 DefaultSupportedPropRates.propRate,
4061 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
4063 else
4064 {
4065 // No proprietary modes
4066 ProprietaryOperationalRatesLength = 0;
4067 }
4068 }
4069 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4070 {
4071 // 11b rates into the Operational Rate Set.
4072 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4073 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304074 vos_mem_copy(OperationalRates,
4075 DefaultSupportedRates11b.supportedRateSet.rate,
4076 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 // Nothing in the Extended rate set.
4078 ExtendedOperationalRatesLength = 0;
4079 // No proprietary modes
4080 ProprietaryOperationalRatesLength = 0;
4081 }
4082 else
4083 {
4084 // 11G
4085
4086 // 11b rates into the Operational Rate Set.
4087 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4088 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304089 vos_mem_copy(OperationalRates,
4090 DefaultSupportedRates11b.supportedRateSet.rate,
4091 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004092
4093 // 11a rates go in the Extended rate set.
4094 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4095 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304096 vos_mem_copy(ExtendedOperationalRates,
4097 DefaultSupportedRates11a.supportedRateSet.rate,
4098 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004099
4100 // populate proprietary rates if user allows them
4101 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4102 {
4103 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4104 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304105 vos_mem_copy(ProprietaryOperationalRates,
4106 DefaultSupportedPropRates.propRate,
4107 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 }
4109 else
4110 {
4111 // No proprietary modes
4112 ProprietaryOperationalRatesLength = 0;
4113 }
4114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4116 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4117 {
4118 PropRatesEnable = 1;
4119 }
4120 else
4121 {
4122 PropRatesEnable = 0;
4123 }
4124
4125 // Set the operational rate set CFG variables...
4126 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4127 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4128 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4129 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4130 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4131 ProprietaryOperationalRates,
4132 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4133 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004134}
Jeff Johnson295189b2012-06-20 16:38:30 -07004135void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4136{
4137 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004138
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4140 tANI_U32 sessionId;
4141 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 if(NULL == pEntry)
4143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004144 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 return;
4146 }
4147 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4148 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304149 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4150 " current state : %d sub state : %d "),
4151 result, pMac->roam.curState[sessionId],
4152 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4154 {
4155 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4156 }
4157}
4158
Jeff Johnson295189b2012-06-20 16:38:30 -07004159//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4160tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4161{
4162 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4163 {
4164 return (WNI_CFG_PHY_MODE_11B);
4165 }
4166 else
4167 {
4168 if(eCSR_BAND_24 == band)
4169 return (WNI_CFG_PHY_MODE_11G);
4170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 return (WNI_CFG_PHY_MODE_11A);
4172}
Jeff Johnson295189b2012-06-20 16:38:30 -07004173
Jeff Johnsone7245742012-09-05 17:12:55 -07004174
4175#ifdef WLAN_FEATURE_11AC
4176ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4177{
4178 switch ( aniCBMode )
4179 {
4180 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4181 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4182 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4183 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4184 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4185 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4186 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4187 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4188 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004189 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004190 return PHY_SINGLE_CHANNEL_CENTERED;
4191 }
4192}
4193#endif
4194
Jeff Johnson295189b2012-06-20 16:38:30 -07004195//pIes may be NULL
4196eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4197 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304198 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004199{
4200 eHalStatus status = eHAL_STATUS_SUCCESS;
4201 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4202 tANI_U8 channel = 0;
4203 //Make sure we have the domain info for the BSS we try to connect to.
4204 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304205 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304207 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 {
4209 //Make sure the 11d info from this BSSDesc can be applied
4210 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304211 if (VOS_TRUE == resetCountry)
4212 {
4213 csrApplyCountryInformation(pMac, FALSE);
4214 }
4215 else
4216 {
4217 csrApplyCountryInformation(pMac, TRUE);
4218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 }
Kiran4a17ebe2013-01-31 10:43:43 -08004220 if ((csrIs11dSupported (pMac)) && pIes)
4221 {
4222 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004223 {
Kiran4a17ebe2013-01-31 10:43:43 -08004224 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004225 }
4226 else
4227 {
4228 //Let's also update the below to make sure we don't update CC while
4229 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304230 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004231 pBssDesc->bssId, sizeof(tSirMacAddr));
4232 }
Kiran4a17ebe2013-01-31 10:43:43 -08004233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 //Qos
4236 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4237 //SSID
4238 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4239 //fragment threshold
4240 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4241 //RTS threshold
4242 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4243
4244 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 //Auth type
4246 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4247 //encryption type
4248 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4249 //short slot time
4250 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 //11d
4252 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4253 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4254 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 /*//11h
4256 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4257 */
4258 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4259 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004260
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004261 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 {
4263 channel = pProfile->operationChannel;
4264 }
4265 else
4266 {
4267 if(pBssDesc)
4268 {
4269 channel = pBssDesc->channelId;
4270 }
4271 }
4272 if(0 != channel)
4273 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304274 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4275 !pMac->roam.configParam.channelBondingMode24GHz &&
4276 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4277 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304279 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4280 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4281 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 }
4283 else
4284 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004285 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 }
4287 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004288#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004289 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4290 // in function csrConvertCBIniValueToPhyCBState()
4291 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4292 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004293 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004294 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004295 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004296 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304297 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004298 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004299 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004300 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004301 }
4302 else
4303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4305 //Rate
4306 //Fixed Rate
4307 if(pBssDesc)
4308 {
4309 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4310 }
4311 else
4312 {
4313 csrSetCfgRateSetFromProfile(pMac, pProfile);
4314 }
4315 //Make this the last CFG to set. The callback will trigger a join_req
4316 //Join time out
4317 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4318
4319 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 return (status);
4321}
4322
Jeff Johnson295189b2012-06-20 16:38:30 -07004323eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4324 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4325{
4326 eHalStatus status;
4327 tBssConfigParam *pBssConfig;
4328 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004329
4330 if(!pSession)
4331 {
4332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4333 return eHAL_STATUS_FAILURE;
4334 }
4335
Kiet Lam64c1b492013-07-12 13:56:44 +05304336 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4337 if ( NULL == pBssConfig )
4338 status = eHAL_STATUS_FAILURE;
4339 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304341 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4343 if(HAL_STATUS_SUCCESS(status))
4344 {
4345 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004346 /* This will allow to pass cbMode during join req */
4347 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 //For IBSS, we need to prepare some more information
4349 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 )
4352 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004353 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 }
4355 // If we are in an IBSS, then stop the IBSS...
4356 ////Not worry about WDS connection for now
4357 if ( csrIsConnStateIbss( pMac, sessionId ) )
4358 {
4359 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4360 }
4361 else
4362 {
4363 // if we are in an Infrastructure association....
4364 if ( csrIsConnStateInfra( pMac, sessionId ) )
4365 {
4366 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4367 // across SSIDs (roaming to a new SSID)... //
4368 //Not worry about WDS connection for now
4369 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304370 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 {
4372 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304373 status = csrRoamIssueDisassociate( pMac, sessionId,
4374 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304376 else
4377 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4379 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304380 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304382 // Set parameters for this Bss.
4383 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4384 pBssDesc, pBssConfig,
4385 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304389 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 {
4391 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4392 // Nothing to stop.
4393 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304395 )
4396 {
4397 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4398 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4399 // Set parameters for this Bss.
4400 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4401 pBssDesc, pBssConfig,
4402 pIes, is11rRoamingFlag);
4403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 }
4405 }
4406 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304407 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 return (status);
4410}
4411
Jeff Johnson295189b2012-06-20 16:38:30 -07004412eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4413 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4414{
4415 eCsrJoinState eRoamState = eCsrContinueRoaming;
4416 eHalStatus status;
4417 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4418 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4419 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004420
4421 if(!pSession)
4422 {
4423 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4424 return (eCsrStopRoaming);
4425 }
4426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 if( CSR_IS_WDS_STA( pProfile ) )
4428 {
4429 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4430 if( !HAL_STATUS_SUCCESS( status ) )
4431 {
4432 eRoamState = eCsrStopRoaming;
4433 }
4434 }
4435 else
4436 {
4437 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4438 {
4439 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4440 return (eCsrStopRoaming);
4441 }
4442 if ( csrIsInfraBssDesc( pBssDesc ) )
4443 {
4444 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4445 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4446 // have changed and handle the changes (without disturbing the current association).
4447
4448 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4449 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4450 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4451 )
4452 {
4453 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4454 // with Authenticating first. To force this, stop the current association (Disassociate) and
4455 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4456 // a new Association.
4457 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4458 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004459 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4461 {
4462 eRoamState = eCsrReassocToSelfNoCapChange;
4463 }
4464 else
4465 {
4466 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304468 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4470 if(HAL_STATUS_SUCCESS(status))
4471 {
4472 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004473 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304475 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4476 pBssDesc, &bssConfig,
4477 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 if(!HAL_STATUS_SUCCESS(status))
4479 {
4480 eRoamState = eCsrStopRoaming;
4481 }
4482 }
4483 else
4484 {
4485 eRoamState = eCsrStopRoaming;
4486 }
4487 }//same profile
4488 }
4489 else
4490 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304491 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4493 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304494 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4495 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304499 }
4500 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 {
4502 // 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 -07004503 // stop the existing network before attempting to join the new network...
4504 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4505 {
4506 eRoamState = eCsrStopRoaming;
4507 }
4508 }
4509 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304510 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 {
4512 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4513 {
4514 eRoamState = eCsrStopRoaming;
4515 }
4516 }
4517 if( pIesLocal && !pScanResult->pvIes )
4518 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304519 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 }
4521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 return( eRoamState );
4523}
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4526 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4527{
4528 eHalStatus status = eHAL_STATUS_SUCCESS;
4529 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304530 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 roamInfo.pBssDesc = pBssDesc;
4532 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4533 return (status);
4534}
Jeff Johnson295189b2012-06-20 16:38:30 -07004535//In case no matching BSS is found, use whatever default we can find
4536static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4537{
4538 //Need to get all negotiated types in place first
4539 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004540 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 {
4542 default:
4543 case eCSR_AUTH_TYPE_WPA:
4544 case eCSR_AUTH_TYPE_WPA_PSK:
4545 case eCSR_AUTH_TYPE_WPA_NONE:
4546 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4547 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4548 break;
4549
4550 case eCSR_AUTH_TYPE_SHARED_KEY:
4551 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4552 break;
4553
4554 case eCSR_AUTH_TYPE_AUTOSWITCH:
4555 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4556 break;
4557 }
4558 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4559 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4560 //In this case, the multicast encryption needs to follow the uncast ones.
4561 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4562 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4563}
4564
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004565
4566static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4567{
4568 switch(pCommand->u.roamCmd.roamReason)
4569 {
4570 case eCsrLostLink1:
4571 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4572 break;
4573 case eCsrLostLink2:
4574 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4575 break;
4576 case eCsrLostLink3:
4577 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4578 break;
4579 default:
4580 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4581 pCommand->u.roamCmd.roamReason);
4582 break;
4583 }
4584}
4585
Jeff Johnson295189b2012-06-20 16:38:30 -07004586static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4587{
4588 eHalStatus status;
4589 tCsrScanResult *pScanResult = NULL;
4590 eCsrJoinState eRoamState = eCsrStopRoaming;
4591 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4592 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4593 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4594#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4595 v_U8_t acm_mask = 0;
4596#endif
4597 tANI_U32 sessionId = pCommand->sessionId;
4598 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4599 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4600 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004601
4602 if(!pSession)
4603 {
4604 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4605 return (eCsrStopRoaming);
4606 }
4607
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 do
4609 {
4610 // Check for Cardbus eject condition, before trying to Roam to any BSS
4611 //***if( !balIsCardPresent(pAdapter) ) break;
4612
Kiet Lam64c1b492013-07-12 13:56:44 +05304613 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304614 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 if(NULL != pBSSList)
4616 {
4617 // When handling AP's capability change, continue to associate to
4618 // same BSS and make sure pRoamBssEntry is not Null.
4619 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4620 {
4621 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4622 {
4623 //Try the first BSS
4624 pCommand->u.roamCmd.pLastRoamBss = NULL;
4625 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4626 }
4627 else
4628 {
4629 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4630 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4631 {
4632 //Done with all the BSSs
4633 //In this case, will tell HDD the completion
4634 break;
4635 }
4636 else
4637 {
4638 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304639 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4641 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4642 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4643 pRoamInfo = &roamInfo;
4644 }
4645 }
4646 while(pCommand->u.roamCmd.pRoamBssEntry)
4647 {
4648 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 /*If concurrency enabled take the concurrent connected channel first. */
4650 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304651 if (vos_concurrent_open_sessions_running() &&
4652 !csrIsValidMcConcurrentSession(pMac, sessionId,
4653 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 {
4655 concurrentChannel =
4656 csrGetConcurrentOperationChannel(pMac);
4657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004658 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 if ((concurrentChannel) &&
4660 (concurrentChannel ==
4661 pScanResult->Result.BssDescriptor.channelId))
4662 {
4663 //make this 0 because we do not want the
4664 //below check to pass as we don't want to
4665 //connect on other channel
4666 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4667 FL("Concurrent channel match =%d"),
4668 concurrentChannel);
4669 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 }
4671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004672
4673 if (!concurrentChannel)
4674 {
4675
4676 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4677 sessionId, &pScanResult->Result.BssDescriptor,
4678 pCommand->u.roamCmd.roamId)))
4679 {
4680 //Ok to roam this
4681 break;
4682 }
4683 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004684 else
4685 {
4686 eRoamState = eCsrStopRoamingDueToConcurrency;
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4689 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4690 {
4691 //Done with all the BSSs
4692 fDone = eANI_BOOLEAN_TRUE;
4693 break;
4694 }
4695 }
4696 if(fDone)
4697 {
4698 break;
4699 }
4700 }
4701 }
4702 //We have something to roam, tell HDD when it is infra.
4703 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4704 //For WDS, the indication is eCSR_ROAM_WDS_IND
4705 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4706 {
4707 if(pRoamInfo)
4708 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004709 if(pSession->bRefAssocStartCnt)
4710 {
4711 pSession->bRefAssocStartCnt--;
4712 //Complete the last association attemp because a new one is about to be tried
4713 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4714 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004716 }
4717 }
4718 /* If the roaming has stopped, not to continue the roaming command*/
4719 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4720 {
4721 //No need to complete roaming here as it already completes
4722 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4723 pCommand->u.roamCmd.roamReason);
4724 eRoamState = eCsrStopRoaming;
4725 csrSetAbortRoamingCommand(pMac, pCommand);
4726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304728 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 if(pScanResult)
4730 {
4731 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004732 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004734 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 fDone = eANI_BOOLEAN_TRUE;
4736 eRoamState = eCsrStopRoaming;
4737 break;
4738 }
4739 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4740 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4741 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4742 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4743 CSR_IS_QOS_BSS(pIesLocal) &&
4744 CSR_IS_UAPSD_BSS(pIesLocal) )
4745 {
4746#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4748 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004749#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 }
4751 else
4752 {
4753 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4754 }
4755 if( pIesLocal && !pScanResult->Result.pvIes)
4756 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304757 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 }
4759 }
4760 else
4761 {
4762 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4763 }
4764 roamInfo.pProfile = pProfile;
4765 pSession->bRefAssocStartCnt++;
4766 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4767 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4770 {
4771 // If this is a start IBSS profile, then we need to start the IBSS.
4772 if ( CSR_IS_START_IBSS(pProfile) )
4773 {
4774 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 // Attempt to start this IBSS...
4776 csrRoamAssignDefaultParam( pMac, pCommand );
4777 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4778 if(HAL_STATUS_SUCCESS(status))
4779 {
4780 if ( fSameIbss )
4781 {
4782 eRoamState = eCsrStartIbssSameIbss;
4783 }
4784 else
4785 {
4786 eRoamState = eCsrContinueRoaming;
4787 }
4788 }
4789 else
4790 {
4791 //it somehow fail need to stop
4792 eRoamState = eCsrStopRoaming;
4793 }
4794 break;
4795 }
4796 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 )
4799 {
4800 // Attempt to start this WDS...
4801 csrRoamAssignDefaultParam( pMac, pCommand );
4802 /* For AP WDS, we dont have any BSSDescription */
4803 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4804 if(HAL_STATUS_SUCCESS(status))
4805 {
4806 eRoamState = eCsrContinueRoaming;
4807 }
4808 else
4809 {
4810 //it somehow fail need to stop
4811 eRoamState = eCsrStopRoaming;
4812 }
4813 }
4814 else
4815 {
4816 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004817 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 eRoamState = eCsrStopRoaming;
4819 break;
4820 }
4821 }
4822 else //We have BSS
4823 {
4824 //Need to assign these value because they are used in csrIsSameProfile
4825 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004826 /* The OSEN IE doesn't provide the cipher suite.
4827 * Therefore set to constant value of AES */
4828 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4829 {
4830 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4831 eCSR_ENCRYPT_TYPE_AES;
4832 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4833 eCSR_ENCRYPT_TYPE_AES;
4834 }
4835 else
4836 {
4837 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4838 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4839 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4840 pScanResult->mcEncryptionType;
4841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4843 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4844 {
4845 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4846 {
4847 eRoamState = eCsrStartIbssSameIbss;
4848 break;
4849 }
4850 }
4851 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4852 {
4853 //trying to connect to the one already connected
4854 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4855 eRoamState = eCsrReassocToSelfNoCapChange;
4856 break;
4857 }
4858 // Attempt to Join this Bss...
4859 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4860 break;
4861 }
4862
4863 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4865 {
4866 //Need to indicate association_completion if association_start has been done
4867 if(pSession->bRefAssocStartCnt > 0)
4868 {
4869 pSession->bRefAssocStartCnt--;
4870 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004871 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4873 eCSR_ROAM_ASSOCIATION_COMPLETION,
4874 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4875 }
4876 }
4877
4878 return( eRoamState );
4879}
4880
Jeff Johnson295189b2012-06-20 16:38:30 -07004881static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4882{
4883 eHalStatus status = eHAL_STATUS_SUCCESS;
4884 eCsrJoinState RoamState;
4885 tANI_U32 sessionId = pCommand->sessionId;
4886
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 //***if( hddIsRadioStateOn( pAdapter ) )
4888 {
4889 // Attept to join a Bss...
4890 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004891
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004893 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 {
4895 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 // and if connected in Infrastructure mode...
4897 if ( csrIsConnStateInfra(pMac, sessionId) )
4898 {
4899 //... then we need to issue a disassociation
4900 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4901 if(!HAL_STATUS_SUCCESS(status))
4902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004903 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 //roam command is completed by caller in the failed case
4905 fComplete = eANI_BOOLEAN_TRUE;
4906 }
4907 }
4908 else if( csrIsConnStateIbss(pMac, sessionId) )
4909 {
4910 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4911 if(!HAL_STATUS_SUCCESS(status))
4912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004913 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 //roam command is completed by caller in the failed case
4915 fComplete = eANI_BOOLEAN_TRUE;
4916 }
4917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4919 {
4920 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4921 if(!HAL_STATUS_SUCCESS(status))
4922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004923 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 //roam command is completed by caller in the failed case
4925 fComplete = eANI_BOOLEAN_TRUE;
4926 }
4927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 else
4929 {
4930 fComplete = eANI_BOOLEAN_TRUE;
4931 }
4932 if(fComplete)
4933 {
4934 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004935 if(eCsrStopRoamingDueToConcurrency == RoamState)
4936 {
4937 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4938 }
4939 else
4940 {
4941 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 }
4944 }
4945 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4946 {
4947 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4948 }
4949 else if ( eCsrStartIbssSameIbss == RoamState )
4950 {
4951 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4952 }
4953 }//hddIsRadioStateOn
4954
4955 return status;
4956}
Jeff Johnson295189b2012-06-20 16:38:30 -07004957eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4958{
4959 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05304960 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 tCsrScanResult *pScanResult = NULL;
4962 tSirBssDescription *pBssDesc = NULL;
4963 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 sessionId = pCommand->sessionId;
4965 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004966
4967 if(!pSession)
4968 {
4969 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4970 return eHAL_STATUS_FAILURE;
4971 }
4972
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4974 {
4975 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004976 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4978 return eHAL_STATUS_FAILURE;
4979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 if (pCommand->u.roamCmd.pRoamBssEntry)
4981 {
4982 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4983 pBssDesc = &pScanResult->Result.BssDescriptor;
4984 }
4985 else
4986 {
4987 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004988 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4990 return eHAL_STATUS_FAILURE;
4991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4993 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4994 return status;
4995}
4996
Jeff Johnson295189b2012-06-20 16:38:30 -07004997eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4998{
4999 eHalStatus status = eHAL_STATUS_SUCCESS;
5000 tCsrRoamInfo roamInfo;
5001 tANI_U32 sessionId = pCommand->sessionId;
5002 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005003
5004 if(!pSession)
5005 {
5006 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5007 return eHAL_STATUS_FAILURE;
5008 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05305009 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5010 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 switch ( pCommand->u.roamCmd.roamReason )
5012 {
5013 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005015 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 case eCsrSmeIssuedDisassocForHandoff:
5018 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
5019#if 0 // TODO : Confirm this change
5020 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
5021#else
5022 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
5023#endif
5024
5025 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
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 eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005032 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 case eCsrHddIssuedReassocToSameAP:
5035 case eCsrSmeIssuedReassocToSameAP:
5036 {
5037 tDot11fBeaconIEs *pIes = NULL;
5038
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 if( pSession->pConnectBssDesc )
5040 {
5041 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5042 if(!HAL_STATUS_SUCCESS(status) )
5043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005044 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 }
5046 else
5047 {
5048 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5049 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5050 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5052 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5053 pSession->bRefAssocStartCnt++;
5054 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5055 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5056
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005057 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005058 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5059 &pCommand->u.roamCmd.roamProfile );
5060 if(!HAL_STATUS_SUCCESS(status))
5061 {
5062 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005063 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005064 }
5065
Kiet Lam64c1b492013-07-12 13:56:44 +05305066 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 pIes = NULL;
5068 }
5069 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305070 else
5071 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 break;
5073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005075 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5077 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5078 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005080 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5082 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005083
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 case eCsrStopBss:
5085 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5086 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5087 break;
5088
5089 case eCsrForcedDisassocSta:
5090 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5091 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5092 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5093 pCommand->u.roamCmd.reason);
5094 break;
5095
5096 case eCsrForcedDeauthSta:
5097 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5098 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5099 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5100 pCommand->u.roamCmd.reason);
5101 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005102
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005103 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005104 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005105 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5106 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005107 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005108
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305109#ifdef WLAN_FEATURE_LFR_MBB
5110 case ecsr_mbb_perform_preauth_reassoc:
5111 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5112 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5113 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305114 if (eHAL_STATUS_SUCCESS != status)
5115 {
5116 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5117 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5118 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5119 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305120 break;
5121#endif
5122
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 default:
5124 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5125
5126 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5127 {
5128 //Remember the roaming profile
5129 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305130 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5131 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305133 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5135 }
5136 }
5137
5138 //At this point, original uapsd_mask is saved in pCurRoamProfile
5139 //uapsd_mask in the pCommand may change from this point on.
5140
5141 // Attempt to roam with the new scan results (if we need to..)
5142 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005143 if(!HAL_STATUS_SUCCESS(status))
5144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005145 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 break;
5148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 return (status);
5150}
5151
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005152void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5153{
5154 pCommand->u.roamCmd.pLastRoamBss = NULL;
5155 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5156 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305157 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005158}
5159
Jeff Johnson295189b2012-06-20 16:38:30 -07005160void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5161{
5162 if(pCommand->u.roamCmd.fReleaseBssList)
5163 {
5164 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5165 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5166 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5167 }
5168 if(pCommand->u.roamCmd.fReleaseProfile)
5169 {
5170 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5171 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5172 }
5173 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5174 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305175 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005176}
5177
Jeff Johnson295189b2012-06-20 16:38:30 -07005178void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5179{
Kiet Lam64c1b492013-07-12 13:56:44 +05305180 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005181}
Jeff Johnson295189b2012-06-20 16:38:30 -07005182void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5183{
5184 tListElem *pEntry;
5185 tSmeCmd *pCommand;
5186 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005187 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5189 if ( pEntry )
5190 {
5191 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 // If the head of the queue is Active and it is a ROAM command, remove
5193 // and put this on the Free queue.
5194 if ( eSmeCommandRoam == pCommand->command )
5195 {
5196 //we need to process the result first before removing it from active list because state changes
5197 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5198 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5199 if( fReleaseCommand )
5200 {
5201 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5202 {
5203 csrReleaseCommandRoam( pMac, pCommand );
5204 }
5205 else
5206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005207 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005208 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 }
5210 }
5211 else
5212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005213 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005214 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 }
5216 }
5217 else
5218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005219 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 }
5221 }
5222 else
5223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005224 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 if( fReleaseCommand )
5227 {
5228 smeProcessPendingQueue( pMac );
5229 }
5230}
5231
Jeff Johnson295189b2012-06-20 16:38:30 -07005232void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5233{
5234 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005235 if(!pSession)
5236 {
5237 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5238 return;
5239 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305240 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5241 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 pSession->NumPmkidCandidate = 0;
5243}
Jeff Johnson295189b2012-06-20 16:38:30 -07005244#ifdef FEATURE_WLAN_WAPI
5245void csrResetBKIDCandidateList( 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->BkidCandidateInfo[0]),
5254 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 pSession->NumBkidCandidate = 0;
5256}
5257#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005258extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5259
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305260eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5261 tANI_U32 sessionId, eCsrAuthType authType,
5262 tSirBssDescription *pSirBssDesc,
5263 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005264{
5265 eHalStatus status = eHAL_STATUS_SUCCESS;
5266 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5267 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005268
5269 if(!pSession)
5270 {
5271 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5272 return eHAL_STATUS_FAILURE;
5273 }
5274
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 if((eCSR_AUTH_TYPE_WPA == authType) ||
5276 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5277 (eCSR_AUTH_TYPE_RSN == authType) ||
5278 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5279#if defined WLAN_FEATURE_VOWIFI_11R
5280 ||
5281 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5282 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5283#endif /* FEATURE_WLAN_WAPI */
5284#ifdef FEATURE_WLAN_WAPI
5285 ||
5286 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5287 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5288#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005289#ifdef WLAN_FEATURE_11W
5290 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305291 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5292 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005293#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 )
5295 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005298 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 }
5300 if( pIesLocal )
5301 {
5302 tANI_U32 nIeLen;
5303 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 if((eCSR_AUTH_TYPE_RSN == authType) ||
5305#if defined WLAN_FEATURE_VOWIFI_11R
5306 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5307 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5308#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005309#if defined WLAN_FEATURE_11W
5310 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305311 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005312#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5314 {
5315 if(pIesLocal->RSN.present)
5316 {
5317 //Calculate the actual length
5318 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5319 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5320 + 2 //akm_suite_count
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305321 + pIesLocal->RSN.akm_suite_cnt * 4 //akm_suites
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 + 2; //reserved
5323 if( pIesLocal->RSN.pmkid_count )
5324 {
5325 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5326 }
5327 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305328 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5329 if (NULL == pSession->pWpaRsnRspIE)
5330 status = eHAL_STATUS_FAILURE;
5331 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305333 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5335 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305336 //copy upto akm_suite
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305338 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5339 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005340 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305341 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5342 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005343 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305344 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5345 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005346 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 if( pIesLocal->RSN.pwise_cipher_suite_count )
5348 {
5349 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305350 vos_mem_copy(pIeBuf,
5351 pIesLocal->RSN.pwise_cipher_suites,
5352 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5354 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305355 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_cnt, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 pIeBuf += 2;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305357 if( pIesLocal->RSN.akm_suite_cnt )
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 {
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305359 //copy akm_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305360 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305361 pIesLocal->RSN.akm_suite,
5362 pIesLocal->RSN.akm_suite_cnt * 4);
5363 pIeBuf += pIesLocal->RSN.akm_suite_cnt * 4;
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 }
5365 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305366 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305367 pIesLocal->RSN.akm_suite + pIesLocal->RSN.akm_suite_cnt * 4,
Kiet Lam64c1b492013-07-12 13:56:44 +05305368 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5370 }
5371 }
5372 }
5373 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5374 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5375 {
5376 if(pIesLocal->WPA.present)
5377 {
5378 //Calculate the actual length
5379 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5380 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5381 + 2 //auth_suite_count
5382 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5383 // The WPA capabilities follows the Auth Suite (two octects)--
5384 // this field is optional, and we always "send" zero, so just
5385 // remove it. This is consistent with our assumptions in the
5386 // frames compiler; c.f. bug 15234:
5387 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305388
5389 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5390 if ( NULL == pSession->pWpaRsnRspIE )
5391 status = eHAL_STATUS_FAILURE;
5392 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 {
5394 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5395 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5396 pIeBuf = pSession->pWpaRsnRspIE + 2;
5397 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305398 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305400 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5401 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305403 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5404 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5406 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5407 }
5408 }
5409 }
5410#ifdef FEATURE_WLAN_WAPI
5411 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5412 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5413 {
5414 if(pIesLocal->WAPI.present)
5415 {
5416 //Calculate the actual length
5417 nIeLen = 4 //version + akm_suite_count
5418 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5419 + 2 //pwise_cipher_suite_count
5420 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5421 + 6; //gp_cipher_suite + preauth + reserved
5422 if( pIesLocal->WAPI.bkid_count )
5423 {
5424 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5425 }
5426
5427 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305428 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5429 if ( NULL == pSession->pWapiRspIE )
5430 status = eHAL_STATUS_FAILURE;
5431 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 {
5433 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5434 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5435 pIeBuf = pSession->pWapiRspIE + 2;
5436 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305437 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 pIeBuf += 4;
5439 if( pIesLocal->WAPI.akm_suite_count )
5440 {
5441 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305442 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5443 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305445 }
5446 vos_mem_copy(pIeBuf,
5447 &pIesLocal->WAPI.unicast_cipher_suite_count,
5448 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5451 {
5452 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305453 vos_mem_copy( pIeBuf,
5454 pIesLocal->WAPI.unicast_cipher_suites,
5455 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5457 }
lukez3c809222013-05-03 10:23:02 -07005458 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305459 vos_mem_copy(pIeBuf,
5460 pIesLocal->WAPI.multicast_cipher_suite,
5461 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005462 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305463 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305464 vos_mem_copy(pIeBuf,
5465 pIesLocal->WAPI.multicast_cipher_suite + 4,
5466 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005467 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305468 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305470 //bkid_count
5471 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5472 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305474 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5475 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5477 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305478 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 }
5481 }
5482#endif /* FEATURE_WLAN_WAPI */
5483 if( !pIes )
5484 {
5485 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305486 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 }
5488 }
5489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 return (status);
5491}
5492
Jeff Johnson295189b2012-06-20 16:38:30 -07005493static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5494{
5495 v_U8_t bACWeights[WLANTL_MAX_AC];
5496 v_U8_t paramBk, paramBe, paramVi, paramVo;
5497 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5499 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5500 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5501 //This doesn't address the case where the lower AC needs a real higher weight
5502 if( pIEs->WMMParams.present )
5503 {
5504 //no change to the lowest ones
5505 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5506 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5507 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5508 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5509 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5510 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5511 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5512 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5513 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5514 {
5515 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5516 fWeightChange = VOS_TRUE;
5517 }
5518 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5519 {
5520 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5521 fWeightChange = VOS_TRUE;
5522 }
5523 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5524 {
5525 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5526 fWeightChange = VOS_TRUE;
5527 }
5528 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5529 {
5530 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5531 fWeightChange = VOS_TRUE;
5532 }
5533 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5534 {
5535 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5536 fWeightChange = VOS_TRUE;
5537 }
5538 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5539 {
5540 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5541 fWeightChange = VOS_TRUE;
5542 }
5543 if(fWeightChange)
5544 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005545 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 bACWeights[2], bACWeights[3]);
5547 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5548 }
5549 }
5550}
Jeff Johnson295189b2012-06-20 16:38:30 -07005551#ifdef WLAN_FEATURE_VOWIFI_11R
5552//Returns whether the current association is a 11r assoc or not
5553tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5554{
5555#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5556 return csrNeighborRoamIs11rAssoc(pMac);
5557#else
5558 return eANI_BOOLEAN_FALSE;
5559#endif
5560}
5561#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005562#ifdef FEATURE_WLAN_ESE
5563//Returns whether the current association is a ESE assoc or not
5564tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005565{
5566#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005567 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005568#else
5569 return eANI_BOOLEAN_FALSE;
5570#endif
5571}
5572#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005573#ifdef FEATURE_WLAN_LFR
5574//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305575tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005576{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305577 tCsrRoamSession *pSession = NULL;
5578
5579 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5580 {
5581 pSession = CSR_GET_SESSION( pMac, sessionId );
5582 if (NULL != pSession->pCurRoamProfile)
5583 {
5584 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5585 {
5586 return eANI_BOOLEAN_FALSE;
5587 }
5588 }
5589 }
5590
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005591#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5592 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5593 {
5594 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5595 }
5596 else
5597#endif
5598 {
5599 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005600 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005601 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005602}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005603
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005604#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005605/* ---------------------------------------------------------------------------
5606
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005607 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005608
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005609 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005610
5611 \param pMac - The handle returned by macOpen.
5612
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005613 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005614
5615---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005616tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005617{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005618 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005619}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005620#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005621
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005622#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5623//Returns whether "FW based BG scan" is currently enabled...or not
5624tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5625{
5626 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5627}
5628#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005629#endif
5630
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005631#if defined(FEATURE_WLAN_ESE)
5632tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005633{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005634 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005635}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005636#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005637
Jeff Johnson295189b2012-06-20 16:38:30 -07005638//Return true means the command can be release, else not
5639static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5640 eCsrRoamCompleteResult Result, void *Context )
5641{
5642 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5643 tSirBssDescription *pSirBssDesc = NULL;
5644 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5645 tCsrScanResult *pScanResult = NULL;
5646 tCsrRoamInfo roamInfo;
5647 sme_QosAssocInfo assocInfo;
5648 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5649 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5650 tDot11fBeaconIEs *pIes = NULL;
5651 tANI_U32 sessionId = pCommand->sessionId;
5652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5653 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5654 eRoamCmdStatus roamStatus;
5655 eCsrRoamResult roamResult;
5656 eHalStatus status;
5657 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005659
Jeff Johnson32d95a32012-09-10 13:15:23 -07005660 if(!pSession)
5661 {
5662 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5663 return eANI_BOOLEAN_FALSE;
5664 }
5665
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005666 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 switch( Result )
5668 {
5669 case eCsrJoinSuccess:
5670 // reset the IDLE timer
5671 // !!
5672 // !! fall through to the next CASE statement here is intentional !!
5673 // !!
5674 case eCsrReassocSuccess:
5675 if(eCsrReassocSuccess == Result)
5676 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305677 roamInfo.reassoc = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5679 }
5680 else
5681 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305682 roamInfo.reassoc = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5684 }
5685 // Success Join Response from LIM. Tell NDIS we are connected and save the
5686 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005687 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305688 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 //always free the memory here
5690 if(pSession->pWpaRsnRspIE)
5691 {
5692 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305693 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 pSession->pWpaRsnRspIE = NULL;
5695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005696#ifdef FEATURE_WLAN_WAPI
5697 if(pSession->pWapiRspIE)
5698 {
5699 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305700 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 pSession->pWapiRspIE = NULL;
5702 }
5703#endif /* FEATURE_WLAN_WAPI */
5704#ifdef FEATURE_WLAN_BTAMP_UT_RF
5705 //Reset counter so no join retry is needed.
5706 pSession->maxRetryCount = 0;
5707 csrRoamStopJoinRetryTimer(pMac, sessionId);
5708#endif
5709 /* This creates problem since we have not saved the connected profile.
5710 So moving this after saving the profile
5711 */
5712 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305713
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305714 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305715 * by last failed secured connection.
5716 * It should be set only for secured connection.
5717 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305718 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5720 {
5721 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5722 }
5723 else
5724 {
5725 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 //Use the last connected bssdesc for reassoc-ing to the same AP.
5728 //NOTE: What to do when reassoc to a different AP???
5729 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5730 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5731 {
5732 pSirBssDesc = pSession->pConnectBssDesc;
5733 if(pSirBssDesc)
5734 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305735 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5736 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 }
5738 }
5739 else
5740 {
5741
5742 if(pCommand->u.roamCmd.pRoamBssEntry)
5743 {
5744 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5745 if(pScanResult != NULL)
5746 {
5747 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5748 //this can be NULL
5749 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305750 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5751 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 }
5753 }
5754 }
5755 if( pSirBssDesc )
5756 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5759 //Save WPA/RSN IE
5760 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005761#ifdef FEATURE_WLAN_ESE
5762 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005763#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305764#ifdef WLAN_FEATURE_VOWIFI_11R
5765 if (pSirBssDesc->mdiePresent)
5766 {
5767 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5768#ifdef FEATURE_WLAN_ESE
5769 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5770 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5771#endif
5772 )
5773 {
5774 // is11Rconnection;
5775 roamInfo.is11rAssoc = VOS_TRUE;
5776 }
5777 else
5778 {
5779 // is11Rconnection;
5780 roamInfo.is11rAssoc = VOS_FALSE;
5781 }
5782 }
5783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5785 // substate change.
5786 // Moving even save profile above so that below mentioned conditon is also met.
5787 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5788 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5790 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5791 // will be dropped for the security context may not be set properly.
5792 //
5793 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5794 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5795 //
5796 // this reordering was done on titan_prod_usb branch and is being replicated here.
5797 //
5798
5799 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5800 !pProfile->bWPSAssociation)
5801 {
5802 // Issue the set Context request to LIM to establish the Unicast STA context
5803 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5804 pProfile->negotiatedUCEncryptionType,
5805 pSirBssDesc, &(pSirBssDesc->bssId),
5806 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005808 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5810 }
5811 // Issue the set Context request to LIM to establish the Broadcast STA context
5812 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5813 pSirBssDesc, &BroadcastMac,
5814 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5815 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305816 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 {
5818 //Need to wait for supplicant authtication
5819 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 //Set the subestate to WaitForKey in case authentiation is needed
5821 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5822
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 if(pProfile->bWPSAssociation)
5824 {
5825 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5826 }
5827 else
5828 {
5829 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5830 }
5831
5832 //Save sessionId in case of timeout
5833 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5834 //This time should be long enough for the rest of the process plus setting key
5835 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5836 {
5837 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005838 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5840 }
5841 }
5842
5843 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5844 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 if(Context)
5846 {
5847 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5848 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5850 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5851#ifdef WLAN_FEATURE_VOWIFI_11R
5852 len += pJoinRsp->parsedRicRspLen;
5853#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005854#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 len += pJoinRsp->tspecIeLen;
5856#endif
5857 if(len)
5858 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305859 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5860 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305862 vos_mem_copy(pSession->connectedInfo.pbFrames,
5863 pJoinRsp->frames, len);
5864 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5865 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5866 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005867#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305868 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005870#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305871 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005872#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305873 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5874 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5875 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5876 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 }
5878 }
5879 if(pCommand->u.roamCmd.fReassoc)
5880 {
5881 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5882 }
5883 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5884 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5885 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5886 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305887 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305888 roamInfo.vht_caps = pJoinRsp->vht_caps;
5889 roamInfo.ht_caps = pJoinRsp->ht_caps;
5890 roamInfo.hs20vendor_ie = pJoinRsp->hs20vendor_ie;
5891 roamInfo.ht_operation = pJoinRsp->ht_operation;
5892 roamInfo.vht_operation = pJoinRsp->vht_operation;
5893
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 }
5895 else
5896 {
5897 if(pCommand->u.roamCmd.fReassoc)
5898 {
5899 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5900 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5901 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5902 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5903 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5904 }
5905 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305906 /* Update the staId from the previous connected profile info
5907 as the reassociation is triggred at SME/HDD */
5908 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5909 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5910 {
5911 roamInfo.staId = pSession->connectedInfo.staId;
5912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005913#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5914 // Indicate SME-QOS with reassoc success event, only after
5915 // copying the frames
5916 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 roamInfo.pBssDesc = pSirBssDesc;
5919 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5920 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5921#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5922 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5923#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5924 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5926 //It may be better to let QoS do this????
5927 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005929 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5931 pmcStartUapsd( pMac, NULL, NULL );
5932 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305933 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5935 if( pSession->bRefAssocStartCnt > 0 )
5936 {
5937 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005938 //Remove this code once SLM_Sessionization is supported
5939 //BMPS_WORKAROUND_NOT_NEEDED
5940 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005941 {
5942 pMac->roam.configParam.doBMPSWorkaround = 1;
5943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5945 }
5946
5947 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 // reset the PMKID candidate list
5949 csrResetPMKIDCandidateList( pMac, sessionId );
5950 //Update TL's AC weight base on the current EDCA parameters
5951 //These parameters may change in the course of the connection, that sictuation
5952 //is not taken care here. This change is mainly to address a WIFI WMM test where
5953 //BE has a equal or higher TX priority than VI.
5954 //We only do this for infra link
5955 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5956 {
5957 csrCheckAndUpdateACWeight(pMac, pIes);
5958 }
5959#ifdef FEATURE_WLAN_WAPI
5960 // reset the BKID candidate list
5961 csrResetBKIDCandidateList( pMac, sessionId );
5962#endif /* FEATURE_WLAN_WAPI */
5963 }
5964 else
5965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005966 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 csrScanCancelIdleScan(pMac);
5969 //Not to signal link up because keys are yet to be set.
5970 //The linkup function will overwrite the sub-state that we need to keep at this point.
5971 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5972 {
5973 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5976 //enough to let security and DHCP handshake succeed before entry into BMPS
5977 if (pmcShouldBmpsTimerRun(pMac))
5978 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305979 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05305980 * until keys are set before going into BMPS.
5981 */
5982 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5983 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305984 pMac->pmc.full_power_till_set_key = true;
5985 smsLog(pMac, LOG1,
5986 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 +05305987 }
5988
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5990 != eHAL_STATUS_SUCCESS)
5991 {
5992 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5993 }
5994 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 break;
5997
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 case eCsrStartBssSuccess:
5999 // on the StartBss Response, LIM is returning the Bss Description that we
6000 // are beaconing. Add this Bss Description to our scan results and
6001 // chain the Profile to this Bss Description. On a Start BSS, there was no
6002 // detected Bss description (no partner) so we issued the Start Bss to
6003 // start the Ibss without any Bss description. Lim was kind enough to return
6004 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006005 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05306008 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 if( CSR_IS_IBSS( pProfile ) )
6010 {
6011 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 else if (CSR_IS_INFRA_AP(pProfile))
6014 {
6015 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 else
6018 {
6019 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6020 }
6021 if( !CSR_IS_WDS_STA( pProfile ) )
6022 {
6023 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
6026 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306027 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 roamInfo.pBssDesc = pSirBssDesc;
6029 //We need to associate_complete it first, becasue Associate_start already indicated.
6030 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6031 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
6032 break;
6033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07006036 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 }
6038 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6039 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6040 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6041 if(pSirBssDesc)
6042 {
6043 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306044 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6045 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 }
6047 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306048 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006049#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6050 {
6051 vos_log_ibss_pkt_type *pIbssLog;
6052 tANI_U32 bi;
6053
6054 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6055 if(pIbssLog)
6056 {
6057 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6058 {
6059 //We start the IBSS (didn't find any matched IBSS out there)
6060 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6061 }
6062 else
6063 {
6064 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6065 }
6066 if(pSirBssDesc)
6067 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306068 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6070 }
6071 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6072 {
6073 //***U8 is not enough for beacon interval
6074 pIbssLog->beaconInterval = (v_U8_t)bi;
6075 }
6076 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6077 }
6078 }
6079#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6080 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6081 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6083 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6085 csrRoamIssueSetContextReq( pMac, sessionId,
6086 pProfile->negotiatedMCEncryptionType,
6087 pSirBssDesc, &BroadcastMac,
6088 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6089 }
6090 }
6091 else
6092 {
6093 //Keep the state to eCSR_ROAMING_STATE_JOINING
6094 //Need to send join_req.
6095 if(pCommand->u.roamCmd.pRoamBssEntry)
6096 {
6097 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6098 {
6099 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6100 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6101 // Set the roaming substate to 'join attempt'...
6102 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006103 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 }
6105 }
6106 else
6107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006108 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 VOS_ASSERT( 0 );
6110 }
6111 }
6112 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6113 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6114 //trigger the connection start indication in Vista
6115 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6116 {
6117 roamStatus = eCSR_ROAM_IBSS_IND;
6118 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6119 if( CSR_IS_WDS( pProfile ) )
6120 {
6121 roamStatus = eCSR_ROAM_WDS_IND;
6122 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 if( CSR_IS_INFRA_AP( pProfile ) )
6125 {
6126 roamStatus = eCSR_ROAM_INFRA_IND;
6127 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006129
6130 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6131 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6132 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306133 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6135 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006136 //We start the IBSS (didn't find any matched IBSS out there)
6137 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306139 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6140 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006141 //Remove this code once SLM_Sessionization is supported
6142 //BMPS_WORKAROUND_NOT_NEEDED
6143 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006144 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006145 {
6146 pMac->roam.configParam.doBMPSWorkaround = 1;
6147 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006148
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6150 }
6151
6152 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006153
6154 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 {
6156 //need to send stop BSS because we fail to send join_req
6157 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6158 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6159 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 case eCsrStartBssFailure:
6163#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6164 {
6165 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6167 if(pIbssLog)
6168 {
6169 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6170 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6171 }
6172 }
6173#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 roamStatus = eCSR_ROAM_IBSS_IND;
6175 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6176 if( CSR_IS_WDS( pProfile ) )
6177 {
6178 roamStatus = eCSR_ROAM_WDS_IND;
6179 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 if( CSR_IS_INFRA_AP( pProfile ) )
6182 {
6183 roamStatus = eCSR_ROAM_INFRA_IND;
6184 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 if(Context)
6187 {
6188 pSirBssDesc = (tSirBssDescription *)Context;
6189 }
6190 else
6191 {
6192 pSirBssDesc = NULL;
6193 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306194 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 roamInfo.pBssDesc = pSirBssDesc;
6196 //We need to associate_complete it first, becasue Associate_start already indicated.
6197 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6198 csrSetDefaultDot11Mode( pMac );
6199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 case eCsrSilentlyStopRoaming:
6201 // We are here because we try to start the same IBSS
6202 //No message to PE
6203 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006204 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6206 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
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 = pSession->pConnectBssDesc;
6209 if( roamInfo.pBssDesc )
6210 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306211 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6212 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 }
6214 //Since there is no change in the current state, simply pass back no result otherwise
6215 //HDD may be mistakenly mark to disconnected state.
6216 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6217 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 case eCsrSilentlyStopRoamingSaveState:
6220 //We are here because we try to connect to the same AP
6221 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006222 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306223 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006224
6225 //to aviod resetting the substate to NONE
6226 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6227 //No need to change substate to wai_for_key because there is no state change
6228 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6229 if( roamInfo.pBssDesc )
6230 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306231 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6232 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6235 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6236 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6237 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6238 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6239 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6240 roamInfo.staId = pSession->connectedInfo.staId;
6241 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 pSession->bRefAssocStartCnt--;
6244 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6245 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6246 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6247 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 case eCsrReassocFailure:
6249#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6250 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6251#endif
6252 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006253 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 csrFreeConnectBssDesc(pMac, sessionId);
6255 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6256 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306257 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6259 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6260 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6261 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6262 eCSR_ROAM_WDS_IND,
6263 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6264 //Need to issue stop_bss
6265 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 case eCsrJoinFailure:
6267 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006268 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 default:
6270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006271 smsLog(pMac, LOGW, FL("receives no association indication"));
6272 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006273 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6275 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6276 {
6277 //do not free for the other profiles as we need to send down stop BSS later
6278 csrFreeConnectBssDesc(pMac, sessionId);
6279 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6280 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6281 csrSetDefaultDot11Mode( pMac );
6282 }
6283
6284 switch( pCommand->u.roamCmd.roamReason )
6285 {
6286 // If this transition is because of an 802.11 OID, then we transition
6287 // back to INIT state so we sit waiting for more OIDs to be issued and
6288 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006289 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 case eCsrSmeIssuedAssocToSimilarAP:
6291 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006292 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306294 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6296 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6297 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306298 vos_mem_copy(&roamInfo.bssid,
6299 &pSession->joinFailStatusCode.bssId,
6300 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006301
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 /* Defeaturize this later if needed */
6303#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6304 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6305 if (csrRoamIsHandoffInProgress(pMac))
6306 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 /* Should indicate neighbor roam algorithm about the connect failure here */
6308 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006310#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 if(pSession->bRefAssocStartCnt > 0)
6312 {
6313 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006314 if(eCsrJoinFailureDueToConcurrency == Result)
6315 {
6316 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6317 eCSR_ROAM_ASSOCIATION_COMPLETION,
6318 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6319 }
6320 else
6321 {
6322 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 eCSR_ROAM_ASSOCIATION_COMPLETION,
6324 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006327 else
6328 {
6329 /* bRefAssocStartCnt is not incremented when
6330 * eRoamState == eCsrStopRoamingDueToConcurrency
6331 * in csrRoamJoinNextBss API. so handle this in
6332 * else case by sending assoc failure
6333 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006334 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006335 pCommand->u.scanCmd.roamId,
6336 eCSR_ROAM_ASSOCIATION_FAILURE,
6337 eCSR_ROAM_RESULT_FAILURE);
6338 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006339 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006340#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306341 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6343#endif
6344 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6345 csrScanStartIdleScan(pMac);
6346#ifdef FEATURE_WLAN_BTAMP_UT_RF
6347 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6348 //BT activity and not able to recevie WLAN traffic. Retry the join
6349 if( CSR_IS_WDS_STA(pProfile) )
6350 {
6351 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6352 }
6353#endif
6354 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 case eCsrHddIssuedReassocToSameAP:
6356 case eCsrSmeIssuedReassocToSameAP:
6357 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6358
6359 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6360#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6361 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6362#endif
6363 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6364 csrScanStartIdleScan(pMac);
6365 break;
6366 case eCsrForcedDisassoc:
6367 case eCsrForcedDeauth:
6368 case eCsrSmeIssuedIbssJoinFailure:
6369 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6370
6371 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6372 {
6373 // Notify HDD that IBSS join failed
6374 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6375 }
6376 else
6377 {
6378 csrRoamCallCallback(pMac, sessionId, NULL,
6379 pCommand->u.roamCmd.roamId,
6380 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6381 }
6382#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6383 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6384#endif
6385 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006386 /*
6387 *DelSta not done FW still in conneced state so dont
6388 *issue IMPS req
6389 */
6390 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6391 {
6392 smsLog(pMac, LOGW, FL("FW still in connected state "));
6393 break;
6394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 csrScanStartIdleScan(pMac);
6396 break;
6397 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306398 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 csrRoamCallCallback(pMac, sessionId, NULL,
6400 pCommand->u.roamCmd.roamId,
6401 eCSR_ROAM_IBSS_LEAVE,
6402 eCSR_ROAM_RESULT_IBSS_STOP);
6403 break;
6404 case eCsrForcedDisassocMICFailure:
6405 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6406
6407 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6408#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6409 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6410#endif
6411 csrScanStartIdleScan(pMac);
6412 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 case eCsrStopBss:
6414 csrRoamCallCallback(pMac, sessionId, NULL,
6415 pCommand->u.roamCmd.roamId,
6416 eCSR_ROAM_INFRA_IND,
6417 eCSR_ROAM_RESULT_INFRA_STOPPED);
6418 break;
6419 case eCsrForcedDisassocSta:
6420 case eCsrForcedDeauthSta:
6421 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306422 pSession = CSR_GET_SESSION(pMac, sessionId);
6423 if (pSession)
6424 {
6425 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306427 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6428 {
6429 roamInfo.u.pConnectedProfile =
6430 &pSession->connectedProfile;
6431 vos_mem_copy(roamInfo.peerMac,
6432 pCommand->u.roamCmd.peerMac,
6433 sizeof(tSirMacAddr));
6434 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6435 roamInfo.statusCode = eSIR_SME_SUCCESS;
6436 status = csrRoamCallCallback(pMac, sessionId,
6437 &roamInfo, pCommand->u.roamCmd.roamId,
6438 eCSR_ROAM_LOSTLINK,
6439 eCSR_ROAM_RESULT_FORCED);
6440 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306441 }
6442 else
6443 {
6444 smsLog(pMac, LOGE, FL("Inactive session %d"),
6445 sessionId);
6446 return eHAL_STATUS_FAILURE;
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306449 else
6450 {
6451 smsLog(pMac, LOGE, FL("Invalid session"));
6452 return eHAL_STATUS_FAILURE;
6453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 case eCsrLostLink1:
6456 // if lost link roam1 failed, then issue lost link Scan2 ...
6457 csrScanRequestLostLink2(pMac, sessionId);
6458 break;
6459 case eCsrLostLink2:
6460 // if lost link roam2 failed, then issue lost link scan3 ...
6461 csrScanRequestLostLink3(pMac, sessionId);
6462 break;
6463 case eCsrLostLink3:
6464 default:
6465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6466
6467 //We are done with one round of lostlink roaming here
6468 csrScanHandleFailedLostlink3(pMac, sessionId);
6469 break;
6470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 break;
6472 }
6473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 return ( fReleaseCommand );
6475}
6476
Jeff Johnson295189b2012-06-20 16:38:30 -07006477eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6478{
6479 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 return (status);
6481}
6482
Jeff Johnson295189b2012-06-20 16:38:30 -07006483eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6484{
6485 eHalStatus status = eHAL_STATUS_SUCCESS;
6486 tANI_U32 size = 0;
6487
6488 do
6489 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306490 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6492 {
6493 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306494 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6495 if ( NULL == pDstProfile->BSSIDs.bssid )
6496 status = eHAL_STATUS_FAILURE;
6497 else
6498 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 if(!HAL_STATUS_SUCCESS(status))
6500 {
6501 break;
6502 }
6503 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306504 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6505 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 }
6507 if(pSrcProfile->SSIDs.numOfSSIDs)
6508 {
6509 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306510 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6511 if ( NULL == pDstProfile->SSIDs.SSIDList )
6512 status = eHAL_STATUS_FAILURE;
6513 else
6514 status = eHAL_STATUS_SUCCESS;
6515 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 {
6517 break;
6518 }
6519 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306520 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6521 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 }
6523 if(pSrcProfile->nWPAReqIELength)
6524 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306525 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6526 if ( NULL == pDstProfile->pWPAReqIE )
6527 status = eHAL_STATUS_FAILURE;
6528 else
6529 status = eHAL_STATUS_SUCCESS;
6530
6531 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 {
6533 break;
6534 }
6535 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306536 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6537 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 }
6539 if(pSrcProfile->nRSNReqIELength)
6540 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306541 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6542 if ( NULL == pDstProfile->pRSNReqIE )
6543 status = eHAL_STATUS_FAILURE;
6544 else
6545 status = eHAL_STATUS_SUCCESS;
6546
6547 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 {
6549 break;
6550 }
6551 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306552 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6553 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 }
6555#ifdef FEATURE_WLAN_WAPI
6556 if(pSrcProfile->nWAPIReqIELength)
6557 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306558 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6559 if ( NULL == pDstProfile->pWAPIReqIE )
6560 status = eHAL_STATUS_FAILURE;
6561 else
6562 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 if(!HAL_STATUS_SUCCESS(status))
6564 {
6565 break;
6566 }
6567 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306568 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6569 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 }
6571#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 if(pSrcProfile->nAddIEScanLength)
6573 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306574 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6575 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306577 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306578 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306579 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6580 }
6581 else
6582 {
6583 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6584 FL(" AddIEScanLength is not valid %u"),
6585 pSrcProfile->nAddIEScanLength);
6586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 if(pSrcProfile->nAddIEAssocLength)
6589 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306590 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6591 if ( NULL == pDstProfile->pAddIEAssoc )
6592 status = eHAL_STATUS_FAILURE;
6593 else
6594 status = eHAL_STATUS_SUCCESS;
6595
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 if(!HAL_STATUS_SUCCESS(status))
6597 {
6598 break;
6599 }
6600 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306601 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6602 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 if(pSrcProfile->ChannelInfo.ChannelList)
6605 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306606 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6607 pSrcProfile->ChannelInfo.numOfChannels);
6608 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6609 status = eHAL_STATUS_FAILURE;
6610 else
6611 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 if(!HAL_STATUS_SUCCESS(status))
6613 {
6614 break;
6615 }
6616 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306617 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6618 pSrcProfile->ChannelInfo.ChannelList,
6619 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 pDstProfile->AuthType = pSrcProfile->AuthType;
6622 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6623 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6624 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6625 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6626 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006627#ifdef WLAN_FEATURE_11W
6628 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6629 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6630 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6631#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 pDstProfile->BSSType = pSrcProfile->BSSType;
6633 pDstProfile->phyMode = pSrcProfile->phyMode;
6634 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6635
6636#ifdef FEATURE_WLAN_WAPI
6637 if(csrIsProfileWapi(pSrcProfile))
6638 {
6639 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6640 {
6641 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6642 }
6643 }
6644#endif /* FEATURE_WLAN_WAPI */
6645 pDstProfile->CBMode = pSrcProfile->CBMode;
6646 /*Save the WPS info*/
6647 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006648 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 pDstProfile->privacy = pSrcProfile->privacy;
6652 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6653 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6654 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6655 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6656 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6657 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6658 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6659 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6660 pDstProfile->wps_state = pSrcProfile->wps_state;
6661 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Abhishek Singhe3beee22017-07-31 15:35:40 +05306662 pDstProfile->force_24ghz_in_ht20 =
6663 pSrcProfile->force_24ghz_in_ht20;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05306664 pDstProfile->force_rsne_override = pSrcProfile->force_rsne_override;
Kiet Lam64c1b492013-07-12 13:56:44 +05306665 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6666 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006667#ifdef WLAN_FEATURE_VOWIFI_11R
6668 if (pSrcProfile->MDID.mdiePresent)
6669 {
6670 pDstProfile->MDID.mdiePresent = 1;
6671 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6672 }
6673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 }while(0);
6675
6676 if(!HAL_STATUS_SUCCESS(status))
6677 {
6678 csrReleaseProfile(pMac, pDstProfile);
6679 pDstProfile = NULL;
6680 }
6681
6682 return (status);
6683}
Jeff Johnson295189b2012-06-20 16:38:30 -07006684eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6685{
6686 eHalStatus status = eHAL_STATUS_SUCCESS;
6687 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6688 do
6689 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306690 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 if(pSrcProfile->bssid)
6692 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306693 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6694 if ( NULL == pDstProfile->BSSIDs.bssid )
6695 status = eHAL_STATUS_FAILURE;
6696 else
6697 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 if(!HAL_STATUS_SUCCESS(status))
6699 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306700 smsLog( pMac, LOGE,
6701 FL("failed to allocate memory for BSSID"
6702 "%02x:%02x:%02x:%02x:%02x:%02x"),
6703 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6704 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 break;
6706 }
6707 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306708 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6709 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 }
6711 if(pSrcProfile->SSID.ssId)
6712 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306713 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6714 if ( NULL == pDstProfile->SSIDs.SSIDList )
6715 status = eHAL_STATUS_FAILURE;
6716 else
6717 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 if(!HAL_STATUS_SUCCESS(status))
6719 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306720 smsLog( pMac, LOGE,
6721 FL("failed to allocate memory for SSIDList"
6722 "%02x:%02x:%02x:%02x:%02x:%02x"),
6723 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6724 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 break;
6726 }
6727 pDstProfile->SSIDs.numOfSSIDs = 1;
6728 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6729 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306730 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6731 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006733 if(pSrcProfile->nAddIEAssocLength)
6734 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306735 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6736 if ( NULL == pDstProfile->pAddIEAssoc)
6737 status = eHAL_STATUS_FAILURE;
6738 else
6739 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006740 if(!HAL_STATUS_SUCCESS(status))
6741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006742 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006743 break;
6744 }
6745 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306746 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6747 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006748 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306749 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6750 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6751 status = eHAL_STATUS_FAILURE;
6752 else
6753 status = eHAL_STATUS_SUCCESS;
6754
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 if(!HAL_STATUS_SUCCESS(status))
6756 {
6757 break;
6758 }
6759 pDstProfile->ChannelInfo.numOfChannels = 1;
6760 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 pDstProfile->AuthType.numEntries = 1;
6762 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6763 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6764 pDstProfile->EncryptionType.numEntries = 1;
6765 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6766 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6767 pDstProfile->mcEncryptionType.numEntries = 1;
6768 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6769 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6770 pDstProfile->BSSType = pSrcProfile->BSSType;
6771 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306772 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6773 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306774#ifdef WLAN_FEATURE_11W
6775 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6776 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6777 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6778#endif
6779
Jeff Johnson295189b2012-06-20 16:38:30 -07006780#ifdef WLAN_FEATURE_VOWIFI_11R
6781 if (pSrcProfile->MDID.mdiePresent)
6782 {
6783 pDstProfile->MDID.mdiePresent = 1;
6784 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6785 }
6786#endif
6787
6788 }while(0);
6789
6790 if(!HAL_STATUS_SUCCESS(status))
6791 {
6792 csrReleaseProfile(pMac, pDstProfile);
6793 pDstProfile = NULL;
6794 }
6795
6796 return (status);
6797}
6798
Jeff Johnson295189b2012-06-20 16:38:30 -07006799eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6800 tScanResultHandle hBSSList,
6801 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6802 tANI_BOOLEAN fClearScan)
6803{
6804 eHalStatus status = eHAL_STATUS_SUCCESS;
6805 tSmeCmd *pCommand;
6806
6807 pCommand = csrGetCommandBuffer(pMac);
6808 if(NULL == pCommand)
6809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006810 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 status = eHAL_STATUS_RESOURCES;
6812 }
6813 else
6814 {
6815 if( fClearScan )
6816 {
6817 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306818 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 }
6820 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6821 if(NULL == pProfile)
6822 {
6823 //We can roam now
6824 //Since pProfile is NULL, we need to build our own profile, set everything to default
6825 //We can only support open and no encryption
6826 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6827 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6828 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6829 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6830 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6831 }
6832 else
6833 {
6834 //make a copy of the profile
6835 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6836 if(HAL_STATUS_SUCCESS(status))
6837 {
6838 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6839 }
6840 }
6841 pCommand->command = eSmeCommandRoam;
6842 pCommand->sessionId = (tANI_U8)sessionId;
6843 pCommand->u.roamCmd.hBSSList = hBSSList;
6844 pCommand->u.roamCmd.roamId = roamId;
6845 pCommand->u.roamCmd.roamReason = reason;
6846 //We need to free the BssList when the command is done
6847 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6848 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6850 FL("CSR PERSONA=%d"),
6851 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6853 if( !HAL_STATUS_SUCCESS( status ) )
6854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006855 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 csrReleaseCommandRoam( pMac, pCommand );
6857 }
6858 }
6859
6860 return (status);
6861}
Jeff Johnson295189b2012-06-20 16:38:30 -07006862eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6863 tCsrRoamModifyProfileFields *pMmodProfileFields,
6864 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6865{
6866 eHalStatus status = eHAL_STATUS_SUCCESS;
6867 tSmeCmd *pCommand;
6868
6869 pCommand = csrGetCommandBuffer(pMac);
6870 if(NULL == pCommand)
6871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006872 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 status = eHAL_STATUS_RESOURCES;
6874 }
6875 else
6876 {
6877 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306878 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 if(pProfile)
6880 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006881 //This is likely trying to reassoc to different profile
6882 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6883 //make a copy of the profile
6884 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6885 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 }
6887 else
6888 {
6889 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6890 //how to update WPA/WPA2 info in roamProfile??
6891 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006893 if(HAL_STATUS_SUCCESS(status))
6894 {
6895 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6896 }
6897 pCommand->command = eSmeCommandRoam;
6898 pCommand->sessionId = (tANI_U8)sessionId;
6899 pCommand->u.roamCmd.roamId = roamId;
6900 pCommand->u.roamCmd.roamReason = reason;
6901 //We need to free the BssList when the command is done
6902 //For reassoc there is no BSS list, so the boolean set to false
6903 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6904 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6905 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6907 if( !HAL_STATUS_SUCCESS( status ) )
6908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006909 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6911 csrReleaseCommandRoam( pMac, pCommand );
6912 }
6913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 return (status);
6915}
6916
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006917eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6918 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306919// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006920{
6921 eHalStatus status = eHAL_STATUS_SUCCESS;
6922 tSmeCmd *pCommand;
6923
6924 pCommand = csrGetCommandBuffer(pMac);
6925 if(NULL == pCommand)
6926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006927 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006928 status = eHAL_STATUS_RESOURCES;
6929 }
6930 else
6931 {
6932 if(pBssDescription)
6933 {
6934 //copy over the parameters we need later
6935 pCommand->command = eSmeCommandRoam;
6936 pCommand->sessionId = (tANI_U8)sessionId;
6937 pCommand->u.roamCmd.roamReason = reason;
6938 //this is the important parameter
6939 //in this case we are using this field for the "next" BSS
6940 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6941 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6942 if( !HAL_STATUS_SUCCESS( status ) )
6943 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006944 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006945 csrReleaseCommandPreauth( pMac, pCommand );
6946 }
6947 }
6948 else
6949 {
6950 //Return failure
6951 status = eHAL_STATUS_RESOURCES;
6952 }
6953 }
6954 return (status);
6955}
6956
6957eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6958{
6959 tListElem *pEntry;
6960 tSmeCmd *pCommand;
6961 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6962 if ( pEntry )
6963 {
6964 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6965 if ( (eSmeCommandRoam == pCommand->command) &&
6966 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6967 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006968 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006969 pCommand->command, pCommand->u.roamCmd.roamReason);
6970 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6971 csrReleaseCommandPreauth( pMac, pCommand );
6972 }
6973 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006974 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006975 pCommand->command, pCommand->u.roamCmd.roamReason);
6976 }
6977 }
6978 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006979 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006980 }
6981 smeProcessPendingQueue( pMac );
6982 return eHAL_STATUS_SUCCESS;
6983}
6984
Jeff Johnson295189b2012-06-20 16:38:30 -07006985eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6986 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6987{
6988 eHalStatus status = eHAL_STATUS_FAILURE;
6989 tScanResultHandle hBSSList;
6990 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6992 if(HAL_STATUS_SUCCESS(status))
6993 {
6994 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6995 if(pRoamId)
6996 {
6997 *pRoamId = roamId;
6998 }
6999 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7000 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7001 if(!HAL_STATUS_SUCCESS(status))
7002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007003 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 csrScanResultPurge(pMac, hBSSList);
7005 }
7006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 return (status);
7008}
7009
Jeff Johnson295189b2012-06-20 16:38:30 -07007010eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7011 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7012{
7013 eHalStatus status = eHAL_STATUS_SUCCESS;
7014 tScanResultHandle hBSSList;
7015 tCsrScanResultFilter *pScanFilter;
7016 tANI_U32 roamId = 0;
7017 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
7018 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 if (NULL == pProfile)
7020 {
7021 smsLog(pMac, LOGP, FL("No profile specified"));
7022 return eHAL_STATUS_FAILURE;
7023 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307024 if(!pSession)
7025 {
7026 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7027 return eHAL_STATUS_FAILURE;
7028 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307029 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7030 "encryType = %d"),
7031 lim_BssTypetoString(pProfile->BSSType),
7032 pProfile->BSSType,
7033 pProfile->AuthType.authType[0],
7034 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 if( CSR_IS_WDS( pProfile ) &&
7036 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
7037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007038 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007039 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 return status;
7041 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307042 /* Reset abortConnection for the fresh connection */
7043 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 csrRoamCancelRoaming(pMac, sessionId);
7045 csrScanRemoveFreshScanCommand(pMac, sessionId);
7046 csrScanCancelIdleScan(pMac);
7047 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307048 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307049
7050 if (!vos_concurrent_open_sessions_running() &&
7051 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307053 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 csrScanDisable(pMac);
7055 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307056
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7058 //Check whether ssid changes
7059 if(csrIsConnStateConnected(pMac, sessionId))
7060 {
7061 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7062 {
7063 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7064 }
7065 }
7066#ifdef FEATURE_WLAN_BTAMP_UT_RF
7067 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7068#endif
Abhishek Singh5de9efd2017-06-15 10:22:39 +05307069
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007072 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7074 if(pRoamId)
7075 {
7076 roamId = *pRoamId;
7077 }
7078 if(!HAL_STATUS_SUCCESS(status))
7079 {
7080 fCallCallback = eANI_BOOLEAN_TRUE;
7081 }
7082 }
7083 else
7084 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307085 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7086 if ( NULL == pScanFilter )
7087 status = eHAL_STATUS_FAILURE;
7088 else
7089 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 if(HAL_STATUS_SUCCESS(status))
7091 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307092 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 //Try to connect to any BSS
7094 if(NULL == pProfile)
7095 {
7096 //No encryption
7097 pScanFilter->EncryptionType.numEntries = 1;
7098 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7099 }//we don't have a profile
7100 else
7101 {
7102 //Here is the profile we need to connect to
7103 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7104 }//We have a profile
7105 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7106 if(pRoamId)
7107 {
7108 *pRoamId = roamId;
7109 }
7110
7111 if(HAL_STATUS_SUCCESS(status))
7112 {
7113 /*Save the WPS info*/
7114 if(NULL != pProfile)
7115 {
7116 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007117 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 }
7119 else
7120 {
7121 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007122 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 do
7125 {
7126 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 )
7129 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007130 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7132 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7133 if(!HAL_STATUS_SUCCESS(status))
7134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007135 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 fCallCallback = eANI_BOOLEAN_TRUE;
7137 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007138 else
7139 {
7140 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 break;
7143 }
7144 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007145 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 if(HAL_STATUS_SUCCESS(status))
7147 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7149 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7150 if(!HAL_STATUS_SUCCESS(status))
7151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007152 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 csrScanResultPurge(pMac, hBSSList);
7154 fCallCallback = eANI_BOOLEAN_TRUE;
7155 }
7156 }//Have scan result
7157 else if(NULL != pProfile)
7158 {
7159 //Check whether it is for start ibss
7160 if(CSR_IS_START_IBSS(pProfile))
7161 {
7162 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7163 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7164 if(!HAL_STATUS_SUCCESS(status))
7165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007166 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 fCallCallback = eANI_BOOLEAN_TRUE;
7168 }
7169 }
7170 else
7171 {
7172 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007173 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 if(!HAL_STATUS_SUCCESS(status))
7175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007176 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 fCallCallback = eANI_BOOLEAN_TRUE;
7178 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007179 else
7180 {
7181 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 }
7184 }
7185 else
7186 {
7187 fCallCallback = eANI_BOOLEAN_TRUE;
7188 }
7189 } while (0);
7190 if(NULL != pProfile)
7191 {
7192 //we need to free memory for filter if profile exists
7193 csrFreeScanFilter(pMac, pScanFilter);
7194 }
7195 }//Got the scan filter from profile
7196
Kiet Lam64c1b492013-07-12 13:56:44 +05307197 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 }//allocated memory for pScanFilter
7199 }//No Bsslist coming in
7200 //tell the caller if we fail to trigger a join request
7201 if( fCallCallback )
7202 {
7203 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7204 }
7205
7206 return (status);
7207}
Jeff Johnson295189b2012-06-20 16:38:30 -07007208eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7209 tCsrRoamModifyProfileFields modProfileFields,
7210 tANI_U32 *pRoamId)
7211{
7212 eHalStatus status = eHAL_STATUS_SUCCESS;
7213 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7214 tANI_U32 roamId = 0;
7215 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 if (NULL == pProfile)
7217 {
7218 smsLog(pMac, LOGP, FL("No profile specified"));
7219 return eHAL_STATUS_FAILURE;
7220 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307221 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7222 "encryType = %d"),
7223 lim_BssTypetoString(pProfile->BSSType),
7224 pProfile->BSSType,
7225 pProfile->AuthType.authType[0],
7226 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 csrRoamCancelRoaming(pMac, sessionId);
7228 csrScanRemoveFreshScanCommand(pMac, sessionId);
7229 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307230 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 if(csrIsConnStateConnected(pMac, sessionId))
7233 {
7234 if(pProfile)
7235 {
7236 if(pProfile->SSIDs.numOfSSIDs &&
7237 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7238 {
7239 fCallCallback = eANI_BOOLEAN_FALSE;
7240 }
7241 else
7242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007243 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 }
7245 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307246 else if (!vos_mem_compare(&modProfileFields,
7247 &pSession->connectedProfile.modifyProfileFields,
7248 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 {
7250 fCallCallback = eANI_BOOLEAN_FALSE;
7251 }
7252 else
7253 {
7254 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007255 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 }
7257 }
7258 else
7259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007260 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 if(!fCallCallback)
7263 {
7264 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7265 if(pRoamId)
7266 {
7267 *pRoamId = roamId;
7268 }
7269
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7271 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 }
7273 else
7274 {
7275 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7276 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 return status;
7279}
Jeff Johnson295189b2012-06-20 16:38:30 -07007280eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7281{
7282 eHalStatus status = eHAL_STATUS_FAILURE;
7283 tScanResultHandle hBSSList = NULL;
7284 tCsrScanResultFilter *pScanFilter = NULL;
7285 tANI_U32 roamId;
7286 tCsrRoamProfile *pProfile = NULL;
7287 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007288
7289 if(!pSession)
7290 {
7291 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7292 return eHAL_STATUS_FAILURE;
7293 }
7294
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 do
7296 {
7297 if(pSession->pCurRoamProfile)
7298 {
7299 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307300 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307302 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7303 if ( NULL == pProfile )
7304 status = eHAL_STATUS_FAILURE;
7305 else
7306 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 if(!HAL_STATUS_SUCCESS(status))
7308 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307309 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307311 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307313 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7314 if ( NULL == pScanFilter )
7315 status = eHAL_STATUS_FAILURE;
7316 else
7317 status = eHAL_STATUS_SUCCESS;
7318
Jeff Johnson295189b2012-06-20 16:38:30 -07007319 if(!HAL_STATUS_SUCCESS(status))
7320 {
7321 break;
7322 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307323 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7325 if(!HAL_STATUS_SUCCESS(status))
7326 {
7327 break;
7328 }
7329 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7330 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7331 if(HAL_STATUS_SUCCESS(status))
7332 {
7333 //we want to put the last connected BSS to the very beginning, if possible
7334 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7335 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7336 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7337 if(!HAL_STATUS_SUCCESS(status))
7338 {
7339 csrScanResultPurge(pMac, hBSSList);
7340 break;
7341 }
7342 }
7343 else
7344 {
7345 //Do a scan on this profile
7346 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007347 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if(!HAL_STATUS_SUCCESS(status))
7349 {
7350 break;
7351 }
7352 }
7353 }//We have a profile
7354 else
7355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007356 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007357 break;
7358 }
7359 }while(0);
7360 if(pScanFilter)
7361 {
7362 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307363 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 }
7365 if(NULL != pProfile)
7366 {
7367 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307368 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 return (status);
7371}
Jeff Johnson295189b2012-06-20 16:38:30 -07007372eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7373{
7374 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 if(csrIsConnStateConnected(pMac, sessionId))
7376 {
7377 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7378 if(HAL_STATUS_SUCCESS(status))
7379 {
7380 status = csrRoamJoinLastProfile(pMac, sessionId);
7381 }
7382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 return (status);
7384}
7385
Jeff Johnson295189b2012-06-20 16:38:30 -07007386eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7387{
7388 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007389 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 csrRoamCancelRoaming(pMac, sessionId);
7391 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7392 if(csrIsConnStateDisconnected(pMac, sessionId))
7393 {
7394 status = csrRoamJoinLastProfile(pMac, sessionId);
7395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 return (status);
7397}
7398
Jeff Johnson295189b2012-06-20 16:38:30 -07007399eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7400{
7401 eHalStatus status = eHAL_STATUS_SUCCESS;
7402 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7403 eCsrRoamSubState NewSubstate;
7404 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307405
7406 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7407 {
7408 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7409 " eCSR_ROAM_SUBSTATE_NONE"));
7410 csrRoamStopWaitForKeyTimer( pMac );
7411 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 // change state to 'Roaming'...
7414 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7415
7416 if ( csrIsConnStateIbss( pMac, sessionId ) )
7417 {
7418 // If we are in an IBSS, then stop the IBSS...
7419 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7420 fComplete = (!HAL_STATUS_SUCCESS(status));
7421 }
7422 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007424 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 -07007425 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7426 //Restore AC weight in case we change it
7427 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7428 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7429 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7430 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7431 {
7432 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7433 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307434 else
7435 {
7436 // If we are in neighbor preauth done state then on receiving
7437 // disassoc or deauth we dont roam instead we just disassoc
7438 // from current ap and then go to disconnected state
7439 // This happens for ESE and 11r FT connections ONLY.
7440#ifdef WLAN_FEATURE_VOWIFI_11R
7441 if (csrRoamIs11rAssoc(pMac) &&
7442 (csrNeighborRoamStatePreauthDone(pMac)))
7443 {
7444 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7445 }
7446#endif
7447#ifdef FEATURE_WLAN_ESE
7448 if (csrRoamIsESEAssoc(pMac) &&
7449 (csrNeighborRoamStatePreauthDone(pMac)))
7450 {
7451 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7452 }
7453#endif
7454#ifdef FEATURE_WLAN_LFR
7455 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7456 (csrNeighborRoamStatePreauthDone(pMac)))
7457 {
7458 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7459 }
7460#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307461#ifdef WLAN_FEATURE_LFR_MBB
7462 csr_stop_preauth_reassoc_mbb_timer(pMac);
7463#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307464 }
7465
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 if( fDisassoc )
7467 {
7468 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307469 if (pMac->roam.configParam.roamDelayStatsEnabled)
7470 {
7471 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 }
7474 else
7475 {
7476 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7477 }
7478 fComplete = (!HAL_STATUS_SUCCESS(status));
7479 }
7480 else if ( csrIsConnStateWds( pMac, sessionId ) )
7481 {
7482 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7483 {
7484 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7485 fComplete = (!HAL_STATUS_SUCCESS(status));
7486 }
7487 //This has to be WDS station
7488 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7489 {
7490
7491 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7492 if( fDisassoc )
7493 {
7494 status = csrRoamIssueDisassociate( pMac, sessionId,
7495 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7496 fComplete = (!HAL_STATUS_SUCCESS(status));
7497 }
7498 }
7499 } else {
7500 // we got a dis-assoc request while not connected to any peer
7501 // just complete the command
7502 fComplete = eANI_BOOLEAN_TRUE;
7503 status = eHAL_STATUS_FAILURE;
7504 }
7505 if(fComplete)
7506 {
7507 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7508 }
7509
7510 if(HAL_STATUS_SUCCESS(status))
7511 {
7512 if ( csrIsConnStateInfra( pMac, sessionId ) )
7513 {
7514 //Set the state to disconnect here
7515 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307516#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7517 //we don't need to run this timer any more
7518 if (VOS_TIMER_STATE_RUNNING ==
7519 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7520 {
7521 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7522 if (status != eHAL_STATUS_SUCCESS)
7523 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7524 }
7525#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 }
7527 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007528 else
7529 {
7530 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007532 return (status);
7533}
7534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535/* This is been removed from latest code base */
7536/*
7537static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7538{
7539 eHalStatus status;
7540 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7542 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 return ( status );
7544}
7545*/
7546
Jeff Johnson295189b2012-06-20 16:38:30 -07007547eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7548{
7549 eHalStatus status = eHAL_STATUS_SUCCESS;
7550 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307551
Jeff Johnson295189b2012-06-20 16:38:30 -07007552 do
7553 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 pCommand = csrGetCommandBuffer( pMac );
7555 if ( !pCommand )
7556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007557 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 status = eHAL_STATUS_RESOURCES;
7559 break;
7560 }
7561 //Change the substate in case it is wait-for-key
7562 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7563 {
7564 csrRoamStopWaitForKeyTimer( pMac );
7565 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7566 }
7567 pCommand->command = eSmeCommandRoam;
7568 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307569 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7570 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 switch ( reason )
7572 {
7573 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7574 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 case eCSR_DISCONNECT_REASON_DEAUTH:
7577 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7581 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7583 case eCSR_DISCONNECT_REASON_DISASSOC:
7584 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7587 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7590 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 default:
7593 break;
7594 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307595 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 if( !HAL_STATUS_SUCCESS( status ) )
7597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007598 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 csrReleaseCommandRoam( pMac, pCommand );
7600 }
7601 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 return( status );
7603}
7604
Jeff Johnson295189b2012-06-20 16:38:30 -07007605eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7606{
7607 eHalStatus status = eHAL_STATUS_SUCCESS;
7608 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 pCommand = csrGetCommandBuffer( pMac );
7610 if ( NULL != pCommand )
7611 {
7612 //Change the substate in case it is wait-for-key
7613 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7614 {
7615 csrRoamStopWaitForKeyTimer( pMac );
7616 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7617 }
7618 pCommand->command = eSmeCommandRoam;
7619 pCommand->sessionId = (tANI_U8)sessionId;
7620 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7621 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7622 if( !HAL_STATUS_SUCCESS( status ) )
7623 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007624 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 csrReleaseCommandRoam( pMac, pCommand );
7626 }
7627 }
7628 else
7629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007630 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 status = eHAL_STATUS_RESOURCES;
7632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 return ( status );
7634}
7635
Jeff Johnson295189b2012-06-20 16:38:30 -07007636eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7637{
7638 eHalStatus status = eHAL_STATUS_SUCCESS;
7639 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007640
7641 if(!pSession)
7642 {
7643 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7644 return eHAL_STATUS_FAILURE;
7645 }
7646
Jeff Johnson295189b2012-06-20 16:38:30 -07007647#ifdef FEATURE_WLAN_BTAMP_UT_RF
7648 //Stop te retry
7649 pSession->maxRetryCount = 0;
7650 csrRoamStopJoinRetryTimer(pMac, sessionId);
7651#endif
7652 //Not to call cancel roaming here
7653 //Only issue disconnect when necessary
7654 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7655 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7656 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7657
7658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007659 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7661 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307662 else
7663 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307664 csrScanAbortScanForSSID(pMac, sessionId);
Mukul Sharma11841b42017-07-05 13:10:09 +05307665 csrScanStartIdleScan(pMac);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307666 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307667 smsLog(pMac, LOGE,
7668 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 return (status);
7671}
7672
Jeff Johnson295189b2012-06-20 16:38:30 -07007673eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7674{
7675 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007676
7677 if(!pSession)
7678 {
7679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7680 return eHAL_STATUS_FAILURE;
7681 }
7682
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7685
7686 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7687}
7688
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307689void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7690{
7691 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7692 if(!pSession)
7693 {
7694 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7695 return;
7696 }
7697 pSession->abortConnection = TRUE;
7698 return;
7699}
7700
Jeff Johnson295189b2012-06-20 16:38:30 -07007701eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7702 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7703{
7704 eHalStatus status = eHAL_STATUS_SUCCESS;
7705 tDot11fBeaconIEs *pIesTemp = pIes;
7706 tANI_U8 index;
7707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7708 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007709
7710 if(!pSession)
7711 {
7712 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7713 return eHAL_STATUS_FAILURE;
7714 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007715 if(pConnectProfile->pAddIEAssoc)
7716 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307717 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007718 pConnectProfile->pAddIEAssoc = NULL;
7719 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307720 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7722 pConnectProfile->AuthInfo = pProfile->AuthType;
7723 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7724 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7725 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7726 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7727 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7728 pConnectProfile->BSSType = pProfile->BSSType;
7729 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7730 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007731 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307732 if (!pConnectProfile->beaconInterval)
7733 {
7734 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7735 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307736 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007737 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7738 if(pProfile->nAddIEAssocLength)
7739 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307740 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7741 if ( NULL == pConnectProfile->pAddIEAssoc )
7742 status = eHAL_STATUS_FAILURE;
7743 else
7744 status = eHAL_STATUS_SUCCESS;
7745 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007746 {
7747 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7748 return eHAL_STATUS_FAILURE;
7749 }
7750 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307751 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7752 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007753 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307754
7755#ifdef WLAN_FEATURE_11W
7756 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7757 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7758 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7759#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007760
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 //Save bssid
7762 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7763#ifdef WLAN_FEATURE_VOWIFI_11R
7764 if (pSirBssDesc->mdiePresent)
7765 {
7766 pConnectProfile->MDID.mdiePresent = 1;
7767 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7768 }
7769#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007770 if( NULL == pIesTemp )
7771 {
7772 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7773 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007774#ifdef FEATURE_WLAN_ESE
7775 if ((csrIsProfileESE(pProfile) ||
7776 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307777 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7778 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7779 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7780 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7781#ifdef WLAN_FEATURE_11W
7782 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307783 || (pProfile->negotiatedAuthType ==
7784 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307785#endif
7786 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007787 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007788 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007789 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 }
7791#endif
7792 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007793 if(HAL_STATUS_SUCCESS(status))
7794 {
7795 if(pIesTemp->SSID.present)
7796 {
7797 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307798 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7799 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 }
7801
7802 //Save the bss desc
7803 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307804
7805 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307807 //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 -07007808 pConnectProfile->qap = TRUE;
7809 }
7810 else
7811 {
7812 pConnectProfile->qap = FALSE;
7813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007814 if ( NULL == pIes )
7815 {
7816 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307817 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 }
7819 }
7820 //Save Qos connection
7821 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7822
7823 if(!HAL_STATUS_SUCCESS(status))
7824 {
7825 csrFreeConnectBssDesc(pMac, sessionId);
7826 }
7827 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7828 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307829 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7830 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7831 pConnectProfile->SSID.ssId,
7832 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 {
7834 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7835 break;
7836 }
7837 pConnectProfile->handoffPermitted = FALSE;
7838 }
7839
7840 return (status);
7841}
7842
Jeff Johnson295189b2012-06-20 16:38:30 -07007843static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7844{
7845 tListElem *pEntry = NULL;
7846 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307847 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 //The head of the active list is the request we sent
7849 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7850 if(pEntry)
7851 {
7852 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7853 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307854 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7856 {
7857 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7858 {
7859#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7860 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7861#endif
7862 }
7863 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307864 if(!pSession)
7865 {
7866 smsLog(pMac, LOGE, FL(" session %d not found "),
7867 pSmeJoinRsp->sessionId);
7868 return;
7869 }
7870 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 }
7872 else
7873 {
7874 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007875 if(!pSession)
7876 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307877 smsLog(pMac, LOGE, FL(" session %d not found "),
7878 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007879 return;
7880 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307881 if (pSession->abortConnection)
7882 {
Abhinav Kumare548f1e2018-07-12 16:40:43 +05307883 smsLog(pMac, LOG1, FL("Disconnection in progess abort Join request"));
7884
7885 if (pSession->bRefAssocStartCnt)
7886 pSession->bRefAssocStartCnt--;
7887 csrRoamCallCallback(pMac, pSession->sessionId,
7888 NULL, roamId,
7889 eCSR_ROAM_ASSOCIATION_COMPLETION,
7890 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307891 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7892 pSession->abortConnection = FALSE;
7893 return;
7894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 //The head of the active list is the request we sent
7896 //Try to get back the same profile and roam again
7897 if(pCommand)
7898 {
7899 roamId = pCommand->u.roamCmd.roamId;
7900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7902 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007903 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007904#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7905 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7906 if (csrRoamIsHandoffInProgress(pMac))
7907 {
7908 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7909 /* Should indicate neighbor roam algorithm about the connect failure here */
7910 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7911 }
7912#endif
7913 if (pCommand)
7914 {
7915 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7916 {
7917 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7918 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7919 csrRoamReissueRoamCommand(pMac);
7920 }
7921 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7922 {
7923 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7924 }
7925 else
7926 {
7927 csrRoam(pMac, pCommand);
7928 }
7929 }
7930 else
7931 {
7932 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7933 }
7934 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7935}
7936
Jeff Johnson295189b2012-06-20 16:38:30 -07007937eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7938 tDot11fBeaconIEs *pIes,
7939 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7940{
7941 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007942 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7943 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007944
7945 // Set the roaming substate to 'join attempt'...
7946 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007948 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 return (status);
7950}
7951
Jeff Johnson295189b2012-06-20 16:38:30 -07007952static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7953 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7954{
7955 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 // Set the roaming substate to 'join attempt'...
7957 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7958
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307959 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7960 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307961 if (pMac->roam.configParam.roamDelayStatsEnabled)
7962 {
7963 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7964 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007967 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007968}
7969
Jeff Johnson295189b2012-06-20 16:38:30 -07007970void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7971{
7972 tListElem *pEntry;
7973 tSmeCmd *pCommand;
7974 tCsrRoamInfo roamInfo;
7975 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307976 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007977
7978 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7979 if(pEntry)
7980 {
7981 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7982 if ( eSmeCommandRoam == pCommand->command )
7983 {
7984 sessionId = pCommand->sessionId;
7985 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007986
7987 if(!pSession)
7988 {
7989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7990 return;
7991 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307992 /* While switching between two AP, csr will reissue roam command again
7993 to the nextbss if it was interrupted by the dissconnect req for the
7994 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7995 so reset the bRefAssocStartCnt.
7996 */
7997 if(pSession->bRefAssocStartCnt > 0)
7998 {
7999 pSession->bRefAssocStartCnt--;
8000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 if( pCommand->u.roamCmd.fStopWds )
8002 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308003 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8005 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8006 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
8009 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8010 eCSR_ROAM_WDS_IND,
8011 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
8013 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8014 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8015 eCSR_ROAM_INFRA_IND,
8016 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
8017 }
8018
Jeff Johnson295189b2012-06-20 16:38:30 -07008019
Jeff Johnson295189b2012-06-20 16:38:30 -07008020 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
8021 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008022 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8024 }
8025 }
8026 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
8027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008028 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8030 }
8031 }
8032 else
8033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008034 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 }
8036 }
8037 else
8038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008039 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 }
8041}
8042
Jeff Johnson295189b2012-06-20 16:38:30 -07008043tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
8044{
8045 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8046 tListElem *pEntry;
8047 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 //alwasy lock active list before locking pending list
8049 csrLLLock( &pMac->sme.smeCmdActiveList );
8050 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8051 if(pEntry)
8052 {
8053 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8054 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8055 {
8056 fRet = eANI_BOOLEAN_TRUE;
8057 }
8058 }
8059 if(eANI_BOOLEAN_FALSE == fRet)
8060 {
8061 csrLLLock(&pMac->sme.smeCmdPendingList);
8062 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8063 while(pEntry)
8064 {
8065 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8066 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8067 {
8068 fRet = eANI_BOOLEAN_TRUE;
8069 break;
8070 }
8071 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8072 }
8073 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8074 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308075 if (eANI_BOOLEAN_FALSE == fRet)
8076 {
8077 csrLLLock(&pMac->roam.roamCmdPendingList);
8078 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8079 while (pEntry)
8080 {
8081 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8082 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8083 {
8084 fRet = eANI_BOOLEAN_TRUE;
8085 break;
8086 }
8087 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8088 }
8089 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 return (fRet);
8093}
8094
Jeff Johnson295189b2012-06-20 16:38:30 -07008095tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8096{
8097 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8098 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8100 {
8101 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8102 {
8103 break;
8104 }
8105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 return ( fRet );
8107}
8108
Jeff Johnson295189b2012-06-20 16:38:30 -07008109tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8110{
8111 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 //alwasy lock active list before locking pending list
8113 csrLLLock( &pMac->sme.smeCmdActiveList );
8114 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8115 if(eANI_BOOLEAN_FALSE == fRet)
8116 {
8117 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8118 }
8119 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 return (fRet);
8121}
8122
Jeff Johnson295189b2012-06-20 16:38:30 -07008123tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8124{
8125 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8126 tListElem *pEntry;
8127 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008128 //alwasy lock active list before locking pending list
8129 csrLLLock( &pMac->sme.smeCmdActiveList );
8130 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8131 if( pEntry )
8132 {
8133 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8134 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8135 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8136 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8137 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8138 {
8139 fRet = eANI_BOOLEAN_TRUE;
8140 }
8141 }
8142 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 return (fRet);
8144}
Jeff Johnson295189b2012-06-20 16:38:30 -07008145eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8146{
8147 eHalStatus status = eHAL_STATUS_SUCCESS;
8148 tSmeCmd *pCommand = NULL;
8149 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8150 tANI_BOOLEAN fRemoveCmd = FALSE;
8151 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 // Delete the old assoc command. All is setup for reassoc to be serialized
8153 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8154 if ( pEntry )
8155 {
8156 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8157 if ( !pCommand )
8158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008159 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 return eHAL_STATUS_RESOURCES;
8161 }
8162 if ( eSmeCommandRoam == pCommand->command )
8163 {
8164 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8165 {
8166 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8167 }
8168 else
8169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008170 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 }
8172 if (fRemoveCmd == FALSE)
8173 {
8174 // Implies we did not get the serialized assoc command we
8175 // were expecting
8176 pCommand = NULL;
8177 }
8178 }
8179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 if(NULL == pCommand)
8181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008182 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 return eHAL_STATUS_RESOURCES;
8184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 do
8186 {
8187 //Change the substate in case it is wait-for-key
8188 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8189 {
8190 csrRoamStopWaitForKeyTimer( pMac );
8191 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8192 }
8193 pCommand->command = eSmeCommandRoam;
8194 pCommand->sessionId = (tANI_U8)sessionId;
8195 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8197 if( !HAL_STATUS_SUCCESS( status ) )
8198 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008199 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008200 csrReleaseCommandRoam( pMac, pCommand );
8201 }
8202 } while( 0 );
8203
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 return( status );
8205}
8206static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8207{
8208 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8209 tCsrScanResult *pScanResult = NULL;
8210 tSirBssDescription *pBssDesc = NULL;
8211 tSmeCmd *pCommand = NULL;
8212 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308213 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 if(NULL == pEntry)
8215 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308216 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 return;
8218 }
8219 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8220 sessionId = pCommand->sessionId;
8221 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008222
8223 if(!pSession)
8224 {
8225 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8226 return;
8227 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308228 smsLog(pMac, LOG1, FL("CFG return value is %d "
8229 " current state is : %d substate is : %d "),
8230 result, pMac->roam.curState[sessionId],
8231 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8233 {
8234 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008235 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8237 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008238 /* If the roaming has stopped, not to continue the roaming command*/
8239 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8240 {
8241 //No need to complete roaming here as it already completes
8242 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8243 pCommand->u.roamCmd.roamReason);
8244 csrSetAbortRoamingCommand( pMac, pCommand );
8245 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008247 else
8248 {
8249 if ( CCM_IS_RESULT_SUCCESS(result) )
8250 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308251 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 // Successfully set the configuration parameters for the new Bss. Attempt to
8253 // join the roaming Bss.
8254 if(pCommand->u.roamCmd.pRoamBssEntry)
8255 {
8256 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308257 if (!pScanResult)
8258 {
8259 smsLog(pMac, LOGE,
8260 FL("Failed to get base address for pScanResult"));
8261 return;
8262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 pBssDesc = &pScanResult->Result.BssDescriptor;
8264 }
8265 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8266 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 )
8269 {
8270 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8271 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8272 pBssDesc, pCommand->u.roamCmd.roamId )))
8273 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308274 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 //We need to complete the command
8276 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8277 }
8278 }
8279 else
8280 {
8281 if (!pCommand->u.roamCmd.pRoamBssEntry)
8282 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308283 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 //We need to complete the command
8285 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8286 return;
8287 }
8288 // If we are roaming TO an Infrastructure BSS...
8289 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308290 if( !pScanResult->Result.pvIes )
8291 {
8292 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8293 return;
8294 }
8295
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 if ( csrIsInfraBssDesc( pBssDesc ) )
8297 {
8298 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308299 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8301 {
8302 // ..and currently in an Infrastructure connection....
8303 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8304 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308305 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 // ...and the SSIDs are equal, then we Reassoc.
8307 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8308 pIesLocal ) )
8309 // ..and currently in an infrastructure connection
8310 {
8311 // then issue a Reassoc.
8312 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8313 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8314 &pCommand->u.roamCmd.roamProfile );
8315 }
8316 else
8317 {
8318
8319 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8320 // previously associated AP.
8321 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8322 pIesLocal,
8323 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8324 {
8325 //try something else
8326 csrRoam( pMac, pCommand );
8327 }
8328 }
8329 }
8330 else
8331 {
8332 eHalStatus status = eHAL_STATUS_SUCCESS;
8333
8334 /* We need to come with other way to figure out that this is because of HO in BMP
8335 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008336 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 * use join request */
8338#ifdef WLAN_FEATURE_VOWIFI_11R
8339 if (csrRoamIsHandoffInProgress(pMac) &&
8340 csrRoamIs11rAssoc(pMac))
8341 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308342 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008343 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8344 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8345 }
8346 else
8347#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008348#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008350 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008351 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308352 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 // Now serialize the reassoc command.
8354 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8355 }
8356 else
8357#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008358#ifdef FEATURE_WLAN_LFR
8359 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308360 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008361 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308362 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008363 // Now serialize the reassoc command.
8364 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8365 }
8366 else
8367#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 // else we are not connected and attempting to Join. Issue the
8369 // Join request.
8370 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308371 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8373 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8374 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8375 }
8376 if(!HAL_STATUS_SUCCESS(status))
8377 {
8378 //try something else
8379 csrRoam( pMac, pCommand );
8380 }
8381 }
8382 if( !pScanResult->Result.pvIes )
8383 {
8384 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308385 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 }
8387 }
8388 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8389 else
8390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008391 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008392 }
8393 }//else
8394 }//if ( WNI_CFG_SUCCESS == result )
8395 else
8396 {
8397 // In the event the configuration failed, for infra let the roam processor
8398 //attempt to join something else...
8399 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8400 {
8401 csrRoam(pMac, pCommand);
8402 }
8403 else
8404 {
8405 //We need to complete the command
8406 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8407 {
8408 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8409 }
8410 else
8411 {
8412 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8413 }
8414 }
8415 }
8416 }//we have active entry
8417}
8418
Jeff Johnson295189b2012-06-20 16:38:30 -07008419static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8420{
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008423 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8425 // join the new one...
8426 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8428 }
8429 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008430 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 /***profHandleLostLinkAfterReset(pAdapter);
8432 // In the event the authenticate fails, let the roam processor attempt to join something else...
8433 roamRoam( pAdapter );***/
8434 }
8435}
8436
Jeff Johnson295189b2012-06-20 16:38:30 -07008437static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8438{
8439 eCsrRoamCompleteResult result;
8440 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8441 tCsrRoamInfo roamInfo;
8442 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308443 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308444 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308445 tANI_U8 nilMac[6] = {0};
8446
8447 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008449 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 /* Defeaturize this part later if needed */
8452#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8453 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8454 * we need the response contents while processing the result in csrRoamProcessResults() */
8455 if (csrRoamIsHandoffInProgress(pMac))
8456 {
8457 /* Need to dig more on indicating events to SME QoS module */
8458 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8459 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308460#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8461 /* Add previous BSSID to blacklist ; this will be in blacklised for
8462 * some period and score of this AP will be reduced if black listed
8463 * to avoid ping pong */
8464 if (pMac->PERroamCandidatesCnt)
8465 {
8466 current_timestamp = jiffies_to_msecs(jiffies);
8467 for (candidateApCnt = 0; candidateApCnt <
8468 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8469 {
8470 /* Find one blank entry */
8471 if (sirCompareMacAddr(nilMac,
8472 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8473 {
8474 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8475 bssAddr,
8476 pNeighborRoamInfo->prevConnProfile.bssid,
8477 sizeof(tSirMacAddr));
8478 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8479 current_timestamp;
8480 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8481 MAC_ADDR_ARRAY(
8482 pNeighborRoamInfo->prevConnProfile.bssid),
8483 candidateApCnt);
8484 break;
8485 }
8486 /* if already in the list */
8487 if (sirCompareMacAddr(pMac->previousRoamApInfo
8488 [candidateApCnt].bssAddr,
8489 pNeighborRoamInfo->prevConnProfile.bssid) &&
8490 ((current_timestamp -
8491 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8492 pMac->PERroamTimeout))
8493 {
8494 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8495 bssAddr,
8496 pNeighborRoamInfo->prevConnProfile.bssid,
8497 sizeof(tSirMacAddr));
8498 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8499 current_timestamp;
8500 break;
8501 } else
8502 {
8503 /* find oldest BSSID entry in the blacklist */
8504 if (max_time <
8505 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8506 {
8507 max_time =
8508 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8509 oldestIndex = candidateApCnt;
8510 }
8511 }
8512 }
8513 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8514 {
8515 smsLog(pMac, LOGW,
8516 "%s: Clearing out oldest roam results bssid="
8517 MAC_ADDRESS_STR,
8518 __func__,
8519 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8520 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8521 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8522 pNeighborRoamInfo->prevConnProfile.bssid,
8523 sizeof(tSirMacAddr));
8524 }
8525 }
8526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 }
8528 else
8529#endif
8530 {
8531 csrRoamComplete( pMac, result, NULL );
8532 }
8533 }
8534 /* Should we handle this similar to handling the join failure? Is it ok
8535 * to call csrRoamComplete() with state as CsrJoinFailure */
8536 else
8537 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008538 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308540 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8541 WLAN_LOG_INDICATOR_HOST_DRIVER,
8542 WLAN_LOG_REASON_ROAM_FAIL,
8543 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008544#ifdef WLAN_FEATURE_VOWIFI_11R
8545 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308546 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8547 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 {
8549 // Inform HDD to turn off FT flag in HDD
8550 if (pNeighborRoamInfo)
8551 {
8552 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8553 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8554 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008555 /*
8556 * Since the above callback sends a disconnect
8557 * to HDD, we should clean-up our state
8558 * machine as well to be in sync with the upper
8559 * layers. There is no need to send a disassoc
8560 * since: 1) we will never reassoc to the current
8561 * AP in LFR, and 2) there is no need to issue a
8562 * disassoc to the AP with which we were trying
8563 * to reassoc.
8564 */
8565 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8566 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 }
8568 }
8569#endif
8570 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8571 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8572 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8573 //The disassoc rsp message will remove the command from active list
8574 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8575 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8576 {
8577 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8578 }
8579 }
8580}
8581
Jeff Johnson295189b2012-06-20 16:38:30 -07008582static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8583{
Jeff Johnson295189b2012-06-20 16:38:30 -07008584#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8585 {
8586 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8588 if(pIbssLog)
8589 {
8590 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8591 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8592 {
8593 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8594 }
8595 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8596 }
8597 }
8598#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8600 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8601 {
8602 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8603 }
8604 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8605 {
8606 csrRoamReissueRoamCommand(pMac);
8607 }
8608}
8609
Jeff Johnson295189b2012-06-20 16:38:30 -07008610void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8611{
8612 tSirResultCodes statusCode;
8613#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8614 tScanResultHandle hBSSList;
8615 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8616 eHalStatus status;
8617 tCsrRoamInfo roamInfo;
8618 tCsrScanResultFilter *pScanFilter = NULL;
8619 tANI_U32 roamId = 0;
8620 tCsrRoamProfile *pCurRoamProfile = NULL;
8621 tListElem *pEntry = NULL;
8622 tSmeCmd *pCommand = NULL;
8623#endif
8624 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308625 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008626
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 tSirSmeDisassocRsp SmeDisassocRsp;
8628
8629 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8630 sessionId = SmeDisassocRsp.sessionId;
8631 statusCode = SmeDisassocRsp.statusCode;
8632
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008633 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008634
8635 if ( csrIsConnStateInfra( pMac, sessionId ) )
8636 {
8637 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008640
8641 if(!pSession)
8642 {
8643 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8644 return;
8645 }
8646
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8648 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308649 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8651 }
8652 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8653 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8654 {
8655 if ( eSIR_SME_SUCCESS == statusCode )
8656 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008657 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8659 }
8660 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8663 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308664 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8665 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008666#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008667 /*
8668 * First ensure if the roam profile is in the scan cache.
8669 * If not, post a reassoc failure and disconnect.
8670 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308671 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8672 if ( NULL == pScanFilter )
8673 status = eHAL_STATUS_FAILURE;
8674 else
8675 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008676 if(HAL_STATUS_SUCCESS(status))
8677 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308678 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008679 status = csrRoamPrepareFilterFromProfile(pMac,
8680 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8681 if(!HAL_STATUS_SUCCESS(status))
8682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008683 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008684 __func__, status);
8685 goto POST_ROAM_FAILURE;
8686 }
8687 else
8688 {
8689 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8690 if (!HAL_STATUS_SUCCESS(status))
8691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008692 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008693 __func__, status);
8694 goto POST_ROAM_FAILURE;
8695 }
8696 }
8697 }
8698 else
8699 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008700 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008701 __func__, status);
8702 goto POST_ROAM_FAILURE;
8703 }
8704
8705 /*
8706 * After ensuring that the roam profile is in the scan result list,
8707 * dequeue the command from the active list.
8708 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8710 if ( pEntry )
8711 {
8712 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008713 /* If the head of the queue is Active and it is a ROAM command, remove
8714 * and put this on the Free queue.
8715 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 if ( eSmeCommandRoam == pCommand->command )
8717 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008718
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008719 /*
8720 * we need to process the result first before removing it from active list
8721 * because state changes still happening insides roamQProcessRoamResults so
8722 * no other roam command should be issued.
8723 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8725 if(pCommand->u.roamCmd.fReleaseProfile)
8726 {
8727 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8728 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 else
8733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008734 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008735 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 }
8737 }
8738 else
8739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008740 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 }
8742 }
8743 else
8744 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008745 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008747
8748 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8750
Kiet Lam64c1b492013-07-12 13:56:44 +05308751 vos_mem_copy(roamInfo.bssid,
8752 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8753 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008754
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008755 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8756 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008757
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008758 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308759 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8760 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308762 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008763 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8764 //make sure to put it at the head of the cmd queue
8765 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8766 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8767 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8768
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 if(!HAL_STATUS_SUCCESS(status))
8770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008771 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008772 __func__, status);
8773 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 }
8775
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008776 /* Notify sub-modules like QoS etc. that handoff happening */
8777 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308778 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008779 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308780 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308782 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008783 return;
8784 }
8785
8786POST_ROAM_FAILURE:
8787 if (pScanFilter)
8788 {
8789 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308790 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008791 }
8792 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308793 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008794
8795 /* Inform the upper layers that the reassoc failed */
8796 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8797 csrRoamCallCallback(pMac, sessionId,
8798 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8799
8800 /*
8801 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8802 * Upon success, we would re-enter this routine after receiving the disassoc
8803 * response and will fall into the reassoc fail sub-state. And, eventually
8804 * call csrRoamComplete which would remove the roam command from SME active
8805 * queue.
8806 */
8807 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8808 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008810 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008811 __func__, status);
8812 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008814#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008815
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8817 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8818 {
8819 // Disassoc due to Reassoc failure falls into this codepath....
8820 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8821 }
8822 else
8823 {
8824 if ( eSIR_SME_SUCCESS == statusCode )
8825 {
8826 // Successfully disassociated from the 'old' Bss...
8827 //
8828 // We get Disassociate response in three conditions.
8829 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8830 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8831 // Infrastructure network.
8832 // - Third is where we are doing an Infra to Infra roam between networks with different
8833 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8834
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008835 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 }
8837 else
8838 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008839 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 }
8841 //We are not done yet. Get the data and continue roaming
8842 csrRoamReissueRoamCommand(pMac);
8843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008844}
8845
Jeff Johnson295189b2012-06-20 16:38:30 -07008846static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8847{
8848 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008850 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8852 {
8853 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8854 }
8855 else
8856 {
8857 if ( eSIR_SME_SUCCESS == statusCode )
8858 {
8859 // Successfully deauth from the 'old' Bss...
8860 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008861 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 }
8863 else
8864 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008865 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 }
8867 //We are not done yet. Get the data and continue roaming
8868 csrRoamReissueRoamCommand(pMac);
8869 }
8870}
8871
Jeff Johnson295189b2012-06-20 16:38:30 -07008872static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8873{
8874 eCsrRoamCompleteResult result;
8875
8876 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008878 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 result = eCsrStartBssSuccess;
8880 }
8881 else
8882 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008883 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 //Let csrRoamComplete decide what to do
8885 result = eCsrStartBssFailure;
8886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008888}
8889
Jeff Johnson295189b2012-06-20 16:38:30 -07008890/*
8891 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8892 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8893 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8894 For the messages where sender allocates memory for specific structures, then it can be
8895 cast accordingly.
8896*/
8897void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8898{
8899 tSirSmeRsp *pSmeRsp;
8900 tSmeIbssPeerInd *pIbssPeerInd;
8901 tCsrRoamInfo roamInfo;
8902 // TODO Session Id need to be acquired in this function
8903 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308905 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8906 pSmeRsp->messageType, pSmeRsp->messageType,
8907 macTraceGetcsrRoamSubState(
8908 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 pSmeRsp->messageType = (pSmeRsp->messageType);
8910 pSmeRsp->length = (pSmeRsp->length);
8911 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008912 switch (pSmeRsp->messageType)
8913 {
8914
8915 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8916 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8917 {
8918 //We sent a JOIN_REQ
8919 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8920 }
8921 break;
8922
8923 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8924 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8925 {
8926 //We sent a AUTH_REQ
8927 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8928 }
8929 break;
8930
8931 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8932 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8933 {
8934 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8935 }
8936 break;
8937
8938 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8939 {
8940 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8941 }
8942 break;
8943
8944 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8945 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8946 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8947 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8948 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8949 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8950//HO
8951 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8952 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308953 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8954 macTraceGetcsrRoamSubState(
8955 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308957 if (pMac->roam.configParam.roamDelayStatsEnabled)
8958 {
8959 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 }
8962 break;
8963
8964 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8965 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8966 {
8967 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8968 }
8969 break;
8970
8971 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8972 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8973 {
8974 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8975 }
8976 break;
8977
8978 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8979 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8980 {
8981 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008983 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8985 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8986 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008987 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308988 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8989 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8991 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308992 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8993 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8995 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8996 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8997 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05308998 case eWNI_SME_LOST_LINK_PARAMS_IND:
8999 {
9000 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
9001 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9002 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9003 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9004 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
9005 pRoamInfo = &roamInfo;
9006 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
9007 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
9008 break;
9009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309011 smsLog(pMac, LOG1,
9012 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9013 pSmeRsp->messageType, pSmeRsp->messageType,
9014 macTraceGetcsrRoamSubState(
9015 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009016
9017 //If we are connected, check the link status change
9018 if(!csrIsConnStateDisconnected(pMac, sessionId))
9019 {
9020 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
9021 }
9022 break;
9023 }
9024}
9025
Jeff Johnson295189b2012-06-20 16:38:30 -07009026void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
9027{
9028 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 switch (pSirMsg->messageType)
9030 {
9031 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009032 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009033 csrRoamStatsRspProcessor( pMac, pSirMsg );
9034 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9036 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309037 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009038 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9039 tCsrRoamInfo roamInfo;
9040 tCsrRoamInfo *pRoamInfo = NULL;
9041 tANI_U32 sessionId;
9042 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009043 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05309044 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
9047 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9048 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009049
9050 if(!pSession)
9051 {
9052 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9053 return;
9054 }
9055
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9057 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9059 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9060 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9062 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309063 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9064 sizeof(tSirMacAddr));
9065 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9066 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309068#ifdef WLAN_FEATURE_AP_HT40_24G
9069 pRoamInfo->HT40MHzIntoEnabledSta =
9070 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9071 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9072 pRoamInfo->HT40MHzIntoEnabledSta);
9073#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309074 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309075 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9076 pRoamInfo->chan_info = pUpperLayerAssocCnf->chan_info;
9077 if (pUpperLayerAssocCnf->HTCaps.present)
9078 pRoamInfo->ht_caps = pUpperLayerAssocCnf->HTCaps;
9079 if (pUpperLayerAssocCnf->VHTCaps.present)
9080 pRoamInfo->vht_caps = pUpperLayerAssocCnf->VHTCaps;
9081
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9083 {
9084 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9085 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9086 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9087 }
9088 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9089 {
9090 vos_sleep( 100 );
9091 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9092 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9093 }
9094
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 }
9096 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 default:
9098 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9099 break;
9100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009101}
9102
Jeff Johnson295189b2012-06-20 16:38:30 -07009103eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9104 tSirBssDescription *pBssDescription,
9105 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9106 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9107 tANI_U8 keyId, tANI_U16 keyLength,
9108 tANI_U8 *pKey, tANI_U8 paeRole )
9109{
9110 eHalStatus status = eHAL_STATUS_SUCCESS;
9111 tAniEdType edType;
9112
9113 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9114 {
9115 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9116 }
9117
9118 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9119
9120 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9121 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9122 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9123 addKey )
9124 {
9125 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009126 setKey.encType = EncryptType;
9127 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309128 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 setKey.paeRole = paeRole; //0 for supplicant
9130 setKey.keyId = keyId; // Kye index
9131 setKey.keyLength = keyLength;
9132 if( keyLength )
9133 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309134 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 }
9136 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 return (status);
9139}
9140
Jeff Johnson295189b2012-06-20 16:38:30 -07009141static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9142 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9143{
9144 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9145 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009146#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009148#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009149
9150 do
9151 {
9152 pCommand = csrGetCommandBuffer(pMac);
9153 if(NULL == pCommand)
9154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009155 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009156 status = eHAL_STATUS_RESOURCES;
9157 break;
9158 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309159 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 pCommand->command = eSmeCommandSetKey;
9161 pCommand->sessionId = (tANI_U8)sessionId;
9162 // validate the key length, Adjust if too long...
9163 // for static WEP the keys are not set thru' SetContextReq
9164 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9165 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9166 {
9167 //KeyLength maybe 0 for static WEP
9168 if( pSetKey->keyLength )
9169 {
9170 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9171 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009172 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 break;
9174 }
9175
9176 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309177 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9178 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 }
9180 }
9181 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9182 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9183 {
9184 //KeyLength maybe 0 for static WEP
9185 if( pSetKey->keyLength )
9186 {
9187 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9188 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009189 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 break;
9191 }
9192
9193 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309194 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9195 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 }
9197 }
9198 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9199 {
9200 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009202 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 break;
9204 }
9205 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309206 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9207 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009208 }
9209 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9210 {
9211 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009213 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 break;
9215 }
9216 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309217 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9218 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 }
9220#ifdef FEATURE_WLAN_WAPI
9221 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9222 {
9223 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009225 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 break;
9227 }
9228 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309229 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9230 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 }
9232#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009233#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9235 {
9236 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009238 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 break;
9240 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009241 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309242 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009243 pSession->eseCckmInfo.reassoc_req_num=1;
9244 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 status = eHAL_STATUS_SUCCESS;
9246 break;
9247 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009248#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009249
Jeff Johnson295189b2012-06-20 16:38:30 -07009250#ifdef WLAN_FEATURE_11W
9251 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009252 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009254 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009256 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 break;
9258 }
9259 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309260 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009261 }
9262#endif
9263 status = eHAL_STATUS_SUCCESS;
9264 pCommand->u.setKeyCmd.roamId = roamId;
9265 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9266 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309267 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9268 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9270 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309271 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 //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
9273
9274 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9275 if( !HAL_STATUS_SUCCESS( status ) )
9276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009277 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 }
9279 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009281 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009282 if ( ( NULL != pCommand ) &&
9283 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009284#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009286#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009287 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 {
9289 csrReleaseCommandSetKey( pMac, pCommand );
9290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 return( status );
9292}
9293
Jeff Johnson295189b2012-06-20 16:38:30 -07009294eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9295 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9296{
9297 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9298 tSmeCmd *pCommand = NULL;
9299 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 do
9301 {
9302 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009304 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 status = eHAL_STATUS_CSR_WRONG_STATE;
9306 break;
9307 }
9308 pCommand = csrGetCommandBuffer(pMac);
9309 if(NULL == pCommand)
9310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009311 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 status = eHAL_STATUS_RESOURCES;
9313 break;
9314 }
9315 pCommand->command = eSmeCommandRemoveKey;
9316 pCommand->sessionId = (tANI_U8)sessionId;
9317 pCommand->u.removeKeyCmd.roamId = roamId;
9318 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309319 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9320 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009321 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9322 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9323 {
9324 //in this case, put it to the end of the Q incase there is a set key pending.
9325 fImediate = eANI_BOOLEAN_FALSE;
9326 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009327 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009329 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9331 if( !HAL_STATUS_SUCCESS( status ) )
9332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009333 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 break;
9335 }
9336 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9338 {
9339 csrReleaseCommandRemoveKey( pMac, pCommand );
9340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 return (status );
9342}
9343
Jeff Johnson295189b2012-06-20 16:38:30 -07009344eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9345{
9346 eHalStatus status;
9347 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9348 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9349 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9350 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9352 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9353 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309354 if(!pSession)
9355 {
9356 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9357 return eHAL_STATUS_FAILURE;
9358 }
lukez3c809222013-05-03 10:23:02 -07009359 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309361 vos_mem_set(&setKeyEvent,
9362 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9364 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309365 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9367 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9368 }
9369 else
9370 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309371 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9373 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9374 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309375 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009376 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 {
9378 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 //It has to be static WEP here
9380 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9381 {
9382 setKeyEvent.keyId = (v_U8_t)defKeyId;
9383 }
9384 }
9385 else
9386 {
9387 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9388 }
9389 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9390 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9391 }
9392#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 if( csrIsSetKeyAllowed(pMac, sessionId) )
9394 {
9395 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9396 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9397 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9398 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9399 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9400 pCommand->u.setKeyCmd.keyRsc);
9401 }
9402 else
9403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009404 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 //Set this status so the error handling take care of the case.
9406 status = eHAL_STATUS_CSR_WRONG_STATE;
9407 }
9408 if( !HAL_STATUS_SUCCESS(status) )
9409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009410 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009411 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009412#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009413 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 {
9415 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9416 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309417 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 }
9419 else
9420 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309421 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 }
9423 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9424 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9425 }
9426#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 return ( status );
9429}
9430
Jeff Johnson295189b2012-06-20 16:38:30 -07009431eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9432{
9433 eHalStatus status;
9434 tpSirSmeRemoveKeyReq pMsg = NULL;
9435 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9436 tANI_U8 *p;
9437 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009438#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9439 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9440 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309441 if(!pSession)
9442 {
9443 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9444 return eHAL_STATUS_FAILURE;
9445 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309446 vos_mem_set(&removeKeyEvent,
9447 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9449 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9450 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309451 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9453 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9454 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9455#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 if( csrIsSetKeyAllowed(pMac, sessionId) )
9457 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309458 pMsg = vos_mem_malloc(wMsgLen);
9459 if ( NULL == pMsg )
9460 status = eHAL_STATUS_FAILURE;
9461 else
9462 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 }
9464 else
9465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009466 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 //Set the error status so error handling kicks in below
9468 status = eHAL_STATUS_CSR_WRONG_STATE;
9469 }
9470 if( HAL_STATUS_SUCCESS( status ) )
9471 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309472 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9474 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 pMsg->sessionId = (tANI_U8)sessionId;
9476 pMsg->transactionId = 0;
9477 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9478 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9479 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309480 vos_mem_copy(p,
9481 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9482 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 p += sizeof(tSirMacAddr);
9484 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309485 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 p += sizeof(tSirMacAddr);
9487 // edType
9488 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9489 p++;
9490 // weptype
9491 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9492 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9493 {
9494 *p = (tANI_U8)eSIR_WEP_STATIC;
9495 }
9496 else
9497 {
9498 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9499 }
9500 p++;
9501 //keyid
9502 *p = pCommand->u.removeKeyCmd.keyId;
9503 p++;
9504 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 status = palSendMBMessage(pMac->hHdd, pMsg);
9506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 if( !HAL_STATUS_SUCCESS( status ) )
9508 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009509 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009510#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9511 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009512 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9514#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 return ( status );
9518}
9519
Jeff Johnson295189b2012-06-20 16:38:30 -07009520eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9521{
9522 eHalStatus status;
9523
9524 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9525 {
9526 status = eHAL_STATUS_CSR_WRONG_STATE;
9527 }
9528 else
9529 {
9530 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 return ( status );
9533}
9534
Jeff Johnson295189b2012-06-20 16:38:30 -07009535/*
9536 Prepare a filter base on a profile for parsing the scan results.
9537 Upon successful return, caller MUST call csrFreeScanFilter on
9538 pScanFilter when it is done with the filter.
9539*/
9540eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9541 tCsrScanResultFilter *pScanFilter)
9542{
9543 eHalStatus status = eHAL_STATUS_SUCCESS;
9544 tANI_U32 size = 0;
9545 tANI_U8 index = 0;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309546 uint8_t i;
Jeff Johnson295189b2012-06-20 16:38:30 -07009547
9548 do
9549 {
9550 if(pProfile->BSSIDs.numOfBSSIDs)
9551 {
9552 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309553 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9554 if ( NULL == pScanFilter->BSSIDs.bssid )
9555 status = eHAL_STATUS_FAILURE;
9556 else
9557 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009558 if(!HAL_STATUS_SUCCESS(status))
9559 {
9560 break;
9561 }
9562 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309563 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 }
9565 if(pProfile->SSIDs.numOfSSIDs)
9566 {
9567 if( !CSR_IS_WDS_STA( pProfile ) )
9568 {
9569 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9570 }
9571 else
9572 {
9573 //For WDS station
9574 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9575 pScanFilter->SSIDs.numOfSSIDs = 1;
9576 }
9577 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309578 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9579 if ( NULL == pScanFilter->SSIDs.SSIDList )
9580 status = eHAL_STATUS_FAILURE;
9581 else
9582 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 if(!HAL_STATUS_SUCCESS(status))
9584 {
9585 break;
9586 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309587 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9588 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 }
9590 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9591 {
9592 pScanFilter->ChannelInfo.numOfChannels = 0;
9593 pScanFilter->ChannelInfo.ChannelList = NULL;
9594 }
9595 else if(pProfile->ChannelInfo.numOfChannels)
9596 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309597 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9598 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9599 pProfile->ChannelInfo.numOfChannels);
9600 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9601 status = eHAL_STATUS_FAILURE;
9602 else
9603 status = eHAL_STATUS_SUCCESS;
9604
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 pScanFilter->ChannelInfo.numOfChannels = 0;
9606 if(HAL_STATUS_SUCCESS(status))
9607 {
9608 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9609 {
9610 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9611 {
9612 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9613 = pProfile->ChannelInfo.ChannelList[index];
9614 pScanFilter->ChannelInfo.numOfChannels++;
9615 }
9616 else
9617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009618 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 }
9621 }
9622 else
9623 {
9624 break;
9625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 }
9627 else
9628 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309629 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 status = eHAL_STATUS_FAILURE;
9631 break;
9632 }
9633 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309634 if (pProfile->force_rsne_override) {
9635 smsLog(pMac, LOG1, FL("force_rsne_override enabled fill all auth type and enctype"));
9636
9637 pScanFilter->authType.numEntries = eCSR_NUM_OF_SUPPORT_AUTH_TYPE;
9638 for (i = 0; i < pScanFilter->authType.numEntries; i++)
9639 pScanFilter->authType.authType[i] = i;
9640 index = 0;
9641 for (i = 0; i < eCSR_NUM_OF_ENCRYPT_TYPE; i++) {
9642 if (i == eCSR_ENCRYPT_TYPE_TKIP ||
9643 i == eCSR_ENCRYPT_TYPE_AES) {
9644 pScanFilter->
9645 EncryptionType.encryptionType[index] = i;
9646 pScanFilter->
9647 mcEncryptionType.encryptionType[index] = i;
9648 index++;
9649 }
9650 }
9651 pScanFilter->EncryptionType.numEntries = index;
9652 pScanFilter->mcEncryptionType.numEntries = index;
9653 pScanFilter->ignore_pmf_cap = true;
9654 } else {
9655 pScanFilter->authType = pProfile->AuthType;
9656 pScanFilter->EncryptionType = pProfile->EncryptionType;
9657 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 pScanFilter->BSSType = pProfile->BSSType;
9660 pScanFilter->phyMode = pProfile->phyMode;
9661#ifdef FEATURE_WLAN_WAPI
9662 //check if user asked for WAPI with 11n or auto mode, in that case modify
9663 //the phymode to 11g
9664 if(csrIsProfileWapi(pProfile))
9665 {
9666 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9667 {
9668 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9669 }
9670 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9671 {
9672 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9673 }
9674 if(!pScanFilter->phyMode)
9675 {
9676 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9677 }
9678 }
9679#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 /*Save the WPS info*/
9681 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009682 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 if( pProfile->countryCode[0] )
9684 {
9685 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309686 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9687 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 }
9689#ifdef WLAN_FEATURE_VOWIFI_11R
9690 if (pProfile->MDID.mdiePresent)
9691 {
9692 pScanFilter->MDID.mdiePresent = 1;
9693 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9694 }
9695#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309696 vos_mem_copy(pScanFilter->bssid_hint,
9697 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309698
9699#ifdef WLAN_FEATURE_11W
9700 // Management Frame Protection
9701 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9702 pScanFilter->MFPRequired = pProfile->MFPRequired;
9703 pScanFilter->MFPCapable = pProfile->MFPCapable;
9704#endif
9705
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 }while(0);
9707
9708 if(!HAL_STATUS_SUCCESS(status))
9709 {
9710 csrFreeScanFilter(pMac, pScanFilter);
9711 }
9712
9713 return(status);
9714}
9715
Jeff Johnson295189b2012-06-20 16:38:30 -07009716tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9717 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9718{
9719 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9720 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 do
9722 {
9723 // Validate the type is ok...
9724 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9725 pCommand = csrGetCommandBuffer( pMac );
9726 if ( !pCommand )
9727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009728 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009729 break;
9730 }
9731 //Change the substate in case it is waiting for key
9732 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9733 {
9734 csrRoamStopWaitForKeyTimer( pMac );
9735 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9736 }
9737 pCommand->command = eSmeCommandWmStatusChange;
9738 pCommand->sessionId = (tANI_U8)sessionId;
9739 pCommand->u.wmStatusChangeCmd.Type = Type;
9740 if ( eCsrDisassociated == Type )
9741 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309742 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9743 pSmeRsp,
9744 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 }
9746 else
9747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309748 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9749 pSmeRsp,
9750 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 }
9752 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9753 {
9754 fCommandQueued = eANI_BOOLEAN_TRUE;
9755 }
9756 else
9757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009758 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 csrReleaseCommandWmStatusChange( pMac, pCommand );
9760 }
9761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9763 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 return( fCommandQueued );
9766}
9767
Jeff Johnson295189b2012-06-20 16:38:30 -07009768static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9769{
9770 v_S7_t rssi = 0;
9771 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9772 if(pGetRssiReq)
9773 {
9774 if(NULL != pGetRssiReq->pVosContext)
9775 {
9776 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9777 }
9778 else
9779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009780 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 return;
9782 }
9783
9784 if(NULL != pGetRssiReq->rssiCallback)
9785 {
9786 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9787 }
9788 else
9789 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009790 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 return;
9792 }
9793 }
9794 else
9795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009796 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 }
9798 return;
9799}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309800
9801static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9802{
9803 tANI_S8 snr = 0;
9804 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9805
9806 if (pGetSnrReq)
9807 {
9808 if (VOS_STATUS_SUCCESS !=
9809 WDA_GetSnr(pGetSnrReq->staId, &snr))
9810 {
9811 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9812 return;
9813 }
9814
9815 if (pGetSnrReq->snrCallback)
9816 {
9817 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9818 pGetSnrReq->pDevContext);
9819 }
9820 else
9821 {
9822 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9823 return;
9824 }
9825 }
9826 else
9827 {
9828 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9829 }
9830 return;
9831}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009832#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009833void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9834{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009835 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9836
Jeff Johnson36d483b2013-04-08 11:08:53 -07009837 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009838 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009839 /* Get roam Rssi request is backed up and passed back to the response,
9840 Extract the request message to fetch callback */
9841 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9842 v_S7_t rssi = pRoamRssiRsp->rssi;
9843
9844 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009845 {
9846 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9847 reqBkp->rssiCallback = NULL;
9848 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009849 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009850 }
9851 else
9852 {
9853 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9854 if (NULL != reqBkp)
9855 {
9856 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009857 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009858 }
9859 }
9860 }
9861 else
9862 {
9863 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9864 }
9865 return;
9866}
9867#endif
9868
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009869
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009870#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009871void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9872{
9873 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9874
9875 if (NULL != pTsmStatsRsp)
9876 {
9877 /* Get roam Rssi request is backed up and passed back to the response,
9878 Extract the request message to fetch callback */
9879 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9880
9881 if (NULL != reqBkp)
9882 {
9883 if (NULL != reqBkp->tsmStatsCallback)
9884 {
9885 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9886 pTsmStatsRsp->staId, reqBkp->pDevContext);
9887 reqBkp->tsmStatsCallback = NULL;
9888 }
9889 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009890 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009891 }
9892 else
9893 {
9894 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9895 if (NULL != reqBkp)
9896 {
9897 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009898 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009899 }
9900 }
9901 }
9902 else
9903 {
9904 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9905 }
9906 return;
9907}
9908
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009909void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009910{
9911 tANI_U32 roamTS2 = 0;
9912 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009913 tpPESession pSessionEntry = NULL;
9914 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009915
9916 if (NULL == pSession)
9917 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009918 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009919 return;
9920 }
9921
9922 roamTS2 = vos_timer_get_system_time();
9923 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009924 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9925 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009926 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009927
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009928 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9929 if (NULL == pSessionEntry)
9930 {
9931 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9932 return;
9933 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009934 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009935 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009936 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009937}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009938#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009939
Jeff Johnsone7245742012-09-05 17:12:55 -07009940static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9941{
9942 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9943 if(pTlRssiInd)
9944 {
9945 if(NULL != pTlRssiInd->tlCallback)
9946 {
9947 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009948 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009949 }
9950 else
9951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009952 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009953 }
9954 }
9955 else
9956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009957 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009958 }
9959 return;
9960}
Jeff Johnson295189b2012-06-20 16:38:30 -07009961
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309962eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9963{
9964 tpSirResetAPCapsChange pMsg;
9965 tANI_U16 len;
9966 eHalStatus status = eHAL_STATUS_SUCCESS;
9967
9968 /* Create the message and send to lim */
9969 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309970 pMsg = vos_mem_malloc(len);
9971 if ( NULL == pMsg )
9972 status = eHAL_STATUS_FAILURE;
9973 else
9974 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309975 if (HAL_STATUS_SUCCESS(status))
9976 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309977 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309978 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9979 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309980 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009981 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9982 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309983 status = palSendMBMessage(pMac->hHdd, pMsg);
9984 }
9985 else
9986 {
9987 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9988 }
9989 return status;
9990}
9991
Jeff Johnson295189b2012-06-20 16:38:30 -07009992void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9993{
9994 tSirSmeAssocInd *pAssocInd;
9995 tSirSmeDisassocInd *pDisassocInd;
9996 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +05309997 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9999 tSirSmeNewBssInfo *pNewBss;
10000 tSmeIbssPeerInd *pIbssPeerInd;
10001 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10002 tSirSmeApNewCaps *pApNewCaps;
10003 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10004 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
10005 tCsrRoamInfo *pRoamInfo = NULL;
10006 tCsrRoamInfo roamInfo;
10007 eHalStatus status;
10008 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
10009 tCsrRoamSession *pSession = NULL;
10010 tpSirSmeSwitchChannelInd pSwitchChnInd;
10011 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +053010012 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -080010013
10014
10015 if (NULL == pSirMsg)
10016 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
10017 return;
10018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 switch( pSirMsg->messageType )
10020 {
10021 case eWNI_SME_ASSOC_IND:
10022 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053010023 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053010024 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
10026 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
10027 if( HAL_STATUS_SUCCESS( status ) )
10028 {
10029 pSession = CSR_GET_SESSION(pMac, sessionId);
10030
Jeff Johnson32d95a32012-09-10 13:15:23 -070010031 if(!pSession)
10032 {
10033 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10034 return;
10035 }
10036
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 pRoamInfo = &roamInfo;
10038
10039 // Required for indicating the frames to upper layer
10040 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
10041 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
10042
10043 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
10044 pRoamInfo->beaconLength = pAssocInd->beaconLength;
10045 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
10046 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10047
10048 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
10049 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
10050 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10051
10052 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
10053 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +053010054 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
10055 sizeof(tSirMacAddr));
10056 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
10057 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +053010059 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053010060#ifdef WLAN_FEATURE_AP_HT40_24G
10061 pRoamInfo->HT40MHzIntoEnabledSta =
10062 pAssocInd->HT40MHzIntoEnabledSta;
10063 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
10064 pRoamInfo->HT40MHzIntoEnabledSta);
10065#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
10069 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010070#ifdef SAP_AUTH_OFFLOAD
10071 if (pMac->sap_auth_offload)
10072 {
10073 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
10074 pRoamInfo->fAuthRequired = FALSE;
10075 }
10076 else
10077 {
10078#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10080 {
10081 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10082 pSession->pConnectBssDesc,
10083 &(pRoamInfo->peerMac),
10084 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10085 pRoamInfo->fAuthRequired = FALSE;
10086 }
10087 else
10088 {
10089 pRoamInfo->fAuthRequired = TRUE;
10090 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010091#ifdef SAP_AUTH_OFFLOAD
10092 }
10093#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10095 if (!HAL_STATUS_SUCCESS(status))
10096 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 /* Send Association completion message to PE */
10099 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10100
10101 /* send a message to CSR itself just to avoid the EAPOL frames going
10102 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10104 {
10105 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10108 {
10109 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10110 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10111 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 }
10114 }
10115 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010118 // Check if AP dis-associated us because of MIC failure. If so,
10119 // then we need to take action immediately and not wait till the
10120 // the WmStatusChange requests is pushed and processed
10121 tSmeCmd *pCommand;
10122
10123 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10124 status = csrRoamGetSessionIdFromBSSID( pMac,
10125 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10126 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010128 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10129 " for session %d "), sessionId);
10130 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10131 MAC_ADDRESS_STR " "
10132 " reason = %d status = %d "),
10133 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10134 pDisassocInd->reasonCode,
10135 pDisassocInd->statusCode);
10136 // If we are in neighbor preauth done state then on receiving
10137 // disassoc or deauth we dont roam instead we just disassoc
10138 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010139 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010140#ifdef WLAN_FEATURE_VOWIFI_11R
10141 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10142 {
10143 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010145#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010146#ifdef FEATURE_WLAN_ESE
10147 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010148 {
10149 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010151#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010152#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010153 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10154 {
10155 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10156 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010157#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010158#ifdef WLAN_FEATURE_LFR_MBB
10159 csr_stop_preauth_reassoc_mbb_timer(pMac);
10160#endif
10161
Agarwal Ashish4f616132013-12-30 23:32:50 +053010162 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010163
Agarwal Ashish4f616132013-12-30 23:32:50 +053010164 if (!pSession)
10165 {
10166 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10167 return;
10168 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010169
Agarwal Ashish4f616132013-12-30 23:32:50 +053010170 if ( csrIsConnStateInfra( pMac, sessionId ) )
10171 {
10172 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010174#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010175 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010176#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010177 csrRoamLinkDown(pMac, sessionId);
10178 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10179 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10180 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010181 /*
10182 * STA/P2P client got disassociated so remove any pending deauth
10183 * commands in sme pending list
10184 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010185 pCommand = csrGetCommandBuffer(pMac);
10186 if (NULL == pCommand)
10187 {
10188 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10189 status = eHAL_STATUS_RESOURCES;
10190 return;
10191 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010192 pCommand->command = eSmeCommandRoam;
10193 pCommand->sessionId = (tANI_U8)sessionId;
10194 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10195 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10196 pDisassocInd->peerMacAddr,
10197 sizeof(tSirMacAddr));
10198 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10199 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010200
Agarwal Ashish4f616132013-12-30 23:32:50 +053010201 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010203 else
10204 {
10205 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10206 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10207 }
Kiet Lam82004c62013-11-11 13:24:28 +053010208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010211 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10213 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10214 if( HAL_STATUS_SUCCESS( status ) )
10215 {
10216 // If we are in neighbor preauth done state then on receiving
10217 // disassoc or deauth we dont roam instead we just disassoc
10218 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010219 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010220#ifdef WLAN_FEATURE_VOWIFI_11R
10221 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10222 {
10223 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10224 }
10225#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010226#ifdef FEATURE_WLAN_ESE
10227 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 {
10229 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10230 }
10231#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010232#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010233 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010234 {
10235 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10236 }
10237#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010238#ifdef WLAN_FEATURE_LFR_MBB
10239 csr_stop_preauth_reassoc_mbb_timer(pMac);
10240#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 pSession = CSR_GET_SESSION( pMac, sessionId );
10242
Jeff Johnson32d95a32012-09-10 13:15:23 -070010243 if(!pSession)
10244 {
10245 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10246 return;
10247 }
10248
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 if ( csrIsConnStateInfra( pMac, sessionId ) )
10250 {
10251 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010253#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10254 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10255#endif
Yeshwanth Sriram Guntuka381bfa82018-11-06 18:29:50 +053010256#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
10257 csrRemoveNeighbourRoamPreauthCommand(pMac);
10258#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 csrRoamLinkDown(pMac, sessionId);
10260 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 }
10262 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010263
10264 case eWNI_SME_DISCONNECT_DONE_IND:
10265 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10266 smsLog( pMac, LOG1,
10267 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10268 pDisConDoneInd->reasonCode);
10269 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10270 {
10271 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10272 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10273 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10274 sizeof(tSirMacAddr));
10275 status = csrRoamCallCallback(pMac,
10276 pDisConDoneInd->sessionId,
10277 &roamInfo, 0,
10278 eCSR_ROAM_LOSTLINK,
10279 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010280 pSession = CSR_GET_SESSION(pMac,
10281 pDisConDoneInd->sessionId);
10282 if (pSession &&
10283 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10284 csrRoamStateChange(pMac,
10285 eCSR_ROAMING_STATE_IDLE,
10286 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010287 }
10288 else
10289 {
10290 smsLog(pMac, LOGE, FL("Inactive session %d"),
10291 pDisConDoneInd->sessionId);
10292 }
10293 break;
10294
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 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 -080010296 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010297
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10299 //Update with the new channel id.
10300 //The channel id is hidden in the statusCode.
10301 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10302 if( HAL_STATUS_SUCCESS( status ) )
10303 {
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010304 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010306 if(!pSession)
10307 {
10308 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10309 return;
10310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10312 if(pSession->pConnectBssDesc)
10313 {
10314 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10315 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010316 pRoamInfo->chan_info.chan_id =
10317 (tANI_U8)pSwitchChnInd->newChannelId;
10318 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10319 eCSR_ROAM_STA_CHANNEL_SWITCH,
10320 eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 }
10322 break;
10323
10324 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010325 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 {
10327 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10328 sessionId = pDeauthRsp->sessionId;
10329 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10330 {
10331 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10333 {
10334 pRoamInfo = &roamInfo;
10335 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010336 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10337 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10339 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10340 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10341 }
10342 }
10343 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 break;
10345
10346 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010347 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010348 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010349 {
10350 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10351 sessionId = pDisassocRsp->sessionId;
10352 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10353 {
10354 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10356 {
10357 pRoamInfo = &roamInfo;
10358 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010359 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10360 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10362 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10363 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10364 }
10365 }
10366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010368 case eWNI_SME_LOST_LINK_PARAMS_IND:
10369 {
10370 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10371 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10372 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10373 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10374 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10375 pRoamInfo = &roamInfo;
10376 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10377 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10378 break;
10379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010380 case eWNI_SME_MIC_FAILURE_IND:
10381 {
10382 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10383 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10384 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010385
10386 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10387 if( HAL_STATUS_SUCCESS( status ) )
10388 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010389 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010390 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10391 pRoamInfo = &roamInfo;
10392 if(pMicInd->info.multicast)
10393 {
10394 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10395 }
10396 else
10397 {
10398 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10399 }
10400 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10401 }
10402
Jeff Johnson295189b2012-06-20 16:38:30 -070010403#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10404 {
lukez3c809222013-05-03 10:23:02 -070010405 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010407 if(!pSession)
10408 {
10409 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10410 return;
10411 }
lukez3c809222013-05-03 10:23:02 -070010412
Kiet Lam64c1b492013-07-12 13:56:44 +053010413 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10415 secEvent.encryptionModeMulticast =
10416 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10417 secEvent.encryptionModeUnicast =
10418 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10419 secEvent.authMode =
10420 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010421 vos_mem_copy(secEvent.bssid,
10422 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010423 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10424 }
10425#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010426 }
10427 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10429 {
10430 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10431 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010432 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010433
10434 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10435 if( HAL_STATUS_SUCCESS( status ) )
10436 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010437 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010438 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10439 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10440 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10441 }
10442 }
10443 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010444
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10446 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10447 switch( pStatusChangeMsg->statusChangeCode )
10448 {
10449 case eSIR_SME_IBSS_ACTIVE:
10450 sessionId = csrFindIbssSession( pMac );
10451 if( CSR_SESSION_ID_INVALID != sessionId )
10452 {
10453 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010454 if(!pSession)
10455 {
10456 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10457 return;
10458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10460 if(pSession->pConnectBssDesc)
10461 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010462 vos_mem_copy(&roamInfo.bssid,
10463 pSession->pConnectBssDesc->bssId,
10464 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10466 pRoamInfo = &roamInfo;
10467 }
10468 else
10469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010470 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 }
10472 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10473 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10474 }
10475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 case eSIR_SME_IBSS_INACTIVE:
10477 sessionId = csrFindIbssSession( pMac );
10478 if( CSR_SESSION_ID_INVALID != sessionId )
10479 {
10480 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010481 if(!pSession)
10482 {
10483 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10484 return;
10485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10487 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10488 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10489 }
10490 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10492 sessionId = csrFindIbssSession( pMac );
10493 if( CSR_SESSION_ID_INVALID != sessionId )
10494 {
10495 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010496 if(!pSession)
10497 {
10498 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10499 return;
10500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010501 // update the connection state information
10502 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010503#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10504 {
10505 vos_log_ibss_pkt_type *pIbssLog;
10506 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010507 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10508 if(pIbssLog)
10509 {
10510 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10511 if(pNewBss)
10512 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010513 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Yeshwanth Sriram Guntuka7231db02018-08-10 15:18:21 +053010514 if(pNewBss->ssId.length >
10515 VOS_LOG_MAX_SSID_SIZE)
10516 pNewBss->ssId.length =
10517 VOS_LOG_MAX_SSID_SIZE;
10518
10519 vos_mem_copy(pIbssLog->ssid,
10520 pNewBss->ssId.ssId,
10521 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 pIbssLog->operatingChannel = pNewBss->channelNumber;
10523 }
10524 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10525 {
10526 //***U8 is not enough for beacon interval
10527 pIbssLog->beaconInterval = (v_U8_t)bi;
10528 }
10529 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10530 }
10531 }
10532#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010533 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010534
10535 if ((eCSR_ENCRYPT_TYPE_NONE ==
10536 pSession->connectedProfile.EncryptionType ))
10537 {
10538 csrRoamIssueSetContextReq( pMac, sessionId,
10539 pSession->connectedProfile.EncryptionType,
10540 pSession->pConnectBssDesc,
10541 &Broadcastaddr,
10542 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10545 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010546 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10547 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010548 pRoamInfo = &roamInfo;
10549 //This BSSID is th ereal BSSID, let's save it
10550 if(pSession->pConnectBssDesc)
10551 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010552 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10553 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010556 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 // detection by LIM that the capabilities of the associated AP have changed.
10559 case eSIR_SME_AP_CAPS_CHANGED:
10560 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010561 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10563 if( HAL_STATUS_SUCCESS( status ) )
10564 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010565 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10566 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010567 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010568 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10569 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10570 )
10571 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010572 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10573 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010574 }
10575 else
10576 {
10577 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010578 FL("Skipping csrScanForCapabilityChange as "
10579 "CSR is in state %s and sub-state %s"),
10580 macTraceGetcsrRoamState(
10581 pMac->roam.curState[sessionId]),
10582 macTraceGetcsrRoamSubState(
10583 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010584 /* We ignore the caps change event if CSR is not in full connected state.
10585 * Send one event to PE to reset limSentCapsChangeNtf
10586 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10587 * otherwise lim cannot send any CAPS change events to SME */
10588 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 }
10591 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010592
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 default:
10594 roamStatus = eCSR_ROAM_FAILED;
10595 result = eCSR_ROAM_RESULT_NONE;
10596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 } // end switch on statusChangeCode
10598 if(eCSR_ROAM_RESULT_NONE != result)
10599 {
10600 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10601 }
10602 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 case eWNI_SME_IBSS_NEW_PEER_IND:
10604 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10606 {
10607 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10609 if(pIbssLog)
10610 {
10611 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010612 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10614 }
10615 }
10616#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 sessionId = csrFindIbssSession( pMac );
10618 if( CSR_SESSION_ID_INVALID != sessionId )
10619 {
10620 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010621
10622 if(!pSession)
10623 {
10624 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10625 return;
10626 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10628 if(pSession->pConnectBssDesc)
10629 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010630 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10631 sizeof(tCsrBssid));
10632 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10633 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10635 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010636 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10637 - sizeof(tSmeIbssPeerInd)));
10638 if ( NULL == roamInfo.pbFrames )
10639 status = eHAL_STATUS_FAILURE;
10640 else
10641 status = eHAL_STATUS_SUCCESS;
10642 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010643 {
10644 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010645 vos_mem_copy(roamInfo.pbFrames,
10646 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10647 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010648 }
10649 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10650 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10651 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010652 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10653 if ( NULL == roamInfo.pBssDesc )
10654 status = eHAL_STATUS_FAILURE;
10655 else
10656 status = eHAL_STATUS_SUCCESS;
10657 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010659 vos_mem_copy(roamInfo.pBssDesc,
10660 pSession->pConnectBssDesc,
10661 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010662 }
10663 if(HAL_STATUS_SUCCESS(status))
10664 {
10665 pRoamInfo = &roamInfo;
10666 }
10667 else
10668 {
10669 if(roamInfo.pbFrames)
10670 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010671 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010672 }
10673 if(roamInfo.pBssDesc)
10674 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010675 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 }
10677 }
10678 }
10679 else
10680 {
10681 pRoamInfo = &roamInfo;
10682 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010683 if ((eCSR_ENCRYPT_TYPE_NONE ==
10684 pSession->connectedProfile.EncryptionType ))
10685 {
10686 csrRoamIssueSetContextReq( pMac, sessionId,
10687 pSession->connectedProfile.EncryptionType,
10688 pSession->pConnectBssDesc,
10689 &(pIbssPeerInd->peerAddr),
10690 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010692 }
10693 else
10694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010695 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 }
10697 //send up the sec type for the new peer
10698 if (pRoamInfo)
10699 {
10700 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10701 }
10702 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10703 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10704 if(pRoamInfo)
10705 {
10706 if(roamInfo.pbFrames)
10707 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010708 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 }
10710 if(roamInfo.pBssDesc)
10711 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010712 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010713 }
10714 }
10715 }
10716 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10718 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10719 sessionId = csrFindIbssSession( pMac );
10720 if( CSR_SESSION_ID_INVALID != sessionId )
10721 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010722#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10723 {
10724 vos_log_ibss_pkt_type *pIbssLog;
10725
10726 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10727 if(pIbssLog)
10728 {
10729 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10730 if(pIbssPeerInd)
10731 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010732 vos_mem_copy(pIbssLog->peerMacAddr,
10733 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010734 }
10735 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10736 }
10737 }
10738#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010739 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10741 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10742 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010743 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10744 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10746 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10747 }
10748 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 case eWNI_SME_SETCONTEXT_RSP:
10750 {
10751 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10752 tListElem *pEntry;
10753 tSmeCmd *pCommand;
10754
10755 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10756 if ( pEntry )
10757 {
10758 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10759 if ( eSmeCommandSetKey == pCommand->command )
10760 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010761 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010763
10764 if(!pSession)
10765 {
10766 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10767 return;
10768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010769
10770#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10771 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10772 {
10773 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010774 vos_mem_set(&setKeyEvent,
10775 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 if( pRsp->peerMacAddr[0] & 0x01 )
10777 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010778 setKeyEvent.eventId =
10779 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 }
10781 else
10782 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010783 setKeyEvent.eventId =
10784 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010786 if( pRsp->peerMacAddr[0] & 0x01 )
10787 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010788 pMac->pmc.full_power_till_set_key = false;
10789 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 setKeyEvent.encryptionModeMulticast =
10792 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10793 setKeyEvent.encryptionModeUnicast =
10794 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010795 vos_mem_copy(setKeyEvent.bssid,
10796 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 setKeyEvent.authMode =
10798 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010799 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 {
10801 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10802 }
10803 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10804 }
10805#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10806 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10807 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010808 csrRoamStopWaitForKeyTimer( pMac );
10809
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 //We are done with authentication, whethere succeed or not
10811 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 //We do it here because this linkup function is not called after association
10813 //when a key needs to be set.
10814 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10815 {
10816 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10817 }
10818 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010819 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010820 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010821 vos_mem_copy(&roamInfo.peerMac,
10822 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010823 //Make sure we install the GTK before indicating to HDD as authenticated
10824 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010825 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10826 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010827 {
Yathish9f22e662012-12-10 14:21:35 -080010828#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10829 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10830 {
10831 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010832 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010833 if (NULL == pMsg)
10834 {
10835 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10836 return;
10837 }
10838
Yathish9f22e662012-12-10 14:21:35 -080010839 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010840 pMsg->length = pal_cpu_to_be16(sizeof(
10841 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010842 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010843 vos_mem_copy(pMsg->bssid,
10844 pSession->connectedProfile.bssid,
10845 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010846 status = palSendMBMessage(pMac->hHdd, pMsg );
10847 }
10848#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010849 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010850 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010851 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010852 && (pSession->connectState ==
10853 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10854 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010855 && (VOS_P2P_GO_MODE !=
10856 pSession->pCurRoamProfile->csrPersona
10857 && VOS_STA_SAP_MODE !=
10858 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010859 {
10860 tpSirSmeHT40OBSSScanInd pMsg;
10861 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010862 if (NULL == pMsg)
10863 {
10864 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10865 return;
10866 }
10867
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010868 pMsg->messageType =
10869 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10870 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010871 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10872 vos_mem_copy(pMsg->peerMacAddr,
10873 pSession->connectedProfile.bssid,
10874 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010875 status = palSendMBMessage(pMac->hHdd,
10876 pMsg );
10877 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010878 else
10879 {
10880 smsLog( pMac, LOG1,FL("OBSS SCAN"
10881 "Indication not sent to FW"
10882 "channel %d OBSS_SCAN: %d"),
10883 pSession->connectedProfile.
10884 operationChannel,
10885 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10886 smsLog( pMac, LOG1,FL("connectState %d"
Jeff Johnson89477502017-09-19 08:35:23 -070010887 "pCurRoamProfile %pK"),
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010888 pSession->connectState,
10889 pSession->pCurRoamProfile);
10890 }
10891
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010892 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010893 }
10894 else
10895 {
10896 result = eCSR_ROAM_RESULT_NONE;
10897 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010898 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010899 }
10900 else
10901 {
10902 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010903 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10904 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10905 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010906 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010907 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010908 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10909 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10911 // can go ahead and initiate the TSPEC if any are pending
10912 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010913#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010914 //Send Adjacent AP repot to new AP.
10915 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10916 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010917 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010918 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010919#ifdef FEATURE_WLAN_ESE_UPLOAD
10920 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010921#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010922 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010923#endif
10924 pSession->isPrevApInfoValid = FALSE;
10925 }
10926#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10928 {
10929 csrReleaseCommandSetKey( pMac, pCommand );
10930 }
10931 }
10932 else
10933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010934 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 }
10936 }
10937 else
10938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010939 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 smeProcessPendingQueue( pMac );
10942 }
10943 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010944 case eWNI_SME_REMOVEKEY_RSP:
10945 {
10946 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10947 tListElem *pEntry;
10948 tSmeCmd *pCommand;
10949
10950 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10951 if ( pEntry )
10952 {
10953 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10954 if ( eSmeCommandRemoveKey == pCommand->command )
10955 {
10956 sessionId = pCommand->sessionId;
10957 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010958
10959 if(!pSession)
10960 {
10961 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10962 return;
10963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010964#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10965 {
10966 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010967 vos_mem_set(&removeKeyEvent,
10968 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10970 removeKeyEvent.encryptionModeMulticast =
10971 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10972 removeKeyEvent.encryptionModeUnicast =
10973 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010974 vos_mem_copy( removeKeyEvent.bssid,
10975 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 removeKeyEvent.authMode =
10977 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010978 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 {
10980 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10981 }
10982 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10983 }
10984#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010985 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010986 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010987 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10988 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 result = eCSR_ROAM_RESULT_NONE;
10990 pRoamInfo = &roamInfo;
10991 }
10992 else
10993 {
10994 result = eCSR_ROAM_RESULT_FAILURE;
10995 }
10996 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10997 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10998 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10999 {
11000 csrReleaseCommandRemoveKey( pMac, pCommand );
11001 }
11002 }
11003 else
11004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011005 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011006 }
11007 }
11008 else
11009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011010 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011011 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011012 smeProcessPendingQueue( pMac );
11013 }
11014 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011016 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 csrRoamStatsRspProcessor( pMac, pSirMsg );
11018 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011019#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011020 case eWNI_SME_GET_ROAM_RSSI_RSP:
11021 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
11022 csrRoamRssiRspProcessor( pMac, pSirMsg );
11023 break;
11024#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011025#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011026 case eWNI_SME_GET_TSM_STATS_RSP:
11027 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
11028 csrTsmStatsRspProcessor( pMac, pSirMsg );
11029 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011030#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011032 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 csrUpdateRssi( pMac, pSirMsg );
11034 break;
11035
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011036 case eWNI_SME_GET_SNR_REQ:
11037 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
11038 csrUpdateSnr(pMac, pSirMsg);
11039 break;
11040
Jeff Johnson295189b2012-06-20 16:38:30 -070011041#ifdef WLAN_FEATURE_VOWIFI_11R
11042 case eWNI_SME_FT_PRE_AUTH_RSP:
11043 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
11044 break;
11045#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053011046#ifdef WLAN_FEATURE_LFR_MBB
11047 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
11048 csr_roam_preauth_rsp_mbb_processor(pMac,
11049 (tpSirFTPreAuthRsp)pSirMsg);
11050 break;
11051#endif
11052
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11054 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011055 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 -070011056 sessionId = pSmeMaxAssocInd->sessionId;
11057 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011058 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
11059 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11061 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11062 break;
11063
11064 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011065 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011066#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011067 btampEstablishLogLinkHdlr( pSirMsg );
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011068#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011069 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070011070 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011071 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011072 csrRoamRssiIndHdlr( pMac, pSirMsg );
11073 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011074#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11075 case eWNI_SME_CANDIDATE_FOUND_IND:
11076 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
11077 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
11078 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070011079 case eWNI_SME_HANDOFF_REQ:
11080 smsLog( pMac, LOG2, FL("Handoff Req from self"));
11081 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
11082 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011083#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011084
11085 default:
11086 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070011088}
11089
Jeff Johnson295189b2012-06-20 16:38:30 -070011090void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
11091 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
11092{
11093 if(pSession)
11094 {
11095 if(pSession->bRefAssocStartCnt)
11096 {
11097 pSession->bRefAssocStartCnt--;
11098 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11099 //Need to call association_completion because there is an assoc_start pending.
11100 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11101 eCSR_ROAM_ASSOCIATION_COMPLETION,
11102 eCSR_ROAM_RESULT_FAILURE);
11103 }
11104 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11105 }
11106 else
11107 {
11108 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11109 }
11110}
11111
11112
11113eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11114{
11115 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011116 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11117 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11118 {
11119 status = csrScanRequestLostLink1( pMac, sessionId );
11120 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011121 return(status);
11122}
11123
Jeff Johnson295189b2012-06-20 16:38:30 -070011124//return a boolean to indicate whether roaming completed or continue.
11125tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11126 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11127{
11128 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11129 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11130 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011132 if(!pSession)
11133 {
11134 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11135 return eANI_BOOLEAN_FALSE;
11136 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011137 //Check whether time is up
11138 if(pSession->fCancelRoaming || fForce ||
11139 ((curTime - pSession->roamingStartTime) > roamTime) ||
11140 eCsrReassocRoaming == pSession->roamingReason ||
11141 eCsrDynamicRoaming == pSession->roamingReason)
11142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011143 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11145 {
11146 //roaming is cancelled, tell HDD to indicate disconnect
11147 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11148 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11149 //to be eSIR_BEACON_MISSED
11150 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11151 {
11152 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11153 }
11154 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11155 {
11156 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11157 }
11158 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11159 {
11160 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11161 }
11162 else
11163 {
11164 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11165 }
11166 }
11167 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11168 pSession->roamingReason = eCsrNotRoaming;
11169 }
11170 else
11171 {
11172 pSession->roamResult = roamResult;
11173 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11174 {
11175 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11176 pSession->roamingReason = eCsrNotRoaming;
11177 }
11178 else
11179 {
11180 fCompleted = eANI_BOOLEAN_FALSE;
11181 }
11182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 return(fCompleted);
11184}
11185
Jeff Johnson295189b2012-06-20 16:38:30 -070011186void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11187{
11188 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011189
11190 if(!pSession)
11191 {
11192 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11193 return;
11194 }
11195
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 if(CSR_IS_ROAMING(pSession))
11197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011198 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11200 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11201 {
11202 //No need to do anything in here because the handler takes care of it
11203 }
11204 else
11205 {
11206 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11207 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11208 //Roaming is stopped after here
11209 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11210 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011211 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 csrRoamStopRoamingTimer(pMac, sessionId);
11213 }
11214 }
11215}
11216
Jeff Johnson295189b2012-06-20 16:38:30 -070011217void csrRoamRoamingTimerHandler(void *pv)
11218{
11219 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11220 tpAniSirGlobal pMac = pInfo->pMac;
11221 tANI_U32 sessionId = pInfo->sessionId;
11222 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011223
11224 if(!pSession)
11225 {
11226 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11227 return;
11228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011229
11230 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11231 {
11232 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11233 {
11234 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11235 pSession->roamingReason = eCsrNotRoaming;
11236 }
11237 }
11238}
11239
Jeff Johnson295189b2012-06-20 16:38:30 -070011240eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11241{
11242 eHalStatus status;
11243 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011244
11245 if(!pSession)
11246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011247 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011248 return eHAL_STATUS_FAILURE;
11249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011250
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011251 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011252 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011253 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011254
11255 return (status);
11256}
11257
Jeff Johnson295189b2012-06-20 16:38:30 -070011258eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11259{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011260 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011261}
11262
Jeff Johnson295189b2012-06-20 16:38:30 -070011263void csrRoamWaitForKeyTimeOutHandler(void *pv)
11264{
11265 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11266 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011267 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011268 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011269
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011270 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011271 macTraceGetNeighbourRoamState(
11272 pMac->roam.neighborRoamInfo.neighborRoamState),
11273 macTraceGetcsrRoamSubState(
11274 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011275
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011276 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011278 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011279 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11280 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011281 //Change the substate so command queue is unblocked.
11282 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11283 pMac->roam.curSubState[pInfo->sessionId] =
11284 eCSR_ROAM_SUBSTATE_NONE;
11285 vos_spin_lock_release(&pMac->roam.roam_state_lock);
11286
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011287#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011288 if (csrNeighborRoamIsHandoffInProgress(pMac))
11289 {
11290 /*
11291 * Enable heartbeat timer when hand-off is in progress
11292 * and Key Wait timer expired.
11293 */
11294 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11295 " (nHBCount=%d)",
11296 pMac->roam.configParam.HeartbeatThresh24);
11297 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11298 pMac->roam.configParam.HeartbeatThresh24,
11299 NULL, eANI_BOOLEAN_FALSE);
11300 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011301#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011302
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011303 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011304
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011305 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011306 {
11307 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11308 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011309 status = sme_AcquireGlobalLock(&pMac->sme);
11310 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011311 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011312 csrRoamDisconnect(pMac, pInfo->sessionId,
11313 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11314 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011315 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011316 }
11317 else
11318 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011319 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11320 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011321 }
11322 }
11323 else
11324 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011325 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011326 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 }
11329
11330}
11331
Jeff Johnson295189b2012-06-20 16:38:30 -070011332eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11333{
11334 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011335#ifdef FEATURE_WLAN_LFR
11336 if (csrNeighborRoamIsHandoffInProgress(pMac))
11337 {
11338 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011339 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11340 macTraceGetNeighbourRoamState(
11341 pMac->roam.neighborRoamInfo.neighborRoamState),
11342 macTraceGetcsrRoamSubState(
11343 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11344 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011345 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11346 }
11347#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011348 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011349 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011350
11351 return (status);
11352}
11353
Jeff Johnson295189b2012-06-20 16:38:30 -070011354eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11355{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011356 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11357 macTraceGetNeighbourRoamState(
11358 pMac->roam.neighborRoamInfo.neighborRoamState),
11359 macTraceGetcsrRoamSubState(
11360 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011361#ifdef FEATURE_WLAN_LFR
11362 if (csrNeighborRoamIsHandoffInProgress(pMac))
11363 {
11364 /*
11365 * Enable heartbeat timer when hand-off is in progress
11366 * and Key Wait timer got stopped for some reason
11367 */
11368 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011369 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011370 pMac->roam.configParam.HeartbeatThresh24);
11371 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11372 pMac->roam.configParam.HeartbeatThresh24,
11373 NULL, eANI_BOOLEAN_FALSE);
11374 }
11375#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011376 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011377}
11378
Jeff Johnson295189b2012-06-20 16:38:30 -070011379void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11380 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11381{
11382 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11383 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011384 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11385 /* To silence the KW tool Null chaeck is added */
11386 if(!pSession)
11387 {
11388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11389 return;
11390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011391
11392 if(pCommand)
11393 {
11394 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011395 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11398 {
11399 //if success, force roaming completion
11400 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11401 }
11402 else
11403 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011404 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011405 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11407 }
11408}
11409
Jeff Johnson295189b2012-06-20 16:38:30 -070011410eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11411{
11412 eHalStatus status = eHAL_STATUS_SUCCESS;
11413 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11414 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11415 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011416 tCsrRoamInfo roamInfo;
11417 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011418 /* To silence the KW tool Null chaeck is added */
11419 if(!pSession)
11420 {
11421 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11422 return eHAL_STATUS_FAILURE;
11423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011425 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 if ( eWNI_SME_DISASSOC_IND == type )
11427 {
11428 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11429 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11430 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011431 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011432 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11433 sizeof(tSirMacAddr));
11434 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 }
11436 else if ( eWNI_SME_DEAUTH_IND == type )
11437 {
11438 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11439 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11440 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011441 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011442 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11443 sizeof(tSirMacAddr));
11444 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 }
11446 else
11447 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011448 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011450 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011451 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011452 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11453 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11454 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
11455
11456 if (type == eWNI_SME_DEAUTH_IND || type == eWNI_SME_DISASSOC_IND) {
11457 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11458 eCSR_ROAM_LOSTLINK_DETECTED, result);
11459 } else if(!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11460 csrRoamCallCallback(pMac, sessionId, NULL, 0,
11461 eCSR_ROAM_LOSTLINK_DETECTED, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 }
11463
11464 if ( eWNI_SME_DISASSOC_IND == type )
11465 {
11466 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11467 }
11468 else if ( eWNI_SME_DEAUTH_IND == type )
11469 {
11470 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011472
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011473 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11474 {
Jingxiang Ge6298d0a2018-10-18 16:12:54 +080011475 //remove the connected BSS in infrastructure mode
11476 csrRoamRemoveConnectedBssFromScanCache(pMac,
11477 &pSession->connectedProfile);
11478
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011479 csrScanStartIdleScan(pMac);
11480 }
11481
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 return (status);
11483}
11484
Jeff Johnson295189b2012-06-20 16:38:30 -070011485eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11486{
11487 eHalStatus status = eHAL_STATUS_SUCCESS;
11488 tListElem *pEntry = NULL;
11489 tSmeCmd *pCommand = NULL;
11490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011491
11492 if(!pSession)
11493 {
11494 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11495 return eHAL_STATUS_FAILURE;
11496 }
11497
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 //Only remove the connected BSS in infrastructure mode
11500 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11501 if(pMac->roam.configParam.nRoamingTime)
11502 {
11503 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11504 {
11505 //before starting the lost link logic release the roam command for handoff
11506 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11507 if(pEntry)
11508 {
11509 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11510 }
11511 if(pCommand)
11512 {
11513 if (( eSmeCommandRoam == pCommand->command ) &&
11514 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11515 {
11516 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11517 {
11518 csrReleaseCommandRoam( pMac, pCommand );
11519 }
11520 }
11521 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011522 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 }
11524 }
11525 else
11526 {
11527 //We are told not to roam, indicate lostlink
11528 status = eHAL_STATUS_FAILURE;
11529 }
11530
11531 return (status);
11532}
Jeff Johnson295189b2012-06-20 16:38:30 -070011533void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11534{
11535 tListElem *pEntry;
11536 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11538 if ( pEntry )
11539 {
11540 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11541 if ( eSmeCommandWmStatusChange == pCommand->command )
11542 {
11543 // Nothing to process in a Lost Link completion.... It just kicks off a
11544 // roaming sequence.
11545 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11546 {
11547 csrReleaseCommandWmStatusChange( pMac, pCommand );
11548 }
11549 else
11550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011551 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 }
11553
11554 }
11555 else
11556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011557 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 }
11559 }
11560 else
11561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011562 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 smeProcessPendingQueue( pMac );
11565}
11566
Jeff Johnson295189b2012-06-20 16:38:30 -070011567void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11568{
11569 eHalStatus status = eHAL_STATUS_FAILURE;
11570 tSirSmeRsp *pSirSmeMsg;
11571 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011572
11573 if(!pSession)
11574 {
11575 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11576 return;
11577 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011578 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11579 pCommand->sessionId,
11580 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 switch ( pCommand->u.wmStatusChangeCmd.Type )
11582 {
11583 case eCsrDisassociated:
11584 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11585 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 case eCsrDeauthenticated:
11588 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11589 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11590 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011592 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 break;
11594 }
11595 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11596 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11597 {
11598 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11599 {
11600 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011601 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 }
11603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11605 // command here since there is nothing else to do.
11606 csrRoamWmStatusChangeComplete( pMac );
11607}
11608
Jeff Johnson295189b2012-06-20 16:38:30 -070011609//This function returns band and mode information.
11610//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11611//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011612static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11613 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011614{
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11616 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11617 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011619
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 //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 -070011621 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11622 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11623 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11624 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011625 {
11626 switch( pMac->roam.configParam.uCfgDot11Mode )
11627 {
11628 case eCSR_CFG_DOT11_MODE_11A:
11629 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11630 eBand = eCSR_BAND_5G;
11631 break;
11632 case eCSR_CFG_DOT11_MODE_11B:
11633 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11634 eBand = eCSR_BAND_24;
11635 break;
11636 case eCSR_CFG_DOT11_MODE_11G:
11637 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11638 eBand = eCSR_BAND_24;
11639 break;
11640 case eCSR_CFG_DOT11_MODE_11N:
11641 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011642 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11643 break;
11644#ifdef WLAN_FEATURE_11AC
11645 case eCSR_CFG_DOT11_MODE_11AC:
11646 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11647 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011648 /* If the operating channel is in 2.4 GHz band, check for
11649 * INI item to disable VHT operation in 2.4 GHz band
11650 */
11651 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11652 !pMac->roam.configParam.enableVhtFor24GHz)
11653 {
11654 /* Disable 11AC operation */
11655 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11656 }
11657 else
11658 {
11659 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11660 }
11661 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011662 }
11663 else
11664 {
11665 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11666 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11667 }
11668 break;
11669 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11670 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11671 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011672 /* If the operating channel is in 2.4 GHz band, check for
11673 * INI item to disable VHT operation in 2.4 GHz band
11674 */
11675 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11676 !pMac->roam.configParam.enableVhtFor24GHz)
11677 {
11678 /* Disable 11AC operation */
11679 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11680 }
11681 else
11682 {
11683 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11684 }
11685 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011686 }
11687 else
11688 {
11689 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11690 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11691 }
11692 break;
11693#endif
11694 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011695#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011696 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11697 {
11698 /* If the operating channel is in 2.4 GHz band, check for
11699 * INI item to disable VHT operation in 2.4 GHz band
11700 */
11701 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11702 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011703 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011704 /* Disable 11AC operation */
11705 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011706 }
11707 else
11708 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011709 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11710 }
11711 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11712 }
11713 else
11714 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011715 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11716 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011717 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011718#else
11719 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11720 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11721#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011722 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 default:
11724 // Global dot11 Mode setting is 11a/b/g.
11725 // use the channel number to determine the Mode setting.
11726 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11727 {
11728 eBand = pMac->roam.configParam.eBand;
11729 if(eCSR_BAND_24 == eBand)
11730 {
11731 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11732 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11733 }
11734 else
11735 {
11736 //prefer 5GHz
11737 eBand = eCSR_BAND_5G;
11738 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11739 }
11740 }
11741 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11742 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011743 // WiFi tests require IBSS networks to start in 11b mode
11744 // without any change to the default parameter settings
11745 // on the adapter. We use ACU to start an IBSS through
11746 // creation of a startIBSS profile. This startIBSS profile
11747 // has Auto MACProtocol and the adapter property setting
11748 // for dot11Mode is also AUTO. So in this case, let's
11749 // start the IBSS network in 11b mode instead of 11g mode.
11750 // So this is for Auto=profile->MacProtocol && Auto=Global.
11751 // dot11Mode && profile->channel is < 14, then start the IBSS
11752 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011754 // Note: we used to have this start as an 11g IBSS for best
11755 // performance... now to specify that the user will have to
11756 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11758 eBand = eCSR_BAND_24;
11759 }
11760 else
11761 {
11762 // else, it's a 5.0GHz channel. Set mode to 11a.
11763 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11764 eBand = eCSR_BAND_5G;
11765 }
11766 break;
11767 }//switch
11768 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11769 else
11770 {
11771 //dot11 mode is set, lets pick the band
11772 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11773 {
11774 // channel is Auto also.
11775 eBand = pMac->roam.configParam.eBand;
11776 if(eCSR_BAND_ALL == eBand)
11777 {
11778 //prefer 5GHz
11779 eBand = eCSR_BAND_5G;
11780 }
11781 }
11782 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11783 {
11784 eBand = eCSR_BAND_24;
11785 }
11786 else
11787 {
11788 eBand = eCSR_BAND_5G;
11789 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 if(pBand)
11792 {
11793 *pBand = eBand;
11794 }
11795
11796 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011797 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11799 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011800
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011801 /* 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 +053011802 if (
11803#ifdef SAP_AUTH_OFFLOAD
11804 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11805#endif
11806 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11807 ((pProfile->privacy == 1) &&
11808 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011809 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011810#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011811 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011812#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011813 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11814 {
11815 //We cannot do 11n here
11816 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11817 {
11818 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11819 }
11820 else
11821 {
11822 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11823 }
11824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 return( cfgDot11Mode );
11826}
11827
Jeff Johnson295189b2012-06-20 16:38:30 -070011828eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11829{
11830 eHalStatus status;
11831 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011832
11833 if(!pSession)
11834 {
11835 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11836 return eHAL_STATUS_FAILURE;
11837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011838
11839#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11840 {
11841 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11843 if(pIbssLog)
11844 {
11845 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11846 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11847 }
11848 }
11849#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 // Set the roaming substate to 'stop Bss request'...
11851 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11852
11853 // attempt to stop the Bss (reason code is ignored...)
11854 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011855 if(!HAL_STATUS_SUCCESS(status))
11856 {
11857 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 return (status);
11860}
11861
Jeff Johnson295189b2012-06-20 16:38:30 -070011862//pNumChan is a caller allocated space with the sizeof pChannels
11863eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11864{
11865
11866 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11867 (tANI_U8 *)pChannels,
11868 pNumChan));
11869}
11870
Kiran4a17ebe2013-01-31 10:43:43 -080011871tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11872{
11873 tANI_U32 cfgLength = 0;
11874 tANI_U16 cfgId = 0;
11875 tPowerdBm maxTxPwr = 0;
11876 tANI_U8 *pCountryInfo = NULL;
11877 eHalStatus status;
11878 tANI_U8 count = 0;
11879 tANI_U8 firstChannel;
11880 tANI_U8 maxChannels;
11881
11882 if (CSR_IS_CHANNEL_5GHZ(channel))
11883 {
11884 cfgId = WNI_CFG_MAX_TX_POWER_5;
11885 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11886 }
11887 else if (CSR_IS_CHANNEL_24GHZ(channel))
11888 {
11889 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11890 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11891 }
11892 else
11893 return maxTxPwr;
11894
Kiet Lam64c1b492013-07-12 13:56:44 +053011895 pCountryInfo = vos_mem_malloc(cfgLength);
11896 if ( NULL == pCountryInfo )
11897 status = eHAL_STATUS_FAILURE;
11898 else
11899 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011900 if (status != eHAL_STATUS_SUCCESS)
11901 {
11902 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011903 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011904 __FUNCTION__, status);
11905 goto error;
11906 }
11907 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11908 if (status != eHAL_STATUS_SUCCESS)
11909 {
11910 goto error;
11911 }
11912 /* Identify the channel and maxtxpower */
11913 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11914 {
11915 firstChannel = pCountryInfo[count++];
11916 maxChannels = pCountryInfo[count++];
11917 maxTxPwr = pCountryInfo[count++];
11918
11919 if ((channel >= firstChannel) &&
11920 (channel < (firstChannel + maxChannels)))
11921 {
11922 break;
11923 }
11924 }
11925
11926error:
11927 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011928 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011929
11930 return maxTxPwr;
11931}
11932
11933
Jeff Johnson295189b2012-06-20 16:38:30 -070011934tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11935{
11936 tANI_BOOLEAN fValid = FALSE;
11937 tANI_U32 idxValidChannels;
11938 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11939
11940 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11941 {
11942 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11943 {
11944 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11945 {
11946 fValid = TRUE;
11947 break;
11948 }
11949 }
11950 }
11951 pMac->roam.numValidChannels = len;
11952 return fValid;
11953}
11954
Jeff Johnson295189b2012-06-20 16:38:30 -070011955tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11956{
11957 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11958 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011959 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11960 {
11961 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11962 {
11963 fValid = eANI_BOOLEAN_TRUE;
11964 break;
11965 }
11966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011967 return (fValid);
11968}
11969
Jeff Johnson295189b2012-06-20 16:38:30 -070011970//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011971 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011972{
Jeff Johnsone7245742012-09-05 17:12:55 -070011973 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 tANI_U8 centerChn;
11975 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011976
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11978 {
11979 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11980 }
11981 else
11982 {
11983 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11984 }
11985 //Figure what the other side's CB mode
11986 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11987 {
11988 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11989 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011990 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11991 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11992 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11993 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011994 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11995 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011996 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011997 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011998
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011999 {
12000 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
12001 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12002 }
12003
12004 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012006 /* This is called during INFRA STA/CLIENT and should use the merged value of
12007 * supported channel width and recommended tx width as per standard
12008 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012009 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070012010 pIes->HTCaps.supportedChannelWidthSet,
12011 pIes->HTInfo.recommendedTxWidthSet,
12012 pIes->HTInfo.secondaryChannelOffset);
12013
12014 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12015 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070012016 else
Jeff Johnsone7245742012-09-05 17:12:55 -070012017 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12018 switch (eRet) {
12019 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12020 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12021 break;
12022 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12023 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12024 break;
12025 case PHY_SINGLE_CHANNEL_CENTERED:
12026 default:
12027 centerChn = primaryChn;
12028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012030 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012032 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012033 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012035 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12036 {
12037 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12038 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 }
12041 }
12042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 return eRet;
12044}
Jeff Johnson295189b2012-06-20 16:38:30 -070012045tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12046{
12047 tANI_BOOLEAN fFound = FALSE;
12048 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12050 {
12051 if( pCipherList->encryptionType[idx] == encryptionType )
12052 {
12053 fFound = TRUE;
12054 break;
12055 }
12056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012057 return fFound;
12058}
Jeff Johnson295189b2012-06-20 16:38:30 -070012059tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12060{
12061 tANI_BOOLEAN fFound = FALSE;
12062 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12064 {
12065 if( pAuthList->authType[idx] == authType )
12066 {
12067 fFound = TRUE;
12068 break;
12069 }
12070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 return fFound;
12072}
Jeff Johnson295189b2012-06-20 16:38:30 -070012073tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12074{
12075 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12076 tCsrScanResultFilter *pScanFilter = NULL;
12077 eHalStatus status = eHAL_STATUS_SUCCESS;
12078
12079 if(pProfile1 && pProfile2)
12080 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012081 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12082 if ( NULL == pScanFilter )
12083 status = eHAL_STATUS_FAILURE;
12084 else
12085 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 if(HAL_STATUS_SUCCESS(status))
12087 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012088 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12090 if(HAL_STATUS_SUCCESS(status))
12091 {
12092 fCheck = eANI_BOOLEAN_FALSE;
12093 do
12094 {
12095 tANI_U32 i;
12096 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12097 {
12098 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12099 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12100 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12101 if ( fCheck ) break;
12102 }
12103 if(!fCheck)
12104 {
12105 break;
12106 }
12107 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12108 || pProfile2->BSSType != pProfile1->BSSType
12109 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12110 )
12111 {
12112 fCheck = eANI_BOOLEAN_FALSE;
12113 break;
12114 }
12115#ifdef WLAN_FEATURE_VOWIFI_11R
12116 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12117 {
12118 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12119 {
12120 fCheck = eANI_BOOLEAN_FALSE;
12121 break;
12122 }
12123 }
12124#endif
12125 //Match found
12126 fCheck = eANI_BOOLEAN_TRUE;
12127 }while(0);
12128 csrFreeScanFilter(pMac, pScanFilter);
12129 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012130 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 }
12132 }
12133
12134 return (fCheck);
12135}
12136
Jeff Johnson295189b2012-06-20 16:38:30 -070012137tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12138{
12139 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12140 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012141 do
12142 {
12143 //Only check for static WEP
12144 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12145 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12146 {
12147 fCheck = eANI_BOOLEAN_TRUE;
12148 break;
12149 }
12150 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12151 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12152 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12153 {
12154 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012155 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12156 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 {
12158 break;
12159 }
12160 }
12161 if( i == CSR_MAX_NUM_KEY)
12162 {
12163 fCheck = eANI_BOOLEAN_TRUE;
12164 }
12165 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 return (fCheck);
12167}
12168
Jeff Johnson295189b2012-06-20 16:38:30 -070012169//IBSS
12170
Jeff Johnson295189b2012-06-20 16:38:30 -070012171tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12172{
12173 tANI_U8 channel = 0;
12174 tANI_U32 idx;
12175 tANI_U32 idxValidChannels;
12176 tANI_BOOLEAN fFound = FALSE;
12177 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12178
12179 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12180 {
12181 channel = pMac->roam.configParam.AdHocChannel5G;
12182 if(!csrRoamIsChannelValid(pMac, channel))
12183 {
12184 channel = 0;
12185 }
12186 }
12187 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12188 {
12189 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12190 {
12191 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12192 {
12193 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12194 {
12195 fFound = TRUE;
12196 channel = csrStartIbssChannels50[ idx ];
12197 }
12198 }
12199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12201 if (!fFound)
12202 {
12203 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12204 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012205 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012207 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 break;
12209 }
12210 }
12211 }
12212 }//if
12213
12214 return( channel );
12215}
12216
Jeff Johnson295189b2012-06-20 16:38:30 -070012217tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12218{
12219 tANI_U8 channel = 1;
12220 tANI_U32 idx;
12221 tANI_U32 idxValidChannels;
12222 tANI_BOOLEAN fFound = FALSE;
12223 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12224
12225 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12226 {
12227 channel = pMac->roam.configParam.AdHocChannel24;
12228 if(!csrRoamIsChannelValid(pMac, channel))
12229 {
12230 channel = 0;
12231 }
12232 }
12233
12234 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12235 {
12236 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12237 {
12238 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12239 {
12240 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12241 {
12242 fFound = TRUE;
12243 channel = csrStartIbssChannels24[ idx ];
12244 }
12245 }
12246 }
12247 }
12248
12249 return( channel );
12250}
12251
Jeff Johnson295189b2012-06-20 16:38:30 -070012252static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12253 tCsrRoamStartBssParams *pParam )
12254{
12255 eCsrCfgDot11Mode cfgDot11Mode;
12256 eCsrBand eBand;
12257 tANI_U8 channel = 0;
12258 tSirNwType nwType;
12259 tANI_U8 operationChannel = 0;
12260
12261 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12262 {
12263 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12264 }
12265
Jeff Johnson295189b2012-06-20 16:38:30 -070012266 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012267
Jeff Johnson295189b2012-06-20 16:38:30 -070012268 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12269 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12270 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12271 )
12272 {
12273 /* This should never happen */
12274 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012275 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 pProfile->csrPersona);
12277 VOS_ASSERT(0);
12278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 switch( cfgDot11Mode )
12280 {
12281 case eCSR_CFG_DOT11_MODE_11G:
12282 nwType = eSIR_11G_NW_TYPE;
12283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 case eCSR_CFG_DOT11_MODE_11B:
12285 nwType = eSIR_11B_NW_TYPE;
12286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 case eCSR_CFG_DOT11_MODE_11A:
12288 nwType = eSIR_11A_NW_TYPE;
12289 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012290 default:
12291 case eCSR_CFG_DOT11_MODE_11N:
12292 case eCSR_CFG_DOT11_MODE_TAURUS:
12293 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12294 if(eCSR_BAND_24 == eBand)
12295 {
12296 nwType = eSIR_11G_NW_TYPE;
12297 }
12298 else
12299 {
12300 nwType = eSIR_11A_NW_TYPE;
12301 }
12302 break;
12303 }
12304
12305 pParam->extendedRateSet.numRates = 0;
12306
12307 switch ( nwType )
12308 {
12309 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012310 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012311 case eSIR_11A_NW_TYPE:
12312
12313 pParam->operationalRateSet.numRates = 8;
12314
12315 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12316 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12317 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12318 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12319 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12320 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12321 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12322 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12323
12324 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12325 {
12326 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12327 if( 0 == channel &&
12328 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12329 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12330 )
12331 {
12332 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12333 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12334 nwType = eSIR_11B_NW_TYPE;
12335 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12336 pParam->operationalRateSet.numRates = 4;
12337 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12338 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12339 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12340 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12341 }
12342 }
12343 else
12344 {
12345 channel = operationChannel;
12346 }
12347 break;
12348
12349 case eSIR_11B_NW_TYPE:
12350 pParam->operationalRateSet.numRates = 4;
12351 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12352 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12353 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12354 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12356 {
12357 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12358 }
12359 else
12360 {
12361 channel = operationChannel;
12362 }
12363
12364 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 /* For P2P Client and P2P GO, disable 11b rates */
12367 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12368 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12369 )
12370 {
12371 pParam->operationalRateSet.numRates = 8;
12372
12373 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12374 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12375 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12376 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12377 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12378 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12379 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12380 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12381 }
12382 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 {
12384 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12386 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12387 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12388 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12389
12390 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12392 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12393 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12394 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12395 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12396 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12397 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12398 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12399 }
12400
12401 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12402 {
12403 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12404 }
12405 else
12406 {
12407 channel = operationChannel;
12408 }
12409
12410 break;
12411 }
12412 pParam->operationChn = channel;
12413 pParam->sirNwType = nwType;
12414}
12415
Jeff Johnson295189b2012-06-20 16:38:30 -070012416static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12417 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12418{
12419
12420 if( pParam )
12421 {
12422 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012423 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012425 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012426
12427 if( pIes )
12428 {
12429 if(pIes->SuppRates.present)
12430 {
12431 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12432 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012434 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 -070012435 pIes->SuppRates.num_rates);
12436 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12437 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012438 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12439 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012441 if (pIes->ExtSuppRates.present)
12442 {
12443 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012444 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012445 {
12446 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12447 SIR_MAC_RATESET_EID_MAX, resetting to \
12448 SIR_MAC_RATESET_EID_MAX"),
12449 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012450 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012451 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012452 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012453 pIes->ExtSuppRates.rates,
12454 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 if( pIes->SSID.present )
12457 {
12458 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012459 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12460 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012461 }
12462 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 }
12464 else
12465 {
12466 pParam->ssId.length = 0;
12467 pParam->operationalRateSet.numRates = 0;
12468 }
12469 }
12470}
12471
Jeff Johnson295189b2012-06-20 16:38:30 -070012472static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12473{
12474 tANI_U8 MaxRate = 0;
12475 tANI_U32 i;
12476 tANI_U8 *pRate;
12477
12478 pRate = pSirRateSet->rate;
12479 for ( i = 0; i < pSirRateSet->numRates; i++ )
12480 {
12481 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12482 }
12483
12484 // Save the max rate in the connected state information...
12485
12486 // modify LastRates variable as well
12487
12488 return;
12489}
12490
Jeff Johnson295189b2012-06-20 16:38:30 -070012491eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12492 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12493{
12494 eHalStatus status = eHAL_STATUS_SUCCESS;
12495 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 // Set the roaming substate to 'Start BSS attempt'...
12497 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012498#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12499 //Need to figure out whether we need to log WDS???
12500 if( CSR_IS_IBSS( pProfile ) )
12501 {
12502 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12504 if(pIbssLog)
12505 {
12506 if(pBssDesc)
12507 {
12508 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012509 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 }
12511 else
12512 {
12513 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12514 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012515 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 if(pProfile->ChannelInfo.numOfChannels == 0)
12517 {
12518 pIbssLog->channelSetting = AUTO_PICK;
12519 }
12520 else
12521 {
12522 pIbssLog->channelSetting = SPECIFIED;
12523 }
12524 pIbssLog->operatingChannel = pParam->operationChn;
12525 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12526 }
12527 }
12528#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12529 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012530 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12531 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012532
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 pParam->privacy = pProfile->privacy;
12534 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12535 pParam->authType = pProfile->csr80211AuthType;
12536 pParam->beaconInterval = pProfile->beaconInterval;
12537 pParam->dtimPeriod = pProfile->dtimPeriod;
12538 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12539 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12540 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12541 {
12542 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12543 {
12544 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12545 }
12546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 pParam->protEnabled = pProfile->protEnabled;
12548 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12549 pParam->ht_protection = pProfile->cfg_protection;
12550 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012551
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12553 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012554 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012555
12556#ifdef WLAN_FEATURE_11W
12557 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12558 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12559#endif
12560
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 // When starting an IBSS, start on the channel from the Profile.
12562 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 return (status);
12564}
12565
Jeff Johnson295189b2012-06-20 16:38:30 -070012566static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012567 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012568{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012569 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012570 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012572
12573 if(!pSession)
12574 {
12575 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12576 return;
12577 }
12578
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 if( pBssDesc )
12580 {
12581 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12582 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12583 //The following code has to be do after that.
12584 //For WDS station, use selfMac as the self BSSID
12585 if( CSR_IS_WDS_STA( pProfile ) )
12586 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012587 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12588 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 }
12590 }
12591 else
12592 {
12593 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 //Use the first SSID
12595 if(pProfile->SSIDs.numOfSSIDs)
12596 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012597 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12598 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 }
12600 //For WDS station, use selfMac as the self BSSID
12601 if( CSR_IS_WDS_STA( pProfile ) )
12602 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012603 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12604 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 }
12606 //Use the first BSSID
12607 else if( pProfile->BSSIDs.numOfBSSIDs )
12608 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012609 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12610 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 }
12612 else
12613 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012614 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 }
12616 }
12617 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 //Set operating channel in pProfile which will be used
12619 //in csrRoamSetBssConfigCfg() to determine channel bonding
12620 //mode and will be configured in CFG later
12621 pProfile->operationChannel = Channel;
12622
12623 if(Channel == 0)
12624 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012625 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 }
12627 else
12628 {
12629
12630 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012631 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012632 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012633 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012634 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012635#ifdef WLAN_FEATURE_AP_HT40_24G
12636 if (CSR_IS_INFRA_AP(pProfile))
12637 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12638 else
12639 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12640#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012641 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012642#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012643 }
12644 else
12645 {
12646 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12647 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012648 pBssConfig->cbMode = cbMode;
12649 pSession->bssParams.cbMode = cbMode;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012650 if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
12651 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
12652 else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
12653 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
12654 else
12655 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
12656 smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
12657 pSession->bssParams.orig_ch_width);
Jeff Johnsone7245742012-09-05 17:12:55 -070012658 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 }
12660}
12661
Jeff Johnson295189b2012-06-20 16:38:30 -070012662static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12663 tANI_BOOLEAN *pfSameIbss )
12664{
12665 eHalStatus status = eHAL_STATUS_SUCCESS;
12666 tANI_BOOLEAN fSameIbss = FALSE;
12667
12668 if ( csrIsConnStateIbss( pMac, sessionId ) )
12669 {
12670 // Check if any profile parameter has changed ? If any profile parameter
12671 // has changed then stop old BSS and start a new one with new parameters
12672 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12673 {
12674 fSameIbss = TRUE;
12675 }
12676 else
12677 {
12678 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12679 }
12680 }
12681 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12682 {
12683 // Disassociate from the connected Infrastructure network...
12684 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12685 }
12686 else
12687 {
12688 tBssConfigParam *pBssConfig;
12689
Kiet Lam64c1b492013-07-12 13:56:44 +053012690 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12691 if ( NULL == pBssConfig )
12692 status = eHAL_STATUS_FAILURE;
12693 else
12694 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 if(HAL_STATUS_SUCCESS(status))
12696 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012697 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012698 // there is no Bss description before we start an IBSS so we need to adopt
12699 // all Bss configuration parameters from the Profile.
12700 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12701 if(HAL_STATUS_SUCCESS(status))
12702 {
12703 //save dotMode
12704 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12705 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012706 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012707 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12708 NULL, pBssConfig,
12709 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012711
12712 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 }//Allocate memory
12714 }
12715
12716 if(pfSameIbss)
12717 {
12718 *pfSameIbss = fSameIbss;
12719 }
12720 return( status );
12721}
12722
Jeff Johnson295189b2012-06-20 16:38:30 -070012723static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12724 tSirSmeNewBssInfo *pNewBss )
12725{
12726 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012727
12728 if(!pSession)
12729 {
12730 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12731 return;
12732 }
12733
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 if( pNewBss )
12735 {
12736 // Set the operating channel.
12737 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12738 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012739 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12740 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 return;
12743}
12744
Jeff Johnson295189b2012-06-20 16:38:30 -070012745#ifdef FEATURE_WLAN_WAPI
12746eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12747 tANI_U32 numItems )
12748{
12749 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012750 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012753 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 return status;
12755 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012756 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 pSession = CSR_GET_SESSION( pMac, sessionId );
12758 if(numItems <= CSR_MAX_BKID_ALLOWED)
12759 {
12760 status = eHAL_STATUS_SUCCESS;
12761 //numItems may be 0 to clear the cache
12762 pSession->NumBkidCache = (tANI_U16)numItems;
12763 if(numItems && pBKIDCache)
12764 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012765 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12766 sizeof(tBkidCacheInfo) * numItems);
12767 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 }
12769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 return (status);
12771}
Jeff Johnson295189b2012-06-20 16:38:30 -070012772eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12773 tBkidCacheInfo *pBkidCache)
12774{
12775 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012776 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12778 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012779 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 return status;
12781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 pSession = CSR_GET_SESSION( pMac, sessionId );
12783 if(pNum && pBkidCache)
12784 {
12785 if(pSession->NumBkidCache == 0)
12786 {
12787 *pNum = 0;
12788 status = eHAL_STATUS_SUCCESS;
12789 }
12790 else if(*pNum >= pSession->NumBkidCache)
12791 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012792 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012794 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 -070012795 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012796 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012798 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12799 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 *pNum = pSession->NumBkidCache;
12801 status = eHAL_STATUS_SUCCESS;
12802 }
12803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012805}
Jeff Johnson295189b2012-06-20 16:38:30 -070012806tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12807{
12808 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012809}
12810#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012811eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012812 tPmkidCacheInfo *pPMKIDCache,
12813 tANI_U32 numItems,
12814 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012815{
12816 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12817 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012818
12819 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012820 {
12821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12822 return eHAL_STATUS_FAILURE;
12823 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012824
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012825 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012826
12827 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 {
12829#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12830 {
12831 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012832 vos_mem_set(&secEvent,
12833 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12835 secEvent.encryptionModeMulticast =
12836 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12837 secEvent.encryptionModeUnicast =
12838 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012839 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 secEvent.authMode =
12841 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12842 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12843 }
12844#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012846 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012847 if (numItems && pPMKIDCache)
12848 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012849 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012850 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12851 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012852 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012853 }
12854 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012855 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012856 tPmkidCacheInfo *pmksa;
12857
12858 for (i = 0; i < numItems; i++) {
12859 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012860
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012861 /* Delete the entry if present */
12862 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12863
12864 /* Add entry to the cache */
12865 vos_mem_copy(
12866 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12867 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12868 vos_mem_copy(
12869 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12870 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12871
12872 /* Increment the CSR local cache index */
12873 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12874 pSession->CurCacheIndex++;
12875 else
12876 pSession->CurCacheIndex = 0;
12877
12878 pSession->NumPmkidCache++;
12879 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12880 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012882 }
12883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 return (status);
12885}
12886
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012887eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012888#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12889 const tANI_U8 *pBSSId,
12890#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012891 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012892#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012893 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012894{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012895 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12896 tANI_BOOLEAN fMatchFound = FALSE;
12897 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012898 tANI_U32 CurIndex;
12899 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012900
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012901 if(!pSession)
12902 {
12903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12904 return eHAL_STATUS_FAILURE;
12905 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012906
12907 /* Check if there are no entries to delete */
12908 if (0 == pSession->NumPmkidCache) {
12909 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12910 return eHAL_STATUS_SUCCESS;
12911 }
12912
12913 if (!flush_cache) {
12914 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12915 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12916 pBSSId, VOS_MAC_ADDR_SIZE)) {
12917 fMatchFound = 1;
12918
12919 /* Clear this - the matched entry */
12920 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12921 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012922 break;
12923 }
12924 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012925
12926 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12927 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12928 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012929 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012930 else {
12931 /* Match Found */
12932 CurIndex = pSession->CurCacheIndex;
12933 if(Index < CurIndex) {
12934 for(i = Index; i < (CurIndex-1); i++) {
12935 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12936 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12937 }
12938 pSession->CurCacheIndex--;
12939 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12940 sizeof(tPmkidCacheInfo));
12941 } else if(Index > CurIndex) {
12942 for(i = Index; i > (CurIndex); i--) {
12943 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12944 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12945 }
12946 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12947 sizeof(tPmkidCacheInfo));
12948 }
12949 pSession->NumPmkidCache--;
12950 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012951 } else {
12952 /* Flush the entire cache */
12953 vos_mem_zero(pSession->PmkidCacheInfo,
12954 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12955 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012956 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012957 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012958
12959 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012960}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012961
Jeff Johnson295189b2012-06-20 16:38:30 -070012962tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12963{
12964 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12965}
12966
Jeff Johnson295189b2012-06-20 16:38:30 -070012967eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12968{
12969 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12970 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012971 tPmkidCacheInfo *pmksa;
12972 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012973
12974 if(!pSession)
12975 {
12976 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12977 return eHAL_STATUS_FAILURE;
12978 }
12979
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 if(pNum && pPmkidCache)
12981 {
12982 if(pSession->NumPmkidCache == 0)
12983 {
12984 *pNum = 0;
12985 status = eHAL_STATUS_SUCCESS;
12986 }
12987 else if(*pNum >= pSession->NumPmkidCache)
12988 {
12989 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012991 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 -070012992 pSession->NumPmkidCache);
12993 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12994 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012995
12996 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12997 pmksa = &pSession->PmkidCacheInfo[i];
12998 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12999 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
13000 pPmkidCache++;
13001 j++;
13002 }
13003 }
13004
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 *pNum = pSession->NumPmkidCache;
13006 status = eHAL_STATUS_SUCCESS;
13007 }
13008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 return (status);
13010}
13011
Jeff Johnson295189b2012-06-20 16:38:30 -070013012eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13013{
13014 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13015 tANI_U32 len;
13016 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013017
13018 if(!pSession)
13019 {
13020 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13021 return eHAL_STATUS_FAILURE;
13022 }
13023
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 if(pLen)
13025 {
13026 len = *pLen;
13027 *pLen = pSession->nWpaRsnReqIeLength;
13028 if(pBuf)
13029 {
13030 if(len >= pSession->nWpaRsnReqIeLength)
13031 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013032 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13033 pSession->nWpaRsnReqIeLength);
13034 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 }
13036 }
13037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 return (status);
13039}
13040
Jeff Johnson295189b2012-06-20 16:38:30 -070013041eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13042{
13043 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13044 tANI_U32 len;
13045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013046
13047 if(!pSession)
13048 {
13049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13050 return eHAL_STATUS_FAILURE;
13051 }
13052
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 if(pLen)
13054 {
13055 len = *pLen;
13056 *pLen = pSession->nWpaRsnRspIeLength;
13057 if(pBuf)
13058 {
13059 if(len >= pSession->nWpaRsnRspIeLength)
13060 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013061 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13062 pSession->nWpaRsnRspIeLength);
13063 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013064 }
13065 }
13066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 return (status);
13068}
Jeff Johnson295189b2012-06-20 16:38:30 -070013069#ifdef FEATURE_WLAN_WAPI
13070eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13071{
13072 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13073 tANI_U32 len;
13074 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013075
13076 if(!pSession)
13077 {
13078 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13079 return eHAL_STATUS_FAILURE;
13080 }
13081
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 if(pLen)
13083 {
13084 len = *pLen;
13085 *pLen = pSession->nWapiReqIeLength;
13086 if(pBuf)
13087 {
13088 if(len >= pSession->nWapiReqIeLength)
13089 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013090 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13091 pSession->nWapiReqIeLength);
13092 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 }
13094 }
13095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 return (status);
13097}
Jeff Johnson295189b2012-06-20 16:38:30 -070013098eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13099{
13100 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13101 tANI_U32 len;
13102 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013103
13104 if(!pSession)
13105 {
13106 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13107 return eHAL_STATUS_FAILURE;
13108 }
13109
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 if(pLen)
13111 {
13112 len = *pLen;
13113 *pLen = pSession->nWapiRspIeLength;
13114 if(pBuf)
13115 {
13116 if(len >= pSession->nWapiRspIeLength)
13117 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013118 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13119 pSession->nWapiRspIeLength);
13120 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 }
13122 }
13123 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013124 return (status);
13125}
13126#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013127eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13128{
13129 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13130 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013131
13132 if(!pSession)
13133 {
13134 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13135 return (retStatus);
13136 }
13137
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 if(CSR_IS_ROAMING(pSession))
13139 {
13140 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13141 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 return (retStatus);
13144}
13145
Jeff Johnson295189b2012-06-20 16:38:30 -070013146//This function remove the connected BSS from te cached scan result
13147eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13148 tCsrRoamConnectedProfile *pConnProfile)
13149{
13150 eHalStatus status = eHAL_STATUS_FAILURE;
13151 tCsrScanResultFilter *pScanFilter = NULL;
13152 tListElem *pEntry;
13153 tCsrScanResult *pResult;
13154 tDot11fBeaconIEs *pIes;
13155 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13157 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13158 {
13159 do
13160 {
13161 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013162 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13163 if ( NULL == pScanFilter )
13164 status = eHAL_STATUS_FAILURE;
13165 else
13166 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013168 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13169 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13170 if ( NULL == pScanFilter->BSSIDs.bssid )
13171 status = eHAL_STATUS_FAILURE;
13172 else
13173 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013175 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13176 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13178 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13179 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013180 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13181 if ( NULL == pScanFilter->SSIDs.SSIDList )
13182 status = eHAL_STATUS_FAILURE;
13183 else
13184 status = eHAL_STATUS_SUCCESS;
13185 if (!HAL_STATUS_SUCCESS(status)) break;
13186 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13187 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 }
13189 pScanFilter->authType.numEntries = 1;
13190 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13191 pScanFilter->BSSType = pConnProfile->BSSType;
13192 pScanFilter->EncryptionType.numEntries = 1;
13193 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13194 pScanFilter->mcEncryptionType.numEntries = 1;
13195 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13196 //We ignore the channel for now, BSSID should be enough
13197 pScanFilter->ChannelInfo.numOfChannels = 0;
13198 //Also ignore the following fields
13199 pScanFilter->uapsd_mask = 0;
13200 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013201 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 pScanFilter->countryCode[0] = 0;
13203 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013204 csrLLLock(&pMac->scan.scanResultList);
13205 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13206 while( pEntry )
13207 {
13208 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13209 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13210 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13211 pScanFilter, NULL, NULL, NULL, &pIes);
13212 //Release the IEs allocated by csrMatchBSS is needed
13213 if( !pResult->Result.pvIes )
13214 {
13215 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013216 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 }
13218 if(fMatch)
13219 {
13220 //We found the one
13221 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13222 {
13223 //Free the memory
13224 csrFreeScanResultEntry( pMac, pResult );
13225 }
13226 break;
13227 }
13228 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13229 }//while
13230 csrLLUnlock(&pMac->scan.scanResultList);
13231 }while(0);
13232 if(pScanFilter)
13233 {
13234 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013235 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 }
13237 }
13238 return (status);
13239}
13240
Jeff Johnson295189b2012-06-20 16:38:30 -070013241//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013242eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13243{
13244 eHalStatus status = eHAL_STATUS_SUCCESS;
13245 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13247 {
13248 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13249 {
13250 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13251 {
13252 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013253 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 status = eHAL_STATUS_CSR_WRONG_STATE;
13255 break;
13256 }
13257 if( csrIsConnStateInfra( pMac, sessionId ) )
13258 {
13259 if( chnId &&
13260 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013262 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13264 status = eHAL_STATUS_CSR_WRONG_STATE;
13265 break;
13266 }
13267 }
13268 }
13269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 return ( status );
13271}
13272
Jeff Johnson295189b2012-06-20 16:38:30 -070013273static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13274{
13275 eHalStatus status = eHAL_STATUS_SUCCESS;
13276 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13277 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013278
13279 if(!pSession)
13280 {
13281 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13282 return eHAL_STATUS_FAILURE;
13283 }
13284
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 if ( csrIsConnStateIbss( pMac, sessionId ) )
13286 {
13287 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13288 }
13289 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13290 {
13291 // Disassociate from the connected Infrastructure network...
13292 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13293 }
13294 else
13295 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13297 //Otherwise we need to add code to handle the
13298 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13299 //send stop_bss to PE, before we can continue.
13300 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013301 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013303 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13304 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 // there is no Bss description before we start an WDS so we need
13306 // to adopt all Bss configuration parameters from the Profile.
13307 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13308 if(HAL_STATUS_SUCCESS(status))
13309 {
13310 //Save profile for late use
13311 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013312 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13313 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013315 vos_mem_set(pSession->pCurRoamProfile,
13316 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013317 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013320 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013321 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13322 NULL, &bssConfig,
13323 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 }
13325 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013326
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 return( status );
13328}
13329
Jeff Johnson295189b2012-06-20 16:38:30 -070013330////////////////////Mail box
13331
Jeff Johnson295189b2012-06-20 16:38:30 -070013332//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13333//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013334static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13335 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13337{
13338 tCsrChannelSet channelGroup;
13339 tSirMacCapabilityInfo *pAP_capabilityInfo;
13340 tAniBool fTmp;
13341 tANI_BOOLEAN found = FALSE;
13342 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013343 tANI_S8 pwrLimit = 0;
13344 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13346 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13347 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13348 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 // 802.11h
13350 //We can do this because it is in HOST CPU order for now.
13351 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013352 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13353 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13354 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 fTmp = (tAniBool)pal_cpu_to_be32(1);
13356 }
13357 else
13358 fTmp = (tAniBool)0;
13359
13360 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013361 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013363 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013364 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 // This is required for 11k test VoWiFi Ent: Test 2.
13366 // We need the power capabilities for Assoc Req.
13367 // This macro is provided by the halPhyCfg.h. We pick our
13368 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013369 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13370 if (0 != pwrLimit)
13371 {
13372 *pBuf++ = pwrLimit;
13373 }
13374 else
13375 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013376 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013377 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 size = sizeof(pMac->roam.validChannelList);
13379 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013380 {
13381 tANI_U8 *actualSize = pBuf++;
13382 *actualSize = 0;
13383
13384 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013386 /* Only add 5ghz channels*/
13387 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13388 {
13389 *actualSize +=1;
13390 *pBuf++ = pMac->roam.validChannelList[ i ];
13391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 }
13393 }
13394 else
13395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013396 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 *pBuf++ = 0; //tSirSupChnl->numChnl
13398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 //Check whether it is ok to enter UAPSD
13400#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13401 if( btcIsReadyForUapsd(pMac) )
13402#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13403 {
13404 *pBuf++ = uapsdMask;
13405 }
13406#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13407 else
13408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013409 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 *pBuf++ = 0;
13411 }
13412#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13413
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013415 vos_mem_copy(pBuf, pBssDescription,
13416 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13418}
13419
Jeff Johnson295189b2012-06-20 16:38:30 -070013420/*
13421 * The communication between HDD and LIM is thru mailbox (MB).
13422 * Both sides will access the data structure "tSirSmeJoinReq".
13423 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13424 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13425 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13426 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13427 */
13428eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013429 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013430{
13431 eHalStatus status = eHAL_STATUS_SUCCESS;
13432 tSirSmeJoinReq *pMsg;
13433 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013434 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 tANI_U16 msgLen, wTmp, ieLen;
13436 tSirMacRateSet OpRateSet;
13437 tSirMacRateSet ExRateSet;
13438 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13439 tANI_U32 dwTmp;
13440 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013441 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013442 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013443 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013444
13445 if(!pSession)
13446 {
13447 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13448 return eHAL_STATUS_FAILURE;
13449 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013450 /* To satisfy klockworks */
13451 if (NULL == pBssDescription)
13452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013453 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013454 return eHAL_STATUS_FAILURE;
13455 }
13456
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 do {
13458 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13459 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013460 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13462 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13463 // IE fields, but the length field in the bssDescription needs to be interpreted to
13464 // determine length of the IE fields.
13465 //
13466 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13467 // add in the length from the bssDescription (then add the size of the 'length' field
13468 // itself because that is NOT included in the length field).
13469 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13470 pBssDescription->length + sizeof( pBssDescription->length ) +
13471 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 +053013472 pMsg = vos_mem_malloc(msgLen);
13473 if (NULL == pMsg)
13474 status = eHAL_STATUS_FAILURE;
13475 else
13476 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013478 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013479 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 pMsg->length = pal_cpu_to_be16(msgLen);
13481 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 // sessionId
13483 *pBuf = (tANI_U8)sessionId;
13484 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 // transactionId
13486 *pBuf = 0;
13487 *( pBuf + 1 ) = 0;
13488 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 // ssId
13490 if( pIes->SSID.present && pIes->SSID.num_ssid )
13491 {
13492 // ssId len
13493 *pBuf = pIes->SSID.num_ssid;
13494 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013495 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 pBuf += pIes->SSID.num_ssid;
13497 }
13498 else
13499 {
13500 *pBuf = 0;
13501 pBuf++;
13502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013504 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13505 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 pBuf += sizeof(tSirMacAddr);
13507 // bsstype
13508 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13509 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013510 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 pBuf += sizeof(tSirBssType);
13512 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013513 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13514 if (pBssDescription->channelId <= 14 &&
13515 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13516 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13517 {
13518 //Need to disable VHT operation in 2.4 GHz band
13519 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13520 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013521 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13522 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13523
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013524 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 //Persona
13527 *pBuf = (tANI_U8)pProfile->csrPersona;
13528 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013529 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13530 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013531 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13532 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013533 //CBMode
13534 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13535 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013536 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13537 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538
13539 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013540 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13541 pProfile->csrPersona, pSession->bssParams.cbMode,
13542 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013543
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 // uapsdPerAcBitmask
13545 *pBuf = pProfile->uapsd_mask;
13546 pBuf++;
13547
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013548
13549
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013550 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013551 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 {
13553 // OperationalRateSet
13554 if (OpRateSet.numRates) {
13555 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013556 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 pBuf += OpRateSet.numRates;
13558 } else *pBuf++ = 0;
13559 // ExtendedRateSet
13560 if (ExRateSet.numRates) {
13561 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013562 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 pBuf += ExRateSet.numRates;
13564 } else *pBuf++ = 0;
13565 }
13566 else
13567 {
13568 *pBuf++ = 0;
13569 *pBuf++ = 0;
13570 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013571
13572 //rateBitmap
13573 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13574 pBuf += sizeof(tANI_U16);
13575
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 // rsnIE
13577 if ( csrIsProfileWpa( pProfile ) )
13578 {
13579 // Insert the Wpa IE into the join request
13580 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13581 (tCsrWpaIe *)( wpaRsnIE ) );
13582 }
13583 else if( csrIsProfileRSN( pProfile ) )
13584 {
13585 // Insert the RSN IE into the join request
13586 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13587 (tCsrRSNIe *)( wpaRsnIE ) );
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +053013588 pMsg->force_rsne_override =
13589 pProfile->force_rsne_override;
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 }
13591#ifdef FEATURE_WLAN_WAPI
13592 else if( csrIsProfileWapi( pProfile ) )
13593 {
13594 // Insert the WAPI IE into the join request
13595 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13596 (tCsrWapiIe *)( wpaRsnIE ) );
13597 }
13598#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 else
13600 {
13601 ieLen = 0;
13602 }
13603 //remember the IE for future use
13604 if( ieLen )
13605 {
13606 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13607 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013608 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 -070013609 ieLen = DOT11F_IE_RSN_MAX_LEN;
13610 }
13611#ifdef FEATURE_WLAN_WAPI
13612 if( csrIsProfileWapi( pProfile ) )
13613 {
13614 //Check whether we need to allocate more memory
13615 if(ieLen > pSession->nWapiReqIeLength)
13616 {
13617 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13618 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013621 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13622 if (NULL == pSession->pWapiReqIE)
13623 status = eHAL_STATUS_FAILURE;
13624 else
13625 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 if(!HAL_STATUS_SUCCESS(status)) break;
13627 }
13628 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013629 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013633 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 pBuf += ieLen;
13635 }
13636 else//should be WPA/WPA2 otherwise
13637#endif /* FEATURE_WLAN_WAPI */
13638 {
13639 //Check whether we need to allocate more memory
13640 if(ieLen > pSession->nWpaRsnReqIeLength)
13641 {
13642 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13643 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013644 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13647 if (NULL == pSession->pWpaRsnReqIE)
13648 status = eHAL_STATUS_FAILURE;
13649 else
13650 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 if(!HAL_STATUS_SUCCESS(status)) break;
13652 }
13653 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013654 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013658 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 pBuf += ieLen;
13660 }
13661 }
13662 else
13663 {
13664 //free whatever old info
13665 pSession->nWpaRsnReqIeLength = 0;
13666 if(pSession->pWpaRsnReqIE)
13667 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013668 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 pSession->pWpaRsnReqIE = NULL;
13670 }
13671#ifdef FEATURE_WLAN_WAPI
13672 pSession->nWapiReqIeLength = 0;
13673 if(pSession->pWapiReqIE)
13674 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013675 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 pSession->pWapiReqIE = NULL;
13677 }
13678#endif /* FEATURE_WLAN_WAPI */
13679 //length is two bytes
13680 *pBuf = 0;
13681 *(pBuf + 1) = 0;
13682 pBuf += 2;
13683 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013684#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013685 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013687 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 //length is two bytes
13689 *pBuf = 0;
13690 *(pBuf + 1) = 0;
13691 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013692 }
13693 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013695 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013696 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013697 {
13698 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013699#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013700 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013701 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013702 pSession->suppCckmIeInfo.cckmIe, ieLen);
13703#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013704 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013705 pSession,
13706 pProfile,
13707 pBssDescription,
13708 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 pSession->nWpaRsnReqIeLength,
13710 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013711#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013712 }
13713 else
13714 {
13715 ieLen = 0;
13716 }
13717 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13718 if( ieLen )
13719 {
13720 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13721 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013722 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013723 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013724 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013725 pBuf += ieLen;
13726 }
13727 else
13728 {
13729 //Indicate you have no CCKM IE
13730 //length is two bytes
13731 *pBuf = 0;
13732 *(pBuf + 1) = 0;
13733 pBuf += 2;
13734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013736#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013738 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 {
13740 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013741 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013743 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013745 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013746 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013747 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 pBuf += ieLen;
13749 }
13750 else
13751 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013752 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 *pBuf = 0;
13755 *(pBuf + 1) = 0;
13756 pBuf += 2;
13757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013758 // addIEAssoc
13759 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13760 {
13761 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 if(ieLen > pSession->nAddIEAssocLength)
13763 {
13764 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013765 {
13766 vos_mem_free(pSession->pAddIEAssoc);
13767 }
13768 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13769 if (NULL == pSession->pAddIEAssoc)
13770 status = eHAL_STATUS_FAILURE;
13771 else
13772 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013776 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013780 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 pBuf += ieLen;
13782 }
13783 else
13784 {
13785 pSession->nAddIEAssocLength = 0;
13786 if(pSession->pAddIEAssoc)
13787 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013788 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 pSession->pAddIEAssoc = NULL;
13790 }
13791 *pBuf = 0;
13792 *(pBuf + 1) = 0;
13793 pBuf += 2;
13794 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013795
13796 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013798 //Unmask any AC in reassoc that is ACM-set
13799 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13800 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013802 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13803 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013804#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013805 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013806#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013807 }
13808 else
13809 {
13810 uapsd_mask = 0;
13811 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 }
13813 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013814
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013817 pBuf += sizeof(tANI_U32);
13818
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013820 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013821 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013822#ifdef WLAN_FEATURE_11W
13823 //MgmtEncryption
13824 if (pProfile->MFPEnabled)
13825 {
13826 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13827 }
13828 else
13829 {
13830 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13831 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013832 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013833 pBuf += sizeof(tANI_U32);
13834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013835#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013836 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013837 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013838#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013839 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013840 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013841#endif
13842 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013843 {
13844 // is11Rconnection;
13845 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013846 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013847 pBuf += sizeof(tAniBool);
13848 }
13849 else
13850 {
13851 // is11Rconnection;
13852 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013854 pBuf += sizeof(tAniBool);
13855 }
13856#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013857#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013858
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013859 // isESEFeatureIniEnabled
13860 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013861 {
13862 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013863 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013864 pBuf += sizeof(tAniBool);
13865 }
13866 else
13867 {
13868 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013869 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013870 pBuf += sizeof(tAniBool);
13871 }
13872
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013873 /* A profile can not be both ESE and 11R. But an 802.11R AP
13874 * may be advertising support for ESE as well. So if we are
13875 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013876 * If we are associating explictly 11R only then we will get
13877 * 11R.
13878 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013879 if ((csrIsProfileESE(pProfile) ||
13880 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013881 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13882 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13883 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13884 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13885#ifdef WLAN_FEATURE_11W
13886 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013887 || (pProfile->negotiatedAuthType ==
13888 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013889#endif
13890 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013891 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013892 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013893 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013894 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013895 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013896 pBuf += sizeof(tAniBool);
13897 }
13898 else
13899 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013900 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013901 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013902 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013903 pBuf += sizeof(tAniBool);
13904 }
13905
13906 if (eWNI_SME_JOIN_REQ == messageType)
13907 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013908 tESETspecInfo eseTspec;
13909 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013910 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013911 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13912 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13913 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013914 }
13915 else if (eWNI_SME_REASSOC_REQ == messageType)
13916 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013917 if ((csrIsProfileESE(pProfile) ||
13918 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013919 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13920 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13921 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13922 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13923#ifdef WLAN_FEATURE_11W
13924 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013925 || (pProfile->negotiatedAuthType ==
13926 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013927#endif
13928 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013929 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013931 tESETspecInfo eseTspec;
13932 // ESE Tspec information
13933 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13934 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13935 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013937 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013938 if (eseTspec.numTspecs) {
13939 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13940 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013942 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013944 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013946 tESETspecInfo eseTspec;
13947 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013949 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13950 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13951 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 }
13953 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013954#endif // FEATURE_WLAN_ESE
13955#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013957 if (pMac->roam.configParam.isFastTransitionEnabled
13958#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013959 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013960#endif
13961 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013963 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013964 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013965 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 }
13967 else
13968 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013969 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013970 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013971 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 }
13973#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013974#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013975 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013976 {
13977 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013978 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013979 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013980 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013981 }
13982 else
13983 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013984 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013985 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013986 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013987 }
13988#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013989
13990 // txLdpcIniFeatureEnabled
13991 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13992 pBuf++;
13993
Kiran4a17ebe2013-01-31 10:43:43 -080013994 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13995 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13996 {
13997 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13998 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13999 csrApplyPower2Current(pMac);
14000 }
14001
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014002#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014003 // txBFIniFeatureEnabled
14004 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14005 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014006
14007 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014008 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014009 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014010 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14011 if (pIes->VHTCaps.numSoundingDim)
14012 txBFCsnValue = CSR_ROAM_MIN
14013 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014014 }
14015 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014016 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014017
14018 /* Only enable MuBf if no other MuBF session exist
14019 * and FW and HOST is MuBF capable.
14020 */
14021 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14022 {
14023 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14024 pBuf++;
14025 }
14026 else
14027 {
14028 *pBuf = 0;
14029 pBuf++;
14030 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014031#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014032 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14033 pBuf++;
14034
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014035 // WME
14036 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14037 {
14038 //WME enabled
14039 dwTmp = pal_cpu_to_be32(TRUE);
14040 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14041 pBuf += sizeof(tAniBool);
14042 }
14043 else
14044 {
14045 dwTmp = pal_cpu_to_be32(FALSE);
14046 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14047 pBuf += sizeof(tAniBool);
14048 }
14049
14050 // QOS
14051 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14052 {
14053 //QOS enabled
14054 dwTmp = pal_cpu_to_be32(TRUE);
14055 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14056 pBuf += sizeof(tAniBool);
14057 }
14058 else
14059 {
14060 dwTmp = pal_cpu_to_be32(FALSE);
14061 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14062 pBuf += sizeof(tAniBool);
14063 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014064 //BssDesc
14065 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14066 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014067
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014068 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014069 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14070 pMsg = NULL;
14071
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014072 if(!HAL_STATUS_SUCCESS(status))
14073 {
14074 break;
14075 }
14076 else
14077 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014078#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014079 if (eWNI_SME_JOIN_REQ == messageType)
14080 {
14081 //Tush-QoS: notify QoS module that join happening
14082 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14083 }
14084 else if (eWNI_SME_REASSOC_REQ == messageType)
14085 {
14086 //Tush-QoS: notify QoS module that reassoc happening
14087 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014089#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014092
14093 if (pMsg != NULL)
14094 {
14095 vos_mem_free( pMsg );
14096 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014097 pMac->roam.roamSession[sessionId].connect_req_start_time =
14098 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014099
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014101}
14102
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014103#ifdef WLAN_FEATURE_LFR_MBB
14104/**
14105 * csr_prepare_reassoc_req () - Prepares reassoc request
14106 * @mac: MAC context
14107 * @session_id: session id
14108 * @pbss_description: bss description
14109 * @ies: pointer to beacon IE's
14110 * @reassoc_req: pointer to reassociation request
14111 *
14112 *Return: None
14113 */
14114eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14115 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14116 tSirSmeJoinReq **reassoc_req)
14117{
14118 eHalStatus status = eHAL_STATUS_SUCCESS;
14119 tSirSmeJoinReq *csr_join_req;
14120 tANI_U8 *buf;
14121 v_U8_t acm_mask = 0, uapsd_mask;
14122 tANI_U16 msg_len, w_tmp, ie_len;
14123 tSirMacRateSet op_rate_set;
14124 tSirMacRateSet ex_rate_set;
14125 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14126 tANI_U32 dw_tmp;
14127 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14128 tANI_U32 uc_dot11_mode = 0;
14129 tANI_U8 tx_bf_csn_value = 0;
14130 tANI_U16 rate_bitmap = 0;
14131 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014132 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014133
14134 if(!session) {
14135 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14136 return eHAL_STATUS_FAILURE;
14137 }
14138
14139 if (NULL == bss_description) {
14140 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14141 return eHAL_STATUS_FAILURE;
14142 }
14143
14144 smsLog(mac, LOG1,
14145 FL("session_id %d"), session_id);
14146
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014147 profile = vos_mem_malloc(sizeof(*profile));
14148 if (NULL == profile) {
14149 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14150 return eHAL_STATUS_RESOURCES;
14151 }
14152
14153 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014154 if(!HAL_STATUS_SUCCESS(status)) {
14155 smsLog(mac, LOGE, FL("Profile copy failed"));
14156 return eHAL_STATUS_FAILURE;
14157 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014158
14159 do {
14160 /*
14161 * There are a number of variable length fields to consider.
14162 * First, the tSirSmeJoinReq includes a single bssDescription.
14163 * bssDescription includes a single tANI_U32 for the IE fields,
14164 * but the length field in the bssDescription needs to be
14165 * interpreted to determine length of the IE fields.
14166 * So, take the size of the JoinReq, subtract the size of the
14167 * bssDescription and add in the length from the bssDescription
14168 * (then add the size of the 'length' field itself because that is
14169 * NOT included in the length field). msgLen =
14170 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14171 * pBssDescription->length + sizeof( pBssDescription->length ) +
14172 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14173 * add in the size of the WPA IE that we may build.
14174 */
14175
14176 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14177 bss_description->length + sizeof(bss_description->length) +
14178 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14179
14180 csr_join_req = vos_mem_malloc(msg_len);
14181 if (NULL == csr_join_req)
14182 status = eHAL_STATUS_FAILURE;
14183 else
14184 status = eHAL_STATUS_SUCCESS;
14185 if (!HAL_STATUS_SUCCESS(status)) break;
14186
14187 vos_mem_set(csr_join_req, msg_len, 0);
14188 *reassoc_req = csr_join_req;
14189
14190 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14191 csr_join_req->length = pal_cpu_to_be16(msg_len);
14192 buf = &csr_join_req->sessionId;
14193
14194 /* session_id */
14195 *buf = (tANI_U8)session_id;
14196 buf++;
14197
14198 /* transactionId */
14199 *buf = 0;
14200 *(buf + 1) = 0;
14201 buf += sizeof(tANI_U16);
14202
14203 /* ssId */
14204 if(ies->SSID.present && ies->SSID.num_ssid)
14205 {
14206 /* ssId len */
14207 *buf = ies->SSID.num_ssid;
14208 buf++;
14209 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14210 buf += ies->SSID.num_ssid;
14211 }
14212 else
14213 {
14214 *buf = 0;
14215 buf++;
14216 }
14217
14218 /* selfMacAddr */
14219 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14220 sizeof(tSirMacAddr));
14221 buf += sizeof(tSirMacAddr);
14222
14223 /* bsstype */
14224 dw_tmp =
14225 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14226 /* Override BssType for BTAMP */
14227 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14228 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14229 buf += sizeof(tSirBssType);
14230
14231 /* dot11mode */
14232 uc_dot11_mode =
14233 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14234 if (bss_description->channelId <= 14 &&
14235 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14236 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14237 {
14238 /* Need to disable VHT operation in 2.4 GHz band */
14239 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14240 }
14241 *buf = (tANI_U8)uc_dot11_mode;
14242 buf++;
14243
14244 /* Persona */
14245 *buf = (tANI_U8)profile->csrPersona;
14246 buf++;
14247 *buf = (tANI_U8)profile->bOSENAssociation;
14248 buf++;
14249 *buf = (tANI_U8)profile->bWPSAssociation;
14250 buf++;
14251
14252 /* CBMode */
14253 *buf = (tANI_U8)session->bssParams.cbMode;
14254 buf++;
14255
14256 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14257 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14258 session->bssParams.cbMode);
14259
14260 /* uapsdPerAcBitmask */
14261 *buf = profile->uapsd_mask;
14262 buf++;
14263
14264
14265 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14266 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14267 if (HAL_STATUS_SUCCESS(status))
14268 {
14269 /* OperationalRateSet */
14270 if (op_rate_set.numRates) {
14271 *buf++ = op_rate_set.numRates;
14272 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14273 buf += op_rate_set.numRates;
14274 } else *buf++ = 0;
14275
14276 /* ExtendedRateSet */
14277 if (ex_rate_set.numRates) {
14278 *buf++ = ex_rate_set.numRates;
14279 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14280 buf += ex_rate_set.numRates;
14281 } else *buf++ = 0;
14282 }
14283 else
14284 {
14285 *buf++ = 0;
14286 *buf++ = 0;
14287 }
14288
14289 /* rateBitmap */
14290 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14291 buf += sizeof(tANI_U16);
14292
14293 profile->negotiatedAuthType =
14294 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14295 profile->negotiatedUCEncryptionType =
14296 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14297
14298 /* rsnIE */
14299 if ( csrIsProfileWpa(profile))
14300 {
14301 /* Insert the Wpa IE into the join request */
14302 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14303 (tCsrWpaIe *)(wpa_rsn_ie));
14304 }
14305 else if( csrIsProfileRSN(profile))
14306 {
14307 /* Insert the RSN IE into the join request */
14308 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14309 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14310 }
14311#ifdef FEATURE_WLAN_WAPI
14312 else if( csrIsProfileWapi(profile))
14313 {
14314 /* Insert the WAPI IE into the join request */
14315 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14316 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14317 }
14318#endif
14319 else
14320 {
14321 ie_len = 0;
14322 }
14323 /* remember the IE for future use */
14324 if(ie_len)
14325 {
14326 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14327 {
14328 smsLog(mac, LOGE,
14329 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14330 ie_len, DOT11F_IE_RSN_MAX_LEN);
14331 ie_len = DOT11F_IE_RSN_MAX_LEN;
14332 }
14333#ifdef FEATURE_WLAN_WAPI
14334 if( csrIsProfileWapi(profile))
14335 {
14336 /* Check whether we need to allocate more memory */
14337 if(ie_len > session->nWapiReqIeLength)
14338 {
14339 if(session->pWapiReqIE && session->nWapiReqIeLength)
14340 {
14341 vos_mem_free(session->pWapiReqIE);
14342 }
14343 session->pWapiReqIE = vos_mem_malloc(ie_len);
14344 if (NULL == session->pWapiReqIE)
14345 status = eHAL_STATUS_FAILURE;
14346 else
14347 status = eHAL_STATUS_SUCCESS;
14348 if(!HAL_STATUS_SUCCESS(status)) break;
14349 }
14350 session->nWapiReqIeLength = ie_len;
14351 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14352 w_tmp = pal_cpu_to_be16(ie_len);
14353 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14354 buf += sizeof(tANI_U16);
14355 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14356 buf += ie_len;
14357 }
14358 else /* should be WPA/WPA2 otherwise */
14359#endif
14360 {
14361 /* Check whether we need to allocate more memory */
14362 if(ie_len > session->nWpaRsnReqIeLength)
14363 {
14364 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14365 {
14366 vos_mem_free(session->pWpaRsnReqIE);
14367 }
14368 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14369 if (NULL == session->pWpaRsnReqIE)
14370 status = eHAL_STATUS_FAILURE;
14371 else
14372 status = eHAL_STATUS_SUCCESS;
14373 if(!HAL_STATUS_SUCCESS(status)) break;
14374 }
14375 session->nWpaRsnReqIeLength = ie_len;
14376 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14377 w_tmp = pal_cpu_to_be16(ie_len);
14378 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14379 buf += sizeof(tANI_U16);
14380 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14381 buf += ie_len;
14382 }
14383 }
14384 else
14385 {
14386 /* free whatever old info */
14387 session->nWpaRsnReqIeLength = 0;
14388 if(session->pWpaRsnReqIE)
14389 {
14390 vos_mem_free(session->pWpaRsnReqIE);
14391 session->pWpaRsnReqIE = NULL;
14392 }
14393#ifdef FEATURE_WLAN_WAPI
14394 session->nWapiReqIeLength = 0;
14395 if(session->pWapiReqIE)
14396 {
14397 vos_mem_free(session->pWapiReqIE);
14398 session->pWapiReqIE = NULL;
14399 }
14400#endif
14401 /* length is two bytes */
14402 *buf = 0;
14403 *(buf + 1) = 0;
14404 buf += 2;
14405 }
14406#ifdef FEATURE_WLAN_ESE
14407 if(eWNI_SME_JOIN_REQ == message_type)
14408 {
14409 /*
14410 * Never include the cckmIE in an Join Request
14411 * length is two bytes
14412 */
14413 *buf = 0;
14414 *(buf + 1) = 0;
14415 buf += 2;
14416 }
14417 else if(eWNI_SME_REASSOC_REQ == message_type)
14418 {
14419 /* cckmIE */
14420 if( csrIsProfileESE(profile))
14421 {
14422 /* Insert the CCKM IE into the join request */
14423#ifdef FEATURE_WLAN_ESE_UPLOAD
14424 ie_len = session->suppCckmIeInfo.cckmIeLen;
14425 vos_mem_copy((void *) (wpa_rsn_ie),
14426 session->suppCckmIeInfo.cckmIe, ie_len);
14427#else
14428 ie_len = csrConstructEseCckmIe(mac,
14429 session,
14430 profile,
14431 bss_description,
14432 session->pWpaRsnReqIE,
14433 session->nWpaRsnReqIeLength,
14434 (void *)(wpa_rsn_ie));
14435#endif
14436 }
14437 else
14438 {
14439 ie_len = 0;
14440 }
14441 /*
14442 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14443 * message buffer
14444 */
14445 if(ie_len)
14446 {
14447 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14448 w_tmp = pal_cpu_to_be16(ie_len);
14449 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14450 buf += sizeof(tANI_U16);
14451 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14452 buf += ie_len;
14453 }
14454 else
14455 {
14456 /* Indicate you have no CCKM IE length is two bytes */
14457 *buf = 0;
14458 *(buf + 1) = 0;
14459 buf += 2;
14460 }
14461 }
14462#endif
14463 /* addIEScan */
14464 if (profile->nAddIEScanLength)
14465 {
14466 ie_len = profile->nAddIEScanLength;
14467 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14468 session->nAddIEScanLength = ie_len;
14469 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14470 w_tmp = pal_cpu_to_be16(ie_len);
14471 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14472 buf += sizeof(tANI_U16);
14473 vos_mem_copy(buf, profile->addIEScan, ie_len);
14474 buf += ie_len;
14475 }
14476 else
14477 {
14478 memset(session->addIEScan, 0, session->nAddIEScanLength);
14479 session->nAddIEScanLength = 0;
14480 *buf = 0;
14481 *(buf + 1) = 0;
14482 buf += 2;
14483 }
14484 /* addIEAssoc */
14485 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14486 {
14487 ie_len = profile->nAddIEAssocLength;
14488 if(ie_len > session->nAddIEAssocLength)
14489 {
14490 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14491 {
14492 vos_mem_free(session->pAddIEAssoc);
14493 }
14494 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14495 if (NULL == session->pAddIEAssoc)
14496 status = eHAL_STATUS_FAILURE;
14497 else
14498 status = eHAL_STATUS_SUCCESS;
14499 if(!HAL_STATUS_SUCCESS(status)) break;
14500 }
14501 session->nAddIEAssocLength = ie_len;
14502 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14503 w_tmp = pal_cpu_to_be16(ie_len);
14504 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14505 buf += sizeof(tANI_U16);
14506 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14507 buf += ie_len;
14508 }
14509 else
14510 {
14511 session->nAddIEAssocLength = 0;
14512 if(session->pAddIEAssoc)
14513 {
14514 vos_mem_free(session->pAddIEAssoc);
14515 session->pAddIEAssoc = NULL;
14516 }
14517 *buf = 0;
14518 *(buf + 1) = 0;
14519 buf += 2;
14520 }
14521
14522 if(eWNI_SME_REASSOC_REQ == message_type )
14523 {
14524 /*Unmask any AC in reassoc that is ACM-set */
14525 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14526 if( uapsd_mask && (NULL != bss_description))
14527 {
14528 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14529 {
14530#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14531 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14532#endif
14533 }
14534 else
14535 {
14536 uapsd_mask = 0;
14537 }
14538 }
14539 }
14540
14541 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14542 profile->negotiatedUCEncryptionType));
14543 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14544 buf += sizeof(tANI_U32);
14545
14546 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14547 profile->negotiatedMCEncryptionType));
14548 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14549 buf += sizeof(tANI_U32);
14550#ifdef WLAN_FEATURE_11W
14551 /* MgmtEncryption */
14552 if (profile->MFPEnabled)
14553 {
14554 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14555 }
14556 else
14557 {
14558 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14559 }
14560 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14561 buf += sizeof(tANI_U32);
14562#endif
14563#ifdef WLAN_FEATURE_VOWIFI_11R
14564 profile->MDID.mdiePresent = bss_description->mdiePresent;
14565 if (csrIsProfile11r(profile)
14566#ifdef FEATURE_WLAN_ESE
14567 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14568 (ies->ESEVersion.present) &&
14569 (mac->roam.configParam.isEseIniFeatureEnabled))
14570#endif
14571 )
14572 {
14573 /* is11Rconnection */
14574 dw_tmp = pal_cpu_to_be32(TRUE);
14575 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14576 buf += sizeof(tAniBool);
14577 }
14578 else
14579 {
14580 /* is11Rconnection */
14581 dw_tmp = pal_cpu_to_be32(FALSE);
14582 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14583 buf += sizeof(tAniBool);
14584 }
14585#endif
14586#ifdef FEATURE_WLAN_ESE
14587
14588 /* isESEFeatureIniEnabled */
14589 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14590 {
14591 dw_tmp = pal_cpu_to_be32(TRUE);
14592 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14593 buf += sizeof(tAniBool);
14594 }
14595 else
14596 {
14597 dw_tmp = pal_cpu_to_be32(FALSE);
14598 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14599 buf += sizeof(tAniBool);
14600 }
14601
14602 /* A profile can not be both ESE and 11R. But an 802.11R AP
14603 * may be advertising support for ESE as well. So if we are
14604 * associating Open or explicitly ESE then we will get ESE.
14605 * If we are associating explictly 11R only then we will get
14606 * 11R.
14607 */
14608 if ((csrIsProfileESE(profile) ||
14609 ((ies->ESEVersion.present)
14610 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14611 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14612 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14613 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14614#ifdef WLAN_FEATURE_11W
14615 || (profile->negotiatedAuthType ==
14616 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14617 || (profile->negotiatedAuthType ==
14618 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14619#endif
14620 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14621 && (mac->roam.configParam.isEseIniFeatureEnabled))
14622 {
14623 /* isESEconnection */
14624 dw_tmp = pal_cpu_to_be32(TRUE);
14625 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14626 buf += sizeof(tAniBool);
14627 }
14628 else
14629 {
14630 /* isESEconnection */
14631 dw_tmp = pal_cpu_to_be32(FALSE);
14632 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14633 buf += sizeof(tAniBool);
14634 }
14635
14636 if (eWNI_SME_JOIN_REQ == message_type)
14637 {
14638 tESETspecInfo eseTspec;
14639 /*
14640 * ESE-Tspec IEs in the ASSOC request is presently not supported
14641 * so nullify the TSPEC parameters
14642 */
14643 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14644 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14645 buf += sizeof(tESETspecInfo);
14646 }
14647 else if (eWNI_SME_REASSOC_REQ == message_type)
14648 {
14649 if ((csrIsProfileESE(profile) ||
14650 ((ies->ESEVersion.present)
14651 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14652 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14653 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14654 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14655#ifdef WLAN_FEATURE_11W
14656 || (profile->negotiatedAuthType ==
14657 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14658 || (profile->negotiatedAuthType ==
14659 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14660#endif
14661 || (profile->negotiatedAuthType ==
14662 eCSR_AUTH_TYPE_RSN_PSK))))
14663 && (mac->roam.configParam.isEseIniFeatureEnabled))
14664 {
14665 tESETspecInfo eseTspec;
14666 /* ESE Tspec information */
14667 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14668 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14669 (tTspecInfo *) &eseTspec.tspec[0]);
14670 *buf = eseTspec.numTspecs;
14671 buf += sizeof(tANI_U8);
14672 // Copy the TSPEC information only if present
14673 if (eseTspec.numTspecs) {
14674 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14675 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14676 }
14677 buf += sizeof(eseTspec.tspec);
14678 }
14679 else
14680 {
14681 tESETspecInfo eseTspec;
14682 /*
14683 * ESE-Tspec IEs in the ASSOC request is presently
14684 * not supported so nullify the TSPEC parameters
14685 */
14686 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14687 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14688 buf += sizeof(tESETspecInfo);
14689 }
14690 }
14691#endif
14692#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14693 /* Fill in isFastTransitionEnabled */
14694 if (mac->roam.configParam.isFastTransitionEnabled
14695#ifdef FEATURE_WLAN_LFR
14696 || csrRoamIsFastRoamEnabled(mac, session_id)
14697#endif
14698 )
14699 {
14700 dw_tmp = pal_cpu_to_be32(TRUE);
14701 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14702 buf += sizeof(tAniBool);
14703 }
14704 else
14705 {
14706 dw_tmp = pal_cpu_to_be32(FALSE);
14707 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14708 buf += sizeof(tAniBool);
14709 }
14710#endif
14711#ifdef FEATURE_WLAN_LFR
14712 if(csrRoamIsFastRoamEnabled(mac, session_id))
14713 {
14714 /* legacy fast roaming enabled */
14715 dw_tmp = pal_cpu_to_be32(TRUE);
14716 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14717 buf += sizeof(tAniBool);
14718 }
14719 else
14720 {
14721 dw_tmp = pal_cpu_to_be32(FALSE);
14722 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14723 buf += sizeof(tAniBool);
14724 }
14725#endif
14726
14727 /* txLdpcIniFeatureEnabled */
14728 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14729 buf++;
14730
14731 if ((csrIs11hSupported(mac)) &&
14732 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14733 (ies->Country.present) &&\
14734 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14735 {
14736 csrSaveToChannelPower2G_5G(mac,
14737 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14738 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14739 csrApplyPower2Current(mac);
14740 }
14741
14742#ifdef WLAN_FEATURE_11AC
14743 /* txBFIniFeatureEnabled */
14744 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14745 buf++;
14746
14747 /* txBFCsnValue */
14748 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14749 {
14750 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14751 if (ies->VHTCaps.numSoundingDim)
14752 tx_bf_csn_value = CSR_ROAM_MIN
14753 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14754 }
14755 *buf = tx_bf_csn_value;
14756 buf++;
14757
14758 /* Only enable MuBf if no other MuBF session exist
14759 * and FW and HOST is MuBF capable.
14760 */
14761 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14762 {
14763 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14764 buf++;
14765 }
14766 else
14767 {
14768 *buf = 0;
14769 buf++;
14770 }
14771#endif
14772 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14773 buf++;
14774
14775 /* WME */
14776 if(mac->roam.roamSession[session_id].fWMMConnection)
14777 {
14778 /* WME enabled */
14779 dw_tmp = pal_cpu_to_be32(TRUE);
14780 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14781 buf += sizeof(tAniBool);
14782 }
14783 else
14784 {
14785 dw_tmp = pal_cpu_to_be32(FALSE);
14786 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14787 buf += sizeof(tAniBool);
14788 }
14789
14790 /* QOS */
14791 if(mac->roam.roamSession[session_id].fQOSConnection)
14792 {
14793 /* QOS enabled */
14794 dw_tmp = pal_cpu_to_be32(TRUE);
14795 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14796 buf += sizeof(tAniBool);
14797 }
14798 else
14799 {
14800 dw_tmp = pal_cpu_to_be32(FALSE);
14801 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14802 buf += sizeof(tAniBool);
14803 }
14804 /* BssDesc */
14805 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14806 (tANI_U8)profile->uapsd_mask);
14807 } while( 0 );
14808
14809 smsLog(mac, LOG1, FL("status %d"), status);
14810
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014811 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014812 return status;
14813}
14814#endif
14815
Jeff Johnson295189b2012-06-20 16:38:30 -070014816//
14817eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14818{
14819 eHalStatus status = eHAL_STATUS_SUCCESS;
14820 tSirSmeDisassocReq *pMsg;
14821 tANI_U8 *pBuf;
14822 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14824 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14825 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014826 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014827 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14828 if (NULL == pMsg)
14829 status = eHAL_STATUS_FAILURE;
14830 else
14831 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014833 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14835 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 pBuf = &pMsg->sessionId;
14837 // sessionId
14838 *pBuf++ = (tANI_U8)sessionId;
14839 // transactionId
14840 *pBuf = 0;
14841 *( pBuf + 1 ) = 0;
14842 pBuf += sizeof(tANI_U16);
14843
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014844 if ( (pSession->pCurRoamProfile != NULL) &&
14845 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14846 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 {
14848 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014849 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14850 sizeof( tSirMacAddr ));
14851 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014854 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14855 //perMacAddr is passed as bssId for softAP
14856 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 pBuf = pBuf + sizeof ( tSirMacAddr );
14858 }
14859 else
14860 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014862 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14863 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053014865 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
14866 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 if(!HAL_STATUS_SUCCESS(status))
14870 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014871 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 break;
14873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 // reasonCode
14875 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014876 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
14877 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 if(!HAL_STATUS_SUCCESS(status))
14879 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014880 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 break;
14882 }
14883 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014884 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14885 Here we should not send the disassoc over the air to the AP */
14886 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14887#ifdef WLAN_FEATURE_VOWIFI_11R
14888 && csrRoamIs11rAssoc(pMac)
14889#endif
14890 )
14891 {
14892 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14893 }
14894 pBuf += sizeof(tANI_U8);
14895 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 return( status );
14898}
Jeff Johnson295189b2012-06-20 16:38:30 -070014899eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14900{
14901 eHalStatus status = eHAL_STATUS_SUCCESS;
14902 tSirSmeTkipCntrMeasReq *pMsg;
14903 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 do
14905 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014906 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14907 if ( NULL == pMsg )
14908 status = eHAL_STATUS_FAILURE;
14909 else
14910 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014911 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014912 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14914 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 pBuf = &pMsg->sessionId;
14916 // sessionId
14917 *pBuf++ = (tANI_U8)sessionId;
14918 // transactionId
14919 *pBuf = 0;
14920 *( pBuf + 1 ) = 0;
14921 pBuf += sizeof(tANI_U16);
14922 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014923 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14924 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 pBuf = pBuf + sizeof ( tSirMacAddr );
14926 // bEnable
14927 *pBuf = (tANI_BOOLEAN)bEnable;
14928 if(!HAL_STATUS_SUCCESS(status))
14929 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014930 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 break;
14932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 return( status );
14936}
Jeff Johnson295189b2012-06-20 16:38:30 -070014937eHalStatus
14938csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
14939 VOS_MODULE_ID modId, tSirMacAddr bssId,
14940 void *pUsrContext, void *pfnSapEventCallback,
14941 tANI_U8 *pAssocStasBuf )
14942{
14943 eHalStatus status = eHAL_STATUS_SUCCESS;
14944 tSirSmeGetAssocSTAsReq *pMsg;
14945 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14946 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 do
14948 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014949 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
14950 if ( NULL == pMsg )
14951 status = eHAL_STATUS_FAILURE;
14952 else
14953 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014955 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 pBuf = (tANI_U8 *)&pMsg->bssId;
14958 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014960 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 // modId
14963 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014964 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014967 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
14968 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014970 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
14971 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080014973 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
14974 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 status = palSendMBMessage( pMac->hHdd, pMsg );
14977 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 return( status );
14979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014980eHalStatus
14981csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
14982 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
14983 {
14984 eHalStatus status = eHAL_STATUS_SUCCESS;
14985 tSirSmeGetWPSPBCSessionsReq *pMsg;
14986 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080014987
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 do
14989 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014990 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
14991 if ( NULL == pMsg )
14992 status = eHAL_STATUS_FAILURE;
14993 else
14994 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014996 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070014999 VOS_ASSERT(pBuf);
15000
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015003 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15004 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015006 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15007 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015009 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015012 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 return( status );
15018}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015019
15020eHalStatus
15021csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15022{
15023 tpSirChangeBIParams pMsg;
15024 tANI_U16 len = 0;
15025 eHalStatus status = eHAL_STATUS_SUCCESS;
15026 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15027
15028 if(!pSession)
15029 {
15030 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15031 return eHAL_STATUS_FAILURE;
15032 }
15033
15034 //NO need to update the Beacon Params if update beacon parameter flag is not set
15035 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15036 return eHAL_STATUS_SUCCESS;
15037
15038 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15039
15040 /* Create the message and send to lim */
15041 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015042 pMsg = vos_mem_malloc(len);
15043 if ( NULL == pMsg )
15044 status = eHAL_STATUS_FAILURE;
15045 else
15046 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015047 if(HAL_STATUS_SUCCESS(status))
15048 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015049 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015050 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15051 pMsg->length = len;
15052
15053 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015054 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15055 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015056 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15057 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015058 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015059 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015060 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15061 status = palSendMBMessage(pMac->hHdd, pMsg);
15062 }
15063 return status;
15064}
15065
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015066#ifdef WLAN_FEATURE_AP_HT40_24G
15067eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15068{
15069 tpSirSetHT2040Mode pMsg;
15070 tANI_U16 len = 0;
15071 eHalStatus status = eHAL_STATUS_SUCCESS;
15072 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15073
15074 if(!pSession)
15075 {
15076 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15077 return eHAL_STATUS_FAILURE;
15078 }
15079
15080 /* Create the message and send to lim */
15081 len = sizeof(tSirSetHT2040Mode);
15082 pMsg = vos_mem_malloc(len);
15083
15084 if ( NULL == pMsg )
15085 {
15086 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15087 status = eHAL_STATUS_FAILURE;
15088 }
15089 else
15090 status = eHAL_STATUS_SUCCESS;
15091
15092 if(HAL_STATUS_SUCCESS(status))
15093 {
15094 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15095 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15096 pMsg->length = len;
15097
15098 // bssId
15099 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15100 sizeof(tSirMacAddr));
15101
15102 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15103 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15104 MAC_ADDR_ARRAY(pMsg->bssId));
15105
15106 pMsg->sessionId = sessionId;
15107 pMsg->cbMode = cbMode;
15108
15109 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15110 sessionId, cbMode);
15111
15112 status = palSendMBMessage(pMac->hHdd, pMsg);
15113 }
15114 return status;
15115}
15116#endif
15117
Jeff Johnson295189b2012-06-20 16:38:30 -070015118eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15119{
15120 eHalStatus status = eHAL_STATUS_SUCCESS;
15121 tSirSmeDeauthReq *pMsg;
15122 tANI_U8 *pBuf;
15123 tANI_U16 wTmp;
15124 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15125 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15126 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015128 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15129 if ( NULL == pMsg )
15130 status = eHAL_STATUS_FAILURE;
15131 else
15132 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015134 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15136 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15137 //sessionId
15138 pBuf = &pMsg->sessionId;
15139 *pBuf++ = (tANI_U8)sessionId;
15140
15141 //tansactionId
15142 *pBuf = 0;
15143 *(pBuf + 1 ) = 0;
15144 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015145 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15148 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015149 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15150 sizeof( pMsg->peerMacAddr ) );
15151 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 pBuf = pBuf + sizeof(tSirMacAddr);
15153 }
15154 else
15155 {
15156 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015157 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15158 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 }
15161 if(!HAL_STATUS_SUCCESS(status))
15162 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015163 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 break;
15165 }
15166 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015167 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15168 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 pBuf = pBuf + sizeof(tSirMacAddr);
15170 if(!HAL_STATUS_SUCCESS(status))
15171 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015172 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015173 break;
15174 }
15175 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015176 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15177 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 if(!HAL_STATUS_SUCCESS(status))
15179 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015180 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 break;
15182 }
15183 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 return( status );
15186}
15187
Jeff Johnson295189b2012-06-20 16:38:30 -070015188eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15189{
15190 eHalStatus status = eHAL_STATUS_SUCCESS;
15191 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015193 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15194 if ( NULL == pMsg )
15195 status = eHAL_STATUS_FAILURE;
15196 else
15197 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015198 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015199 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015200 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15201 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15202 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015203 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015204 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15205 sizeof(pMsg->peerMacAddr));
15206 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 if(!HAL_STATUS_SUCCESS(status))
15208 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015209 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015210 break;
15211 }
15212//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015213 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15214 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 if(!HAL_STATUS_SUCCESS(status))
15216 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015217 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 break;
15219 }
15220//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015221 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015223 return( status );
15224}
15225
Jeff Johnson295189b2012-06-20 16:38:30 -070015226eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15227{
15228 eHalStatus status = eHAL_STATUS_SUCCESS;
15229 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015230 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015231 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15232 if ( NULL == pMsg )
15233 status = eHAL_STATUS_FAILURE;
15234 else
15235 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015237 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15239 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15240 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015241 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015242 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15243 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 if(!HAL_STATUS_SUCCESS(status))
15245 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015246 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015247 break;
15248 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015249 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15250 sizeof(pMsg->peerMacAddr));
15251 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 if(!HAL_STATUS_SUCCESS(status))
15253 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015254 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 break;
15256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015258 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015259 return( status );
15260}
Jeff Johnson295189b2012-06-20 16:38:30 -070015261eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15262{
15263 eHalStatus status = eHAL_STATUS_SUCCESS;
15264 tSirSmeAssocCnf *pMsg;
15265 tANI_U8 *pBuf;
15266 tSirResultCodes statusCode;
15267 tANI_U16 wTmp;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015268 vos_msg_t msg;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015269
15270 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15271 "HalStatus : %d"),
15272 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015274 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15275 if ( NULL == pMsg )
15276 status = eHAL_STATUS_FAILURE;
15277 else
15278 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015279 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015280 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15282 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 pBuf = (tANI_U8 *)&pMsg->statusCode;
15284 if(HAL_STATUS_SUCCESS(Halstatus))
15285 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15286 else
15287 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015288 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015289 pBuf += sizeof(tSirResultCodes);
15290 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015291 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15292 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 pBuf += sizeof (tSirMacAddr);
15294 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015295 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15296 sizeof(tSirMacAddr));
15297 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 pBuf += sizeof (tSirMacAddr);
15299 // aid
15300 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015301 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 pBuf += sizeof (tANI_U16);
15303 // alternateBssId
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 // alternateChannelId
15308 *pBuf = 11;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015309 msg.type = pMsg->messageType;
15310 msg.bodyval = 0;
15311 msg.bodyptr = pMsg;
15312 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 if(!HAL_STATUS_SUCCESS(status))
15314 {
15315 //pMsg is freed by palSendMBMessage
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015316 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 break;
15318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 return( status );
15321}
Jeff Johnson295189b2012-06-20 16:38:30 -070015322eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15323 tpSirSmeAssocInd pAssocInd,
15324 eHalStatus Halstatus,
15325 tANI_U8 sessionId)
15326{
15327 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15329 tANI_U8 *pBuf;
15330 tSirResultCodes statusCode;
15331 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015333 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15334 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15335 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015336
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15338 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15339
15340 pMsg->sessionId = sessionId;
15341
15342 pBuf = (tANI_U8 *)&pMsg->statusCode;
15343 if(HAL_STATUS_SUCCESS(Halstatus))
15344 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15345 else
15346 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015347 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 pBuf += sizeof(tSirResultCodes);
15349 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015350 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 pBuf += sizeof (tSirMacAddr);
15352 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015353 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15354 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 pBuf += sizeof (tSirMacAddr);
15356 // StaId
15357 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015358 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 pBuf += sizeof (tANI_U16);
15360 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015361 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 pBuf += sizeof (tSirMacAddr);
15363 // alternateChannelId
15364 *pBuf = 11;
15365 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015366 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 //Wmm
15368 *pBuf = pAssocInd->wmmEnabledSta;
15369 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015371 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015374 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 //reassocReq
15377 *pBuf = pAssocInd->reassocReq;
15378 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015379#ifdef WLAN_FEATURE_AP_HT40_24G
15380 // 40 MHz Intolerant
15381 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15382 pBuf += sizeof (tANI_U8);
15383#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015384 *pBuf = pAssocInd->rate_flags;
15385 pBuf += sizeof (uint32_t);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053015386
15387 pBuf = (tANI_U8 *)&pMsg->chan_info;
15388 vos_mem_copy((void *)pBuf, &pAssocInd->chan_info,
15389 sizeof(tSirSmeChanInfo));
15390
15391 pBuf = (tANI_U8 *)&pMsg->ch_width;
15392 *pBuf = pAssocInd->ch_width;
15393
15394 if (pAssocInd->HTCaps.present) {
15395 pBuf = (tANI_U8 *)&pMsg->HTCaps;
15396 vos_mem_copy(pBuf, &pAssocInd->HTCaps, sizeof(pMsg->HTCaps));
15397 }
15398
15399 if (pAssocInd->VHTCaps.present) {
15400 pBuf = (tANI_U8 *)&pMsg->VHTCaps;
15401 vos_mem_copy(pBuf, &pAssocInd->VHTCaps, sizeof(pMsg->VHTCaps));
15402 }
15403
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15405 msgQ.bodyptr = pMsg;
15406 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015409 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015410}
Jeff Johnson295189b2012-06-20 16:38:30 -070015411
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015412eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15414 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15415 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15416 tANI_U8 *pKeyRsc )
15417{
15418 tSirSmeSetContextReq *pMsg;
15419 tANI_U16 msgLen;
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015420 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 tAniEdType tmpEdType;
15422 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015423 tANI_U8 *pBuf = NULL;
15424 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015426 vos_msg_t msg;
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015427 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15428 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15432 // key set. Since we only support upto one key, we always allocate memory for 1 key
15433 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15434 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15435 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15436 ( sizeof( pMsg->keyMaterial.key ) );
15437
Kiet Lam64c1b492013-07-12 13:56:44 +053015438 pMsg = vos_mem_malloc(msgLen);
15439 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15440 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15442 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 //sessionId
15444 pBuf = &pMsg->sessionId;
15445 *pBuf = (tANI_U8)sessionId;
15446 pBuf++;
15447 // transactionId
15448 *pBuf = 0;
15449 *(pBuf + 1) = 0;
15450 pBuf += sizeof(tANI_U16);
15451 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015452 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015453
15454 pBuf += sizeof(tSirMacAddr);
15455
15456 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015457 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15458 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015459
15460 pBuf += sizeof(tSirMacAddr);
15461
15462 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15464 // in the tSirKeyMaterial keyMaterial; field).
15465 //
15466 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15467 // shorter than this max size. Is LIM interpreting this ok ?
15468 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 -070015469 // set pMsg->keyMaterial.edType
15470 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015471 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015473 // set the pMsg->keyMaterial.numKeys field
15474 *p = numKeys;
15475 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 // set pSirKey->keyId = keyId;
15477 *p = keyId;
15478 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015479 // set pSirKey->unicast = (tANI_U8)fUnicast;
15480 *p = (tANI_U8)fUnicast;
15481 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015482 // set pSirKey->keyDirection = aniKeyDirection;
15483 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015484 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 p += sizeof(tAniKeyDirection);
15486 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015487 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 // set pSirKey->paeRole
15490 *p = paeRole; // 0 is Supplicant
15491 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015492 // set pSirKey->keyLength = keyLength;
15493 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015495 vos_mem_copy(p, pKey, keyLength);
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015496 msg.type = pMsg->messageType;
15497 msg.bodyptr = pMsg;
15498 msg.bodyval = 0;
15499 if (fUnicast)
15500 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
15501 else
15502 status = vos_mq_post_message(VOS_MQ_ID_PE, &msg);
15503 if (!VOS_IS_STATUS_SUCCESS(status)) {
15504 vos_mem_free(pMsg);
15505 return eHAL_STATUS_FAILURE;
15506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015507 } while( 0 );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015508 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015509}
15510
Jeff Johnson295189b2012-06-20 16:38:30 -070015511eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15512 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15513{
15514 eHalStatus status;
15515 tSirSmeStartBssReq *pMsg;
15516 tANI_U8 *pBuf = NULL;
15517 tANI_U8 *wTmpBuf = NULL;
15518 tANI_U16 msgLen, wTmp;
15519 tANI_U32 dwTmp;
15520 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015521 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015523 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015524
15525 if(!pSession)
15526 {
15527 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15528 return eHAL_STATUS_FAILURE;
15529 }
15530
Jeff Johnson295189b2012-06-20 16:38:30 -070015531 do {
15532 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15533 pSession->joinFailStatusCode.reasonCode = 0;
15534 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015535 pMsg = vos_mem_malloc(msgLen);
15536 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15537 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015538 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 //sessionId
15542 *pBuf = (tANI_U8)sessionId;
15543 pBuf++;
15544 // transactionId
15545 *pBuf = 0;
15546 *(pBuf + 1) = 0;
15547 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015549 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015550 pBuf += sizeof(tSirMacAddr);
15551 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015552 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 pBuf += sizeof(tSirMacAddr);
15554 // beaconInterval
15555 if( pBssDesc && pBssDesc->beaconInterval )
15556 {
15557 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 else if(pParam->beaconInterval)
15560 {
15561 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15562 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015563 else
15564 {
15565 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15566 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015567 if(csrIsconcurrentsessionValid (pMac, sessionId,
15568 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015569 == eHAL_STATUS_SUCCESS )
15570 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015571 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015572 pParam->bssPersona);
15573 //Update the beacon Interval
15574 pParam->beaconInterval = wTmp;
15575 }
15576 else
15577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015578 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015579 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015580 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015581 return status;
15582 }
15583
Kiet Lam64c1b492013-07-12 13:56:44 +053015584 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015585 pBuf += sizeof(tANI_U16);
15586 // dot11mode
15587 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15588 pBuf += 1;
15589 // bssType
15590 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015591 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015592 pBuf += sizeof(tSirBssType);
15593 // ssId
15594 if( pParam->ssId.length )
15595 {
15596 // ssId len
15597 *pBuf = pParam->ssId.length;
15598 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015599 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015600 pBuf += pParam->ssId.length;
15601 }
15602 else
15603 {
15604 *pBuf = 0;
15605 pBuf++;
15606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 // set the channel Id
15608 *pBuf = pParam->operationChn;
15609 pBuf++;
15610 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015611 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015612 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015613 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015614
Jeff Johnson295189b2012-06-20 16:38:30 -070015615 // Set privacy
15616 *pBuf = pParam->privacy;
15617 pBuf++;
15618
15619 //Set Uapsd
15620 *pBuf = pParam->ApUapsdEnable;
15621 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 //Set SSID hidden
15623 *pBuf = pParam->ssidHidden;
15624 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015625 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15626 pBuf++;
15627
15628 //Ht protection Enable/Disable
15629 *pBuf = (tANI_U8)pParam->protEnabled;
15630 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 //Enable Beacons to Receive for OBSS protection Enable/Disable
15632 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15633 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015634 //set cfg related to protection
15635 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015636 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015637 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015638 // Set Auth type
15639 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015640 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015642 // Set DTIM
15643 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015644 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015645 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015646 // Set wps_state
15647 *pBuf = pParam->wps_state;
15648 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015649 // set isCoalesingInIBSSAllowed
15650 *pBuf = pMac->isCoalesingInIBSSAllowed;
15651 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015652 //Persona
15653 *pBuf = (tANI_U8)pParam->bssPersona;
15654 pBuf++;
15655
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015656 //txLdpcIniFeatureEnabled
15657 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15658 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015659
Chet Lanctot8cecea22014-02-11 19:09:36 -080015660#ifdef WLAN_FEATURE_11W
15661 // Set MFP capable/required
15662 *pBuf = (tANI_U8)pParam->mfpCapable;
15663 pBuf++;
15664 *pBuf = (tANI_U8)pParam->mfpRequired;
15665 pBuf++;
15666#endif
15667
krunal soni4f087d22013-07-29 16:32:26 -070015668 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015669 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15670 {
15671 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015672 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 break;
15674 }
15675 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015676 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 pBuf += sizeof(tANI_U16);
15678 if( wTmp )
15679 {
15680 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015681 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015682 pBuf += wTmp;
15683 }
15684 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015685 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015687 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15688 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015689 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15690 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015691 pBuf += pParam->operationalRateSet.numRates ;
15692 *pBuf++ = pParam->extendedRateSet.numRates;
15693 if(0 != pParam->extendedRateSet.numRates)
15694 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015695 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15696 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015697 pBuf += pParam->extendedRateSet.numRates;
15698 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015699#ifdef WLAN_FEATURE_AP_HT40_24G
15700 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15701#endif
krunal sonie9002db2013-11-25 14:24:17 -080015702
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15704 pMsg->length = pal_cpu_to_be16(msgLen);
15705
15706 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015707 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 return( status );
15709}
15710
Jeff Johnson295189b2012-06-20 16:38:30 -070015711eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15712{
15713 eHalStatus status = eHAL_STATUS_FAILURE;
15714 tSirSmeStopBssReq *pMsg;
15715 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15716 tANI_U8 *pBuf;
15717 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015718
15719 if(!pSession)
15720 {
15721 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15722 return eHAL_STATUS_FAILURE;
15723 }
15724
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015725 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15726 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15727 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15728 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15729 pBuf = &pMsg->sessionId;
15730 //sessionId
15731 *pBuf = (tANI_U8)sessionId;
15732 pBuf++;
15733 // transactionId
15734 *pBuf = 0;
15735 pBuf += sizeof(tANI_U16);
15736 //reason code
15737 *pBuf = 0;
15738 pBuf += sizeof(tSirResultCodes);
15739 // bssid
15740 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15741 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15742 {
15743 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15744 sizeof(tSirMacAddr));
15745 }
15746 else
15747 {
15748 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15749 sizeof(tSirMacAddr));
15750 }
15751 pBuf += sizeof(tSirMacAddr);
15752 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15753 pMsg->length = pal_cpu_to_be16(msgLen);
15754 status = palSendMBMessage( pMac->hHdd, pMsg );
15755
Jeff Johnson295189b2012-06-20 16:38:30 -070015756 return( status );
15757}
15758
Jeff Johnson295189b2012-06-20 16:38:30 -070015759eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15760 tCsrRoamModifyProfileFields *pModProfileFields,
15761 tANI_U32 *pRoamId, v_BOOL_t fForce)
15762{
Jeff Johnson295189b2012-06-20 16:38:30 -070015763 eHalStatus status = eHAL_STATUS_FAILURE;
15764 tANI_U32 roamId = 0;
15765 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015766 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015767 (fForce || (!vos_mem_compare( &pModProfileFields,
15768 &pSession->connectedProfile.modifyProfileFields,
15769 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015770 {
15771 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15772 if(pRoamId)
15773 {
15774 *pRoamId = roamId;
15775 }
15776
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15778 eCsrSmeIssuedReassocToSameAP, roamId,
15779 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 return status;
15782}
Jeff Johnson295189b2012-06-20 16:38:30 -070015783static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15784{
15785 eHalStatus status = eHAL_STATUS_SUCCESS;
15786 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015787 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015788 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15789 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15790 return (status);
15791}
Jeff Johnson295189b2012-06-20 16:38:30 -070015792eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15793{
15794 eHalStatus status = eHAL_STATUS_SUCCESS;
15795 tListElem *pEntry = NULL;
15796 tSmeCmd *pCommand = NULL;
15797 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015798 do
15799 {
15800 if(pMsg == NULL)
15801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015802 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015803 status = eHAL_STATUS_FAILURE;
15804 break;
15805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015806 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15807 if(pEntry)
15808 {
15809 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15810 if(eSmeCommandAddStaSession == pCommand->command)
15811 {
15812 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015813 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015814 if (pRsp->status == eSIR_FAILURE) {
15815 VOS_ASSERT( 0 );
15816 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015817 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015818 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 //Remove this command out of the active list
15820 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15821 {
15822 //Now put this command back on the avilable command list
15823 csrReleaseCommand(pMac, pCommand);
15824 }
15825 smeProcessPendingQueue( pMac );
15826 }
15827 else
15828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015829 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 -070015830 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015831 status = eHAL_STATUS_FAILURE;
15832 break;
15833 }
15834 }
15835 else
15836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015837 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 -070015838 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 status = eHAL_STATUS_FAILURE;
15840 break;
15841 }
15842 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015843 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015844}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015845eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15846 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015847{
15848 tSirSmeAddStaSelfReq *pMsg;
15849 tANI_U16 msgLen;
15850 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015852 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015853 pMsg = vos_mem_malloc(msgLen);
15854 if ( NULL == pMsg ) break;
15855 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15857 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015858 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015859 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015860 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15861
15862 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
15863
Arif Hussain24bafea2013-11-15 15:10:03 -080015864 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
15865 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015866 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015867 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015868 return( status );
15869}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015870eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
15871 tANI_U32 sessionId,
15872 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070015873{
15874 eHalStatus status = eHAL_STATUS_SUCCESS;
15875 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015876 pCommand = csrGetCommandBuffer(pMac);
15877 if(NULL == pCommand)
15878 {
15879 status = eHAL_STATUS_RESOURCES;
15880 }
15881 else
15882 {
15883 pCommand->command = eSmeCommandAddStaSession;
15884 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053015885 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
15886 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015887 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015888 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
15889 if( !HAL_STATUS_SUCCESS( status ) )
15890 {
15891 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015892 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015893 }
15894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 return (status);
15896}
Jeff Johnson295189b2012-06-20 16:38:30 -070015897eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15898{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015899 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070015900}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015901eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
15902 csrRoamCompleteCallback callback,
15903 void *pContext, tANI_U8 *pSelfMacAddr,
15904 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070015905{
15906 eHalStatus status = eHAL_STATUS_SUCCESS;
15907 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053015908 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 *pbSessionId = CSR_SESSION_ID_INVALID;
15910 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15911 {
15912 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15913 {
15914 pSession = CSR_GET_SESSION( pMac, i );
15915 status = eHAL_STATUS_SUCCESS;
15916 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15917 pSession->sessionId = (tANI_U8)i;
15918 pSession->callback = callback;
15919 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015920 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015921 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015922 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15923 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015924 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015925 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015927 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015928 break;
15929 }
15930#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015931 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15932 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015933 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015934 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015936 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 break;
15938 }
15939#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015940 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 break;
15942 }
15943 }
15944 if( CSR_ROAM_SESSION_MAX == i )
15945 {
15946 //No session is available
15947 status = eHAL_STATUS_RESOURCES;
15948 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015949 return ( status );
15950}
Jeff Johnson295189b2012-06-20 16:38:30 -070015951eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15952{
15953 eHalStatus status = eHAL_STATUS_SUCCESS;
15954 tListElem *pEntry = NULL;
15955 tSmeCmd *pCommand = NULL;
15956 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 do
15958 {
15959 if(pMsg == NULL)
15960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015961 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015962 status = eHAL_STATUS_FAILURE;
15963 break;
15964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15966 if(pEntry)
15967 {
15968 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15969 if(eSmeCommandDelStaSession == pCommand->command)
15970 {
15971 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015972 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015973 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 //This session is done.
15975 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015976 if(pCommand->u.delStaSessionCmd.callback)
15977 {
15978
15979 status = sme_ReleaseGlobalLock( &pMac->sme );
15980 if ( HAL_STATUS_SUCCESS( status ) )
15981 {
15982 pCommand->u.delStaSessionCmd.callback(
15983 pCommand->u.delStaSessionCmd.pContext);
15984 status = sme_AcquireGlobalLock( &pMac->sme );
15985 if (! HAL_STATUS_SUCCESS( status ) )
15986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015987 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 return status;
15989 }
15990 }
15991 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015992 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 }
15994 }
15995
15996 //Remove this command out of the active list
15997 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15998 {
15999 //Now put this command back on the avilable command list
16000 csrReleaseCommand(pMac, pCommand);
16001 }
16002 smeProcessPendingQueue( pMac );
16003 }
16004 else
16005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016006 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 -070016007 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 status = eHAL_STATUS_FAILURE;
16009 break;
16010 }
16011 }
16012 else
16013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016014 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 -070016015 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 status = eHAL_STATUS_FAILURE;
16017 break;
16018 }
16019 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016021}
Jeff Johnson295189b2012-06-20 16:38:30 -070016022eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16023{
16024 tSirSmeDelStaSelfReq *pMsg;
16025 tANI_U16 msgLen;
16026 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016027 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016028 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16029 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016030 pMsg = vos_mem_malloc(msgLen);
16031 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16032 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16034 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016036 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16037 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 return( status );
16041}
Jeff Johnson295189b2012-06-20 16:38:30 -070016042eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016043 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016044 tSirMacAddr sessionMacAddr,
16045 csrRoamSessionCloseCallback callback,
16046 void *pContext)
16047{
16048 eHalStatus status = eHAL_STATUS_SUCCESS;
16049 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016050 pCommand = csrGetCommandBuffer(pMac);
16051 if(NULL == pCommand)
16052 {
16053 status = eHAL_STATUS_RESOURCES;
16054 }
16055 else
16056 {
16057 pCommand->command = eSmeCommandDelStaSession;
16058 pCommand->sessionId = (tANI_U8)sessionId;
16059 pCommand->u.delStaSessionCmd.callback = callback;
16060 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016061 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16062 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016063 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016064 if( !HAL_STATUS_SUCCESS( status ) )
16065 {
16066 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016067 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016068 }
16069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 return (status);
16071}
Jeff Johnson295189b2012-06-20 16:38:30 -070016072eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16073{
16074 return csrSendMBDelSelfStaReqMsg( pMac,
16075 pCommand->u.delStaSessionCmd.selfMacAddr );
16076}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016077static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16078 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016079{
16080 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16081 tListElem *pEntry, *pNext;
16082 tSmeCmd *pCommand;
16083 tDblLinkList localList;
16084
16085 vos_mem_zero(&localList, sizeof(tDblLinkList));
16086 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16087 {
16088 smsLog(pMac, LOGE, FL(" failed to open list"));
16089 return;
16090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 csrLLLock(pList);
16092 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16093 while(pEntry != NULL)
16094 {
16095 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16096 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016097
16098 if (!flush_all &&
16099 csr_is_disconnect_full_power_cmd(pCommand)) {
16100 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16101 pEntry = pNext;
16102 continue;
16103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 if(pCommand->sessionId == sessionId)
16105 {
16106 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16107 {
16108 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16109 }
16110 }
16111 pEntry = pNext;
16112 }
16113 csrLLUnlock(pList);
16114
16115 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16116 {
16117 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16118 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16119 }
16120 csrLLClose(&localList);
16121}
16122
Jeff Johnson295189b2012-06-20 16:38:30 -070016123void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16124{
16125 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16126 {
16127 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016128 csrRoamStop(pMac, sessionId);
16129 csrFreeConnectBssDesc(pMac, sessionId);
16130 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16131 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016132 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016133#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016134 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016135#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016136 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016137 csrInitSession(pMac, sessionId);
16138 }
16139}
16140
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016141void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16142 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016143{
16144 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016145 &pMac->sme.smeCmdPendingList,
16146 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016147 if (pMac->fScanOffload)
16148 {
16149 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016150 &pMac->sme.smeScanCmdPendingList,
16151 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016152 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016153 purgeCsrSessionCmdList(pMac, sessionId,
16154 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016155}
16156
Jeff Johnson295189b2012-06-20 16:38:30 -070016157eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016158 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016159 csrRoamSessionCloseCallback callback,
16160 void *pContext )
16161{
16162 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016163 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16164 {
16165 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16166 if(fSync)
16167 {
16168 csrCleanupSession(pMac, sessionId);
16169 }
16170 else
mukul sharmabab477d2015-06-11 17:14:55 +053016171 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016172 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016173 /* If bPurgeList is FALSE, it means HDD already free all the
16174 * cmd and later queue few essential cmd. Now sme should process
16175 * the cmd in pending queue order only.Hence we should
16176 * avoid DEL_SELF_STA as high priority cmd.
16177 */
16178 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016179 pSession->selfMacAddr, callback, pContext);
16180 }
16181 }
16182 else
16183 {
16184 status = eHAL_STATUS_INVALID_PARAMETER;
16185 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016186 return ( status );
16187}
16188
Jeff Johnson295189b2012-06-20 16:38:30 -070016189static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16190{
16191 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016192
16193 if(!pSession)
16194 {
16195 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16196 return;
16197 }
16198
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16200 pSession->sessionId = CSR_SESSION_ID_INVALID;
16201 pSession->callback = NULL;
16202 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016203 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16204 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16205 csrFreeRoamProfile( pMac, sessionId );
16206 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16207 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16208 csrFreeConnectBssDesc(pMac, sessionId);
16209 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016210 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16211 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016212 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016213 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016214 pSession->pWpaRsnReqIE = NULL;
16215 }
16216 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016217 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016218 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016219 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016220 pSession->pWpaRsnRspIE = NULL;
16221 }
16222 pSession->nWpaRsnRspIeLength = 0;
16223#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016224 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016225 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016226 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 pSession->pWapiReqIE = NULL;
16228 }
16229 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016230 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016232 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016233 pSession->pWapiRspIE = NULL;
16234 }
16235 pSession->nWapiRspIeLength = 0;
16236#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016237 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016238 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016239 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016240 }
16241 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016242
Kiet Lam64c1b492013-07-12 13:56:44 +053016243 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016244 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016245 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016246 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016248 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016249}
16250
Jeff Johnson295189b2012-06-20 16:38:30 -070016251eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16252{
16253 eHalStatus status = eHAL_STATUS_FAILURE;
16254 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016255 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16256 {
16257 if( CSR_IS_SESSION_VALID( pMac, i ) )
16258 {
16259 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16260 {
16261 //Found it
16262 status = eHAL_STATUS_SUCCESS;
16263 *pSessionId = i;
16264 break;
16265 }
16266 }
16267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016268 return( status );
16269}
16270
Jeff Johnson295189b2012-06-20 16:38:30 -070016271//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16272//session because for IBSS, the bssid changes.
16273static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16274{
16275 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16276 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016277 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16278 {
16279 if( CSR_IS_SESSION_VALID( pMac, i ) )
16280 {
16281 pSession = CSR_GET_SESSION( pMac, i );
16282 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16283 {
16284 //Found it
16285 nRet = i;
16286 break;
16287 }
16288 }
16289 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016290 return (nRet);
16291}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016292void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016293{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016294 VOS_STATUS status = VOS_STATUS_SUCCESS;
16295
16296 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016297 profile info from pmac global structure */
16298
Arif Hussain24bafea2013-11-15 15:10:03 -080016299 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16300 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016301 /* Check for user misconfig of RSSI trigger threshold */
16302 pMac->roam.configParam.vccRssiThreshold =
16303 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16304 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16305 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016306 /* Check for user misconfig of UL MAC Loss trigger threshold */
16307 pMac->roam.configParam.vccUlMacLossThreshold =
16308 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16309 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016310#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16311 {
16312 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016313 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016314 /* Indicate the neighbor roal algorithm about the connect indication */
16315 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16316 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016317
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016318 /* Making sure we are roaming force fully to 5GHz AP only once and
16319 * only when we connected to 2.4GH AP only during initial association.
16320 */
16321 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16322 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16323 SIR_BAND_2_4_GHZ)
16324 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016325 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016326 status = vos_timer_start(
16327 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16328 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016329 if ( status != VOS_STATUS_SUCCESS )
16330 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016331 smsLog(pMac, LOGE,
16332 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16333 status);
16334 //Send RSO start because in case 5G roaming
16335 //host have not enabled at initial connection
16336 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016337 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016338 else
16339 {
16340 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16341 __func__);
16342 }
16343 }
16344 /*
16345 * Making ini value to false here only so we just roam to
16346 * only once for whole driver load to unload tenure
16347 * This feature is only applicable for first connection only
16348 */
16349 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16350 {
16351 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16352 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 }
16355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016356}
16357
Jeff Johnson295189b2012-06-20 16:38:30 -070016358static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16359{
16360 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016361
16362 if(!pSession)
16363 {
16364 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16365 return;
16366 }
16367
Jeff Johnson295189b2012-06-20 16:38:30 -070016368 //Only to handle the case for Handover on infra link
16369 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16370 {
16371 return;
16372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016373 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16374 csrRoamDeregStatisticsReq(pMac);
16375 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16376#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16377 /* Indicate the neighbor roal algorithm about the disconnect indication */
16378 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16379#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016380
16381 //Remove this code once SLM_Sessionization is supported
16382 //BMPS_WORKAROUND_NOT_NEEDED
16383 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016384 csrIsInfraApStarted( pMac ) &&
16385 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016386 {
16387 pMac->roam.configParam.doBMPSWorkaround = 0;
16388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016389}
16390
Jeff Johnson295189b2012-06-20 16:38:30 -070016391void csrRoamTlStatsTimerHandler(void *pv)
16392{
16393 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16394 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016395 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16396
Jeff Johnsone7245742012-09-05 17:12:55 -070016397 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16398
Jeff Johnson295189b2012-06-20 16:38:30 -070016399#if 0
16400 // TODO Persession .???
16401 //req TL for stats
16402 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016404 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016405 }
16406 else
16407 {
16408 //save in SME
16409 csrRoamSaveStatsFromTl(pMac, tlStats);
16410 }
16411#endif
16412 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16413 {
16414 if(pMac->roam.tlStatsReqInfo.periodicity)
16415 {
16416 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016417 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16418 pMac->roam.tlStatsReqInfo.periodicity);
16419 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016421 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016422 return;
16423 }
16424 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16425 }
16426 }
16427}
Jeff Johnson295189b2012-06-20 16:38:30 -070016428void csrRoamPeStatsTimerHandler(void *pv)
16429{
16430 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16431 eHalStatus status;
16432 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16433 VOS_STATUS vosStatus;
16434 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 pPeStatsReqListEntry->timerRunning = FALSE;
16436 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16437 {
16438 // If we entered here, meaning the timer could not be successfully
16439 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16440
16441 /* Destroy the timer */
16442 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16443 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016445 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 }
16447
16448 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016449 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 pPeStatsReqListEntry = NULL;
16451 }
16452 else
16453 {
16454 if(!pPeStatsReqListEntry->rspPending)
16455 {
16456 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16457 pPeStatsReqListEntry->staId);
16458 if(!HAL_STATUS_SUCCESS(status))
16459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016460 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 }
16462 else
16463 {
16464 pPeStatsReqListEntry->rspPending = TRUE;
16465 }
16466 }
16467
16468 //send down a req
16469 if(pPeStatsReqListEntry->periodicity &&
16470 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16471 {
16472 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16473 if(ePMC_FULL_POWER == powerState)
16474 {
16475 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16476 {
16477 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16478 }
16479 }
16480 else
16481 {
16482 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16483 {
16484 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16485 }
16486 }
16487 //start timer
16488 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16489 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016491 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016492 return;
16493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 pPeStatsReqListEntry->timerRunning = TRUE;
16495
16496 }
16497
16498 }
16499}
Jeff Johnson295189b2012-06-20 16:38:30 -070016500void csrRoamStatsClientTimerHandler(void *pv)
16501{
16502 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016503 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16504 {
16505#if 0
16506 // TODO Stats fix for multisession
16507 //start the timer
16508 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16509
16510 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016512 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 }
16514#endif
16515 }
16516#if 0
16517 //send up the stats report
16518 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16519 pStaEntry->staId, pStaEntry->pContext);
16520#endif
16521}
16522
16523
16524
Jeff Johnson295189b2012-06-20 16:38:30 -070016525eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16526{
16527 tAniGetPEStatsReq *pMsg;
16528 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016529 tSirMsgQ msgQ;
16530
Kiet Lam64c1b492013-07-12 13:56:44 +053016531 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16532 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016534 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016535 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016536 }
16537 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016538 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016539 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16540 pMsg->staId = staId;
16541 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016542
16543 msgQ.type = WDA_GET_STATISTICS_REQ;
16544 msgQ.reserved = 0;
16545 msgQ.bodyptr = pMsg;
16546 msgQ.bodyval = 0;
16547 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016548 if(!HAL_STATUS_SUCCESS(status))
16549 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016550 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016551 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016553 return status;
16554}
Jeff Johnson295189b2012-06-20 16:38:30 -070016555void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16556{
16557 tAniGetPEStatsRsp *pSmeStatsRsp;
16558 eHalStatus status = eHAL_STATUS_FAILURE;
16559 tListElem *pEntry = NULL;
16560 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16561 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16562 tANI_U32 tempMask = 0;
16563 tANI_U8 counter = 0;
16564 tANI_U8 *pStats = NULL;
16565 tANI_U32 length = 0;
16566 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016567 v_S7_t rssi = 0, snr = 0;
16568 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016569 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016570 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016571 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16572 if(pSmeStatsRsp->rc)
16573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016574 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016575 goto post_update;
16576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016577 tempMask = pSmeStatsRsp->statsMask;
16578 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016579 /* subtract all statistics from this length, and after processing the entire
16580 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16581 * in this 'stats' message.
16582 */
16583 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 //new stats info from PE, fill up the stats strucutres in PMAC
16585 while(tempMask)
16586 {
16587 if(tempMask & 1)
16588 {
16589 switch(counter)
16590 {
16591 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016592 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016593 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16594 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016595 pStats += sizeof(tCsrSummaryStatsInfo);
16596 length -= sizeof(tCsrSummaryStatsInfo);
16597 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016599 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016600 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16601 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016602 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16603 length -= sizeof(tCsrGlobalClassAStatsInfo);
16604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016606 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016607 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16608 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016609 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16610 length -= sizeof(tCsrGlobalClassBStatsInfo);
16611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016612 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016613 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016614 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16615 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016616 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16617 length -= sizeof(tCsrGlobalClassCStatsInfo);
16618 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016619 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016620 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016621 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16622 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016623 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016624 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16625 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016626 }
16627 else
16628 {
16629 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016630 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 VOS_ASSERT( 0 );
16632 }
16633 if(!HAL_STATUS_SUCCESS(status))
16634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016635 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016636 }
16637 pStats += sizeof(tCsrPerStaStatsInfo);
16638 length -= sizeof(tCsrPerStaStatsInfo);
16639 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016640 case eCsrPerPktStats:
16641 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16642 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16643 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16644 {
16645 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16646 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16647 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016648 /* for reserved bytes */
16649 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16650 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016651 }
16652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016654 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016655 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016656 }
16657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 tempMask >>=1;
16659 counter++;
16660 }
16661 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16662 if (length != 0)
16663 {
16664 pRssi = (tANI_U32*)pStats;
16665 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016666 pStats += sizeof(tANI_U32);
16667 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 }
16669 else
16670 {
16671 /* If riva is not sending rssi, continue to use the hack */
16672 rssi = RSSI_HACK_BMPS;
16673 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016674 /* send positive value of rssi to wifi_hal */
16675 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016676 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016678
16679 if (length != 0)
16680 {
16681 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016682 pStats += sizeof(tANI_U32);
16683 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016684 }
16685 else
16686 {
16687 linkCapacity = 0;
16688 }
16689
16690 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016691
16692 if (length != 0)
16693 {
16694 pSnr = (tANI_U32*)pStats;
16695 snr = (v_S7_t)*pSnr;
16696 }
16697 else
16698 {
16699 snr = SNR_HACK_BMPS;
16700 }
16701
16702 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016703post_update:
16704 //make sure to update the pe stats req list
16705 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16706 if(pEntry)
16707 {
16708 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16709 pPeStaEntry->rspPending = FALSE;
16710
16711 }
16712 //check the one timer cases
16713 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16714 if(pEntry)
16715 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016717 if(pTempStaEntry->timerExpired)
16718 {
16719 //send up the stats report
16720 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16721 pTempStaEntry->staId, pTempStaEntry->pContext);
16722 //also remove from the client list
16723 csrRoamRemoveStatListEntry(pMac, pEntry);
16724 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016725 }
16726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016727}
Jeff Johnson295189b2012-06-20 16:38:30 -070016728tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16729{
16730 tListElem *pEntry = NULL;
16731 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016732 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016733 if(!pEntry)
16734 {
16735 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016736 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 return NULL;
16738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 while( pEntry )
16740 {
16741 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 if(pTempStaEntry->statsMask == statsMask)
16743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016744 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016745 break;
16746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016749 return pEntry;
16750}
16751
Jeff Johnson295189b2012-06-20 16:38:30 -070016752tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16753 tANI_BOOLEAN update)
16754{
16755 tListElem *pEntry;
16756 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016757 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 if(!pEntry)
16759 {
16760 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016761 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016762 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 return NULL;
16764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 while( pEntry )
16766 {
16767 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016768 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16769 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016771 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016772 if(update)
16773 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016774 pTempStaEntry->periodicity = pStaEntry->periodicity;
16775 pTempStaEntry->callback = pStaEntry->callback;
16776 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016777 }
16778 break;
16779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016780 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016782 return pEntry;
16783}
Jeff Johnson295189b2012-06-20 16:38:30 -070016784tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16785{
16786 tListElem *pEntry;
16787 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016788 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016789 if(!pEntry)
16790 {
16791 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016792 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016793 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 return NULL;
16795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 while( pEntry )
16797 {
16798 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016799 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016801 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 break;
16803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016804 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 return pEntry;
16807}
Jeff Johnson295189b2012-06-20 16:38:30 -070016808eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16809 csrRoamLinkQualityIndCallback callback,
16810 void *pContext)
16811{
16812 pMac->roam.linkQualityIndInfo.callback = callback;
16813 pMac->roam.linkQualityIndInfo.context = pContext;
16814 if( NULL == callback )
16815 {
16816 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16817 }
16818 else
16819 {
16820 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016821 /* do we need to invoke the callback to notify client of initial value ?? */
16822 }
16823 return eHAL_STATUS_SUCCESS;
16824}
Jeff Johnson295189b2012-06-20 16:38:30 -070016825void csrRoamVccTrigger(tpAniSirGlobal pMac)
16826{
16827 eCsrRoamLinkQualityInd newVccLinkQuality;
16828 tANI_U32 ul_mac_loss = 0;
16829 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016830 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16831 /*-------------------------------------------------------------------------
16832 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 Check for a change in link quality and notify client if necessary
16834 -------------------------------------------------------------------------*/
16835 ul_mac_loss_trigger_threshold =
16836 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016837 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016838 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016839 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016840 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016842 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16844 }
16845 else
16846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016847 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016848 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16851 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016854 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016857 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 newVccLinkQuality );
16859
16860 /* we now invoke the callback once to notify client of initial value */
16861 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16862 pMac->roam.linkQualityIndInfo.context );
16863 //event: EVENT_WLAN_VCC
16864 }
16865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 pMac->roam.vccLinkQuality = newVccLinkQuality;
16867
Jeff Johnson295189b2012-06-20 16:38:30 -070016868}
Jeff Johnson295189b2012-06-20 16:38:30 -070016869VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
16870 v_U8_t rssiNotification,
16871 void * context)
16872{
16873 tpAniSirGlobal pMac = PMAC_STRUCT( context );
16874 eCsrRoamLinkQualityInd newVccLinkQuality;
16875 // TODO : Session info unavailable
16876 tANI_U32 sessionId = 0;
16877 VOS_STATUS status = VOS_STATUS_SUCCESS;
16878 /*-------------------------------------------------------------------------
16879 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016880 Check for a change in link quality and notify client if necessary
16881 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016882 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 pMac->roam.configParam.vccRssiThreshold);
16884 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
16885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016886 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 return VOS_STATUS_SUCCESS;
16888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016889 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
16890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016891 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070016892 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16893 }
16894 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
16895 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016896 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016897 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16898 }
16899 else
16900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016901 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070016902 //Set to this so the code below won't do anything
16903 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 VOS_ASSERT(0);
16905 }
16906
Jeff Johnson295189b2012-06-20 16:38:30 -070016907 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016909 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016910 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016912 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016913 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016914 /* we now invoke the callback once to notify client of initial value */
16915 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16916 pMac->roam.linkQualityIndInfo.context );
16917 //event: EVENT_WLAN_VCC
16918 }
16919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 return status;
16922}
Jeff Johnson295189b2012-06-20 16:38:30 -070016923tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16924 tDblLinkList *pStaList,
16925 tCsrStatsClientReqInfo *pStaEntry)
16926{
16927 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016928 //if same entity requested for same set of stats with different periodicity &
16929 // callback update it
16930 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16931 {
16932
Kiet Lam64c1b492013-07-12 13:56:44 +053016933 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16934 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016935 {
16936 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016937 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016938 return NULL;
16939 }
16940
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 pNewStaEntry->callback = pStaEntry->callback;
16942 pNewStaEntry->pContext = pStaEntry->pContext;
16943 pNewStaEntry->periodicity = pStaEntry->periodicity;
16944 pNewStaEntry->requesterId = pStaEntry->requesterId;
16945 pNewStaEntry->statsMask = pStaEntry->statsMask;
16946 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16947 pNewStaEntry->pMac = pStaEntry->pMac;
16948 pNewStaEntry->staId = pStaEntry->staId;
16949 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16950
16951 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
16952 }
16953 return pNewStaEntry;
16954}
16955
Jeff Johnson295189b2012-06-20 16:38:30 -070016956tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
16957 tDblLinkList *pStaList,
16958 tCsrPeStatsReqInfo *pStaEntry)
16959{
16960 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016961 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
16962 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016963 {
16964 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016965 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016966 return NULL;
16967 }
16968
Jeff Johnson295189b2012-06-20 16:38:30 -070016969 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
16970 pNewStaEntry->numClient = pStaEntry->numClient;
16971 pNewStaEntry->periodicity = pStaEntry->periodicity;
16972 pNewStaEntry->statsMask = pStaEntry->statsMask;
16973 pNewStaEntry->pMac = pStaEntry->pMac;
16974 pNewStaEntry->staId = pStaEntry->staId;
16975 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
16976 pNewStaEntry->rspPending = pStaEntry->rspPending;
16977
16978 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016979 return pNewStaEntry;
16980}
Jeff Johnson295189b2012-06-20 16:38:30 -070016981eHalStatus csrGetRssi(tpAniSirGlobal pMac,
16982 tCsrRssiCallback callback,
16983 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16984{
16985 eHalStatus status = eHAL_STATUS_SUCCESS;
16986 vos_msg_t msg;
16987 tANI_U32 sessionId;
16988
16989 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016990 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016991 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16992 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016994 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016995 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
16998
16999 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
17000 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17001 pMsg->sessionId = sessionId;
17002 pMsg->staId = staId;
17003 pMsg->rssiCallback = callback;
17004 pMsg->pDevContext = pContext;
17005 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070017006 msg.type = eWNI_SME_GET_RSSI_REQ;
17007 msg.bodyptr = pMsg;
17008 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017009 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017011 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017012 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017013 status = eHAL_STATUS_FAILURE;
17014 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017015 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017016 return status;
17017}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017018
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017019eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17020 tCsrSnrCallback callback,
17021 tANI_U8 staId, tCsrBssid bssId,
17022 void *pContext)
17023{
17024 eHalStatus status = eHAL_STATUS_SUCCESS;
17025 vos_msg_t msg;
17026 tANI_U32 sessionId;
17027
17028 tAniGetSnrReq *pMsg;
17029
17030 smsLog(pMac, LOG2, FL("called"));
17031
17032 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17033 if (NULL == pMsg )
17034 {
17035 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17036 return status;
17037 }
17038
17039 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17040
17041 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17042 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17043 pMsg->sessionId = sessionId;
17044 pMsg->staId = staId;
17045 pMsg->snrCallback = callback;
17046 pMsg->pDevContext = pContext;
17047 msg.type = eWNI_SME_GET_SNR_REQ;
17048 msg.bodyptr = pMsg;
17049 msg.reserved = 0;
17050
17051 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17052 {
17053 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17054 vos_mem_free((v_VOID_t *)pMsg);
17055 status = eHAL_STATUS_FAILURE;
17056 }
17057
17058 smsLog(pMac, LOG2, FL("returned"));
17059 return status;
17060}
17061
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017062#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017063eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17064 tCsrRssiCallback callback,
17065 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17066{
17067 eHalStatus status = eHAL_STATUS_SUCCESS;
17068 tAniGetRssiReq *pMsg;
17069
Kiet Lam64c1b492013-07-12 13:56:44 +053017070 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17071 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017072 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017073 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017074 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017075 }
17076 // need to initiate a stats request to PE
17077 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17078 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17079 pMsg->staId = staId;
17080 pMsg->rssiCallback = callback;
17081 pMsg->pDevContext = pContext;
17082 pMsg->pVosContext = pVosContext;
17083 status = palSendMBMessage(pMac->hHdd, pMsg );
17084 if(!HAL_STATUS_SUCCESS(status))
17085 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017086 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017087 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017088 status = eHAL_STATUS_FAILURE;
17089 }
17090 return status;
17091}
17092#endif
17093
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017094
17095
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017096#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017097eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17098 tCsrTsmStatsCallback callback,
17099 tANI_U8 staId,
17100 tCsrBssid bssId,
17101 void *pContext,
17102 void* pVosContext,
17103 tANI_U8 tid)
17104{
17105 eHalStatus status = eHAL_STATUS_SUCCESS;
17106 tAniGetTsmStatsReq *pMsg = NULL;
17107
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017108 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17109 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017110 {
17111 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017112 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017113 }
17114 // need to initiate a stats request to PE
17115 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17116 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17117 pMsg->staId = staId;
17118 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017119 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017120 pMsg->tsmStatsCallback = callback;
17121 pMsg->pDevContext = pContext;
17122 pMsg->pVosContext = pVosContext;
17123 status = palSendMBMessage(pMac->hHdd, pMsg );
17124 if(!HAL_STATUS_SUCCESS(status))
17125 {
17126 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17127 //pMsg is freed by palSendMBMessage
17128 status = eHAL_STATUS_FAILURE;
17129 }
17130 return status;
17131}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017132#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017133
17134
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017135/* ---------------------------------------------------------------------------
17136 \fn csrGetTLSTAState
17137 \helper function to get teh TL STA State whenever the function is called.
17138
17139 \param staId - The staID to be passed to the TL
17140 to get the relevant TL STA State
17141 \return the state as tANI_U16
17142 ---------------------------------------------------------------------------*/
17143tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17144{
17145 WLANTL_STAStateType tlSTAState;
17146 tlSTAState = WLANTL_STA_INIT;
17147
17148 //request TL for STA State
17149 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17150 {
17151 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17152 }
17153
17154 return tlSTAState;
17155}
17156
Jeff Johnson295189b2012-06-20 16:38:30 -070017157eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17158 tANI_U32 statsMask,
17159 tCsrStatsCallback callback,
17160 tANI_U32 periodicity, tANI_BOOLEAN cache,
17161 tANI_U8 staId, void *pContext)
17162{
17163 tCsrStatsClientReqInfo staEntry;
17164 tCsrStatsClientReqInfo *pStaEntry = NULL;
17165 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17166 tListElem *pEntry = NULL;
17167 tANI_BOOLEAN found = FALSE;
17168 eHalStatus status = eHAL_STATUS_SUCCESS;
17169 tANI_BOOLEAN insertInClientList = FALSE;
17170 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017171 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017172
17173 if( csrIsAllSessionDisconnected(pMac) )
17174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017175 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 return eHAL_STATUS_FAILURE;
17177 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017178
17179 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17180 {
17181 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17182 return eHAL_STATUS_FAILURE;
17183 }
17184
Jeff Johnson295189b2012-06-20 16:38:30 -070017185 if((!statsMask) && (!callback))
17186 {
17187 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017188 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017189 return eHAL_STATUS_FAILURE;
17190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017191 //for the search list method for deregister
17192 staEntry.requesterId = requesterId;
17193 staEntry.statsMask = statsMask;
17194 //requester wants to deregister or just an error
17195 if((statsMask) && (!callback))
17196 {
17197 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17198 if(!pEntry)
17199 {
17200 //msg
17201 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017202 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017203 return eHAL_STATUS_FAILURE;
17204 }
17205 else
17206 {
17207 //clean up & return
17208 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017209 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017210 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017211 pStaEntry->pPeStaEntry->numClient--;
17212 //check if we need to delete the entry from peStatsReqList too
17213 if(!pStaEntry->pPeStaEntry->numClient)
17214 {
17215 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017218
Jeff Johnson295189b2012-06-20 16:38:30 -070017219 //check if we need to stop the tl stats timer too
17220 pMac->roam.tlStatsReqInfo.numClient--;
17221 if(!pMac->roam.tlStatsReqInfo.numClient)
17222 {
17223 if(pMac->roam.tlStatsReqInfo.timerRunning)
17224 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017225 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17226 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017228 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017229 return eHAL_STATUS_FAILURE;
17230 }
17231 }
17232 pMac->roam.tlStatsReqInfo.periodicity = 0;
17233 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17234 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017235 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017236 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017237 vos_timer_stop(&pStaEntry->timer);
17238 // Destroy the vos timer
17239 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17240 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17241 {
17242 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017245 csrRoamRemoveStatListEntry(pMac, pEntry);
17246 pStaEntry = NULL;
17247 return eHAL_STATUS_SUCCESS;
17248 }
17249 }
17250
17251 if(cache && !periodicity)
17252 {
17253 //return the cached stats
17254 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17255 }
17256 else
17257 {
17258 //add the request in the client req list
17259 staEntry.callback = callback;
17260 staEntry.pContext = pContext;
17261 staEntry.periodicity = periodicity;
17262 staEntry.pPeStaEntry = NULL;
17263 staEntry.staId = staId;
17264 staEntry.pMac = pMac;
17265 staEntry.timerExpired = FALSE;
17266
17267
Jeff Johnson295189b2012-06-20 16:38:30 -070017268 //if periodic report requested with non cached result from PE/TL
17269 if(periodicity)
17270 {
17271
17272 //if looking for stats from PE
17273 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17274 {
17275
17276 //check if same request made already & waiting for rsp
17277 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17278 periodicity, &found, staId);
17279 if(!pPeStaEntry)
17280 {
17281 //bail out, maxed out on number of req for PE
17282 return eHAL_STATUS_FAILURE;
17283 }
17284 else
17285 {
17286 staEntry.pPeStaEntry = pPeStaEntry;
17287 }
17288
17289 }
17290 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17291 if(statsMask & (1 << eCsrGlobalClassDStats))
17292 {
17293 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017295 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017296 }
17297 else
17298 {
17299
17300 //update periodicity
17301 if(pMac->roam.tlStatsReqInfo.periodicity)
17302 {
17303 pMac->roam.tlStatsReqInfo.periodicity =
17304 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17305 }
17306 else
17307 {
17308 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17309 }
17310 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17311 {
17312 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17313 }
17314
17315 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17316 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017317 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017318 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017319 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017320 //req TL for class D stats
17321 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17322 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017323 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017324 }
17325 else
17326 {
17327 //save in SME
17328 csrRoamSaveStatsFromTl(pMac, pTlStats);
17329 }
17330 vos_mem_free(pTlStats);
17331 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017332 }
17333 else
17334 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017335 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017336 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017337
Jeff Johnson295189b2012-06-20 16:38:30 -070017338 if(pMac->roam.tlStatsReqInfo.periodicity)
17339 {
17340 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017341 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17342 pMac->roam.tlStatsReqInfo.periodicity);
17343 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017345 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017346 return eHAL_STATUS_FAILURE;
17347 }
17348 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17349 }
17350 }
17351 }
17352 pMac->roam.tlStatsReqInfo.numClient++;
17353 }
17354
17355 insertInClientList = TRUE;
17356 }
17357 //if one time report requested with non cached result from PE/TL
17358 else if(!cache && !periodicity)
17359 {
17360 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17361 {
17362 //send down a req
17363 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17364 if(!HAL_STATUS_SUCCESS(status))
17365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017366 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017367 }
17368 //so that when the stats rsp comes back from PE we respond to upper layer
17369 //right away
17370 staEntry.timerExpired = TRUE;
17371 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017372 }
17373 if(statsMask & (1 << eCsrGlobalClassDStats))
17374 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017375 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017376 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017377 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017378 //req TL for class D stats
17379 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017381 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017382 }
17383 else
17384 {
17385 //save in SME
17386 csrRoamSaveStatsFromTl(pMac, pTlStats);
17387 }
17388 vos_mem_free(pTlStats);
17389 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017390 }
17391 else
17392 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017393 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017395
17396 }
17397 //if looking for stats from TL only
17398 if(!insertInClientList)
17399 {
17400 //return the stats
17401 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017404 if(insertInClientList)
17405 {
17406 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17407 if(!pStaEntry)
17408 {
17409 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017410 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017411 return eHAL_STATUS_FAILURE;
17412 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017413 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017414 //Init & start timer if needed
17415 if(periodicity)
17416 {
17417 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17418 csrRoamStatsClientTimerHandler, pStaEntry );
17419 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017421 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017422 return eHAL_STATUS_FAILURE;
17423 }
17424 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17425 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17426 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017427 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017428 return eHAL_STATUS_FAILURE;
17429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017430 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017432 }
17433 return eHAL_STATUS_SUCCESS;
17434}
17435
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017436#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17437
17438static tSirRetStatus
17439csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17440 tANI_U8* pBD,
17441 tANI_U8 type,
17442 tANI_U8 subType,
17443 tSirMacAddr peerAddr,
17444 tSirMacAddr selfMacAddr)
17445{
17446 tSirRetStatus statusCode = eSIR_SUCCESS;
17447 tpSirMacMgmtHdr pMacHdr;
17448
17449 /* Prepare MAC management header */
17450 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17451
17452 /* Prepare FC */
17453 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17454 pMacHdr->fc.type = type;
17455 pMacHdr->fc.subType = subType;
17456
17457 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017458 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17459 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017460
17461 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17462
17463 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017464 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17465 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017466 return statusCode;
17467} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17468
17469static tSirRetStatus
17470csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17471 tANI_U8 nChannelNum,
17472 tANI_U32 dot11mode,
17473 tSirMacAddr selfMacAddr,
17474 tANI_U8 *pFrame,
17475 tANI_U16 *pusLen)
17476{
17477 tDot11fProbeRequest pr;
17478 tANI_U32 nStatus, nBytes, nPayload;
17479 tSirRetStatus nSirStatus;
17480 /*Bcast tx*/
17481 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17482 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17483
17484
Kiet Lam64c1b492013-07-12 13:56:44 +053017485 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017486
17487 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17488
17489 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17490 {
17491 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17492 }
17493
17494
17495 if (IS_DOT11_MODE_HT(dot11mode))
17496 {
17497 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17498 }
17499
17500
17501 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17502 if ( DOT11F_FAILED( nStatus ) )
17503 {
17504 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17505 "Failed to calculate the packed size f"
17506 "or a Probe Request (0x%08x).\n", nStatus );
17507
17508
17509 nPayload = sizeof( tDot11fProbeRequest );
17510 }
17511 else if ( DOT11F_WARNED( nStatus ) )
17512 {
17513 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17514 "There were warnings while calculating"
17515 "the packed size for a Probe Request ("
17516 "0x%08x).\n", nStatus );
17517 }
17518
17519 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17520
17521 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017522 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017523
17524
17525 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017526 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017527
17528 if ( eSIR_SUCCESS != nSirStatus )
17529 {
17530 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17531 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17532 nSirStatus );
17533 return nSirStatus;
17534 }
17535
17536
17537 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17538 sizeof( tSirMacMgmtHdr ),
17539 nPayload, &nPayload );
17540 if ( DOT11F_FAILED( nStatus ) )
17541 {
17542 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17543 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17544 return eSIR_FAILURE;
17545 }
17546 else if ( DOT11F_WARNED( nStatus ) )
17547 {
17548 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017549 "There were warnings while packing a Probe Request (0x%08x).\n",
17550 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017551 }
17552
17553 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17554 return eSIR_SUCCESS;
17555}
17556
Mukul Sharmad68cda62015-03-20 21:25:41 +053017557/*
17558 * Below Table describe whether RSO command can be send down to fimrware or not.
17559 * Host check it on the basis of previous RSO command sent down to firmware.
17560||===========================================================================||
17561|| New cmd | LAST SENT COMMAND ---> ||
17562||====|======================================================================||
17563|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17564|| --------------------------------------------------------------------------||
17565|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017566|| RSO_STOP | YES | NO | YES | YES ||
17567|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017568|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17569||===========================================================================||
17570*/
17571
17572#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17573#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17574#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17575#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17576
17577#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17578#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017579 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017580#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17581 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017582#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017583 RSO_START_BIT)
17584
17585tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17586{
17587 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17588 tANI_U8 desiredMask = 0;
17589 switch(command)
17590 {
17591 case ROAM_SCAN_OFFLOAD_START:
17592 desiredMask = RSO_START_ALLOW_MASK;
17593 break;
17594 case ROAM_SCAN_OFFLOAD_STOP:
17595 desiredMask = RSO_STOP_ALLOW_MASK;
17596 break;
17597 case ROAM_SCAN_OFFLOAD_RESTART:
17598 desiredMask = RSO_RESTART_ALLOW_MASK;
17599 break;
17600 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17601 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17602 break;
17603 default:
17604 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17605 FL("Wrong RSO command %d, not allowed"), command);
17606 return 0;/*Cmd Not allowed*/
17607 }
17608 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17609}
17610
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017611eCsrBand GetCurrentBand(tANI_U8 channel)
17612{
17613 tSirRFBand Rfband;
17614 eCsrBand band;
17615
17616 Rfband = GetRFBand(channel);
17617
17618 if (Rfband == SIR_BAND_5_GHZ)
17619 band = eCSR_BAND_5G;
17620 else if (Rfband == SIR_BAND_2_4_GHZ)
17621 band = eCSR_BAND_24;
17622 else if (Rfband == SIR_BAND_UNKNOWN)
17623 band = eCSR_BAND_MAX;
17624
17625 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17626 "channel %d Rfband %d band %d", channel, Rfband, band);
17627
17628 return band;
17629}
17630
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017631eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17632{
17633 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017634 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017635 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017636 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017637 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017638 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017639 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017640 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017641 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017642 eHalStatus status = eHAL_STATUS_SUCCESS;
17643 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017644 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017645 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017646 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017647 tSirBssDescription *pBssDesc = NULL;
17648 tDot11fBeaconIEs *pIes = NULL;
17649 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017650 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017651
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017652 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17653
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017654 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017655 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017656 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017657 return eHAL_STATUS_FAILURE;
17658 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017659
17660 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17661 {
17662 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17663 return eHAL_STATUS_FAILURE;
17664 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017665
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017666 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17667 * It is important to ensure that the command is passed down to the FW only
17668 * if the Infra Station is in a connected state.A connected station could also be
17669 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17670 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17671 * irrespective of whichever state we are in.*/
17672 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17673 (command != ROAM_SCAN_OFFLOAD_STOP))
17674 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017675 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17676 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17677 macTraceGetNeighbourRoamState(
17678 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017679 return eHAL_STATUS_FAILURE;
17680 }
17681
Mukul Sharmad68cda62015-03-20 21:25:41 +053017682 if (!CsrIsRSOCommandAllowed(pMac, command))
17683 {
17684 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17685 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17686 command, pNeighborRoamInfo->lastSentCmd);
17687 return eHAL_STATUS_FAILURE;
17688 }
17689
Abhishek Singh3e915632014-11-01 17:14:50 +053017690 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17691 * Also there are cases where pNeighborRoamInfo->currAPbssid
17692 * is set to 0 during disconnect and so we might return without stopping
17693 * the roam scan. So no need to find the session if command is
17694 * ROAM_SCAN_OFFLOAD_STOP.
17695 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017696 status = csrRoamGetSessionIdFromBSSID(pMac,
17697 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17698 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017699 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017700 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017701 if ( !HAL_STATUS_SUCCESS( status ) )
17702 {
17703 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17704 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17705 return eHAL_STATUS_FAILURE;
17706 }
17707 pSession = CSR_GET_SESSION( pMac, sessionId );
17708 if (NULL == pSession)
17709 {
17710 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080017711 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053017712 return eHAL_STATUS_FAILURE;
17713 }
17714 pBssDesc = pSession->pConnectBssDesc;
17715 if (pBssDesc == NULL)
17716 {
17717 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17718 "%s: pBssDesc not found for current session", __func__);
17719 return eHAL_STATUS_FAILURE;
17720 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017721
17722 operationChannel = pSession->connectedProfile.operationChannel;
17723 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17724 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017725 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017726 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17727 if (NULL == pRequestBuf)
17728 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017729 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17730 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17731 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017732 }
17733
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017734#ifdef FEATURE_WLAN_DIAG_SUPPORT
17735 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17736 eSIR_SUCCESS, eSIR_SUCCESS);
17737#endif
17738
Abhishek Singh3e915632014-11-01 17:14:50 +053017739 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17740 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17741 * host driver reloads, but Riva still up and running*/
17742 pRequestBuf->Command = command;
17743 if(command == ROAM_SCAN_OFFLOAD_STOP)
17744 {
17745 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017746 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017747 /*For a STOP Command, there is no need to
17748 * go through filling up all the below parameters
17749 * since they are not required for the STOP command*/
17750 goto send_roam_scan_offload_cmd;
17751 }
17752 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017753 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017754 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17755 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017756 sizeof(tCsrBssid));
17757 pRequestBuf->ConnectedNetwork.ssId.length =
17758 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17759 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17760 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17761 pRequestBuf->ConnectedNetwork.ssId.length);
17762 pRequestBuf->ConnectedNetwork.authentication =
17763 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17764 pRequestBuf->ConnectedNetwork.encryption =
17765 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17766 pRequestBuf->ConnectedNetwork.mcencryption =
17767 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017768 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17769 {
17770 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017771 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017772 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17773 }
17774 else
17775 {
17776 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017777
17778 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17779 {
17780 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17781 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17782 vos_mem_free(pRequestBuf);
17783 return eHAL_STATUS_FAILURE;
17784 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017785 if(NULL == pIes)
17786 {
17787 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17788 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017789 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017790 return eHAL_STATUS_FAILURE;
17791 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017792 if (pIes->SuppRates.present)
17793 {
17794 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17795 /*Check for both basic rates and extended rates.*/
17796 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17797 {
17798 /*Check if the Rate is Mandatory or Not*/
17799 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17800 && (pIes->SuppRates.rates[i] & 0x80))
17801 {
17802 /*Retrieve the actual data rate*/
17803 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17804 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17805 if (minRate == 0)
17806 minRate = dataRate;
17807 else
17808 minRate = (minRate < dataRate) ? minRate:dataRate;
17809 }
17810 }
17811
17812 if (pIes->ExtSuppRates.present)
17813 {
17814 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17815 {
17816 /*Check if the Rate is Mandatory or Not*/
17817 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17818 && (pIes->ExtSuppRates.rates[i] & 0x80))
17819 {
17820 /*Retrieve the actual data rate*/
17821 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17822 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17823 if (minRate == 0)
17824 minRate = dataRate;
17825 else
17826 minRate = (minRate < dataRate) ? minRate:dataRate;
17827 }
17828 }
17829 }
17830 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17831 }
17832 else
17833 {
17834 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17835 "%s: Supp Rates not present in pIes", __func__);
17836 vos_mem_free(pRequestBuf);
17837 return eHAL_STATUS_FAILURE;
17838 }
17839 if (NULL != pIes)
17840 {
17841 vos_mem_free(pIes);
17842 pIes = NULL;
17843 }
17844 switch (minRate)
17845 {
17846 case 1:
17847 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
17848 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
17849 break;
17850 case 2:
17851 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
17852 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
17853 break;
17854 case 5:
17855 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
17856 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
17857 break;
17858 case 6:
17859 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17860 {
17861 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
17862 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
17863 }
17864 else
17865 {
17866 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
17867 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
17868 }
17869 break;
17870 case 11:
17871 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
17872 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
17873 break;
17874 case 12:
17875 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17876 {
17877 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
17878 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
17879 }
17880 else
17881 {
17882 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
17883 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
17884 }
17885 break;
17886 case 24:
17887 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17888 {
17889 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
17890 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
17891 }
17892 else
17893 {
17894 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
17895 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
17896 }
17897 break;
17898 default:
17899 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
17900 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17901 break;
17902 }
17903 }
17904 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17905 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
17906 operationChannel, minRate,
17907 pRequestBuf->RxSensitivityThreshold,
17908 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017909 pRequestBuf->RoamRssiDiff =
17910 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017911 pRequestBuf->StartScanReason = reason;
17912 pRequestBuf->NeighborScanTimerPeriod =
17913 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
17914 pRequestBuf->NeighborRoamScanRefreshPeriod =
17915 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
17916 pRequestBuf->NeighborScanChannelMinTime =
17917 pNeighborRoamInfo->cfgParams.minChannelScanTime;
17918 pRequestBuf->NeighborScanChannelMaxTime =
17919 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
17920 pRequestBuf->EmptyRefreshScanPeriod =
17921 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080017922 /* MAWC feature */
17923 pRequestBuf->MAWCEnabled =
17924 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017925
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017926#ifdef FEATURE_WLAN_ESE
17927 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017928#endif
17929 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017930#ifdef FEATURE_WLAN_ESE
17931 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017932 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17933 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017934 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17935#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017936 currChannelListInfo->numOfChannels == 0)
17937 {
17938
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017939 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
17940 * Give Preference to INI Channels.*/
17941 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
17942 {
17943 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
17944 /*The INI channels need to be filtered with respect to the current
17945 * band that is supported.*/
17946 eBand = pMac->roam.configParam.bandCapability;
17947 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017948 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017949 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17950 "Invalid band, No operation carried out (Band %d)", eBand);
17951 vos_mem_free(pRequestBuf);
17952 return eHAL_STATUS_FAILURE;
17953 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017954
17955 if (pMac->roam.configParam.nRoamIntraBand)
17956 {
17957 eBand = GetCurrentBand(operationChannel);
17958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17959 "Current Band %d", eBand);
17960 }
17961
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017962 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
17963 {
17964 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17965 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
17966 (eCSR_BAND_ALL == eBand))
17967 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017968 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
17969 ((pMac->roam.configParam.allowDFSChannelRoam) ||
17970 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
17971 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017972 {
17973 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
17974 }
17975 }
17976 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017977 }
17978 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17979 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017980 }
17981 else
17982 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017983 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017984
17985 if (pMac->roam.configParam.nRoamIntraBand)
17986 {
17987 Rfband = GetCurrentBand(operationChannel);
17988 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17989 "Current Band %d", Rfband);
17990 }
17991
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017992 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
17993 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017994 if(((eCSR_BAND_24 == Rfband) &&
17995 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17996 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
17997 || (eCSR_BAND_ALL == Rfband))
17998 {
17999 /* Allow DFS channels only if the DFS channel roam flag is
18000 * enabled
18001 */
18002 if(*ChannelList && ((pMac->roam.configParam.
18003 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
18004 && (num_channels < SIR_ROAM_MAX_CHANNELS))
18005 {
18006 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
18007 = *ChannelList;
18008 }
18009 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018010 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018011 }
18012 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18013 /* If the profile changes as to what it was earlier, inform the FW through
18014 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
18015 * for the earlier profile and try to learn them afresh.*/
18016 if (reason == REASON_FLUSH_CHANNEL_LIST)
18017 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18018 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018019 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18020 (pMac->roam.configParam.nRoamIntraBand))
18021 pRequestBuf->ChannelCacheType =
18022 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018023 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018024 pRequestBuf->ChannelCacheType =
18025 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018026 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018027 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018028 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018029#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018030 else
18031 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018032 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018033 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018034 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018035 if (currChannelListInfo->numOfChannels != 0)
18036 {
18037 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018038
18039 if (pMac->roam.configParam.nRoamIntraBand)
18040 {
18041 Rfband = GetCurrentBand(operationChannel);
18042 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18043 "Current Band %d", Rfband);
18044 }
18045
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018046 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018047 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018048 if(((eCSR_BAND_24 == Rfband) &&
18049 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18050 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18051 || (eCSR_BAND_ALL == Rfband))
18052 {
18053 if(*ChannelList && ((pMac->roam.configParam.
18054 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18055 {
18056 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018057 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018058 }
18059 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018060 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018061 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018062 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018063 if (pMac->roam.configParam.nRoamIntraBand)
18064 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18065 else
18066 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018067 }
18068 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018069#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018070 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18071 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018072 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018073 if (j < sizeof(ChannelCacheStr))
18074 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018075 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18076 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018077 }
18078 else
18079 {
18080 break;
18081 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018082 }
18083 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18084 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18085 pRequestBuf->ChannelCacheType,
18086 pRequestBuf->ConnectedNetwork.ChannelCount,
18087 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018088 num_channels = 0;
18089 ChannelList = NULL;
18090
18091 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018092 host_channels = sizeof(pMac->roam.validChannelList);
18093 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018094 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018095 ChannelList = pMac->roam.validChannelList;
18096 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018097 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018098 else
18099 {
18100 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18101 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018102 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018103 return eHAL_STATUS_FAILURE;
18104 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018105
18106 if (pMac->roam.configParam.nRoamIntraBand)
18107 {
18108 Rfband = GetCurrentBand(operationChannel);
18109 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18110 Rfband);
18111 }
18112
Srinivas Girigowda56076852013-08-20 14:00:50 -070018113 for(i=0; i<pMac->roam.numValidChannels; i++)
18114 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018115 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18116 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18117 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018118 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018119 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18120 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18121 {
18122 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18123 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018124 }
18125 ChannelList++;
18126 }
18127 pRequestBuf->ValidChannelCount = num_channels;
18128
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018129 pRequestBuf->MDID.mdiePresent =
18130 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18131 pRequestBuf->MDID.mobilityDomain =
18132 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018133 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18134
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018135 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018136 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18137 * where RFS is the RF Switching time. It is twice RFS to consider the
18138 * time to go off channel and return to the home channel. */
18139 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18140 {
18141 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18142 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18143 " Hence enforcing home away time to disable (0)",
18144 __func__, pRequestBuf->HomeAwayTime,
18145 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18146 pRequestBuf->HomeAwayTime = 0;
18147 }
18148 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018149
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018150 pRequestBuf->WeakZoneRssiThresholdForRoam =
18151 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018152 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18153 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18154 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18155 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18156 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18157
18158 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18159 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018160send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018161 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018162 msg.reserved = 0;
18163 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018164 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18165 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018166 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18167 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018168 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18169 vos_mem_free(pRequestBuf);
18170 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018171 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018172 else
18173 {
18174 if (ROAM_SCAN_OFFLOAD_START == command)
18175 bRoamScanOffloadStarted = VOS_TRUE;
18176 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18177 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018178
18179 /*update the last sent cmd*/
18180 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018181 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018182
18183 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 +053018184
18185 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018186 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18187 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018188 {
18189
18190 /* PER ROAM SCAN */
18191 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18192 if (!PERRoamReqBuf)
18193 {
18194 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18195 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18196 return eHAL_STATUS_FAILURE;
18197 }
18198 /* PER Roam Config */
18199 PERRoamReqBuf->rateUpThreshold =
18200 pMac->roam.configParam.rateUpThreshold;
18201 PERRoamReqBuf->rateDownThreshold =
18202 pMac->roam.configParam.rateDownThreshold;
18203 PERRoamReqBuf->waitPeriodForNextPERScan =
18204 pMac->roam.configParam.waitPeriodForNextPERScan;
18205 PERRoamReqBuf->PERtimerThreshold =
18206 pMac->roam.configParam.PERtimerThreshold;
18207 PERRoamReqBuf->isPERRoamCCAEnabled =
18208 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018209 PERRoamReqBuf->PERRoamFullScanThreshold =
18210 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018211 PERRoamReqBuf->PERroamTriggerPercent =
18212 pMac->roam.configParam.PERroamTriggerPercent;
18213 PERRoamReqBuf->sessionId = sessionId;
18214
18215 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18216 PERroamScanConfigMsg.reserved = 0;
18217 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18218 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18219 &PERroamScanConfigMsg))) {
18220 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18221 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18222 vos_mem_free(PERRoamReqBuf);
18223 return eHAL_STATUS_FAILURE;
18224 }
18225 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18226 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18227 PERRoamReqBuf->rateUpThreshold,
18228 PERRoamReqBuf->rateDownThreshold,
18229 PERRoamReqBuf->waitPeriodForNextPERScan,
18230 PERRoamReqBuf->PERtimerThreshold);
18231 }
18232
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018233 return status;
18234}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018235
18236eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18237{
18238 switch(reason)
18239 {
18240 case 0:
18241 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18242 break;
18243 case REASON_OS_REQUESTED_ROAMING_NOW:
18244 csrNeighborRoamProceedWithHandoffReq(pMac);
18245 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018246 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18247 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18248 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018249 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018250 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 -070018251 }
18252 return eHAL_STATUS_SUCCESS;
18253}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018254#endif
18255
Jeff Johnson295189b2012-06-20 16:38:30 -070018256tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18257 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18258{
18259 tANI_BOOLEAN found = FALSE;
18260 eHalStatus status = eHAL_STATUS_SUCCESS;
18261 tCsrPeStatsReqInfo staEntry;
18262 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18263 tListElem *pStaEntry = NULL;
18264 VOS_STATUS vosStatus;
18265 tPmcPowerState powerState;
18266 *pFound = FALSE;
18267
18268 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18269 if(pStaEntry)
18270 {
18271 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18272 if(pTempStaEntry->periodicity)
18273 {
18274 pTempStaEntry->periodicity =
18275 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18276 }
18277 else
18278 {
18279 pTempStaEntry->periodicity = periodicity;
18280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018281 pTempStaEntry->numClient++;
18282 found = TRUE;
18283 }
18284 else
18285 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018286 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018287 staEntry.numClient = 1;
18288 staEntry.periodicity = periodicity;
18289 staEntry.pMac = pMac;
18290 staEntry.rspPending = FALSE;
18291 staEntry.staId = staId;
18292 staEntry.statsMask = statsMask;
18293 staEntry.timerRunning = FALSE;
18294 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18295 if(!pTempStaEntry)
18296 {
18297 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018298 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018299 return NULL;
18300 }
18301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018302 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18303 if(ePMC_FULL_POWER == powerState)
18304 {
18305 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18306 {
18307 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18308 }
18309 }
18310 else
18311 {
18312 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18313 {
18314 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18315 }
18316 }
18317 if(!pTempStaEntry->timerRunning)
18318 {
18319 //send down a req in case of one time req, for periodic ones wait for timer to expire
18320 if(!pTempStaEntry->rspPending &&
18321 !pTempStaEntry->periodicity)
18322 {
18323 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18324 if(!HAL_STATUS_SUCCESS(status))
18325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018326 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018327 }
18328 else
18329 {
18330 pTempStaEntry->rspPending = TRUE;
18331 }
18332 }
18333 if(pTempStaEntry->periodicity)
18334 {
18335 if(!found)
18336 {
18337
18338 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18339 csrRoamPeStatsTimerHandler, pTempStaEntry );
18340 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018342 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018343 return NULL;
18344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018345 }
18346 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018347 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018348 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18349 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018351 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018352 return NULL;
18353 }
18354 pTempStaEntry->timerRunning = TRUE;
18355 }
18356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018357 *pFound = found;
18358 return pTempStaEntry;
18359}
18360
Jeff Johnson295189b2012-06-20 16:38:30 -070018361/*
18362 pStaEntry is no longer invalid upon the return of this function.
18363*/
18364static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18365{
18366 if(pEntry)
18367 {
18368 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18369 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018370 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018372 }
18373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018374
18375void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18376{
18377 tListElem *pEntry;
18378 tCsrPeStatsReqInfo *pTempStaEntry;
18379 VOS_STATUS vosStatus;
18380 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018381 if(!pEntry)
18382 {
18383 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018384 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018385 return;
18386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018387 while( pEntry )
18388 {
18389 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018390 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18391 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018392 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018393 if(pTempStaEntry->timerRunning)
18394 {
18395 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18396 /* If we are not able to stop the timer here, just remove
18397 * the entry from the linked list. Destroy the timer object
18398 * and free the memory in the timer CB
18399 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018400 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018401 {
18402 /* the timer is successfully stopped */
18403 pTempStaEntry->timerRunning = FALSE;
18404
18405 /* Destroy the timer */
18406 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18407 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018409 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018410 }
18411 }
18412 else
18413 {
18414 // the timer could not be stopped. Hence destroy and free the
18415 // memory for the PE stat entry in the timer CB.
18416 pTempStaEntry->timerStopFailed = TRUE;
18417 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018419
18420 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18421 {
18422 // Only free the memory if we could stop the timer successfully
18423 if(!pTempStaEntry->timerStopFailed)
18424 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018425 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018426 pTempStaEntry = NULL;
18427 }
18428 break;
18429 }
18430
18431 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18432 }
18433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018434 return;
18435}
18436
18437
Jeff Johnsone7245742012-09-05 17:12:55 -070018438void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018439{
18440
Jeff Johnsone7245742012-09-05 17:12:55 -070018441 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18442 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18443 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18444 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18445 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18446 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18447 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018448 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018449 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18450 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18451 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18452 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18453 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18454 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018455 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018456 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18457 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018458
18459}
18460
Jeff Johnson295189b2012-06-20 16:38:30 -070018461void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18462 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18463{
18464 tANI_U8 stats[500];
18465 tANI_U8 *pStats = NULL;
18466 tANI_U32 tempMask = 0;
18467 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018468 if(!callback)
18469 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018470 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018471 return;
18472 }
18473 if(!statsMask)
18474 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018475 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018476 return;
18477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018478 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018479 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018480 while(tempMask)
18481 {
18482 if(tempMask & 1)
18483 {
18484 //new stats info from PE, fill up the stats strucutres in PMAC
18485 switch(counter)
18486 {
18487 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018488 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018489 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18490 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018491 pStats += sizeof(tCsrSummaryStatsInfo);
18492 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018493 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018494 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018495 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18496 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018497 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018498 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018499 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018500 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018501 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18502 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018503 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018504 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018505 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018506 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018507 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18508 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018509 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018510 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018511 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018512 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018513 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18514 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018515 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018516 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018517 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018518 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018519 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18520 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018521 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018522 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018523 case eCsrPerPktStats:
18524 smsLog( pMac, LOG2, FL("PerPkt stats"));
18525 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18526 sizeof(tPerTxPacketFrmFw));
18527 pStats += sizeof(tPerTxPacketFrmFw);
18528 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018529 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018530 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018531 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018532 }
18533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018534 tempMask >>=1;
18535 counter++;
18536 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018537 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018538}
18539
Jeff Johnson295189b2012-06-20 16:38:30 -070018540eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18541{
18542 tListElem *pEntry = NULL;
18543 tListElem *pPrevEntry = NULL;
18544 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18545 eHalStatus status = eHAL_STATUS_SUCCESS;
18546 VOS_STATUS vosStatus;
18547 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018548 if(!pEntry)
18549 {
18550 //list empty
18551 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018552 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018553 return status;
18554 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018555 while( pEntry )
18556 {
18557 if(pPrevEntry)
18558 {
18559 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18560 //send up the stats report
18561 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18562 pTempStaEntry->staId, pTempStaEntry->pContext);
18563 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018565 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018566 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18567 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018568 pTempStaEntry->pPeStaEntry->numClient--;
18569 //check if we need to delete the entry from peStatsReqList too
18570 if(!pTempStaEntry->pPeStaEntry->numClient)
18571 {
18572 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018575 //check if we need to stop the tl stats timer too
18576 pMac->roam.tlStatsReqInfo.numClient--;
18577 if(!pMac->roam.tlStatsReqInfo.numClient)
18578 {
18579 if(pMac->roam.tlStatsReqInfo.timerRunning)
18580 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018581 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18582 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018584 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018585 //we will continue
18586 }
18587 }
18588 pMac->roam.tlStatsReqInfo.periodicity = 0;
18589 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18590 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018591 if (pTempStaEntry->periodicity)
18592 {
18593 //While creating StaEntry in csrGetStatistics,
18594 //Initializing and starting timer only when periodicity is set.
18595 //So Stop and Destroy timer only when periodicity is set.
18596
Jeff Johnsone7245742012-09-05 17:12:55 -070018597 vos_timer_stop( &pTempStaEntry->timer );
18598 // Destroy the vos timer...
18599 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18600 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018602 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018604 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018605
Jeff Johnson295189b2012-06-20 16:38:30 -070018606
18607 pPrevEntry = pEntry;
18608 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18609 }
18610 //the last one
18611 if(pPrevEntry)
18612 {
18613 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18614 //send up the stats report
18615 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18616 pTempStaEntry->staId, pTempStaEntry->pContext);
18617 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18618 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018619 return status;
18620
18621}
18622
Jeff Johnson295189b2012-06-20 16:38:30 -070018623eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18624 tRequestFullPowerReason *pReason,
18625 tANI_BOOLEAN *pfNeedPower )
18626{
18627 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18628 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18629 tPmcState pmcState;
18630 eHalStatus status = eHAL_STATUS_SUCCESS;
18631 // TODO : Session info unavailable
18632 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018633 if( pfNeedPower )
18634 {
18635 *pfNeedPower = eANI_BOOLEAN_FALSE;
18636 }
18637 //We only handle CSR commands
18638 if( !(eSmeCsrCommandMask & pCommand->command) )
18639 {
18640 return eHAL_STATUS_SUCCESS;
18641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018642 //Check PMC state first
18643 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018644 switch( pmcState )
18645 {
18646 case REQUEST_IMPS:
18647 case IMPS:
18648 if( eSmeCommandScan == pCommand->command )
18649 {
18650 switch( pCommand->u.scanCmd.reason )
18651 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018652#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18653 case eCsrScanGetLfrResult:
18654#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018655 case eCsrScanGetResult:
18656 case eCsrScanBGScanAbort:
18657 case eCsrScanBGScanEnable:
18658 case eCsrScanGetScanChnInfo:
18659 //Internal process, no need for full power
18660 fNeedFullPower = eANI_BOOLEAN_FALSE;
18661 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018662 default:
18663 //Other scans are real scan, ask for power
18664 fNeedFullPower = eANI_BOOLEAN_TRUE;
18665 break;
18666 } //switch
18667 }
18668 else
18669 {
18670 //ask for power for roam and status change
18671 fNeedFullPower = eANI_BOOLEAN_TRUE;
18672 }
18673 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018674 case REQUEST_BMPS:
18675 case BMPS:
18676 case REQUEST_START_UAPSD:
18677 case UAPSD:
18678 //We treat WOWL same as BMPS
18679 case REQUEST_ENTER_WOWL:
18680 case WOWL:
18681 if( eSmeCommandRoam == pCommand->command )
18682 {
18683 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18684 tCsrScanResult *pScanResult;
18685 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018686 switch ( pCommand->u.roamCmd.roamReason )
18687 {
18688 case eCsrForcedDisassoc:
18689 case eCsrForcedDisassocMICFailure:
18690 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18691 fNeedFullPower = eANI_BOOLEAN_TRUE;
18692 break;
18693 case eCsrSmeIssuedDisassocForHandoff:
18694 case eCsrForcedDeauth:
18695 case eCsrHddIssuedReassocToSameAP:
18696 case eCsrSmeIssuedReassocToSameAP:
18697 fNeedFullPower = eANI_BOOLEAN_TRUE;
18698 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018699 case eCsrCapsChange:
18700 fNeedFullPower = eANI_BOOLEAN_TRUE;
18701 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018702 case eCsrForcedDisassocSta:
18703 case eCsrForcedDeauthSta:
18704 fNeedFullPower = eANI_BOOLEAN_FALSE;
18705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018706 default:
18707 //Check whether the profile is already connected. If so, no need for full power
18708 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18709 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18710 {
18711 //Only need to check the first one
18712 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18713 if( pEntry )
18714 {
18715 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18716#if 0
18717 // TODO : Session Specific info pConnectBssDesc
18718 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18719 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18720 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18721 {
18722 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18723 // with Authenticating first. To force this, stop the current association (Disassociate) and
18724 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18725 // a new Association.
18726 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18727 {
18728 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18729 {
18730 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18731 //No need for full power
18732 //Set the flag so the code later can avoid to do the above
18733 //check again.
18734 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18735 break;
18736 }
18737 }
18738 }
18739#endif
18740 }
18741 }
18742 //If we are here, full power is needed
18743 fNeedFullPower = eANI_BOOLEAN_TRUE;
18744 break;
18745 }
18746 }
18747 else if( eSmeCommandWmStatusChange == pCommand->command )
18748 {
18749 //need full power for all
18750 fNeedFullPower = eANI_BOOLEAN_TRUE;
18751 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18752 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018753#ifdef FEATURE_WLAN_TDLS
18754 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18755 {
18756 //TDLS link is getting established. need full power
18757 fNeedFullPower = eANI_BOOLEAN_TRUE;
18758 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18759 }
18760#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018761 else if (eSmeCommandDelStaSession == pCommand->command)
18762 {
18763 //need full power for all
18764 fNeedFullPower = eANI_BOOLEAN_TRUE;
18765 }
18766
Jeff Johnson295189b2012-06-20 16:38:30 -070018767 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018768 case REQUEST_STOP_UAPSD:
18769 case REQUEST_EXIT_WOWL:
18770 if( eSmeCommandRoam == pCommand->command )
18771 {
18772 fNeedFullPower = eANI_BOOLEAN_TRUE;
18773 switch ( pCommand->u.roamCmd.roamReason )
18774 {
18775 case eCsrForcedDisassoc:
18776 case eCsrForcedDisassocMICFailure:
18777 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18778 break;
18779 default:
18780 break;
18781 }
18782 }
18783 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018784 case STOPPED:
18785 case REQUEST_STANDBY:
18786 case STANDBY:
18787 case LOW_POWER:
18788 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018789 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18790 " stopped/standby state %s (%d)" ),
18791 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018792 status = eHAL_STATUS_FAILURE;
18793 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018794 case FULL_POWER:
18795 case REQUEST_FULL_POWER:
18796 default:
18797 //No need to ask for full power. This has to be FULL_POWER state
18798 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018799 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018800 if( pReason )
18801 {
18802 *pReason = reason;
18803 }
18804 if( pfNeedPower )
18805 {
18806 *pfNeedPower = fNeedFullPower;
18807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018808 return ( status );
18809}
18810
Jeff Johnson295189b2012-06-20 16:38:30 -070018811static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18812{
18813 eHalStatus status = eHAL_STATUS_SUCCESS;
18814 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18815 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018816 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018817 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18818 {
18819 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018821 return ( status );
18822}
18823
Jeff Johnson295189b2012-06-20 16:38:30 -070018824tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18825{
18826 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018827 if( pCmd )
18828 {
18829 pMac->roam.sPendingCommands++;
18830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018831 return ( pCmd );
18832}
18833
Jeff Johnson295189b2012-06-20 16:38:30 -070018834void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18835{
18836 if (pMac->roam.sPendingCommands > 0)
18837 {
18838 //All command allocated through csrGetCommandBuffer need to
18839 //decrement the pending count when releasing.
18840 pMac->roam.sPendingCommands--;
18841 smeReleaseCommand( pMac, pCommand );
18842 }
18843 else
18844 {
18845 smsLog(pMac, LOGE, FL( "no pending commands"));
18846 VOS_ASSERT(0);
18847 }
18848}
18849
Jeff Johnson295189b2012-06-20 16:38:30 -070018850//Return SUCCESS is the command is queued, failed
18851eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
18852{
18853 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053018854
18855 if (!SME_IS_START(pMac))
18856 {
18857 smsLog( pMac, LOGE, FL("Sme in stop state"));
18858 return eHAL_STATUS_FAILURE;
18859 }
18860
Jeff Johnson295189b2012-06-20 16:38:30 -070018861 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
18862 {
18863 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
18864 pCommand->u.scanCmd.reason);
18865 return eHAL_STATUS_CSR_WRONG_STATE;
18866 }
18867
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018868 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
18869 {
18870 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
18871 &pCommand->Link, LL_ACCESS_LOCK);
18872 // process the command queue...
18873 smeProcessPendingQueue(pMac);
18874 status = eHAL_STATUS_SUCCESS;
18875 goto end;
18876 }
18877
Jeff Johnson295189b2012-06-20 16:38:30 -070018878 //We can call request full power first before putting the command into pending Q
18879 //because we are holding SME lock at this point.
18880 status = csrRequestFullPower( pMac, pCommand );
18881 if( HAL_STATUS_SUCCESS( status ) )
18882 {
18883 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070018884 //make sure roamCmdPendingList is not empty first
18885 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
18886 if( fNoCmdPending )
18887 {
18888 smePushCommand( pMac, pCommand, fHighPriority );
18889 }
18890 else
18891 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018892 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070018893 //no list lock is needed since SME lock is held
18894 if( !fHighPriority )
18895 {
18896 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18897 }
18898 else {
18899 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18900 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018902 }
18903 else if( eHAL_STATUS_PMC_PENDING == status )
18904 {
18905 //no list lock is needed since SME lock is held
18906 if( !fHighPriority )
18907 {
18908 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18909 }
18910 else {
18911 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18912 }
18913 //Let caller know the command is queue
18914 status = eHAL_STATUS_SUCCESS;
18915 }
18916 else
18917 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018918 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070018919 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018920 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070018921 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018922end:
Jeff Johnson295189b2012-06-20 16:38:30 -070018923 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070018924}
Jeff Johnson295189b2012-06-20 16:38:30 -070018925eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
18926{
18927 eHalStatus status = eHAL_STATUS_SUCCESS;
18928 tSirUpdateAPWPSIEsReq *pMsg;
18929 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
18930
18931 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18932 if (NULL == pSession)
18933 {
18934 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18935 return eHAL_STATUS_FAILURE;
18936 }
18937
Jeff Johnson295189b2012-06-20 16:38:30 -070018938 do
18939 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018940 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
18941 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18942 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018943 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
18944
18945 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070018946 VOS_ASSERT(pBuf);
18947
Jeff Johnson295189b2012-06-20 16:38:30 -070018948 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018949 // transactionId
18950 *pBuf = 0;
18951 *( pBuf + 1 ) = 0;
18952 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070018953 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018954 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18955 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070018956 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018957 //sessionId
18958 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018959 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018960 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070018961 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070018962 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018963 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018964 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018965 return ( status );
18966}
Jeff Johnson295189b2012-06-20 16:38:30 -070018967eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
18968{
18969 eHalStatus status = eHAL_STATUS_SUCCESS;
18970 tSirUpdateAPWPARSNIEsReq *pMsg;
18971 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070018972 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18973 if (NULL == pSession)
18974 {
18975 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18976 return eHAL_STATUS_FAILURE;
18977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018978 do
18979 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018980 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
18981 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18982 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018983 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070018984 pBuf = (tANI_U8 *)&pMsg->transactionId;
18985 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070018986 // transactionId
18987 *pBuf = 0;
18988 *( pBuf + 1 ) = 0;
18989 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070018990 VOS_ASSERT(pBuf);
18991
Jeff Johnson295189b2012-06-20 16:38:30 -070018992 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053018993 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
18994 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070018995 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018996 // sessionId
18997 *pBuf++ = (tANI_U8)sessionId;
18998
18999 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019000 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070019001 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070019002 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019003 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019004 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019005 return ( status );
19006}
Jeff Johnson295189b2012-06-20 16:38:30 -070019007
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019008tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
19009 tpSirBssDescription pBssDescription)
19010{
19011 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19012 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19013 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
19014 eHalStatus status;
19015 tDot11fBeaconIEs *ies_local = NULL;
19016 tANI_U32 dot11mode = 0;
19017
19018 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19019
19020 /* Get IE's */
19021 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19022 if (!HAL_STATUS_SUCCESS(status)) {
19023 smsLog(pMac, LOGE,
19024 FL("csrGetParsedBssDescriptionIEs failed"));
19025 return 0;
19026 }
19027 if(ies_local == NULL) {
19028 smsLog(pMac, LOGE,
19029 FL("ies_local is NULL"));
19030 return 0;
19031 }
19032
19033 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19034 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19035 uCfgDot11Mode = cfgDot11Mode;
19036 else
19037 {
19038 smsLog(pMac, LOGE, "Can not find match phy mode");
19039 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19040 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19041 else
19042 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19043 }
19044
19045 /* dot11mode */
19046 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19047 smsLog(pMac, LOG1,
19048 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19049
19050 if (pBssDescription->channelId <= 14 &&
19051 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19052 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19053 {
19054 /* Need to disable VHT operation in 2.4 GHz band */
19055 dot11mode = WNI_CFG_DOT11_MODE_11N;
19056 }
19057 vos_mem_free(ies_local);
19058 return dot11mode;
19059}
19060
Jeff Johnson295189b2012-06-20 16:38:30 -070019061#ifdef WLAN_FEATURE_VOWIFI_11R
19062//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19063eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19064{
19065 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19066 tpSirFTPreAuthReq pftPreAuthReq;
19067 tANI_U16 auth_req_len = 0;
19068 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019069 auth_req_len = sizeof(tSirFTPreAuthReq);
19070 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019071 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019072 {
19073 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19074 return eHAL_STATUS_RESOURCES;
19075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019076 // Save the SME Session ID here. We need it while processing the preauth response
19077 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019078 vos_mem_zero(pftPreAuthReq, auth_req_len);
19079
19080 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19081 sizeof(pBssDescription->length) + pBssDescription->length);
19082
19083 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19084
19085 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019086 pftPreAuthReq->dot11mode =
19087 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19088 if (!pftPreAuthReq->dot11mode)
19089 {
19090 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19091 vos_mem_free(pftPreAuthReq);
19092 return eHAL_STATUS_FAILURE;
19093 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019094
Kiet Lam64c1b492013-07-12 13:56:44 +053019095 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19096 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19097 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19098 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019099
Jeff Johnson295189b2012-06-20 16:38:30 -070019100#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019101 if (csrRoamIs11rAssoc(pMac) &&
19102 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019103 {
19104 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019105 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19106 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019107 }
19108 else
19109#endif
19110 {
19111 pftPreAuthReq->ft_ies_length = 0;
19112 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019113 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19114 sizeof(pBssDescription->length) + pBssDescription->length);
19115 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019116 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19117}
Jeff Johnson295189b2012-06-20 16:38:30 -070019118/*--------------------------------------------------------------------------
19119 * This will receive and process the FT Pre Auth Rsp from the current
19120 * associated ap.
19121 *
19122 * This will invoke the hdd call back. This is so that hdd can now
19123 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19124 ------------------------------------------------------------------------*/
19125void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19126{
19127 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19128 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019129#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019130 tCsrRoamInfo roamInfo;
19131#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019132 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019133
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019134#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019135 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019136 if (status != eHAL_STATUS_SUCCESS) {
19137 /*
19138 * Bail out if pre-auth was not even processed.
19139 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019140 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19141 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019142 return;
19143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019145 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19146 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19147 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019148 // Implies a success
19149 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019150 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19151 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019152 /* No need to notify qos module if this is a non 11r & ESE roam*/
19153 if (csrRoamIs11rAssoc(pMac)
19154#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19155 || csrRoamIsESEAssoc(pMac)
19156#endif
19157 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019158 {
19159 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19160 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019161 if (pMac->roam.configParam.roamDelayStatsEnabled)
19162 {
19163 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019165 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19166 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019167 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19168 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019169 if (pMac->roam.configParam.roamDelayStatsEnabled)
19170 {
19171 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019173 if (eHAL_STATUS_SUCCESS != status)
19174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019175 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019176 return;
19177 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019178 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019179 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19180 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019181 if (csrRoamIs11rAssoc(pMac))
19182 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19183 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19184
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019185#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19186 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019187 {
19188 /* read TSF */
19189 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19190
19191 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019192 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019193 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19194 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019195#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019196#ifdef FEATURE_WLAN_LFR
19197 // If Legacy Fast Roaming is enabled, signal the supplicant
19198 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019199 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019200 {
19201 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019202 vos_mem_copy((void *)&roamInfo.bssid,
19203 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019204 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19205 }
19206
19207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019208
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019209 // If its an Open Auth, FT IEs are not provided by supplicant
19210 // Hence populate them here
19211 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19212 pMac->ft.ftSmeContext.addMDIE = FALSE;
19213 if( csrRoamIs11rAssoc(pMac) &&
19214 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19215 {
19216 tANI_U16 ft_ies_length;
19217 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19218
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019219 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19220 connectedProfile.MDID.mdiePresent)
19221 pMac->ft.ftSmeContext.addMDIE = TRUE;
19222
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019223 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19224 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19225 {
19226 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19227 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19228 }
19229
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019230 if (!ft_ies_length)
19231 {
19232 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19233 return;
19234 }
19235
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019236 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19237 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19238 {
19239 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19240 }
19241 else
19242 {
19243 // Copy the RIC IEs to reassoc IEs
19244 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19245 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19246 pFTPreAuthRsp->ric_ies_length);
19247 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19248 pMac->ft.ftSmeContext.addMDIE = TRUE;
19249 }
19250 }
19251
Jeff Johnson295189b2012-06-20 16:38:30 -070019252 // Done with it, init it.
19253 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19254}
19255#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019256
Jeff Johnson295189b2012-06-20 16:38:30 -070019257#ifdef FEATURE_WLAN_BTAMP_UT_RF
19258void csrRoamJoinRetryTimerHandler(void *pv)
19259{
19260 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19261 tpAniSirGlobal pMac = pInfo->pMac;
19262 tANI_U32 sessionId = pInfo->sessionId;
19263 tCsrRoamSession *pSession;
19264
19265 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019267 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019268 pSession = CSR_GET_SESSION( pMac, sessionId );
19269 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19270 {
19271 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019273 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019274 }
19275 }
19276 }
19277}
Jeff Johnson295189b2012-06-20 16:38:30 -070019278eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19279{
19280 eHalStatus status = eHAL_STATUS_FAILURE;
19281 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19282
19283 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019285 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019286 pSession->maxRetryCount--;
19287 pSession->joinRetryTimerInfo.pMac = pMac;
19288 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019289 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19290 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019292 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019293 }
19294 }
19295 else
19296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019297 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019298 pSession->maxRetryCount);
19299 }
19300
19301 return (status);
19302}
Jeff Johnson295189b2012-06-20 16:38:30 -070019303eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19304{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019305 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019306 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19307 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019308 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019309 }
19310
19311 return eHAL_STATUS_SUCCESS;
19312}
19313#endif
19314
19315
19316/*
19317 pBuf points to the beginning of the message
19318 LIM packs disassoc rsp as below,
19319 messageType - 2 bytes
19320 messageLength - 2 bytes
19321 sessionId - 1 byte
19322 transactionId - 2 bytes (tANI_U16)
19323 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19324 peerMacAddr - 6 bytes
19325 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19326*/
19327static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19328{
19329 if(pBuf && pRsp)
19330 {
19331 pBuf += 4; //skip type and length
19332 pRsp->sessionId = *pBuf++;
19333 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19334 pBuf += 2;
19335 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19336 pBuf += 4;
19337 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19338 }
19339}
19340
Jeff Johnsond13512a2012-07-17 11:42:19 -070019341eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19342{
19343 static uNvTables nvTables;
19344 eHalStatus status = eHAL_STATUS_SUCCESS;
19345 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19346
19347 /* read the country code from NV and use it */
19348 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19349 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019350 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19351 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019352 return status;
19353 }
19354 else
19355 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019356 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019357 status = eHAL_STATUS_FAILURE;
19358 return status;
19359 }
19360}
19361
19362eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19363{
Kiet Lam64c1b492013-07-12 13:56:44 +053019364 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019365 return eHAL_STATUS_SUCCESS;
19366}
schang86c22c42013-03-13 18:41:24 -070019367
19368eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19369{
19370 tSirSetTxPowerReq *pMsg = NULL;
19371 eHalStatus status = eHAL_STATUS_SUCCESS;
19372 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19373
19374 if (!pSession)
19375 {
19376 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19377 return eHAL_STATUS_FAILURE;
19378 }
19379
Kiet Lam64c1b492013-07-12 13:56:44 +053019380 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19381 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19382 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19383 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19384 pMsg->length = sizeof(tSirSetTxPowerReq);
19385 pMsg->mwPower = mW;
19386 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19387 sizeof(tSirMacAddr));
19388 status = palSendMBMessage(pMac->hHdd, pMsg);
19389 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019390 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019391 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19392 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019393 }
19394 return status;
19395}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019396
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019397eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19398{
19399 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19400 eHalStatus status = eHAL_STATUS_SUCCESS;
19401 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19402
19403 if (!pSession)
19404 {
19405 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19406 return eHAL_STATUS_FAILURE;
19407 }
19408 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19409 {
19410 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019411
19412 if( NULL == pMsg )
19413 {
19414 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19415 return eHAL_STATUS_FAILURE;
19416 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019417 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19418 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019419 pMsg->length =
19420 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019421 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019422 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19423 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019424 status = palSendMBMessage(pMac->hHdd, pMsg);
19425 if (!HAL_STATUS_SUCCESS(status))
19426 {
19427 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19428 //pMsg is freed by palSendMBMessage
19429 }
19430 }
19431 else
19432 {
19433 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19434 status = eHAL_STATUS_FAILURE;
19435 }
19436 return status;
19437}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019438/* Returns whether a session is in VOS_STA_MODE...or not */
19439tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19440{
19441 tCsrRoamSession *pSession = NULL;
19442 pSession = CSR_GET_SESSION ( pMac, sessionId );
19443 if(!pSession)
19444 {
19445 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19446 return eANI_BOOLEAN_FALSE;
19447 }
19448 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19449 {
19450 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19451 return eANI_BOOLEAN_FALSE;
19452 }
19453 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19454 {
19455 return eANI_BOOLEAN_FALSE;
19456 }
19457 /* There is a possibility that the above check may fail,because
19458 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19459 * when it is connected.So,we may sneak through the above check even
19460 * if we are not a STA mode INFRA station. So, if we sneak through
19461 * the above condition, we can use the following check if we are
19462 * really in STA Mode.*/
19463
19464 if ( NULL != pSession->pCurRoamProfile )
19465 {
19466 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19467 {
19468 return eANI_BOOLEAN_TRUE;
19469 } else {
19470 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19471 return eANI_BOOLEAN_FALSE;
19472 }
19473 }
19474
19475 return eANI_BOOLEAN_FALSE;
19476}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019477
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019478/**
19479 * csr_set_src_handoff_request() - Set handoff source to
19480 * SME handoff request
19481 * @pHandoffInfo: Pointer to Handoff info
19482 * @pMsg: Pointer to SME handoff request message
19483 *
19484 * Return: None
19485 */
19486#ifndef QCA_WIFI_ISOC
19487static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19488 tCsrHandoffRequest *pHandoffInfo)
19489{
19490 pMsg->handoff_src = pHandoffInfo->src;
19491}
19492#else
19493static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19494 tCsrHandoffRequest *pHandoffInfo)
19495{
19496}
19497#endif
19498
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019499#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19500eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19501 tCsrHandoffRequest *pHandoffInfo)
19502{
19503 eHalStatus status = eHAL_STATUS_SUCCESS;
19504 vos_msg_t msg;
19505
19506 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019507 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19508 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019509 {
19510 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019511 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019512 }
19513 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19514 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19515 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19516 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019517 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019518 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019519 pHandoffInfo->bssid,
19520 6);
19521 msg.type = eWNI_SME_HANDOFF_REQ;
19522 msg.bodyptr = pMsg;
19523 msg.reserved = 0;
19524 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19525 {
19526 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019527 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019528 status = eHAL_STATUS_FAILURE;
19529 }
19530 return status;
19531}
19532#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019533
Abhishek Singh00b71972016-01-07 10:51:04 +053019534#ifdef WLAN_FEATURE_RMC
19535eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19536{
19537 tSirSetRMCReq *pMsg = NULL;
19538 eHalStatus status = eHAL_STATUS_SUCCESS;
19539 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19540
19541 if (!pSession)
19542 {
19543 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19544 return eHAL_STATUS_FAILURE;
19545 }
19546
19547 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19548 if (NULL != pMsg)
19549 {
19550 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19551 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19552 pMsg->msgLen = sizeof(tSirSetRMCReq);
19553 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19554 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19555
19556 status = palSendMBMessage(pMac->hHdd, pMsg);
19557 if (!HAL_STATUS_SUCCESS(status))
19558 {
19559 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19560 //pMsg is freed by palSendMBMessage
19561 }
19562 }
19563 else
19564 {
19565 return eHAL_STATUS_FAILURE;
19566 }
19567 return status;
19568}
19569
19570eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19571{
19572 tSirSetRMCReq *pMsg = NULL;
19573 eHalStatus status = eHAL_STATUS_SUCCESS;
19574 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19575
19576 if (!pSession)
19577 {
19578 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19579 return eHAL_STATUS_FAILURE;
19580 }
19581
19582 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19583 if (NULL != pMsg)
19584 {
19585 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19586 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19587 pMsg->msgLen = sizeof(tSirSetRMCReq);
19588 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19589 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19590
19591 status = palSendMBMessage(pMac->hHdd, pMsg);
19592 if (!HAL_STATUS_SUCCESS(status))
19593 {
19594 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19595 //pMsg is freed by palSendMBMessage
19596 }
19597 }
19598 else
19599 {
19600 return eHAL_STATUS_FAILURE;
19601 }
19602 return status;
19603}
19604
19605#endif /* WLAN_FEATURE_RMC */
19606
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019607
19608#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019609/* ---------------------------------------------------------------------------
19610 \fn csrSetCCKMIe
19611 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19612 data structure and this IE will be packed inside reassociation request
19613 \param pMac - pMac global structure
19614 \param sessionId - Current session id
19615 \param pCckmIe - pointer to CCKM IE data
19616 \param ccKmIeLen - length of the CCKM IE
19617 \- return Success or failure
19618 -------------------------------------------------------------------------*/
19619VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19620 const tANI_U8 *pCckmIe,
19621 const tANI_U8 ccKmIeLen)
19622{
19623 eHalStatus status = eHAL_STATUS_SUCCESS;
19624 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19625
19626 if (!pSession)
19627 {
19628 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19629 return eHAL_STATUS_FAILURE;
19630 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019631 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019632 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19633 return status;
19634}
19635
19636/* ---------------------------------------------------------------------------
19637 \fn csrRoamReadTSF
19638 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19639 probe response reception from the hand off AP to arrive at the latest TSF value.
19640 \param pMac - pMac global structure
19641 \param pTimestamp - output TSF timestamp
19642 \- return Success or failure
19643 -------------------------------------------------------------------------*/
19644VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19645{
19646 eHalStatus status = eHAL_STATUS_SUCCESS;
19647 tCsrNeighborRoamBSSInfo handoffNode;
19648 tANI_U32 timer_diff = 0;
19649 tANI_U32 timeStamp[2];
19650 tpSirBssDescription pBssDescription = NULL;
19651
19652 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19653 pBssDescription = handoffNode.pBssDescription;
19654
19655 // Get the time diff in milli seconds
19656 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19657 // Convert msec to micro sec timer
19658 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19659
19660 timeStamp[0] = pBssDescription->timeStamp[0];
19661 timeStamp[1] = pBssDescription->timeStamp[1];
19662
19663 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19664
Kiet Lamf2f201e2013-11-16 21:24:16 +053019665 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019666 sizeof (tANI_U32) * 2);
19667 return status;
19668}
19669
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019670#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019671
Agarwal Ashish738843c2014-09-25 12:27:56 +053019672/* ---------------------------------------------------------------------------
19673 \fn csrDisableDfsChannel
19674 \brief This function will call csrApplyChannelPowerCountryInfo to
19675 \ to trim the list on basis of NO_DFS flag.
19676 \param pMac - pMac global structure
19677 \- return void
19678 -------------------------------------------------------------------------*/
19679void csrDisableDfsChannel(tpAniSirGlobal pMac)
19680{
19681 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19682 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19683}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019684
19685/* ---------------------------------------------------------------------------
19686 \fn csrGetStaticUapsdMask
19687 \brief This function will get the static uapsd settings for an existing
19688 \ Infra session.
19689 \param pMac - pMac global structure
19690 \- return void
19691 -------------------------------------------------------------------------*/
19692void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19693{
19694 tANI_S8 sessionId;
19695 tCsrRoamSession *pSession = NULL;
19696
19697 *staticUapsdMask = 0;
19698 sessionId = csrGetInfraSessionId(pMac);
19699 if(sessionId == -1)
19700 smsLog(pMac, LOGE, FL("Valid session not present."));
19701 else
19702 pSession = CSR_GET_SESSION(pMac, sessionId);
19703
19704 if(!pSession || !pSession->pCurRoamProfile)
19705 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019706 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019707 else
19708 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19709}
19710
Abhishek Singh02605092017-10-25 14:06:12 +053019711VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19712 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19713{
19714 VOS_STATUS status = VOS_STATUS_SUCCESS;
19715 struct sir_ecsa_ie_req *msg;
19716
19717 msg = vos_mem_malloc(sizeof(*msg));
19718 if (!msg) {
19719 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19720 return VOS_STATUS_E_NOMEM;
19721 }
19722
19723 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19724 msg->len = sizeof(*msg);
19725
19726 msg->new_chan = new_chan;
19727 msg->cb_mode = cb_mode;
19728 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19729
19730 status = palSendMBMessage(mac_ctx->hHdd, msg);
19731 if (!VOS_IS_STATUS_SUCCESS(status))
19732 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019733 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019734 return status;
19735}
19736
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019737VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19738 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19739{
19740 VOS_STATUS status = VOS_STATUS_SUCCESS;
19741 struct sir_channel_chanege_req *msg;
19742 tCsrRoamStartBssParams param;
19743
19744 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19745
19746 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19747
19748 msg = vos_mem_malloc(sizeof(*msg));
19749 if (!msg) {
19750 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19751 return VOS_STATUS_E_NOMEM;
19752 }
19753
19754 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19755 msg->len = sizeof(*msg);
19756
19757 msg->new_chan = new_chan;
19758 msg->cb_mode = cb_mode;
19759 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19760 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19761 mac_ctx->roam.configParam.uCfgDot11Mode);
19762 if (IS_24G_CH(msg->new_chan) &&
19763 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19764 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19765 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19766 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19767
19768 vos_mem_copy(&msg->operational_rateset,
19769 &param.operationalRateSet, sizeof(msg->operational_rateset));
19770 vos_mem_copy(&msg->extended_rateset,
19771 &param.extendedRateSet, sizeof(msg->extended_rateset));
19772
19773 status = palSendMBMessage(mac_ctx->hHdd, msg);
19774 if (!VOS_IS_STATUS_SUCCESS(status))
19775 smsLog(mac_ctx, LOGE,
19776 FL(" channel switch req fauiled status %d "), status);
19777 return status;
19778}