blob: a9d9b63e02205716ec92dfa57cf8284362b29523 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053061#include "sme_Trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "logDump.h"
63#include "smeQosInternal.h"
64#include "wlan_qct_tl.h"
65#include "smeInside.h"
66#include "vos_diag_core_event.h"
67#include "vos_diag_core_log.h"
68#include "csrApi.h"
69#include "pmc.h"
70#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053071#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070072#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
73#include "csrNeighborRoam.h"
74#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080075#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
76#include "csrEse.h"
77#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053078#include "vos_utils.h"
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053079#ifdef WLAN_FEATURE_LFR_MBB
80#include "csr_roam_mbb.h"
81#endif
82
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084#define CSR_NUM_IBSS_START_CHANNELS_50 4
85#define CSR_NUM_IBSS_START_CHANNELS_24 3
86#define CSR_DEF_IBSS_START_CHANNEL_50 36
87#define CSR_DEF_IBSS_START_CHANNEL_24 1
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053088
Jeff Johnson295189b2012-06-20 16:38:30 -070089/*---------------------------------------------------------------------------
90 OBIWAN recommends [8 10]% : pick 9%
91---------------------------------------------------------------------------*/
92#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070093/*---------------------------------------------------------------------------
94 OBIWAN recommends -85dBm
95---------------------------------------------------------------------------*/
96#define CSR_VCC_RSSI_THRESHOLD 80
97#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
98#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
99#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
100#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700101//We use constatnt 4 here
102//This macro returns true when higher AC parameter is bigger than lower AC for a difference
103//The bigger the number, the less chance of TX
104//It must put lower AC as the first parameter.
105#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//Flag to send/do not send disassoc frame over the air
107#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700109#define MAX_CB_VALUE_IN_INI (2)
110
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700111#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
112static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
113#endif
114
Agrawal Ashishe4288772016-01-13 14:10:10 +0530115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121/*--------------------------------------------------------------------------
122 Type declarations
123 ------------------------------------------------------------------------*/
Abhinav Kumard6d8dd22019-08-05 12:38:50 +0530124
125#ifdef WLAN_FEATURE_SAE
126/**
127 * csr_sae_callback - Update SAE info to CSR roam session
128 * @mac_ctx: MAC context
129 * @msg_ptr: pointer to SAE message
130 *
131 * API to update SAE info to roam csr session
132 *
133 * Return: QDF_STATUS
134 */
135static VOS_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
136{
137 tCsrRoamInfo roam_info;
138 uint32_t session_id;
139 struct sir_sae_info *sae_info;
140
141 sae_info = (struct sir_sae_info *) msg_ptr;
142 if (!sae_info) {
143 smsLog(mac_ctx, LOGE, "SAE info is NULL");
144 return VOS_STATUS_E_FAILURE;
145 }
146
147 smsLog(mac_ctx, LOG1, FL("vdev_id %d "MAC_ADDRESS_STR""),
148 sae_info->vdev_id,
149 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
150
151 session_id = sae_info->vdev_id;
152 if (session_id == CSR_SESSION_ID_INVALID)
153 return VOS_STATUS_E_FAILURE;
154
155 roam_info.sae_info = sae_info;
156 csrRoamCallCallback(mac_ctx, session_id, &roam_info, 0,
157 eCSR_ROAM_SAE_COMPUTE, eCSR_ROAM_RESULT_NONE);
158
159 return VOS_STATUS_SUCCESS;
160}
161#else
162static inline VOS_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
163 tSirSmeRsp *msg_ptr)
164{
165 return VOS_STATUS_SUCCESS;
166}
167#endif
168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700170int diagAuthTypeFromCSRType(eCsrAuthType authType)
171{
172 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 switch(authType)
174 {
175 case eCSR_AUTH_TYPE_SHARED_KEY:
176 n = AUTH_SHARED;
177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 case eCSR_AUTH_TYPE_WPA:
179 n = AUTH_WPA_EAP;
180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 case eCSR_AUTH_TYPE_WPA_PSK:
182 n = AUTH_WPA_PSK;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530185#ifdef WLAN_FEATURE_11W
186 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
187#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 n = AUTH_WPA2_EAP;
189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700191#ifdef WLAN_FEATURE_11W
192 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
193#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 n = AUTH_WPA2_PSK;
195 break;
196#ifdef FEATURE_WLAN_WAPI
197 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
198 n = AUTH_WAPI_CERT;
199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
201 n = AUTH_WAPI_PSK;
202 break;
203#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 default:
205 break;
206 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 return (n);
208}
Jeff Johnson295189b2012-06-20 16:38:30 -0700209int diagEncTypeFromCSRType(eCsrEncryptionType encType)
210{
211 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 switch(encType)
213 {
214 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
215 case eCSR_ENCRYPT_TYPE_WEP40:
216 n = ENC_MODE_WEP40;
217 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700218 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
219 case eCSR_ENCRYPT_TYPE_WEP104:
220 n = ENC_MODE_WEP104;
221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 case eCSR_ENCRYPT_TYPE_TKIP:
223 n = ENC_MODE_TKIP;
224 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 case eCSR_ENCRYPT_TYPE_AES:
226 n = ENC_MODE_AES;
227 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700228#ifdef FEATURE_WLAN_WAPI
229 case eCSR_ENCRYPT_TYPE_WPI:
230 n = ENC_MODE_SMS4;
231 break;
232#endif /* FEATURE_WLAN_WAPI */
233 default:
234 break;
235 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 return (n);
237}
Jeff Johnson295189b2012-06-20 16:38:30 -0700238#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700239static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
240static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static void initConfigParam(tpAniSirGlobal pMac);
242static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
243 eCsrRoamCompleteResult Result, void *Context );
244static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
245 tCsrRoamProfile *pProfile,
246 tANI_BOOLEAN *pfSameIbss );
247static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
248static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700249 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
250static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
252static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
253eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
254eHalStatus csrRoamClose(tpAniSirGlobal pMac);
255void csrRoamMICErrorTimerHandler(void *pv);
256void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
257tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
258
259static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
260static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
261static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700262eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
263static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700264static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700265static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
267 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
268 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
269 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
270 tANI_U8 *pKeyRsc );
271static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
272 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
273 tCsrRoamProfile *pProfile );
274void csrRoamStatisticsTimerHandler(void *pv);
275void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700276VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
277 v_U8_t rssiNotification,
278 void * context);
279static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
280void csrRoamVccTrigger(tpAniSirGlobal pMac);
281eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
282/*
283 pStaEntry is no longer invalid upon the return of this function.
284*/
285static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700286static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700287static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700288tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
289 tDblLinkList *pStaList,
290 tCsrStatsClientReqInfo *pStaEntry);
291void csrRoamStatsClientTimerHandler(void *pv);
292tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
293 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
294void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
295 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700296void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700297void csrRoamTlStatsTimerHandler(void *pv);
298void csrRoamPeStatsTimerHandler(void *pv);
299tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
300void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
301tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
302eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
303static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
304static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
305static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
306static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
307 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
308//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
309static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
310void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
311#ifdef FEATURE_WLAN_BTAMP_UT_RF
312void csrRoamJoinRetryTimerHandler(void *pv);
313#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530314void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700315extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530316#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700317extern void btampEstablishLogLinkHdlr(void* pMsg);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530318#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700319static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700320void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700321
322//Initialize global variables
323static void csrRoamInitGlobals(tpAniSirGlobal pMac)
324{
325 if(pMac)
326 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800327 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
328 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330 return;
331}
332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
334{
335 if(pMac)
336 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800337 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 }
339 return;
340}
Jeff Johnson295189b2012-06-20 16:38:30 -0700341eHalStatus csrOpen(tpAniSirGlobal pMac)
342{
343 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530344#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 static uNvTables nvTables;
346 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530348#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 tANI_U32 i;
350
351 do
352 {
353 /* Initialize CSR Roam Globals */
354 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
356 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
357
358 initConfigParam(pMac);
359 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
360 break;
361 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
362 break;
363 pMac->roam.nextRoamId = 1; //Must not be 0
364 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
365 break;
366 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
367 break;
368 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
369 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530370
371#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
373 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
374 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530375 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
376 WNI_CFG_COUNTRY_CODE_LEN);
377 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 }
379 else
380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800381 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 //hardcoded for now
383 pMac->scan.countryCodeDefault[0] = 'U';
384 pMac->scan.countryCodeDefault[1] = 'S';
385 pMac->scan.countryCodeDefault[2] = 'I';
386 //status = eHAL_STATUS_SUCCESS;
387 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700388 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530389
390 if (!('0' == pMac->scan.countryCodeDefault[0] &&
391 '0' == pMac->scan.countryCodeDefault[1]))
392 {
393 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
394 &regId, COUNTRY_NV);
395 }
396 else
397 {
398 regId = REGDOMAIN_WORLD;
399 }
Abhishek Singha306a442013-11-07 18:39:01 +0530400 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 pMac->scan.domainIdDefault = regId;
402 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530403 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
404 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530406#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700407 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530408
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 return (status);
410}
411
Mihir Shetee1093ba2014-01-21 20:13:32 +0530412/* --------------------------------------------------------------------------
413 \fn csrInitChannels
414 \brief This function must be called to initialize CSR channel lists
415 \return eHalStatus
416 ----------------------------------------------------------------------------*/
417eHalStatus csrInitChannels(tpAniSirGlobal pMac)
418{
419 eHalStatus status = eHAL_STATUS_SUCCESS;
420 static uNvTables nvTables;
421 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530422 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530423
424 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
425 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
426 {
427 vos_mem_copy(pMac->scan.countryCodeDefault,
428 nvTables.defaultCountryTable.countryCode,
429 WNI_CFG_COUNTRY_CODE_LEN);
430 }
431 else
432 {
433 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
434 //hardcoded for now
435 pMac->scan.countryCodeDefault[0] = 'U';
436 pMac->scan.countryCodeDefault[1] = 'S';
437 pMac->scan.countryCodeDefault[2] = 'I';
438 }
439 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
440
Mihir Shetee1093ba2014-01-21 20:13:32 +0530441 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
442 pMac->scan.domainIdDefault = regId;
443 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
444 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
445 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530446 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
447 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530448 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
449 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530450 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530451 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530452
453 return status;
454}
455
Mihir Shete04206452014-11-20 17:50:58 +0530456#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530457eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530458{
459 eHalStatus status = eHAL_STATUS_SUCCESS;
460 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530461 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530462
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530463 /* In case of driver load ; driver need to get channel
464 * list with default Countrycode.
465 * In case of SSR; driver need to get channel list
466 * with old country code. 0 is for init and
467 * 1 is for reinit
468 */
469 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530470 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530471 case INIT:
472 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
473 WNI_CFG_COUNTRY_CODE_LEN);
474 if (!('0' == cc[0] &&
475 '0' == cc[1]))
476 {
477 csrGetRegulatoryDomainForCountry(pMac, cc,
478 &regId, COUNTRY_NV);
479 }
480 else
481 {
482 return status;
483 }
484 pMac->scan.domainIdDefault = regId;
485 break;
486 case REINIT:
487 vos_getCurrentCountryCode(&cc[0]);
488 status = csrGetRegulatoryDomainForCountry(pMac,
489 cc, &regId, COUNTRY_QUERY);
490 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530491 }
492 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530493 pMac->scan.domainIdCurrent = regId;
494 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530495 WNI_CFG_COUNTRY_CODE_LEN);
496 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530497
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530498 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
499 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
500 pMac->scan.countryCodeCurrent[1]);
501
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530502 /* reset info based on new cc, and we are done */
503 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
504 csrScanFilterResults(pMac);
505
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530506 return status;
507}
Mihir Shete04206452014-11-20 17:50:58 +0530508#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530509
Jeff Johnson295189b2012-06-20 16:38:30 -0700510eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
511{
512 eHalStatus status = eHAL_STATUS_SUCCESS;
513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
514 v_REGDOMAIN_t regId;
515 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 if(NULL == apCntryCode)
517 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530518 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 return eHAL_STATUS_FAILURE;
520 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530521 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 /* To get correct Regulatory domain from NV table
523 * 2 character Country code should be used
524 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700525 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
526/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700528
529 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800531 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700532 return eHAL_STATUS_FAILURE;
533 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700534*/
Kiet Lam6c583332013-10-14 05:37:09 +0530535 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
536 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 if (status != eHAL_STATUS_SUCCESS)
538 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700539 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 return status;
541 }
Abhishek Singha306a442013-11-07 18:39:01 +0530542 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 if (status != eHAL_STATUS_SUCCESS)
544 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700545 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 return status;
547 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 pMac->scan.domainIdDefault = regId;
549 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530551 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
552
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530554 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
555
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 /* If 2 bytes country code, 3rd byte must be filled with space */
557 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
558 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530559 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530561 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
562 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 return status;
565}
Jeff Johnson295189b2012-06-20 16:38:30 -0700566eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
567{
568 eHalStatus status = eHAL_STATUS_SUCCESS;
569 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
570 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530571 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
572 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
574 {
575 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
576 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
577 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
578 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
579 }
580 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
581
582 return status;
583}
Jeff Johnson295189b2012-06-20 16:38:30 -0700584eHalStatus csrClose(tpAniSirGlobal pMac)
585{
586 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800587
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 csrRoamClose(pMac);
589 csrScanClose(pMac);
590 csrLLClose(&pMac->roam.statsClientReqList);
591 csrLLClose(&pMac->roam.peStatsReqList);
592 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 /* DeInit Globals */
594 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 return (status);
596}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530597
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800598eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530599{
600 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800601 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530602 tANI_U32 numChan = 0;
603 tANI_U32 bufLen ;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530604 tANI_U8 i, j;
605 tANI_U8 num_channel = 0;
606 tANI_U8 channel_state;
607 tANI_U8 cfgnumChannels = 0;
608 tANI_U8 *cfgChannelList = NULL;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530609 eHalStatus status;
610 tSmeCmd *command;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530611
Atul Mittalb849d5a2014-07-29 12:08:39 +0530612 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530613 numChan = sizeof(pMac->roam.validChannelList);
614
615 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
616 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
617 {
618 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
619 return eHAL_STATUS_FAILED_ALLOC;
620 }
621
622 bufLen = sizeof(tSirUpdateChanList) +
623 (sizeof(tSirUpdateChanParam) * (numChan - 1));
624
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530625 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
626 if (!pChanList)
627 {
628 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
629 "Failed to allocate memory for tSirUpdateChanList");
630 return eHAL_STATUS_FAILED_ALLOC;
631 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530632 vos_mem_zero(pChanList, bufLen);
633
634 smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"),
635 pMac->scan.fEnableDFSChnlScan);
636
637 for (i = 0; i < numChan; i++)
638 {
639 channel_state =
640 vos_nv_getChannelEnabledState(pMac->roam.validChannelList[i]);
641
642 if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
643 && (channel_state == NV_CHANNEL_DFS))
644 {
645 continue;
646 }
647 pChanList->chanParam[num_channel].chanId =
648 pMac->roam.validChannelList[i];
649 pChanList->chanParam[num_channel].pwr =
650 cfgGetRegulatoryMaxTransmitPower(pMac,
651 pScan->defaultPowerTable[i].chanId);
Agrawal Ashishe4288772016-01-13 14:10:10 +0530652
Sushant Kaushikece4b562015-04-09 18:27:33 +0530653 if (!pChanList->chanParam[num_channel].pwr)
654 {
655 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
656 "setting to default %d"),
657 pChanList->chanParam[num_channel].chanId,
658 TX_POWER_DEFAULT);
659 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
660 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530661 if (channel_state == NV_CHANNEL_DFS)
662 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
663 else
664 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
665
666 /* When DFS mode is 2, mark static channels as active */
667 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
668 {
669 cfgnumChannels =
670 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
671 cfgChannelList =
672 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
673
674 if (cfgChannelList)
675 {
676 for(j=0; j< cfgnumChannels; j++)
677 {
678 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
679 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
680 {
681 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
682 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
683 "%s Marked DFS ch %d as active\n", __func__,
684 cfgChannelList[j]);
685 }
686 }
687 }
688 else
689 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
690 "%s cfgChannelList is NULL \n", __func__);
691 }
692
693 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
694 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
695 pChanList->chanParam[num_channel].chanId,
696 pChanList->chanParam[num_channel].dfsSet,
697 pChanList->chanParam[num_channel].pwr);
698 num_channel++;
699 }
700 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530701
Sachin Ahuja2d15ff62015-06-30 12:46:44 +0530702 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
703 "%s : regID : %d \n", __func__,
704 pChanList->regId);
705
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530706 pChanList->numChan = num_channel;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530707
708 status = sme_AcquireGlobalLock(&pMac->sme);
709 if (HAL_STATUS_SUCCESS(status)) {
710 command = csrGetCommandBuffer(pMac);
711 if (command) {
712 command->command = eSmeCommandUpdateChannelList;
713 command->u.chan_list = pChanList;
714
715 status = csrQueueSmeCommand(pMac, command, eANI_BOOLEAN_TRUE);
716 if (!HAL_STATUS_SUCCESS(status)) {
717 smsLog(pMac, LOGE, FL("fail to send msg status = %d"), status);
718 csrReleaseCommand(pMac, command);
719 }
720 } else {
721 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
722 status = eHAL_STATUS_RESOURCES;
723 }
724 sme_ReleaseGlobalLock(&pMac->sme);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530725 }
726
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530727 return status;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530728}
729
Jeff Johnson295189b2012-06-20 16:38:30 -0700730eHalStatus csrStart(tpAniSirGlobal pMac)
731{
732 eHalStatus status = eHAL_STATUS_SUCCESS;
733 tANI_U32 i;
734
735 do
736 {
737 //save the global vos context
738 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
739 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
740 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
741
742 status = csrRoamStart(pMac);
743 if(!HAL_STATUS_SUCCESS(status)) break;
744 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
745 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
746 if(!HAL_STATUS_SUCCESS(status)) break;
747 pMac->roam.sPendingCommands = 0;
748 csrScanEnable(pMac);
749#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
750 status = csrNeighborRoamInit(pMac);
751#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
752 pMac->roam.tlStatsReqInfo.numClient = 0;
753 pMac->roam.tlStatsReqInfo.periodicity = 0;
754 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
755 //init the link quality indication also
756 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
757 if(!HAL_STATUS_SUCCESS(status))
758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800759 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 break;
761 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530762
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764#if defined(ANI_LOGDUMP)
765 csrDumpInit(pMac);
766#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return (status);
768}
769
Kiet Lama72a2322013-11-15 11:18:11 +0530770eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700771{
772 tANI_U32 sessionId;
773 tANI_U32 i;
774
775 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
776 {
mukul sharmabab477d2015-06-11 17:14:55 +0530777 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 csrScanDisable(pMac);
780 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
781 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
783
784#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
785 csrNeighborRoamClose(pMac);
786#endif
787 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 // deregister from PMC since we register during csrStart()
789 // (ignore status since there is nothing we can do if it fails)
790 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 //Reset the domain back to the deault
792 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700793
794 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
795 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530796 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530797 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE, i);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 }
799
Kiet Lama72a2322013-11-15 11:18:11 +0530800#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
801 /* When HAL resets all the context information
802 * in HAL is lost, so we might need to send the
803 * scan offload request again when it comes
804 * out of reset for scan offload to be functional
805 */
806 if (HAL_STOP_TYPE_SYS_RESET == stopType)
807 {
808 bRoamScanOffloadStarted = VOS_FALSE;
809 }
810#endif
811
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 return (eHAL_STATUS_SUCCESS);
813}
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815eHalStatus csrReady(tpAniSirGlobal pMac)
816{
817 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 csrScanGetSupportedChannels( pMac );
819 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
820 //use it to init the background scan list
821 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 //Store the AC weights in TL for later use
823 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 status = csrInitChannelList( pMac );
825 if ( ! HAL_STATUS_SUCCESS( status ) )
826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800827 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 status );
829 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 return (status);
831}
Jeff Johnson295189b2012-06-20 16:38:30 -0700832void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
833{
834 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
836 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
837}
Jeff Johnson295189b2012-06-20 16:38:30 -0700838void csrSetGlobalCfgs( tpAniSirGlobal pMac )
839{
Jeff Johnsone7245742012-09-05 17:12:55 -0700840
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
842 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
843 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
844 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
845 NULL, eANI_BOOLEAN_FALSE);
846 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700847 /* 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
848 * Once session is established we will use the session related params stored in PE session for CB mode
849 */
850 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
852
853 //Update the operating mode to configured value during initialization,
854 //So that client can advertise full capabilities in Probe request frame.
855 csrSetDefaultDot11Mode( pMac );
856}
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
859{
860 eHalStatus status = eHAL_STATUS_SUCCESS;
861 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +0530862 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 do
864 {
865 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
866 {
867 pSession = CSR_GET_SESSION( pMac, i );
868 pSession->roamingTimerInfo.pMac = pMac;
869 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
870 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
872 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530873 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
874 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530876 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800878 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 break;
880 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530881 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
882 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
883 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800885 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 return eHAL_STATUS_FAILURE;
887 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530888 vos_spin_lock_init(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 return (status);
891}
892
Jeff Johnson295189b2012-06-20 16:38:30 -0700893eHalStatus csrRoamClose(tpAniSirGlobal pMac)
894{
895 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
897 {
mukul sharmabab477d2015-06-11 17:14:55 +0530898 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530900 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
901 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
902 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
903 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530904 vos_spin_lock_destroy(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 return (eHAL_STATUS_SUCCESS);
906}
907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908eHalStatus csrRoamStart(tpAniSirGlobal pMac)
909{
910 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 return (eHAL_STATUS_SUCCESS);
912}
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
915{
916 csrRoamStopRoamingTimer(pMac, sessionId);
917 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
918 csrRoamDeregStatisticsReq(pMac);
919}
Jeff Johnson295189b2012-06-20 16:38:30 -0700920eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
921{
922 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800923 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 {
925 status = eHAL_STATUS_SUCCESS;
926 *pState = pMac->roam.roamSession[sessionId].connectState;
927 }
928 return (status);
929}
930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
932{
933 eHalStatus status = eHAL_STATUS_FAILURE;
934 tANI_U32 size = 0;
935 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700936
937 if(!pSession)
938 {
939 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
940 return eHAL_STATUS_FAILURE;
941 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700942
943 if(pProfile)
944 {
945 if(pSession->pConnectBssDesc)
946 {
947 do
948 {
949 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
950 if(size)
951 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530952 pProfile->pBssDesc = vos_mem_malloc(size);
953 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530955 vos_mem_copy(pProfile->pBssDesc,
956 pSession->pConnectBssDesc, size);
957 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 }
959 else
960 break;
961 }
962 else
963 {
964 pProfile->pBssDesc = NULL;
965 }
966 pProfile->AuthType = pSession->connectedProfile.AuthType;
967 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
968 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
969 pProfile->BSSType = pSession->connectedProfile.BSSType;
970 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
971 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530972 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
973 sizeof(tCsrBssid));
974 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
975 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700976#ifdef WLAN_FEATURE_VOWIFI_11R
977 if (pSession->connectedProfile.MDID.mdiePresent)
978 {
979 pProfile->MDID.mdiePresent = 1;
980 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
981 }
982 else
983 {
984 pProfile->MDID.mdiePresent = 0;
985 pProfile->MDID.mobilityDomain = 0;
986 }
987#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800988#ifdef FEATURE_WLAN_ESE
989 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
990 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800992 vos_mem_copy (pProfile->eseCckmInfo.krk,
993 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530994 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800995 pProfile->eseCckmInfo.reassoc_req_num=
996 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
997 pProfile->eseCckmInfo.krk_plumbed =
998 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 }
1000#endif
1001 }while(0);
1002 }
1003 }
1004
1005 return (status);
1006}
1007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
1009{
1010 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -07001011
1012 if((csrIsConnStateConnected(pMac, sessionId)) ||
1013 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 {
1015 if(pProfile)
1016 {
1017 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
1018 }
1019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 return (status);
1021}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -07001022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
1024{
1025 eHalStatus status = eHAL_STATUS_SUCCESS;
1026
Kiet Lam64c1b492013-07-12 13:56:44 +05301027 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301029 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301031 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001032 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301033 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001034 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301035 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
1038 return (status);
1039}
1040
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301041eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -07001042{
1043 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if( pConnectedInfo->pbFrames )
1045 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301046 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 pConnectedInfo->pbFrames = NULL;
1048 }
1049 pConnectedInfo->nBeaconLength = 0;
1050 pConnectedInfo->nAssocReqLength = 0;
1051 pConnectedInfo->nAssocRspLength = 0;
1052 pConnectedInfo->staId = 0;
1053#ifdef WLAN_FEATURE_VOWIFI_11R
1054 pConnectedInfo->nRICRspLength = 0;
1055#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001056#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 pConnectedInfo->nTspecIeLength = 0;
1058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 return ( status );
1060}
1061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
1063
Jeff Johnsone7245742012-09-05 17:12:55 -07001064
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001065void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1066{
1067 csrReinitPreauthCmd(pMac, pCommand);
1068 csrReleaseCommand( pMac, pCommand );
1069}
1070
Jeff Johnson295189b2012-06-20 16:38:30 -07001071void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1072{
1073 csrReinitRoamCmd(pMac, pCommand);
1074 csrReleaseCommand( pMac, pCommand );
1075}
1076
Jeff Johnson295189b2012-06-20 16:38:30 -07001077void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1078{
1079 csrReinitScanCmd(pMac, pCommand);
1080 csrReleaseCommand( pMac, pCommand );
1081}
1082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1084{
1085 csrReinitWmStatusChangeCmd(pMac, pCommand);
1086 csrReleaseCommand( pMac, pCommand );
1087}
1088
Jeff Johnson295189b2012-06-20 16:38:30 -07001089void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1090{
Kiet Lam64c1b492013-07-12 13:56:44 +05301091 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001092}
1093
Jeff Johnson295189b2012-06-20 16:38:30 -07001094void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1095{
Kiet Lam64c1b492013-07-12 13:56:44 +05301096 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097}
1098
Jeff Johnson295189b2012-06-20 16:38:30 -07001099void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1100{
1101 csrReinitSetKeyCmd(pMac, pCommand);
1102 csrReleaseCommand( pMac, pCommand );
1103}
Jeff Johnson295189b2012-06-20 16:38:30 -07001104void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1105{
1106 csrReinitRemoveKeyCmd(pMac, pCommand);
1107 csrReleaseCommand( pMac, pCommand );
1108}
Abhishek Singh7b2d0812016-04-28 11:44:29 +05301109
1110/**
1111 * csr_is_disconnect_full_power_cmd() - Check if command is for
1112 * disconnect or for fullpower
1113 * @command: command to check
1114 *
1115 * Return: true if disconnect or full power command else false
1116 */
1117bool csr_is_disconnect_full_power_cmd(tSmeCmd *command)
1118{
1119 switch (command->command) {
1120 case eSmeCommandRoam:
1121 if (CSR_IS_DISCONNECT_COMMAND(command))
1122 return true;
1123 break;
1124 case eSmeCommandWmStatusChange:
1125 case eSmeCommandExitImps:
1126 case eSmeCommandExitBmps:
1127 case eSmeCommandExitUapsd:
1128 case eSmeCommandExitWowl:
1129 return true;
1130 default:
1131 return false;
1132 }
1133 return false;
1134}
1135
Jeff Johnson295189b2012-06-20 16:38:30 -07001136void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1137{
1138
1139 if( eSmeCsrCommandMask & pCommand->command )
1140 {
1141 switch (pCommand->command)
1142 {
1143 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001144 // We need to inform the requester before dropping the scan command
Jeff Johnson89477502017-09-19 08:35:23 -07001145 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %pK",
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001146 __func__, pCommand->u.scanCmd.reason,
1147 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 if (NULL != pCommand->u.scanCmd.callback)
1149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001150 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1152 }
1153 csrReleaseCommandScan( pMac, pCommand );
1154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 case eSmeCommandRoam:
1156 csrReleaseCommandRoam( pMac, pCommand );
1157 break;
1158
1159 case eSmeCommandWmStatusChange:
1160 csrReleaseCommandWmStatusChange( pMac, pCommand );
1161 break;
1162
1163 case eSmeCommandSetKey:
1164 csrReleaseCommandSetKey( pMac, pCommand );
1165 break;
1166
1167 case eSmeCommandRemoveKey:
1168 csrReleaseCommandRemoveKey( pMac, pCommand );
1169 break;
1170
1171 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001172 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 csrReleaseCommand( pMac, pCommand );
1174 break;
1175 }
1176 }
1177}
1178
Jeff Johnson295189b2012-06-20 16:38:30 -07001179void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1180{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301181 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1182 macTraceGetcsrRoamSubState(NewSubstate),
1183 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001184
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1186 {
1187 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001188 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301189 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 pMac->roam.curSubState[sessionId] = NewSubstate;
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301191 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192}
1193
Jeff Johnson295189b2012-06-20 16:38:30 -07001194eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1195{
1196 eCsrRoamState PreviousState;
1197
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301198 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1199 macTraceGetcsrRoamState(NewRoamState),
1200 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001201
1202 PreviousState = pMac->roam.curState[sessionId];
1203
1204 if ( NewRoamState != pMac->roam.curState[sessionId] )
1205 {
1206 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1207 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1208 {
1209 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1210 }
1211
1212 pMac->roam.curState[sessionId] = NewRoamState;
1213 }
1214 return( PreviousState );
1215}
1216
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001217void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001218{
1219 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 if(catOffset)
1221 {
1222 pMac->roam.configParam.bCatRssiOffset = catOffset;
1223 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1224 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001225 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 -07001226 }
1227 }
1228}
1229
Jeff Johnson295189b2012-06-20 16:38:30 -07001230static void initConfigParam(tpAniSirGlobal pMac)
1231{
1232 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301234 pMac->roam.configParam.channelBondingMode24GHz =
1235 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1236 pMac->roam.configParam.channelBondingMode5GHz =
1237 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1239 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1240 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1241 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1242 pMac->roam.configParam.HeartbeatThresh24 = 40;
1243 pMac->roam.configParam.HeartbeatThresh50 = 40;
1244 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1245 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1246 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001247 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 pMac->roam.configParam.RTSThreshold = 2346;
1249 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1250 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1251 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1252 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1253 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1254 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1255 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1256 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1257 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1258 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1259 {
1260 pMac->roam.configParam.BssPreferValue[i] = i;
1261 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001262 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1264 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1265 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1267 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301268 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1270 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1271 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1272 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301273 pMac->roam.configParam.max_chntime_btc_esco =
1274 CSR_ACTIVE_MAX_CHANNEL_TIME_ESCO_BTC;
1275 pMac->roam.configParam.min_chntime_btc_esco =
1276 CSR_ACTIVE_MIN_CHANNEL_TIME_ESCO_BTC;
1277 pMac->roam.configParam.min_chntime_btc_sco =
1278 CSR_ACTIVE_MIN_CHANNEL_TIME_SCO_BTC;
1279 pMac->roam.configParam.max_chntime_btc_sco=
1280 CSR_ACTIVE_MAX_CHANNEL_TIME_SCO_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001281 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001282#ifdef WLAN_AP_STA_CONCURRENCY
1283 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1284 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1285 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1286 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1287 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001288 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1289 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001290#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1292 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1293 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1294 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295#ifdef WLAN_FEATURE_VOWIFI_11R
1296 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001298#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1299 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1300 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1301 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1302 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1303 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1304 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1305 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1306 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1307 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1308 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1309 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001310 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301311 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05301312 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001313#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001314#ifdef WLAN_FEATURE_11AC
1315 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001317
1318 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1319 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301320 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_FALSE;
1321 pMac->roam.configParam.num_ba_buff_btc_sco = DEFAULT_NUM_BUFF_BTC_SCO;
1322 pMac->roam.configParam.num_ba_buff = WNI_CFG_NUM_BUFF_ADVERT_STADEF;
Mohit Khanna349bc392012-09-11 17:24:52 -07001323
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001324 //Remove this code once SLM_Sessionization is supported
1325 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001326 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327
Jeff Johnsone7245742012-09-05 17:12:55 -07001328}
Jeff Johnson295189b2012-06-20 16:38:30 -07001329eCsrBand csrGetCurrentBand(tHalHandle hHal)
1330{
1331 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1332 return pMac->roam.configParam.bandCapability;
1333}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001334
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001335
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001336#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001337/*
1338 This function flushes the roam scan cache
1339*/
1340eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1341{
1342 eHalStatus status = eHAL_STATUS_SUCCESS;
1343 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1344
1345 /* Free up the memory first (if required) */
1346 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1347 {
1348 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1349 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1350 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1351 }
1352 return status;
1353}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001354#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001355
1356
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001357#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001358/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001359 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001360*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001361eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001362{
1363 eHalStatus status = eHAL_STATUS_SUCCESS;
1364 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1365
1366 /* Free up the memory first (if required) */
1367 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1368 {
1369 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1370 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001371 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001372 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001373 return status;
1374}
1375
1376
1377
1378/*
1379 This function flushes the roam scan cache and creates fresh cache
1380 based on the input channel list
1381*/
1382eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1383 const tANI_U8 *pChannelList,
1384 const tANI_U8 numChannels)
1385{
1386 eHalStatus status = eHAL_STATUS_SUCCESS;
1387 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1388
Srinivas Girigowdade697412013-02-14 16:31:48 -08001389 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1390
1391 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1392 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1393
1394 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1395 {
1396 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1397 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1398 return eHAL_STATUS_RESOURCES;
1399 }
1400
1401 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301402 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1403 pChannelList,
1404 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001405 return status;
1406}
1407
1408/* This function modifies the bgscan channel list set via config ini or
1409 runtime, whenever the band changes.
1410 if the band is auto, then no operation is performed on the channel list
1411 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1412 if the band is 5G, then make sure channel list contains only 5G valid channels
1413*/
1414eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1415 eCsrBand eBand)
1416{
1417 eHalStatus status = eHAL_STATUS_SUCCESS;
1418 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1419 tANI_U8 outNumChannels = 0;
1420 tANI_U8 inNumChannels = 0;
1421 tANI_U8 *inPtr = NULL;
1422 tANI_U8 i = 0;
1423 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1424
1425 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1426
1427 {
1428 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1429 "No update required for channel list "
1430 "either cfg.ini channel list is not set up or "
1431 "auto band (Band %d)", eBand);
1432 return status;
1433 }
1434
1435 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1436 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1437 if (eCSR_BAND_24 == eBand)
1438 {
1439 for (i = 0; i < inNumChannels; i++)
1440 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001441 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001442 {
1443 ChannelList[outNumChannels++] = inPtr[i];
1444 }
1445 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001446 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001447 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001448 }
1449 else if (eCSR_BAND_5G == eBand)
1450 {
1451 for (i = 0; i < inNumChannels; i++)
1452 {
1453 /* Add 5G Non-DFS channel */
1454 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001455 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001456 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1457 {
1458 ChannelList[outNumChannels++] = inPtr[i];
1459 }
1460 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001461 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001462 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001463 }
1464 else if (eCSR_BAND_ALL == eBand)
1465 {
1466 for (i = 0; i < inNumChannels; i++)
1467 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001468 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001469 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1470 {
1471 ChannelList[outNumChannels++] = inPtr[i];
1472 }
1473 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001474 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001475 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001476 }
1477 else
1478 {
1479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1480 "Invalid band, No operation carried out (Band %d)", eBand);
1481 status = eHAL_STATUS_INVALID_PARAMETER;
1482 }
1483
1484 return status;
1485}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001486#endif
1487
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001488#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001489/* This function modifies the roam scan channel list as per AP neighbor
1490 report; AP neighbor report may be empty or may include only other AP
1491 channels; in any case, we merge the channel list with the learned occupied
1492 channels list.
1493 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1494 if the band is 5G, then make sure channel list contains only 5G valid channels
1495*/
1496eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1497 tANI_U8 *pChannelList,
1498 tANI_U8 numChannels,
1499 const eCsrBand eBand)
1500{
1501 eHalStatus status = eHAL_STATUS_SUCCESS;
1502 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1503 tANI_U8 outNumChannels = 0;
1504 tANI_U8 inNumChannels = numChannels;
1505 tANI_U8 *inPtr = pChannelList;
1506 tANI_U8 i = 0;
1507 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1508 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1509 tANI_U8 mergedOutputNumOfChannels = 0;
1510 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1511
1512 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1513 * report Channels. This increases the chances of the DUT to get a candidate AP while
1514 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1515 if (pMac->scan.occupiedChannels.numChannels)
1516 {
1517 csrNeighborRoamMergeChannelLists(pMac,
1518 &pMac->scan.occupiedChannels.channelList[0],
1519 pMac->scan.occupiedChannels.numChannels,
1520 inPtr,
1521 inNumChannels,
1522 &mergedOutputNumOfChannels);
1523 inNumChannels = mergedOutputNumOfChannels;
1524 }
1525
1526 if (eCSR_BAND_24 == eBand)
1527 {
1528 for (i = 0; i < inNumChannels; i++)
1529 {
1530 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1531 {
1532 ChannelList[outNumChannels++] = inPtr[i];
1533 }
1534 }
1535 }
1536 else if (eCSR_BAND_5G == eBand)
1537 {
1538 for (i = 0; i < inNumChannels; i++)
1539 {
1540 /* Add 5G Non-DFS channel */
1541 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1542 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1543 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1544 {
1545 ChannelList[outNumChannels++] = inPtr[i];
1546 }
1547 }
1548 }
1549 else if (eCSR_BAND_ALL == eBand)
1550 {
1551 for (i = 0; i < inNumChannels; i++)
1552 {
1553 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1554 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1555 {
1556 ChannelList[outNumChannels++] = inPtr[i];
1557 }
1558 }
1559 }
1560 else
1561 {
1562 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1563 "Invalid band, No operation carried out (Band %d)", eBand);
1564 return eHAL_STATUS_INVALID_PARAMETER;
1565 }
1566
1567 /* if roaming within band is enabled, then select only the
1568 in band channels .
1569 This is required only if the band capability is set to ALL,
1570 E.g., if band capability is only 2.4G then all the channels in the
1571 list are already filtered for 2.4G channels, hence ignore this check*/
1572
1573 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1574 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301575 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001576 pMac,
1577 ChannelList,
1578 outNumChannels,
1579 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301580 &outNumChannels,
1581 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301582 vos_mem_copy(ChannelList,
1583 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001584 }
1585
1586 /* Prepare final roam scan channel list */
1587 if(outNumChannels)
1588 {
1589 /* Clear the channel list first */
1590 if (NULL != currChannelListInfo->ChannelList)
1591 {
1592 vos_mem_free(currChannelListInfo->ChannelList);
1593 currChannelListInfo->ChannelList = NULL;
1594 currChannelListInfo->numOfChannels = 0;
1595 }
1596
1597 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1598 if (NULL == currChannelListInfo->ChannelList)
1599 {
1600 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1601 "Failed to allocate memory for roam scan channel list");
1602 currChannelListInfo->numOfChannels = 0;
1603 return VOS_STATUS_E_RESOURCES;
1604 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301605 vos_mem_copy(currChannelListInfo->ChannelList,
1606 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001607 }
1608 return status;
1609}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001610#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001611
Jeff Johnson295189b2012-06-20 16:38:30 -07001612eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1613{
1614 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1615 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1617 (eBand == eCSR_BAND_24))
1618 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001619 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001621 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001622 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 pMac->roam.configParam.uCfgDot11Mode, eBand);
1624 return eHAL_STATUS_INVALID_PARAMETER;
1625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1627 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1628 (eBand == eCSR_BAND_5G))
1629 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001630 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001632 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001633 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 pMac->roam.configParam.uCfgDot11Mode, eBand);
1635 return eHAL_STATUS_INVALID_PARAMETER;
1636 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001638 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001639 pMac->roam.configParam.eBand = eBand;
1640 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001642#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001643 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1644 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 status = csrInitGetChannels( pMac );
1647 if (eHAL_STATUS_SUCCESS == status)
1648 csrInitChannelList( hHal );
1649 return status;
1650}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001651
1652
Jeff Johnsone7245742012-09-05 17:12:55 -07001653/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1654 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1655 * Ideally we should have kept the ini value and enum value same and representing the same
1656 * cb values as in 11n standard i.e.
1657 * Set to 1 (SCA) if the secondary channel is above the primary channel
1658 * Set to 3 (SCB) if the secondary channel is below the primary channel
1659 * Set to 0 (SCN) if no secondary channel is present
1660 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1661 * 0 - secondary none
1662 * 1 - secondary LOW
1663 * 2 - secondary HIGH
1664 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1665 * The enum values are as follows:
1666 * PHY_SINGLE_CHANNEL_CENTERED = 0
1667 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1668 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1669 */
1670ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1671{
1672
1673 ePhyChanBondState phyCbState;
1674 switch (cbIniValue) {
1675 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301676 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001677 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1678 break;
1679 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301680 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001681 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1682 break;
1683 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301684 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001685 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1686 break;
1687#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301688 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1689 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001690 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301691 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001692 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1693 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301694 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1695 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1696 break;
1697 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001698 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1699 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301700 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001701 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301702 break;
1703 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001704 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1705 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301706 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001707 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301708 break;
1709#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001710 default:
1711 // If an invalid value is passed, disable CHANNEL BONDING
1712 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1713 break;
1714 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301715
Jeff Johnsone7245742012-09-05 17:12:55 -07001716 return phyCbState;
1717}
1718
1719v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1720{
1721
1722 v_U32_t cbIniValue;
1723 switch (phyCbState) {
1724 // secondary none
1725 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301726 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001727 break;
1728 // secondary LOW
1729 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301730 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001731 break;
1732 // secondary HIGH
1733 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301734 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001735 break;
1736#ifdef WLAN_FEATURE_11AC
1737 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301738 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001739 break;
1740 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301741 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001742 break;
1743 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301744 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001745 break;
1746 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301747 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001748 break;
1749 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301750 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001751 break;
1752 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301753 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001754 break;
1755 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301756 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001757 break;
1758#endif
1759 default:
1760 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301761 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001762 break;
1763 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301764
Jeff Johnsone7245742012-09-05 17:12:55 -07001765 return cbIniValue;
1766}
Jeff Johnson295189b2012-06-20 16:38:30 -07001767
1768eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1769{
1770 eHalStatus status = eHAL_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301771 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001772
1773 if(pParam)
1774 {
1775 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1776 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1777 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1778 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1779 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1780 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1781
1782 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001783 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1784
Jeff Johnsone7245742012-09-05 17:12:55 -07001785 /* channelBondingMode5GHz plays a dual role right now
1786 * 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
1787 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1788 */
1789 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001791 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001792 }
1793 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1794 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001796 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001797 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301798#ifdef WLAN_FEATURE_AP_HT40_24G
1799 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1800#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001801 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1803 pMac->roam.configParam.phyMode = pParam->phyMode;
1804 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1805 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1806 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1807 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1808 pMac->roam.configParam.TxRate = pParam->TxRate;
1809 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1810 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1811 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1812 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1813 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001814 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 //if HDD passed down non zero values then only update,
1816 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301817 if (pParam->nInitialDwellTime)
1818 {
1819 pMac->roam.configParam.nInitialDwellTime =
1820 pParam->nInitialDwellTime;
1821 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001822 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 {
1824 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301825 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1826 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001828 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 {
1830 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301831 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1832 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001834 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 {
1836 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301837 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1838 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001840 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 {
1842 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301843 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1844 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301846 if (pParam->nOBSSScanWidthTriggerInterval)
1847 {
1848 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1849 pParam->nOBSSScanWidthTriggerInterval;
1850 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1851 pParam->nOBSSScanWidthTriggerInterval);
1852 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301853 if (pParam->max_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001854 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301855 pMac->roam.configParam.max_chntime_btc_esco =
1856 pParam->max_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001857 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301858 if (pParam->min_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001859 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301860 pMac->roam.configParam.min_chntime_btc_esco =
1861 pParam->min_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001862 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301863 if (pParam->min_chntime_btc_sco)
1864 pMac->roam.configParam.min_chntime_btc_sco =
1865 pParam->min_chntime_btc_sco;
1866 if (pParam->max_chntime_btc_sco)
1867 pMac->roam.configParam.max_chntime_btc_sco =
1868 pParam->max_chntime_btc_sco;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001869#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001870 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001871 {
1872 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1873 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001874 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001875 {
1876 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1877 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001878 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001879 {
1880 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1881 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001882 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001883 {
1884 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1885 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001886 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001887 {
1888 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1889 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001890 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001891 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001892 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1893 }
1894 if (pParam->nNumP2PChanCombinedConc)
1895 {
1896 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001897 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001898#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001900 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 {
1902 //Change the unit from second to microsecond
1903 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1905 {
1906 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1907 }
1908 else
1909 {
1910 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1911 }
1912 }
1913 else
1914 {
1915 pMac->roam.configParam.impsSleepTime = 0;
1916 }
1917 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1919 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 //if HDD passed down non zero values for age params, then only update,
1921 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001922 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 {
1924 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 if(pParam->scanAgeTimeNCNPS)
1927 {
1928 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 if(pParam->scanAgeTimeNCPS)
1931 {
1932 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 if(pParam->scanAgeTimeCNPS)
1935 {
1936 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1937 }
1938 if(pParam->scanAgeTimeCPS)
1939 {
1940 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1941 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301942 if (pParam->initialScanSkipDFSCh)
1943 {
1944 pMac->roam.configParam.initialScanSkipDFSCh =
1945 pParam->initialScanSkipDFSCh;
1946 }
1947
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001948 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1950 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1951 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1952 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1953 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1955 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1957 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1958 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1959 //Assign this before calling CsrInit11dInfo
1960 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 if( csrIs11dSupported( pMac ) )
1962 {
1963 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1964 }
1965 else
1966 {
1967 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1968 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001969
1970 /* Initialize the power + channel information if 11h is enabled.
1971 If 11d is enabled this information has already been initialized */
1972 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1973 {
1974 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1975 }
1976
1977
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301978#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301979 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1980 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001981 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001982#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001983#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001985 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001986 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001987 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001988 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001989 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001990 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001991 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001992 pMac->roam.configParam.nProbes = pParam->nProbes;
1993 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001994#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001995#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301996 pMac->roam.configParam.isRoamOffloadScanEnabled =
1997 pParam->isRoamOffloadScanEnabled;
1998 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1999 pParam->bFastRoamInConIniFeatureEnabled;
2000 pMac->roam.configParam.isPERRoamEnabled =
2001 pParam->isPERRoamEnabled;
2002 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
2003 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
2004 pMac->roam.configParam.waitPeriodForNextPERScan =
2005 pParam->waitPeriodForNextPERScan;
2006 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
2007 pMac->roam.configParam.isPERRoamCCAEnabled =
2008 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302009 pMac->roam.configParam.PERRoamFullScanThreshold =
2010 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302011 pMac->roam.configParam.PERroamTriggerPercent =
2012 pParam->PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302013 pMac->roam.configParam.PERMinRssiThresholdForRoam =
2014 pParam->PERMinRssiThresholdForRoam;
2015 pMac->PERroamTimeout = pParam->waitPeriodForNextPERScan;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002016#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302017
2018#ifdef WLAN_FEATURE_LFR_MBB
2019 pMac->roam.configParam.enable_lfr_mbb = pParam->enable_lfr_mbb;
2020#endif
2021
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002022#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002023 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08002024 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002025#endif
2026
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002027#ifdef FEATURE_WLAN_ESE
2028 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002030#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302031 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
2032 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002033 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
2034 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
2035 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
2036 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
2037 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
2038 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
2039 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
2040 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302041 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05302042 smsLog( pMac, LOG1, "nWeakZoneRssiThresholdForRoam = %d", pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 {
2044 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002045 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 -07002046 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2047 {
2048 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 }
2051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
2053 pMac->scan.fValidateList = pParam->fValidateList;
2054 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2055 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302056 pMac->scan.disable_scan_during_sco = pParam->disable_scan_during_sco;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08002057 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002059 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05302060 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07002061 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2062 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2063 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2064 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2065 * single session
2066 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002067 //Remove this code once SLM_Sessionization is supported
2068 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002069 pMac->roam.configParam.doBMPSWorkaround = 0;
2070
Jeff Johnsone7245742012-09-05 17:12:55 -07002071#ifdef WLAN_FEATURE_11AC
2072 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002073 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002074 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002075 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302076 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2077 if ( pParam->enableTxBF )
2078 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2079 else
2080 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002081#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002082 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002083
2084 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002085 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302086 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302087 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302088 pMac->roam.configParam.disableP2PMacSpoofing =
2089 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302090 pMac->roam.configParam.enableFatalEvent =
2091 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002092 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2093 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302094 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302095 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302096#ifdef WLAN_FEATURE_AP_HT40_24G
2097 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2098#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302099 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302100 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2101 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302102
2103 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2104 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2105 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2106 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2107 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2108
2109 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2110 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2111 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2112 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2113
2114 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2115 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2116 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2117 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302118 pMac->sta_sap_scc_on_dfs_chan = pParam->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302119 pMac->force_scc_with_ecsa = pParam->force_scc_with_ecsa;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302120 for (i = 0; i < 3; i++) {
2121 pMac->roam.configParam.agg_btc_sco_oui[i] =
2122 pParam->agg_btc_sco_oui[i];
2123 }
2124 pMac->roam.configParam.num_ba_buff_btc_sco =
2125 pParam->num_ba_buff_btc_sco;
2126 pMac->roam.configParam.num_ba_buff = pParam->num_ba_buff;
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 }
2128
2129 return status;
2130}
2131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2133{
2134 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302135 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 if(pParam)
2137 {
2138 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2139 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2140 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2141 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2142 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2143 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002144 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302145#ifdef WLAN_FEATURE_AP_HT40_24G
2146 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2147#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002148 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2150 pParam->phyMode = pMac->roam.configParam.phyMode;
2151 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2152 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2153 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2154 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2155 pParam->TxRate = pMac->roam.configParam.TxRate;
2156 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2157 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2158 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2159 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2160 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2162 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2163 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2164 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05302165 pParam->max_chntime_btc_esco =
2166 pMac->roam.configParam.max_chntime_btc_esco;
2167 pParam->min_chntime_btc_esco =
2168 pMac->roam.configParam.min_chntime_btc_esco;
2169 pParam->min_chntime_btc_sco =
2170 pMac->roam.configParam.min_chntime_btc_sco;
2171 pParam->max_chntime_btc_sco =
2172 pMac->roam.configParam.max_chntime_btc_sco;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002173 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002174#ifdef WLAN_AP_STA_CONCURRENCY
2175 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2176 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2177 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2178 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2179 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002180 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2181 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 //Change the unit from microsecond to second
2184 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2185 pParam->eBand = pMac->roam.configParam.eBand;
2186 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2187 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2188 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2189 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2190 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2191 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2192 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2193 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2194 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2195 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2196 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2197 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2198 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2200 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2201 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2202 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2204 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2205 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2206 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302207 pParam->disable_scan_during_sco = pMac->scan.disable_scan_during_sco;
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002209 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002210 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002211 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002212 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302213 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002214#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302215 vos_mem_copy(&pParam->neighborRoamConfig,
2216 &pMac->roam.configParam.neighborRoamConfig,
2217 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002218#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002219#ifdef WLAN_FEATURE_11AC
2220 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002221 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002222 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002223 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302224 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2225 if ( pParam->enableTxBF )
2226 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2227 else
2228 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002229#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002230#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302231 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2232 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002233#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002234#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002235 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2236 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2237 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2238 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2239 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002240 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002241 pParam->nProbes = pMac->roam.configParam.nProbes;
2242 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002243#endif
2244#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2245 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2246 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302247 pParam->isPERRoamEnabled =
2248 pMac->roam.configParam.isPERRoamEnabled;
2249 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2250 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2251 pParam->waitPeriodForNextPERScan =
2252 pMac->roam.configParam.waitPeriodForNextPERScan;
2253 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2254 pParam->isPERRoamCCAEnabled =
2255 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302256 pParam->PERRoamFullScanThreshold =
2257 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302258 pParam->PERroamTriggerPercent =
2259 pMac->roam.configParam.PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302260 pParam->PERMinRssiThresholdForRoam =
2261 pMac->roam.configParam.PERMinRssiThresholdForRoam;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002262#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302263
2264#ifdef WLAN_FEATURE_LFR_MBB
2265 pParam->enable_lfr_mbb = pMac->roam.configParam.enable_lfr_mbb;
2266#endif
2267
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002268#ifdef FEATURE_WLAN_LFR
2269 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2270#endif
2271
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002272#ifdef FEATURE_WLAN_ESE
2273 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002274#endif
2275#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302276 vos_mem_copy(&pParam->neighborRoamConfig,
2277 &pMac->roam.configParam.neighborRoamConfig,
2278 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002279 {
2280 int i;
2281 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2282 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2283 {
2284 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2285 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002286 }
2287#endif
2288
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002289 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002290
krunal soni5afa96c2013-09-06 22:19:02 -07002291 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002292 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302293 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302294 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302295 pParam->disableP2PMacSpoofing =
2296 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302297 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002298
krunal sonie9002db2013-11-25 14:24:17 -08002299 pParam->isCoalesingInIBSSAllowed =
2300 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302301 pParam->allowDFSChannelRoam =
2302 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302303 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302305#ifdef WLAN_FEATURE_AP_HT40_24G
2306 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2307#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302308 pParam->max_chan_for_dwell_time_cfg =
2309 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
Abhishek Singh48cd3402016-03-30 15:20:19 +05302311 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2312 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2313 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2314 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2315 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2316
2317 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2318 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2319 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2320 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2321
2322 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2323 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2324 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2325 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302326 pParam->sta_sap_scc_on_dfs_chan = pMac->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302327 pParam->force_scc_with_ecsa = pMac->force_scc_with_ecsa;
2328
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302329 for (i = 0; i < 3; i++) {
2330 pParam->agg_btc_sco_oui[i] =
2331 pMac->roam.configParam.agg_btc_sco_oui[i];
2332 }
2333 pParam->num_ba_buff_btc_sco =
2334 pMac->roam.configParam.num_ba_buff_btc_sco;
2335 pParam->num_ba_buff = pMac->roam.configParam.num_ba_buff;
2336
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 status = eHAL_STATUS_SUCCESS;
2338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 return (status);
2340}
2341
Jeff Johnson295189b2012-06-20 16:38:30 -07002342eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2343{
2344 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2345 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2346 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2347 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 do
2349 {
2350 if(eCSR_BAND_24 == eBand)
2351 {
2352 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2353 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2354 }
2355 if(eCSR_BAND_5G == eBand)
2356 {
2357 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2358 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2359 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2360 )
2361 {
2362 break;
2363 }
2364 }
2365 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2366 {
2367 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2368 }
2369 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2370 {
2371 newPhyMode = eCSR_DOT11_MODE_AUTO;
2372 }
2373 else
2374 {
2375 //Check for dual band and higher capability first
2376 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2377 {
2378 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2379 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2380 }
2381 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2382 {
2383 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2384 if(eCSR_BAND_24 == eBand) break;
2385 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2386 eBand = eCSR_BAND_5G;
2387 }
2388 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2389 {
2390 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2391 if(eCSR_BAND_5G == eBand) break;
2392 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2393 eBand = eCSR_BAND_24;
2394 }
2395 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2396 {
2397 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2398 if(eCSR_BAND_5G == eBand) break;
2399 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2400 eBand = eCSR_BAND_24;
2401 }
2402 else if(eCSR_DOT11_MODE_11n & phyMode)
2403 {
2404 newPhyMode = eCSR_DOT11_MODE_11n;
2405 }
2406 else if(eCSR_DOT11_MODE_abg & phyMode)
2407 {
2408 newPhyMode = eCSR_DOT11_MODE_abg;
2409 }
2410 else if(eCSR_DOT11_MODE_11a & phyMode)
2411 {
2412 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2413 {
2414 if(eCSR_BAND_ALL == eBand)
2415 {
2416 newPhyMode = eCSR_DOT11_MODE_abg;
2417 }
2418 else
2419 {
2420 //bad setting
2421 break;
2422 }
2423 }
2424 else
2425 {
2426 newPhyMode = eCSR_DOT11_MODE_11a;
2427 eBand = eCSR_BAND_5G;
2428 }
2429 }
2430 else if(eCSR_DOT11_MODE_11g & phyMode)
2431 {
2432 newPhyMode = eCSR_DOT11_MODE_11g;
2433 eBand = eCSR_BAND_24;
2434 }
2435 else if(eCSR_DOT11_MODE_11b & phyMode)
2436 {
2437 newPhyMode = eCSR_DOT11_MODE_11b;
2438 eBand = eCSR_BAND_24;
2439 }
2440 else
2441 {
2442 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002443 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 newPhyMode = eCSR_DOT11_MODE_AUTO;
2445 }
2446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 //Done validating
2448 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 //Now we need to check whether a restart is needed.
2450 if(eBand != pMac->roam.configParam.eBand)
2451 {
2452 fRestartNeeded = eANI_BOOLEAN_TRUE;
2453 break;
2454 }
2455 if(newPhyMode != pMac->roam.configParam.phyMode)
2456 {
2457 fRestartNeeded = eANI_BOOLEAN_TRUE;
2458 break;
2459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 if(HAL_STATUS_SUCCESS(status))
2462 {
2463 pMac->roam.configParam.eBand = eBand;
2464 pMac->roam.configParam.phyMode = newPhyMode;
2465 if(pfRestartNeeded)
2466 {
2467 *pfRestartNeeded = fRestartNeeded;
2468 }
2469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 return (status);
2471}
2472
Jeff Johnson295189b2012-06-20 16:38:30 -07002473void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2474{
2475 tANI_U8 Index;
2476 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 // for dual band NICs, don't need to trim the channel list....
2478 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2479 {
2480 // 2.4 GHz band operation requires the channel list to be trimmed to
2481 // the 2.4 GHz channels only...
2482 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2483 {
2484 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2485 Index++ )
2486 {
2487 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2488 {
2489 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2490 cChannels++;
2491 }
2492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2494 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2495 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2496 // only if we need to.
2497 //
2498 // The amount of memory to clear is the number of channesl that we trimmed
2499 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2500
2501 if ( pChannelList->numChannels > cChannels )
2502 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302503 vos_mem_set(&pChannelList->channelList[ cChannels ],
2504 sizeof( pChannelList->channelList[ 0 ] ) *
2505 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 }
2507
2508 pChannelList->numChannels = cChannels;
2509 }
2510 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2511 {
2512 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2513 {
2514 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2515 {
2516 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2517 cChannels++;
2518 }
2519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2521 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2522 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2523 // only if we need to.
2524 //
2525 // The amount of memory to clear is the number of channesl that we trimmed
2526 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2527 if ( pChannelList->numChannels > cChannels )
2528 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302529 vos_mem_set(&pChannelList->channelList[ cChannels ],
2530 sizeof( pChannelList->channelList[ 0 ] ) *
2531 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 }
2533
2534 pChannelList->numChannels = cChannels;
2535 }
2536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537}
Jeff Johnson295189b2012-06-20 16:38:30 -07002538#define INFRA_AP_DEFAULT_CHANNEL 6
2539eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2540{
2541 tANI_U8 index= 0;
2542 eHalStatus status = eHAL_STATUS_FAILURE;
2543 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2544 {
2545 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2546 status = eHAL_STATUS_SUCCESS;
2547 break;
2548 }
2549 }
2550 return status;
2551}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002552
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002553
Jeff Johnson295189b2012-06-20 16:38:30 -07002554eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2555{
2556 eHalStatus status = eHAL_STATUS_SUCCESS;
2557 tANI_U8 num20MHzChannelsFound = 0;
2558 VOS_STATUS vosStatus;
2559 tANI_U8 Index = 0;
2560 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562
2563 //TODO: this interface changed to include the 40MHz channel list
2564 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2565 // Read the scan channel list (including the power limit) from EEPROM
2566 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2567 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2568 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002570 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 status = eHAL_STATUS_FAILURE;
2572 }
2573 else
2574 {
2575 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2576 {
2577 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2578 }
2579 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2580 // Move the channel list to the global data
2581 // structure -- this will be used as the scan list
2582 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2583 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 }
2586 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2587 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2588 {
2589 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2590 }
2591 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2592 {
2593 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2594 }
2595 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 return (status);
2598}
Jeff Johnson295189b2012-06-20 16:38:30 -07002599eHalStatus csrInitChannelList( tHalHandle hHal )
2600{
2601 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2602 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2604 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002605 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2606 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002608 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302609 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 return (status);
2611}
Jeff Johnson295189b2012-06-20 16:38:30 -07002612eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2613 tCsrUpdateConfigParam *pUpdateConfigParam)
2614{
2615 eHalStatus status = eHAL_STATUS_FAILURE;
2616 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2618 status = CsrInit11dInfo(pMac, ps11dinfo);
2619 return status;
2620}
2621
Jeff Johnson295189b2012-06-20 16:38:30 -07002622static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2623{
2624 eHalStatus status = eHAL_STATUS_FAILURE;
2625 tANI_U8 index;
2626 tANI_U32 count=0;
2627 tSirMacChanInfo *pChanInfo;
2628 tSirMacChanInfo *pChanInfoStart;
2629 tANI_BOOLEAN applyConfig = TRUE;
2630
Mihir Shetebc866f62014-02-13 16:08:53 +05302631 pMac->scan.currentCountryRSSI = -128;
2632
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 if(!ps11dinfo)
2634 {
2635 return (status);
2636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2638 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302639 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2640 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2641 ps11dinfo->Channels.channelList,
2642 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 }
2644 else
2645 {
2646 //No change
2647 return (eHAL_STATUS_SUCCESS);
2648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302650
2651 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2652 WNI_CFG_COUNTRY_CODE_LEN);
2653
2654
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 //Tush: at csropen get this initialized with default, during csr reset if this
2656 // already set with some value no need initilaize with default again
2657 if(0 == pMac->scan.countryCodeCurrent[0])
2658 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302659 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2660 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302663 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2664 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302666 vos_mem_set(pChanInfo,
2667 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2668 0);
2669
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002671 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2672 {
2673 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2674 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2675 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2676 pChanInfo++;
2677 count++;
2678 }
2679 if(count)
2680 {
2681 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2682 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302683 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002684 }
2685 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2686 if( HAL_STATUS_SUCCESS(status) )
2687 {
2688 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2689 {
2690 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2691 {
2692 applyConfig = FALSE;
2693 }
2694 }
2695
2696 if(TRUE == applyConfig)
2697 {
2698 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002699 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002700 }
2701
2702 }
2703 return (status);
2704}
2705/* Initialize the Channel + Power List in the local cache and in the CFG */
2706eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2707{
2708 tANI_U8 index;
2709 tANI_U32 count=0;
2710 tSirMacChanInfo *pChanInfo;
2711 tSirMacChanInfo *pChanInfoStart;
2712
2713 if(!ps11dinfo || !pMac)
2714 {
2715 return eHAL_STATUS_FAILURE;
2716 }
2717
Kiet Lam64c1b492013-07-12 13:56:44 +05302718 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2719 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002720 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302721 vos_mem_set(pChanInfo,
2722 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2723 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002724 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2727 {
2728 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2729 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2730 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2731 pChanInfo++;
2732 count++;
2733 }
2734 if(count)
2735 {
2736 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2737 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302738 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 }
2740
Jeff Johnsone7245742012-09-05 17:12:55 -07002741 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742}
2743
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302744/**
2745 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2746 * list
2747 *
2748 * @pMac: pointer to global mac
2749 * @sessionId: session id for the cmd
2750 * @pList: pending list from which cmd needs to be removed
2751 * @pCommand: cmd to be removed, can be NULL
2752 * @eRoamReason: cmd with reason to be removed
2753 *
2754 * Remove duplicate command from the pending list.
2755 *
2756 * Return: void
2757 */
2758void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2759 tANI_U32 sessionId, tDblLinkList *pList,
2760 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002761{
2762 tListElem *pEntry, *pNextEntry;
2763 tSmeCmd *pDupCommand;
2764 tDblLinkList localList;
2765
2766 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302767 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302769 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 return;
2771 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302772 csrLLLock(pList);
2773 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2774 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302776 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2777 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2778 /*
Abhishek Singhd2ce6802018-05-08 15:21:06 +05302779 * If pCommand is not NULL remove the similar duplicate cmd for same
2780 * reason as pCommand. If pCommand is NULL then check if eRoamReason is
2781 * eCsrForcedDisassoc (disconnect) and remove all roam command for the
2782 * sessionId, else if eRoamReason is eCsrHddIssued (connect) remove all
2783 * connect (non disconenct) commands.
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302784 */
2785 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2786 ((pCommand->command == pDupCommand->command) &&
2787 /*
2788 * This peermac check is requried for Softap/GO scenarios
2789 * For STA scenario below OR check will suffice as pCommand
2790 * will always be NULL for STA scenarios
2791 */
2792 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2793 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2794 ((pCommand->u.roamCmd.roamReason ==
2795 pDupCommand->u.roamCmd.roamReason) ||
2796 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2797 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2798 /* OR if pCommand is NULL */
2799 ((sessionId == pDupCommand->sessionId) &&
2800 (eSmeCommandRoam == pDupCommand->command) &&
2801 ((eCsrForcedDisassoc == eRoamReason) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05302802 (eCsrHddIssued == eRoamReason &&
2803 !CSR_IS_DISCONNECT_COMMAND(pDupCommand)))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302805 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2806 pDupCommand->u.roamCmd.roamReason);
2807 /* Remove the 'stale' roam command from the pending list */
2808 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 }
2811 pEntry = pNextEntry;
2812 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302813 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002814
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302815 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 {
2817 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302818 /* Tell caller that the command is cancelled */
2819 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2820 pDupCommand->u.roamCmd.roamId,
2821 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 csrReleaseCommandRoam(pMac, pDupCommand);
2823 }
2824 csrLLClose(&localList);
2825}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302826
2827/**
2828 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2829 * from pending lists.
2830 *
2831 * @pMac: pointer to global mac
2832 * @sessionId: session id for the cmd
2833 * @pCommand: cmd to be removed, can be null
2834 * @eRoamReason: cmd with reason to be removed
2835 *
2836 * Remove duplicate command from the sme and roam pending list.
2837 *
2838 * Return: void
2839 */
2840void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2841 tANI_U32 sessionId, tSmeCmd *pCommand,
2842 eCsrRoamReason eRoamReason)
2843{
2844 /* Always lock active list before locking pending lists */
2845 csrLLLock(&pMac->sme.smeCmdActiveList);
2846 csr_roam_remove_duplicate_cmd_from_list(pMac,
2847 sessionId, &pMac->sme.smeCmdPendingList,
2848 pCommand, eRoamReason);
2849 csr_roam_remove_duplicate_cmd_from_list(pMac,
2850 sessionId, &pMac->roam.roamCmdPendingList,
2851 pCommand, eRoamReason);
2852 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2853}
2854
Jeff Johnson295189b2012-06-20 16:38:30 -07002855eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2856 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2857{
2858 eHalStatus status = eHAL_STATUS_SUCCESS;
2859#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2860 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2861#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302862 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2864 {
2865 pSession = CSR_GET_SESSION( pMac, sessionId );
2866 }
2867 else
2868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002869 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 VOS_ASSERT(0);
2871 return eHAL_STATUS_FAILURE;
2872 }
krunal soni587bf012014-02-04 12:35:11 -08002873
2874 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2875 {
2876 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2877 return eHAL_STATUS_FAILURE;
2878 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002879
krunal soni587bf012014-02-04 12:35:11 -08002880 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2881
krunal soni7f7d2c92014-02-06 15:08:43 -08002882 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002884 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002886 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2887 /*
2888 * Decrement bRefAssocStartCnt for FT reassoc failure.
2889 * Reason: For FT reassoc failures, we first call
2890 * csrRoamCallCallback before notifying a failed roam
2891 * completion through csrRoamComplete. The latter in
2892 * turn calls csrRoamProcessResults which tries to
2893 * once again call csrRoamCallCallback if bRefAssocStartCnt
2894 * is non-zero. Since this is redundant for FT reassoc
2895 * failure, decrement bRefAssocStartCnt.
2896 */
2897 pSession->bRefAssocStartCnt--;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302898 } else if (u1 == eCSR_ROAM_ECSA_CHAN_CHANGE_RSP && u2 ==
2899 eCSR_ROAM_RESULT_NONE)
2900 pSession->connectedProfile.operationChannel =
2901 pRoamInfo->ap_chan_change_rsp->new_channel;
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002902
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05302903 if (eCSR_ROAM_RESULT_LOSTLINK == u2 ||
2904 eCSR_ROAM_LOSTLINK_DETECTED == u1)
2905 smsLog(pMac, LOG1, "eCSR_ROAM_RESULT_LOSTLINK ");
2906
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 if(NULL != pSession->callback)
2908 {
2909 if( pRoamInfo )
2910 {
2911 pRoamInfo->sessionId = (tANI_U8)sessionId;
2912 }
2913
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302914 /* avoid holding the global lock when making the roaming callback, original change came
2915 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2916 is possible on other OS ports where the callback may need to take locks to protect
2917 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2919 that may actually depend on the lock being held */
2920 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2921 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2922 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2923 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302924 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2925 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002926#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302927 vos_mem_set(&connectionStatus,
2928 sizeof(vos_event_wlan_status_payload_type), 0);
2929
krunal soni7f7d2c92014-02-06 15:08:43 -08002930 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 {
2932 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2933 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2934 if(NULL != pRoamInfo->pBssDesc)
2935 {
2936 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2937 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2940 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2941 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302942 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302943 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2944 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302945
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302947 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2950 {
2951 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2952 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302953 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 if(eCSR_ROAM_RESULT_FORCED == u2)
2956 {
2957 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2958 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302959 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2962 {
2963 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2964 connectionStatus.reason = eCSR_REASON_DISASSOC;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302965 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2968 {
2969 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2970 connectionStatus.reason = eCSR_REASON_DEAUTH;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302971 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002973#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2974
2975 return (status);
2976}
Jeff Johnson295189b2012-06-20 16:38:30 -07002977// Returns whether handoff is currently in progress or not
2978tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2979{
2980#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2981 return csrNeighborRoamIsHandoffInProgress(pMac);
2982#else
2983 return eANI_BOOLEAN_FALSE;
2984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002985}
Jeff Johnson295189b2012-06-20 16:38:30 -07002986eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2987 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2988{
2989 eHalStatus status = eHAL_STATUS_SUCCESS;
2990 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2991 tANI_U16 reasonCode;
2992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002993
2994 if(!pSession)
2995 {
2996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2997 return eHAL_STATUS_FAILURE;
2998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002999
3000 //Restore AC weight in case we change it
3001 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
3002 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003003 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 -07003004 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
3005 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
3006 }
3007
3008 if ( fMICFailure )
3009 {
3010 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
3011 }
3012 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
3013 {
3014 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003015 }
3016 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 {
3018 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003020#ifdef WLAN_FEATURE_VOWIFI_11R
3021 if ( (csrRoamIsHandoffInProgress(pMac)) &&
3022 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
3023 {
3024 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05303025 vos_mem_copy(&bssId,
3026 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
3027 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003028 }
3029 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003030#endif
3031 if(pSession->pConnectBssDesc)
3032 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303033 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003035
Jeff Johnson295189b2012-06-20 16:38:30 -07003036
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303037 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
3038 " subState = %s reason=%d"),
3039 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
3040 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08003041
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3043
3044 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
3045
3046 if(HAL_STATUS_SUCCESS(status))
3047 {
3048 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003049#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3050 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
3051 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
3052 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003053 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
3055 }
3056#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003057 }
3058 else
3059 {
3060 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
3061 }
3062
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 return (status);
3064}
Jeff Johnson295189b2012-06-20 16:38:30 -07003065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066/* ---------------------------------------------------------------------------
3067 \fn csrRoamIssueDisassociateStaCmd
3068 \brief csr function that HDD calls to disassociate a associated station
3069 \param sessionId - session Id for Soft AP
3070 \param pPeerMacAddr - MAC of associated station to delete
3071 \param reason - reason code, be one of the tSirMacReasonCodes
3072 \return eHalStatus
3073 ---------------------------------------------------------------------------*/
3074eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303075 tANI_U32 sessionId,
3076#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3077 const tANI_U8 *pPeerMacAddr,
3078#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303080#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 tANI_U32 reason)
3082{
3083 eHalStatus status = eHAL_STATUS_SUCCESS;
3084 tSmeCmd *pCommand;
3085
3086 do
3087 {
3088 pCommand = csrGetCommandBuffer( pMac );
3089 if ( !pCommand )
3090 {
3091 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3092 status = eHAL_STATUS_RESOURCES;
3093 break;
3094 }
3095 pCommand->command = eSmeCommandRoam;
3096 pCommand->sessionId = (tANI_U8)sessionId;
3097 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
3098 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
3099 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
3100 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3101 if( !HAL_STATUS_SUCCESS( status ) )
3102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003103 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 csrReleaseCommandRoam( pMac, pCommand );
3105 }
3106 }while(0);
3107
3108 return status;
3109}
3110
3111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112/* ---------------------------------------------------------------------------
3113 \fn csrRoamIssueDeauthSta
3114 \brief csr function that HDD calls to delete a associated station
3115 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303116 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 \return eHalStatus
3118 ---------------------------------------------------------------------------*/
3119eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303120 tANI_U32 sessionId,
3121 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003122{
3123 eHalStatus status = eHAL_STATUS_SUCCESS;
3124 tSmeCmd *pCommand;
3125
3126 do
3127 {
3128 pCommand = csrGetCommandBuffer( pMac );
3129 if ( !pCommand )
3130 {
3131 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3132 status = eHAL_STATUS_RESOURCES;
3133 break;
3134 }
3135 pCommand->command = eSmeCommandRoam;
3136 pCommand->sessionId = (tANI_U8)sessionId;
3137 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303138 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3139 sizeof(tSirMacAddr));
3140 pCommand->u.roamCmd.reason =
3141 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3143 if( !HAL_STATUS_SUCCESS( status ) )
3144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003145 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 csrReleaseCommandRoam( pMac, pCommand );
3147 }
3148 }while(0);
3149
3150 return status;
3151}
Jeff Johnson295189b2012-06-20 16:38:30 -07003152eHalStatus
3153csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3154 tANI_BOOLEAN bEnable )
3155{
3156 eHalStatus status = eHAL_STATUS_FAILURE;
3157 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 if (!pSession)
3160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003161 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 return (status);
3163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 if (pSession->pConnectBssDesc)
3165 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303166 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 }
3168 else
3169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003170 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 return (status);
3172 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003173 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3174 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3176 return (status);
3177}
Jeff Johnson295189b2012-06-20 16:38:30 -07003178eHalStatus
3179csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3180 VOS_MODULE_ID modId, void *pUsrContext,
3181 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3182{
3183 eHalStatus status = eHAL_STATUS_SUCCESS;
3184 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3185 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 if (!pSession)
3187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003188 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 return (status);
3190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 if(pSession->pConnectBssDesc)
3192 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303193 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 }
3195 else
3196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003197 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 return (status);
3199 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003200 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3201 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3203 return (status);
3204}
Jeff Johnson295189b2012-06-20 16:38:30 -07003205eHalStatus
3206csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3207 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3208{
3209 eHalStatus status = eHAL_STATUS_SUCCESS;
3210 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3211 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3212
3213 if (!pSession)
3214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003215 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 return (status);
3217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 if(pSession->pConnectBssDesc)
3219 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303220 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222 else
3223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003224 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 return (status);
3226 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003227 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3228 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003229
3230 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3231
3232 return (status);
3233}
Jeff Johnson295189b2012-06-20 16:38:30 -07003234eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3235{
3236 eHalStatus status = eHAL_STATUS_SUCCESS;
3237 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3238 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003239
3240 if (!pSession)
3241 {
3242 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3243 return eHAL_STATUS_FAILURE;
3244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003245
3246 if(pSession->pConnectBssDesc)
3247 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303248 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003250 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3251 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3253
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303254 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303255 if(HAL_STATUS_SUCCESS(status))
3256 {
3257 csrRoamLinkDown(pMac, sessionId);
3258 }
3259 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003260 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303261 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3262 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003263 }
3264
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 return (status);
3266}
3267
Jeff Johnson295189b2012-06-20 16:38:30 -07003268eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3269{
3270 eHalStatus status = eHAL_STATUS_SUCCESS;
3271 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3272 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003273
3274 if(!pSession)
3275 {
3276 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3277 return eHAL_STATUS_FAILURE;
3278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279
3280 // If no BSS description was found in this connection (happens with start IBSS), then
3281 // nix the BSS description that we keep around for the connected BSS) and get out...
3282 if(NULL == pBssDesc)
3283 {
3284 csrFreeConnectBssDesc(pMac, sessionId);
3285 }
3286 else
3287 {
3288 size = pBssDesc->length + sizeof( pBssDesc->length );
3289 if(NULL != pSession->pConnectBssDesc)
3290 {
3291 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3292 {
3293 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3294 csrFreeConnectBssDesc(pMac, sessionId);
3295 }
3296 }
3297 if(NULL == pSession->pConnectBssDesc)
3298 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303299 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303301 if (NULL == pSession->pConnectBssDesc)
3302 status = eHAL_STATUS_FAILURE;
3303 else
3304 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 return (status);
3307}
3308
Jeff Johnson295189b2012-06-20 16:38:30 -07003309eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3310 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3311 tDot11fBeaconIEs *pIes)
3312{
3313 eHalStatus status = eHAL_STATUS_SUCCESS;
3314 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303316 if (pIes == NULL)
3317 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003318
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 do
3320 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303321 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3322 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 //get qos
3324 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3325 //get SSID
3326 if(pIes->SSID.present)
3327 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303328 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3330 }
3331 else
3332 pBssConfig->SSID.length = 0;
3333 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3334 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003335 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 //Return failed if profile doesn't have an SSID either.
3337 if(pProfile->SSIDs.numOfSSIDs == 0)
3338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003339 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 status = eHAL_STATUS_FAILURE;
3341 break;
3342 }
3343 }
3344 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3345 {
3346 pBssConfig->eBand = eCSR_BAND_5G;
3347 }
3348 else
3349 {
3350 pBssConfig->eBand = eCSR_BAND_24;
3351 }
3352 //phymode
3353 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3354 {
3355 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3356 }
3357 else
3358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003359 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 //force it
3361 if(eCSR_BAND_24 == pBssConfig->eBand)
3362 {
3363 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3364 }
3365 else
3366 {
3367 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3368 }
3369 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +05303370 smsLog(pMac, LOG1, FL("phyMode %d uCfgDot11Mode %d"),
3371 pProfile->phyMode, pBssConfig->uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 //Qos
3373 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3374 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3375 {
3376 //Joining BSS is not 11n capable and WMM is disabled on client.
3377 //Disable QoS and WMM
3378 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3379 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303380
3381 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303382 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303383 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3384 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3385 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3386 {
3387 //Joining BSS is 11n capable and WMM is disabled on AP.
3388 //Assume all HT AP's are QOS AP's and enable WMM
3389 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3390 }
3391
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 //auth type
3393 switch( pProfile->negotiatedAuthType )
3394 {
3395 default:
3396 case eCSR_AUTH_TYPE_WPA:
3397 case eCSR_AUTH_TYPE_WPA_PSK:
3398 case eCSR_AUTH_TYPE_WPA_NONE:
3399 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3400 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3401 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 case eCSR_AUTH_TYPE_SHARED_KEY:
3403 pBssConfig->authType = eSIR_SHARED_KEY;
3404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 case eCSR_AUTH_TYPE_AUTOSWITCH:
3406 pBssConfig->authType = eSIR_AUTO_SWITCH;
3407 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303408 case eCSR_AUTH_TYPE_SAE:
3409 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
3410 break;
3411
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 }
3413 //short slot time
3414 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3415 {
3416 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3417 }
3418 else
3419 {
3420 pBssConfig->uShortSlotTime = 0;
3421 }
3422 if(pBssConfig->BssCap.ibss)
3423 {
3424 //We don't support 11h on IBSS
3425 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3426 }
3427 else
3428 {
3429 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3430 }
3431 //power constraint
3432 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3433 //heartbeat
3434 if ( CSR_IS_11A_BSS( pBssDesc ) )
3435 {
3436 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3437 }
3438 else
3439 {
3440 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3441 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303442 /*
3443 * Join timeout, if we find a BeaconInterval in the BssDescription,
3444 * then set the Join Timeout to be 3 BeaconInterval.
3445 */
3446 if (pBssDesc->beaconInterval)
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 {
3448 //Make sure it is bigger than the minimal
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303449 pBssConfig->uJoinTimeOut =
3450 CSR_ROAM_MAX(3 * pBssDesc->beaconInterval,
3451 CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303453 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 {
3455 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3456 }
3457 //validate CB
3458 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Abhishek Singhe3beee22017-07-31 15:35:40 +05303459 if (CSR_IS_CHANNEL_24GHZ(pBssDesc->channelId) &&
3460 pProfile->force_24ghz_in_ht20) {
3461 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
3462 smsLog(pMac, LOG1,
3463 FL("force_24ghz_in_ht20 is set so set cbmode to 0"));
3464 }
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303465 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3466 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 return (status);
3469}
3470
Jeff Johnson295189b2012-06-20 16:38:30 -07003471static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3472 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3473{
3474 eHalStatus status = eHAL_STATUS_SUCCESS;
3475 tANI_U8 operationChannel = 0;
3476 tANI_U8 qAPisEnabled = FALSE;
3477 //SSID
3478 pBssConfig->SSID.length = 0;
3479 if(pProfile->SSIDs.numOfSSIDs)
3480 {
3481 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303482 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3483 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 }
3485 else
3486 {
3487 //SSID must present
3488 return eHAL_STATUS_FAILURE;
3489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 //Settomg up the capabilities
3491 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3492 {
3493 pBssConfig->BssCap.ibss = 1;
3494 }
3495 else
3496 {
3497 pBssConfig->BssCap.ess = 1;
3498 }
3499 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3500 {
3501 pBssConfig->BssCap.privacy = 1;
3502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 pBssConfig->eBand = pMac->roam.configParam.eBand;
3504 //phymode
3505 if(pProfile->ChannelInfo.ChannelList)
3506 {
3507 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3510 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 //QOS
3512 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 if ( pBssConfig->BssCap.ess == 1 )
3514 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 /*For Softap case enable WMM*/
3516 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3517 qAPisEnabled = TRUE;
3518 }
3519 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3521 qAPisEnabled = TRUE;
3522 } else {
3523 qAPisEnabled = FALSE;
3524 }
3525 } else {
3526 qAPisEnabled = TRUE;
3527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3529 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3530 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3531 )
3532 {
3533 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3534 } else {
3535 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3536 }
3537
3538 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003539 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 {
3541 default:
3542 case eCSR_AUTH_TYPE_WPA:
3543 case eCSR_AUTH_TYPE_WPA_PSK:
3544 case eCSR_AUTH_TYPE_WPA_NONE:
3545 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3546 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3547 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 case eCSR_AUTH_TYPE_SHARED_KEY:
3549 pBssConfig->authType = eSIR_SHARED_KEY;
3550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 case eCSR_AUTH_TYPE_AUTOSWITCH:
3552 pBssConfig->authType = eSIR_AUTO_SWITCH;
3553 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303554 case eCSR_AUTH_TYPE_SAE:
3555 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
3556 break;
3557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 }
3559 //short slot time
3560 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3561 {
3562 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3563 }
3564 else
3565 {
3566 pBssConfig->uShortSlotTime = 0;
3567 }
3568 //power constraint. We don't support 11h on IBSS
3569 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3570 pBssConfig->uPowerLimit = 0;
3571 //heartbeat
3572 if ( eCSR_BAND_5G == pBssConfig->eBand )
3573 {
3574 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3575 }
3576 else
3577 {
3578 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3579 }
3580 //Join timeout
3581 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003582
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 return (status);
3584}
Jeff Johnson295189b2012-06-20 16:38:30 -07003585static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3586{
3587 eHalStatus status = eHAL_STATUS_FAILURE;
3588 tDot11fBeaconIEs *pIes = NULL;
3589
3590 do
3591 {
3592 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3593 {
3594 //err msg
3595 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003596 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 break;
3598 }
3599 //check if the AP is QAP & it supports APSD
3600 if( CSR_IS_QOS_BSS(pIes) )
3601 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303602 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 }
3604 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303605
3606 if (NULL != pIes)
3607 {
3608 vos_mem_free(pIes);
3609 }
3610
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 return status;
3612}
3613
Jeff Johnson295189b2012-06-20 16:38:30 -07003614void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3615{
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3617 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3618 // See !!Note: below in this function...
3619 tANI_U32 PrivacyEnabled = 0;
3620 tANI_U32 RsnEnabled = 0;
3621 tANI_U32 WepDefaultKeyId = 0;
3622 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3623 tANI_U32 Key0Length = 0;
3624 tANI_U32 Key1Length = 0;
3625 tANI_U32 Key2Length = 0;
3626 tANI_U32 Key3Length = 0;
3627
3628 // Reserve for the biggest key
3629 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3630 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3631 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3632 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3633
3634 switch ( pProfile->negotiatedUCEncryptionType )
3635 {
3636 case eCSR_ENCRYPT_TYPE_NONE:
3637
3638 // for NO encryption, turn off Privacy and Rsn.
3639 PrivacyEnabled = 0;
3640 RsnEnabled = 0;
3641
3642 // WEP key length and Wep Default Key ID don't matter in this case....
3643
3644 // clear out the WEP keys that may be hanging around.
3645 Key0Length = 0;
3646 Key1Length = 0;
3647 Key2Length = 0;
3648 Key3Length = 0;
3649
3650 break;
3651
3652 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303653 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003654
3655 // Privacy is ON. NO RSN for Wep40 static key.
3656 PrivacyEnabled = 1;
3657 RsnEnabled = 0;
3658
3659 // Set the Wep default key ID.
3660 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 // Wep key size if 5 bytes (40 bits).
3662 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3663
3664 // set encryption keys in the CFG database or clear those that are not present in this profile.
3665 if ( pProfile->Keys.KeyLength[0] )
3666 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303667 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3668 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3670 }
3671 else
3672 {
3673 Key0Length = 0;
3674 }
3675
3676 if ( pProfile->Keys.KeyLength[1] )
3677 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303678 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3679 WNI_CFG_WEP_KEY_LENGTH_5);
3680 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 }
3682 else
3683 {
3684 Key1Length = 0;
3685 }
3686
3687 if ( pProfile->Keys.KeyLength[2] )
3688 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303689 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3690 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3692 }
3693 else
3694 {
3695 Key2Length = 0;
3696 }
3697
3698 if ( pProfile->Keys.KeyLength[3] )
3699 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303700 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3701 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3703 }
3704 else
3705 {
3706 Key3Length = 0;
3707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 break;
3709
3710 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303711 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003712
3713 // Privacy is ON. NO RSN for Wep40 static key.
3714 PrivacyEnabled = 1;
3715 RsnEnabled = 0;
3716
3717 // Set the Wep default key ID.
3718 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3719
3720 // Wep key size if 13 bytes (104 bits).
3721 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3722
3723 // set encryption keys in the CFG database or clear those that are not present in this profile.
3724 if ( pProfile->Keys.KeyLength[0] )
3725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303726 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3727 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3729 }
3730 else
3731 {
3732 Key0Length = 0;
3733 }
3734
3735 if ( pProfile->Keys.KeyLength[1] )
3736 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303737 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3738 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3740 }
3741 else
3742 {
3743 Key1Length = 0;
3744 }
3745
3746 if ( pProfile->Keys.KeyLength[2] )
3747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303748 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3749 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3751 }
3752 else
3753 {
3754 Key2Length = 0;
3755 }
3756
3757 if ( pProfile->Keys.KeyLength[3] )
3758 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303759 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3760 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3762 }
3763 else
3764 {
3765 Key3Length = 0;
3766 }
3767
3768 break;
3769
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 case eCSR_ENCRYPT_TYPE_TKIP:
3771 case eCSR_ENCRYPT_TYPE_AES:
3772#ifdef FEATURE_WLAN_WAPI
3773 case eCSR_ENCRYPT_TYPE_WPI:
3774#endif /* FEATURE_WLAN_WAPI */
3775 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3776 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3777 PrivacyEnabled = (0 != fPrivacy);
3778
3779 // turn on RSN enabled for WPA associations
3780 RsnEnabled = 1;
3781
3782 // WEP key length and Wep Default Key ID don't matter in this case....
3783
3784 // clear out the static WEP keys that may be hanging around.
3785 Key0Length = 0;
3786 Key1Length = 0;
3787 Key2Length = 0;
3788 Key3Length = 0;
3789
3790 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 default:
3792 PrivacyEnabled = 0;
3793 RsnEnabled = 0;
3794 break;
3795 }
3796
3797 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3798 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3799 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3800 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3801 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3802 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3803 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3804 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3805}
3806
Jeff Johnson295189b2012-06-20 16:38:30 -07003807static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3808{
3809 tANI_U32 len = 0;
3810 if(pSSID->length <= WNI_CFG_SSID_LEN)
3811 {
3812 len = pSSID->length;
3813 }
3814 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3815}
3816
Jeff Johnson295189b2012-06-20 16:38:30 -07003817eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3818{
3819 eHalStatus status = eHAL_STATUS_SUCCESS;
3820 tANI_U32 QoSEnabled;
3821 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 // set the CFG enable/disable variables based on the qosType being configured...
3823 switch( qosType )
3824 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3826 QoSEnabled = FALSE;
3827 WmeEnabled = TRUE;
3828 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3830 QoSEnabled = FALSE;
3831 WmeEnabled = TRUE;
3832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3834 QoSEnabled = FALSE;
3835 WmeEnabled = TRUE;
3836 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3838 QoSEnabled = TRUE;
3839 WmeEnabled = FALSE;
3840 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 case eCSR_MEDIUM_ACCESS_11e_HCF:
3842 QoSEnabled = TRUE;
3843 WmeEnabled = FALSE;
3844 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 default:
3846 case eCSR_MEDIUM_ACCESS_DCF:
3847 QoSEnabled = FALSE;
3848 WmeEnabled = FALSE;
3849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 }
3851 //save the WMM setting for later use
3852 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303853 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 return (status);
3855}
Jeff Johnson295189b2012-06-20 16:38:30 -07003856static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303857 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003858{
3859 eHalStatus status = eHAL_STATUS_FAILURE;
3860 int i;
3861 eCsrCfgDot11Mode cfgDot11Mode;
3862 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303863 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303864 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3865 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003867
3868 if( NULL != pIes )
3869 {
3870 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 // Originally, we thought that for 11a networks, the 11a rates are always
3872 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3873 // appear in the Operational Rate set. Consequently, in either case, we
3874 // would blindly put the rates we support into our Operational Rate set
3875 // (including the basic rates, which we have already verified are
3876 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 // However, it turns out that this is not always the case. Some AP's
3878 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3879 // too. Now, we're a little more careful:
3880 pDstRate = pOpRateSet->rate;
3881 if(pIes->SuppRates.present)
3882 {
3883 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3884 {
3885 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3886 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003887 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3888 {
3889 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3890 *pDstRate++ = pIes->SuppRates.rates[ i ];
3891 pOpRateSet->numRates++;
3892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 }
3894 }
3895 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303896 /* If there are Extended Rates in the beacon, we will reflect those
3897 * extended rates that we support in out Extended Operational Rate
3898 * set*/
3899 pDstRate = pExRateSet->rate;
3900 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303902 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303904 if (csrRatesIsDot11RateSupported(pMac,
3905 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303907 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3908 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303910 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3911 &rateBitmap);
3912 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3913 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 }
3915 }
3916 }
3917 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303918 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 }//Parsing BSSDesc
3920 else
3921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003922 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 }
3924 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3925 return status;
3926}
3927
3928static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3929 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3930{
3931 int i;
3932 tANI_U8 *pDstRate;
3933 eCsrCfgDot11Mode cfgDot11Mode;
3934 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3935 tANI_U32 OperationalRatesLength = 0;
3936 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3937 tANI_U32 ExtendedOperationalRatesLength = 0;
3938 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3939 tANI_U32 ProprietaryOperationalRatesLength = 0;
3940 tANI_U32 PropRatesEnable = 0;
3941 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3942 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 if( NULL != pIes )
3945 {
3946 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 // Originally, we thought that for 11a networks, the 11a rates are always
3948 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3949 // appear in the Operational Rate set. Consequently, in either case, we
3950 // would blindly put the rates we support into our Operational Rate set
3951 // (including the basic rates, which we have already verified are
3952 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 // However, it turns out that this is not always the case. Some AP's
3954 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3955 // too. Now, we're a little more careful:
3956 pDstRate = OperationalRates;
3957 if(pIes->SuppRates.present)
3958 {
3959 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3960 {
3961 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3962 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3963 {
3964 *pDstRate++ = pIes->SuppRates.rates[ i ];
3965 OperationalRatesLength++;
3966 }
3967 }
3968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3970 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3971 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3972 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3973 {
3974 // If there are Extended Rates in the beacon, we will reflect those
3975 // extended rates that we support in out Extended Operational Rate
3976 // set:
3977 pDstRate = ExtendedOperationalRates;
3978 if(pIes->ExtSuppRates.present)
3979 {
3980 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3981 {
3982 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3983 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3984 {
3985 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3986 ExtendedOperationalRatesLength++;
3987 }
3988 }
3989 }
3990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 // Enable proprietary MAC features if peer node is Airgo node and STA
3992 // user wants to use them
3993 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3994 {
3995 PropRatesEnable = 1;
3996 }
3997 else
3998 {
3999 PropRatesEnable = 0;
4000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 // For ANI network companions, we need to populate the proprietary rate
4002 // set with any proprietary rates we found in the beacon, only if user
4003 // allows them...
4004 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
4005 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
4006 {
4007 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
4008 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
4009 {
4010 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
4011 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304012 vos_mem_copy(ProprietaryOperationalRates,
4013 pIes->Airgo.PropSuppRates.rates,
4014 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 }
4016 else {
4017 // No proprietary modes...
4018 ProprietaryOperationalRatesLength = 0;
4019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 /* Get MCS Rate */
4021 pDstRate = MCSRateIdxSet;
4022 if ( pIes->HTCaps.present )
4023 {
4024 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
4025 {
4026 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
4027 {
4028 MCSRateLength++;
4029 *pDstRate++ = i;
4030 }
4031 }
4032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 // Set the operational rate set CFG variables...
4034 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4035 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4036 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4037 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4038 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4039 ProprietaryOperationalRates,
4040 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4041 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
4042 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
4043 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
4044 }//Parsing BSSDesc
4045 else
4046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004047 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 }
4049}
4050
Jeff Johnson295189b2012-06-20 16:38:30 -07004051static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
4052 tCsrRoamProfile *pProfile )
4053{
4054 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4055 { 8,
4056 { SIR_MAC_RATE_6,
4057 SIR_MAC_RATE_9,
4058 SIR_MAC_RATE_12,
4059 SIR_MAC_RATE_18,
4060 SIR_MAC_RATE_24,
4061 SIR_MAC_RATE_36,
4062 SIR_MAC_RATE_48,
4063 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4065 { 4,
4066 { SIR_MAC_RATE_1,
4067 SIR_MAC_RATE_2,
4068 SIR_MAC_RATE_5_5,
4069 SIR_MAC_RATE_11 } } };
4070
4071
4072 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4073 { SIR_MAC_RATE_72,
4074 SIR_MAC_RATE_96,
4075 SIR_MAC_RATE_108 } };
4076 eCsrCfgDot11Mode cfgDot11Mode;
4077 eCsrBand eBand;
4078 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4079 tANI_U32 OperationalRatesLength = 0;
4080 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4081 tANI_U32 ExtendedOperationalRatesLength = 0;
4082 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
4083 tANI_U32 ProprietaryOperationalRatesLength = 0;
4084 tANI_U32 PropRatesEnable = 0;
4085 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 if(pProfile->ChannelInfo.ChannelList)
4087 {
4088 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4092 // networks, the 11b rates appear in the Operational Rate set. In either case,
4093 // we can blindly put the rates we support into our Operational Rate set
4094 // (including the basic rates, which we have already verified are supported
4095 // earlier in the roaming decision).
4096 if ( eCSR_BAND_5G == eBand )
4097 {
4098 // 11a rates into the Operational Rate Set.
4099 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4100 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304101 vos_mem_copy(OperationalRates,
4102 DefaultSupportedRates11a.supportedRateSet.rate,
4103 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 // Nothing in the Extended rate set.
4106 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 // populate proprietary rates if user allows them
4108 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4109 {
4110 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4111 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304112 vos_mem_copy(ProprietaryOperationalRates,
4113 DefaultSupportedPropRates.propRate,
4114 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 }
4116 else
4117 {
4118 // No proprietary modes
4119 ProprietaryOperationalRatesLength = 0;
4120 }
4121 }
4122 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4123 {
4124 // 11b rates into the Operational Rate Set.
4125 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4126 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304127 vos_mem_copy(OperationalRates,
4128 DefaultSupportedRates11b.supportedRateSet.rate,
4129 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 // Nothing in the Extended rate set.
4131 ExtendedOperationalRatesLength = 0;
4132 // No proprietary modes
4133 ProprietaryOperationalRatesLength = 0;
4134 }
4135 else
4136 {
4137 // 11G
4138
4139 // 11b rates into the Operational Rate Set.
4140 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4141 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304142 vos_mem_copy(OperationalRates,
4143 DefaultSupportedRates11b.supportedRateSet.rate,
4144 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004145
4146 // 11a rates go in the Extended rate set.
4147 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4148 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304149 vos_mem_copy(ExtendedOperationalRates,
4150 DefaultSupportedRates11a.supportedRateSet.rate,
4151 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004152
4153 // populate proprietary rates if user allows them
4154 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4155 {
4156 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4157 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304158 vos_mem_copy(ProprietaryOperationalRates,
4159 DefaultSupportedPropRates.propRate,
4160 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 }
4162 else
4163 {
4164 // No proprietary modes
4165 ProprietaryOperationalRatesLength = 0;
4166 }
4167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4169 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4170 {
4171 PropRatesEnable = 1;
4172 }
4173 else
4174 {
4175 PropRatesEnable = 0;
4176 }
4177
4178 // Set the operational rate set CFG variables...
4179 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4180 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4181 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4182 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4183 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4184 ProprietaryOperationalRates,
4185 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4186 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004187}
Jeff Johnson295189b2012-06-20 16:38:30 -07004188void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4189{
4190 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004191
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4193 tANI_U32 sessionId;
4194 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 if(NULL == pEntry)
4196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004197 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 return;
4199 }
4200 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4201 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304202 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4203 " current state : %d sub state : %d "),
4204 result, pMac->roam.curState[sessionId],
4205 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4207 {
4208 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4209 }
4210}
4211
Jeff Johnson295189b2012-06-20 16:38:30 -07004212//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4213tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4214{
4215 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4216 {
4217 return (WNI_CFG_PHY_MODE_11B);
4218 }
4219 else
4220 {
4221 if(eCSR_BAND_24 == band)
4222 return (WNI_CFG_PHY_MODE_11G);
4223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 return (WNI_CFG_PHY_MODE_11A);
4225}
Jeff Johnson295189b2012-06-20 16:38:30 -07004226
Jeff Johnsone7245742012-09-05 17:12:55 -07004227
4228#ifdef WLAN_FEATURE_11AC
4229ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4230{
4231 switch ( aniCBMode )
4232 {
4233 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4234 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4235 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4236 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4237 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4238 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4239 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4240 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4241 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004242 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004243 return PHY_SINGLE_CHANNEL_CENTERED;
4244 }
4245}
4246#endif
4247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248//pIes may be NULL
4249eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4250 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304251 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004252{
4253 eHalStatus status = eHAL_STATUS_SUCCESS;
4254 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4255 tANI_U8 channel = 0;
4256 //Make sure we have the domain info for the BSS we try to connect to.
4257 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304258 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304260 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 {
4262 //Make sure the 11d info from this BSSDesc can be applied
4263 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304264 if (VOS_TRUE == resetCountry)
4265 {
4266 csrApplyCountryInformation(pMac, FALSE);
4267 }
4268 else
4269 {
4270 csrApplyCountryInformation(pMac, TRUE);
4271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 }
Kiran4a17ebe2013-01-31 10:43:43 -08004273 if ((csrIs11dSupported (pMac)) && pIes)
4274 {
4275 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004276 {
Kiran4a17ebe2013-01-31 10:43:43 -08004277 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004278 }
4279 else
4280 {
4281 //Let's also update the below to make sure we don't update CC while
4282 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304283 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004284 pBssDesc->bssId, sizeof(tSirMacAddr));
4285 }
Kiran4a17ebe2013-01-31 10:43:43 -08004286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 //Qos
4289 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4290 //SSID
4291 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4292 //fragment threshold
4293 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4294 //RTS threshold
4295 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4296
4297 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 //Auth type
4299 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4300 //encryption type
4301 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4302 //short slot time
4303 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 //11d
4305 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4306 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4307 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 /*//11h
4309 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4310 */
4311 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4312 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004313
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004314 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 {
4316 channel = pProfile->operationChannel;
4317 }
4318 else
4319 {
4320 if(pBssDesc)
4321 {
4322 channel = pBssDesc->channelId;
4323 }
4324 }
4325 if(0 != channel)
4326 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304327 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4328 !pMac->roam.configParam.channelBondingMode24GHz &&
4329 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4330 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304332 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4333 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4334 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 }
4336 else
4337 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004338 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 }
4340 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004341#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004342 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4343 // in function csrConvertCBIniValueToPhyCBState()
4344 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4345 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004346 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004347 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004348 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004349 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304350 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004351 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004352 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004353 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004354 }
4355 else
4356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4358 //Rate
4359 //Fixed Rate
4360 if(pBssDesc)
4361 {
4362 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4363 }
4364 else
4365 {
4366 csrSetCfgRateSetFromProfile(pMac, pProfile);
4367 }
4368 //Make this the last CFG to set. The callback will trigger a join_req
4369 //Join time out
4370 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4371
4372 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 return (status);
4374}
4375
Jeff Johnson295189b2012-06-20 16:38:30 -07004376eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4377 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4378{
4379 eHalStatus status;
4380 tBssConfigParam *pBssConfig;
4381 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004382
4383 if(!pSession)
4384 {
4385 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4386 return eHAL_STATUS_FAILURE;
4387 }
4388
Kiet Lam64c1b492013-07-12 13:56:44 +05304389 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4390 if ( NULL == pBssConfig )
4391 status = eHAL_STATUS_FAILURE;
4392 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304394 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4396 if(HAL_STATUS_SUCCESS(status))
4397 {
4398 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004399 /* This will allow to pass cbMode during join req */
4400 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 //For IBSS, we need to prepare some more information
4402 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 )
4405 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004406 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 }
4408 // If we are in an IBSS, then stop the IBSS...
4409 ////Not worry about WDS connection for now
4410 if ( csrIsConnStateIbss( pMac, sessionId ) )
4411 {
4412 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4413 }
4414 else
4415 {
4416 // if we are in an Infrastructure association....
4417 if ( csrIsConnStateInfra( pMac, sessionId ) )
4418 {
4419 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4420 // across SSIDs (roaming to a new SSID)... //
4421 //Not worry about WDS connection for now
4422 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304423 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 {
4425 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304426 status = csrRoamIssueDisassociate( pMac, sessionId,
4427 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304429 else
4430 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4432 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304433 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304435 // Set parameters for this Bss.
4436 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4437 pBssDesc, pBssConfig,
4438 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304442 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 {
4444 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4445 // Nothing to stop.
4446 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304448 )
4449 {
4450 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4451 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4452 // Set parameters for this Bss.
4453 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4454 pBssDesc, pBssConfig,
4455 pIes, is11rRoamingFlag);
4456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 }
4458 }
4459 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304460 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 return (status);
4463}
4464
Jeff Johnson295189b2012-06-20 16:38:30 -07004465eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4466 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4467{
4468 eCsrJoinState eRoamState = eCsrContinueRoaming;
4469 eHalStatus status;
4470 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4471 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4472 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004473
4474 if(!pSession)
4475 {
4476 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4477 return (eCsrStopRoaming);
4478 }
4479
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 if( CSR_IS_WDS_STA( pProfile ) )
4481 {
4482 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4483 if( !HAL_STATUS_SUCCESS( status ) )
4484 {
4485 eRoamState = eCsrStopRoaming;
4486 }
4487 }
4488 else
4489 {
4490 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4491 {
4492 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4493 return (eCsrStopRoaming);
4494 }
4495 if ( csrIsInfraBssDesc( pBssDesc ) )
4496 {
4497 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4498 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4499 // have changed and handle the changes (without disturbing the current association).
4500
4501 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4502 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4503 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4504 )
4505 {
4506 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4507 // with Authenticating first. To force this, stop the current association (Disassociate) and
4508 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4509 // a new Association.
4510 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4511 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004512 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4514 {
4515 eRoamState = eCsrReassocToSelfNoCapChange;
4516 }
4517 else
4518 {
4519 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304521 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4523 if(HAL_STATUS_SUCCESS(status))
4524 {
4525 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004526 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304528 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4529 pBssDesc, &bssConfig,
4530 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 if(!HAL_STATUS_SUCCESS(status))
4532 {
4533 eRoamState = eCsrStopRoaming;
4534 }
4535 }
4536 else
4537 {
4538 eRoamState = eCsrStopRoaming;
4539 }
4540 }//same profile
4541 }
4542 else
4543 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304544 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4546 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304547 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4548 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304552 }
4553 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 {
4555 // 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 -07004556 // stop the existing network before attempting to join the new network...
4557 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4558 {
4559 eRoamState = eCsrStopRoaming;
4560 }
4561 }
4562 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304563 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 {
4565 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4566 {
4567 eRoamState = eCsrStopRoaming;
4568 }
4569 }
4570 if( pIesLocal && !pScanResult->pvIes )
4571 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304572 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 }
4574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 return( eRoamState );
4576}
4577
Jeff Johnson295189b2012-06-20 16:38:30 -07004578eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4579 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4580{
4581 eHalStatus status = eHAL_STATUS_SUCCESS;
4582 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304583 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 roamInfo.pBssDesc = pBssDesc;
4585 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4586 return (status);
4587}
Jeff Johnson295189b2012-06-20 16:38:30 -07004588//In case no matching BSS is found, use whatever default we can find
4589static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4590{
4591 //Need to get all negotiated types in place first
4592 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004593 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 {
4595 default:
4596 case eCSR_AUTH_TYPE_WPA:
4597 case eCSR_AUTH_TYPE_WPA_PSK:
4598 case eCSR_AUTH_TYPE_WPA_NONE:
4599 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4600 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4601 break;
4602
4603 case eCSR_AUTH_TYPE_SHARED_KEY:
4604 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4605 break;
4606
4607 case eCSR_AUTH_TYPE_AUTOSWITCH:
4608 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4609 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304610 case eCSR_AUTH_TYPE_SAE:
4611 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4612 eCSR_AUTH_TYPE_SAE;
4613 break;
4614
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 }
4616 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4617 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4618 //In this case, the multicast encryption needs to follow the uncast ones.
4619 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4620 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4621}
4622
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004623
4624static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4625{
4626 switch(pCommand->u.roamCmd.roamReason)
4627 {
4628 case eCsrLostLink1:
4629 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4630 break;
4631 case eCsrLostLink2:
4632 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4633 break;
4634 case eCsrLostLink3:
4635 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4636 break;
4637 default:
4638 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4639 pCommand->u.roamCmd.roamReason);
4640 break;
4641 }
4642}
4643
Jeff Johnson295189b2012-06-20 16:38:30 -07004644static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4645{
4646 eHalStatus status;
4647 tCsrScanResult *pScanResult = NULL;
4648 eCsrJoinState eRoamState = eCsrStopRoaming;
4649 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4650 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4651 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4652#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4653 v_U8_t acm_mask = 0;
4654#endif
4655 tANI_U32 sessionId = pCommand->sessionId;
4656 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4657 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4658 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004659
4660 if(!pSession)
4661 {
4662 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4663 return (eCsrStopRoaming);
4664 }
4665
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 do
4667 {
4668 // Check for Cardbus eject condition, before trying to Roam to any BSS
4669 //***if( !balIsCardPresent(pAdapter) ) break;
4670
Kiet Lam64c1b492013-07-12 13:56:44 +05304671 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304672 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 if(NULL != pBSSList)
4674 {
4675 // When handling AP's capability change, continue to associate to
4676 // same BSS and make sure pRoamBssEntry is not Null.
4677 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4678 {
4679 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4680 {
4681 //Try the first BSS
4682 pCommand->u.roamCmd.pLastRoamBss = NULL;
4683 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4684 }
4685 else
4686 {
4687 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4688 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4689 {
4690 //Done with all the BSSs
4691 //In this case, will tell HDD the completion
4692 break;
4693 }
4694 else
4695 {
4696 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304697 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4699 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4700 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4701 pRoamInfo = &roamInfo;
4702 }
4703 }
4704 while(pCommand->u.roamCmd.pRoamBssEntry)
4705 {
4706 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 /*If concurrency enabled take the concurrent connected channel first. */
4708 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304709 if (vos_concurrent_open_sessions_running() &&
4710 !csrIsValidMcConcurrentSession(pMac, sessionId,
4711 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 {
4713 concurrentChannel =
4714 csrGetConcurrentOperationChannel(pMac);
4715 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004716 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 if ((concurrentChannel) &&
4718 (concurrentChannel ==
4719 pScanResult->Result.BssDescriptor.channelId))
4720 {
4721 //make this 0 because we do not want the
4722 //below check to pass as we don't want to
4723 //connect on other channel
4724 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4725 FL("Concurrent channel match =%d"),
4726 concurrentChannel);
4727 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 }
4729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004730
4731 if (!concurrentChannel)
4732 {
4733
4734 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4735 sessionId, &pScanResult->Result.BssDescriptor,
4736 pCommand->u.roamCmd.roamId)))
4737 {
4738 //Ok to roam this
4739 break;
4740 }
4741 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004742 else
4743 {
4744 eRoamState = eCsrStopRoamingDueToConcurrency;
4745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4747 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4748 {
4749 //Done with all the BSSs
4750 fDone = eANI_BOOLEAN_TRUE;
4751 break;
4752 }
4753 }
4754 if(fDone)
4755 {
4756 break;
4757 }
4758 }
4759 }
4760 //We have something to roam, tell HDD when it is infra.
4761 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4762 //For WDS, the indication is eCSR_ROAM_WDS_IND
4763 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4764 {
4765 if(pRoamInfo)
4766 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004767 if(pSession->bRefAssocStartCnt)
4768 {
4769 pSession->bRefAssocStartCnt--;
4770 //Complete the last association attemp because a new one is about to be tried
4771 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4772 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004774 }
4775 }
4776 /* If the roaming has stopped, not to continue the roaming command*/
4777 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4778 {
4779 //No need to complete roaming here as it already completes
4780 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4781 pCommand->u.roamCmd.roamReason);
4782 eRoamState = eCsrStopRoaming;
4783 csrSetAbortRoamingCommand(pMac, pCommand);
4784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304786 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 if(pScanResult)
4788 {
4789 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004792 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 fDone = eANI_BOOLEAN_TRUE;
4794 eRoamState = eCsrStopRoaming;
4795 break;
4796 }
4797 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4798 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4799 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4800 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4801 CSR_IS_QOS_BSS(pIesLocal) &&
4802 CSR_IS_UAPSD_BSS(pIesLocal) )
4803 {
4804#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4806 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004807#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 }
4809 else
4810 {
4811 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4812 }
4813 if( pIesLocal && !pScanResult->Result.pvIes)
4814 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304815 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 }
4817 }
4818 else
4819 {
4820 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4821 }
4822 roamInfo.pProfile = pProfile;
4823 pSession->bRefAssocStartCnt++;
4824 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4825 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4828 {
4829 // If this is a start IBSS profile, then we need to start the IBSS.
4830 if ( CSR_IS_START_IBSS(pProfile) )
4831 {
4832 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 // Attempt to start this IBSS...
4834 csrRoamAssignDefaultParam( pMac, pCommand );
4835 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4836 if(HAL_STATUS_SUCCESS(status))
4837 {
4838 if ( fSameIbss )
4839 {
4840 eRoamState = eCsrStartIbssSameIbss;
4841 }
4842 else
4843 {
4844 eRoamState = eCsrContinueRoaming;
4845 }
4846 }
4847 else
4848 {
4849 //it somehow fail need to stop
4850 eRoamState = eCsrStopRoaming;
4851 }
4852 break;
4853 }
4854 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 )
4857 {
4858 // Attempt to start this WDS...
4859 csrRoamAssignDefaultParam( pMac, pCommand );
4860 /* For AP WDS, we dont have any BSSDescription */
4861 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4862 if(HAL_STATUS_SUCCESS(status))
4863 {
4864 eRoamState = eCsrContinueRoaming;
4865 }
4866 else
4867 {
4868 //it somehow fail need to stop
4869 eRoamState = eCsrStopRoaming;
4870 }
4871 }
4872 else
4873 {
4874 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004875 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 eRoamState = eCsrStopRoaming;
4877 break;
4878 }
4879 }
4880 else //We have BSS
4881 {
4882 //Need to assign these value because they are used in csrIsSameProfile
4883 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004884 /* The OSEN IE doesn't provide the cipher suite.
4885 * Therefore set to constant value of AES */
4886 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4887 {
4888 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4889 eCSR_ENCRYPT_TYPE_AES;
4890 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4891 eCSR_ENCRYPT_TYPE_AES;
4892 }
4893 else
4894 {
4895 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4896 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4897 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4898 pScanResult->mcEncryptionType;
4899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4901 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4902 {
4903 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4904 {
4905 eRoamState = eCsrStartIbssSameIbss;
4906 break;
4907 }
4908 }
4909 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4910 {
4911 //trying to connect to the one already connected
4912 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4913 eRoamState = eCsrReassocToSelfNoCapChange;
4914 break;
4915 }
4916 // Attempt to Join this Bss...
4917 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4918 break;
4919 }
4920
4921 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4923 {
4924 //Need to indicate association_completion if association_start has been done
4925 if(pSession->bRefAssocStartCnt > 0)
4926 {
4927 pSession->bRefAssocStartCnt--;
4928 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004929 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4931 eCSR_ROAM_ASSOCIATION_COMPLETION,
4932 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4933 }
4934 }
4935
4936 return( eRoamState );
4937}
4938
Jeff Johnson295189b2012-06-20 16:38:30 -07004939static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4940{
4941 eHalStatus status = eHAL_STATUS_SUCCESS;
4942 eCsrJoinState RoamState;
4943 tANI_U32 sessionId = pCommand->sessionId;
4944
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 //***if( hddIsRadioStateOn( pAdapter ) )
4946 {
4947 // Attept to join a Bss...
4948 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004949
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004951 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 {
4953 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 // and if connected in Infrastructure mode...
4955 if ( csrIsConnStateInfra(pMac, sessionId) )
4956 {
4957 //... then we need to issue a disassociation
4958 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4959 if(!HAL_STATUS_SUCCESS(status))
4960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004961 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 //roam command is completed by caller in the failed case
4963 fComplete = eANI_BOOLEAN_TRUE;
4964 }
4965 }
4966 else if( csrIsConnStateIbss(pMac, sessionId) )
4967 {
4968 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4969 if(!HAL_STATUS_SUCCESS(status))
4970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004971 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 //roam command is completed by caller in the failed case
4973 fComplete = eANI_BOOLEAN_TRUE;
4974 }
4975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4977 {
4978 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4979 if(!HAL_STATUS_SUCCESS(status))
4980 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004981 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 //roam command is completed by caller in the failed case
4983 fComplete = eANI_BOOLEAN_TRUE;
4984 }
4985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 else
4987 {
4988 fComplete = eANI_BOOLEAN_TRUE;
4989 }
4990 if(fComplete)
4991 {
4992 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004993 if(eCsrStopRoamingDueToConcurrency == RoamState)
4994 {
4995 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4996 }
4997 else
4998 {
4999 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
5000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 }
5002 }
5003 else if ( eCsrReassocToSelfNoCapChange == RoamState )
5004 {
5005 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
5006 }
5007 else if ( eCsrStartIbssSameIbss == RoamState )
5008 {
5009 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
5010 }
5011 }//hddIsRadioStateOn
5012
5013 return status;
5014}
Jeff Johnson295189b2012-06-20 16:38:30 -07005015eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5016{
5017 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05305018 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 tCsrScanResult *pScanResult = NULL;
5020 tSirBssDescription *pBssDesc = NULL;
5021 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 sessionId = pCommand->sessionId;
5023 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005024
5025 if(!pSession)
5026 {
5027 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5028 return eHAL_STATUS_FAILURE;
5029 }
5030
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
5032 {
5033 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005034 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
5036 return eHAL_STATUS_FAILURE;
5037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 if (pCommand->u.roamCmd.pRoamBssEntry)
5039 {
5040 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5041 pBssDesc = &pScanResult->Result.BssDescriptor;
5042 }
5043 else
5044 {
5045 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005046 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
5048 return eHAL_STATUS_FAILURE;
5049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
5051 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
5052 return status;
5053}
5054
Jeff Johnson295189b2012-06-20 16:38:30 -07005055eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5056{
5057 eHalStatus status = eHAL_STATUS_SUCCESS;
5058 tCsrRoamInfo roamInfo;
5059 tANI_U32 sessionId = pCommand->sessionId;
5060 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005061
5062 if(!pSession)
5063 {
5064 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5065 return eHAL_STATUS_FAILURE;
5066 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05305067 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5068 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 switch ( pCommand->u.roamCmd.roamReason )
5070 {
5071 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005073 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 case eCsrSmeIssuedDisassocForHandoff:
5076 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
5077#if 0 // TODO : Confirm this change
5078 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
5079#else
5080 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
5081#endif
5082
5083 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005086 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005090 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 case eCsrHddIssuedReassocToSameAP:
5093 case eCsrSmeIssuedReassocToSameAP:
5094 {
5095 tDot11fBeaconIEs *pIes = NULL;
5096
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 if( pSession->pConnectBssDesc )
5098 {
5099 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5100 if(!HAL_STATUS_SUCCESS(status) )
5101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005102 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 }
5104 else
5105 {
5106 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5107 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5108 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5110 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5111 pSession->bRefAssocStartCnt++;
5112 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5113 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5114
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005115 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005116 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5117 &pCommand->u.roamCmd.roamProfile );
5118 if(!HAL_STATUS_SUCCESS(status))
5119 {
5120 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005121 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005122 }
5123
Kiet Lam64c1b492013-07-12 13:56:44 +05305124 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 pIes = NULL;
5126 }
5127 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305128 else
5129 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 break;
5131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005133 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5135 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005138 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5140 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005141
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 case eCsrStopBss:
5143 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5144 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5145 break;
5146
5147 case eCsrForcedDisassocSta:
5148 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5149 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5150 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5151 pCommand->u.roamCmd.reason);
5152 break;
5153
5154 case eCsrForcedDeauthSta:
5155 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5156 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5157 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5158 pCommand->u.roamCmd.reason);
5159 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005160
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005161 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005162 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005163 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5164 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005166
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305167#ifdef WLAN_FEATURE_LFR_MBB
5168 case ecsr_mbb_perform_preauth_reassoc:
5169 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5170 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5171 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305172 if (eHAL_STATUS_SUCCESS != status)
5173 {
5174 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5175 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5176 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5177 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305178 break;
5179#endif
5180
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 default:
5182 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5183
5184 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5185 {
5186 //Remember the roaming profile
5187 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305188 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5189 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305191 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5193 }
5194 }
5195
5196 //At this point, original uapsd_mask is saved in pCurRoamProfile
5197 //uapsd_mask in the pCommand may change from this point on.
5198
5199 // Attempt to roam with the new scan results (if we need to..)
5200 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005201 if(!HAL_STATUS_SUCCESS(status))
5202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005203 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 break;
5206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 return (status);
5208}
5209
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005210void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5211{
5212 pCommand->u.roamCmd.pLastRoamBss = NULL;
5213 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5214 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305215 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005216}
5217
Jeff Johnson295189b2012-06-20 16:38:30 -07005218void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5219{
5220 if(pCommand->u.roamCmd.fReleaseBssList)
5221 {
5222 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5223 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5224 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5225 }
5226 if(pCommand->u.roamCmd.fReleaseProfile)
5227 {
5228 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5229 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5230 }
5231 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5232 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305233 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005234}
5235
Jeff Johnson295189b2012-06-20 16:38:30 -07005236void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5237{
Kiet Lam64c1b492013-07-12 13:56:44 +05305238 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005239}
Jeff Johnson295189b2012-06-20 16:38:30 -07005240void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5241{
5242 tListElem *pEntry;
5243 tSmeCmd *pCommand;
5244 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005245 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5247 if ( pEntry )
5248 {
5249 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 // If the head of the queue is Active and it is a ROAM command, remove
5251 // and put this on the Free queue.
5252 if ( eSmeCommandRoam == pCommand->command )
5253 {
5254 //we need to process the result first before removing it from active list because state changes
5255 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5256 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5257 if( fReleaseCommand )
5258 {
5259 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5260 {
5261 csrReleaseCommandRoam( pMac, pCommand );
5262 }
5263 else
5264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005265 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005266 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 }
5268 }
5269 else
5270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005271 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005272 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 }
5274 }
5275 else
5276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005277 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 }
5279 }
5280 else
5281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005282 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 if( fReleaseCommand )
5285 {
5286 smeProcessPendingQueue( pMac );
5287 }
5288}
5289
Jeff Johnson295189b2012-06-20 16:38:30 -07005290void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5291{
5292 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005293 if(!pSession)
5294 {
5295 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5296 return;
5297 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305298 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5299 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 pSession->NumPmkidCandidate = 0;
5301}
Jeff Johnson295189b2012-06-20 16:38:30 -07005302#ifdef FEATURE_WLAN_WAPI
5303void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5304{
5305 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005306 if(!pSession)
5307 {
5308 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5309 return;
5310 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305311 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5312 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 pSession->NumBkidCandidate = 0;
5314}
5315#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005316extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5317
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305318eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5319 tANI_U32 sessionId, eCsrAuthType authType,
5320 tSirBssDescription *pSirBssDesc,
5321 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005322{
5323 eHalStatus status = eHAL_STATUS_SUCCESS;
5324 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5325 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005326
5327 if(!pSession)
5328 {
5329 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5330 return eHAL_STATUS_FAILURE;
5331 }
5332
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 if((eCSR_AUTH_TYPE_WPA == authType) ||
5334 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5335 (eCSR_AUTH_TYPE_RSN == authType) ||
5336 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5337#if defined WLAN_FEATURE_VOWIFI_11R
5338 ||
5339 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5340 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5341#endif /* FEATURE_WLAN_WAPI */
5342#ifdef FEATURE_WLAN_WAPI
5343 ||
5344 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5345 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5346#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005347#ifdef WLAN_FEATURE_11W
5348 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305349 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5350 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005351#endif /* FEATURE_WLAN_WAPI */
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305352 || (eCSR_AUTH_TYPE_SAE == authType))
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005356 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 }
5358 if( pIesLocal )
5359 {
5360 tANI_U32 nIeLen;
5361 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 if((eCSR_AUTH_TYPE_RSN == authType) ||
5363#if defined WLAN_FEATURE_VOWIFI_11R
5364 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5365 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5366#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005367#if defined WLAN_FEATURE_11W
5368 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305369 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005370#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5372 {
5373 if(pIesLocal->RSN.present)
5374 {
5375 //Calculate the actual length
5376 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5377 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5378 + 2 //akm_suite_count
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305379 + pIesLocal->RSN.akm_suite_cnt * 4 //akm_suites
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 + 2; //reserved
5381 if( pIesLocal->RSN.pmkid_count )
5382 {
5383 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5384 }
5385 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305386 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5387 if (NULL == pSession->pWpaRsnRspIE)
5388 status = eHAL_STATUS_FAILURE;
5389 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305391 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5393 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305394 //copy upto akm_suite
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305396 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5397 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005398 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305399 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5400 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005401 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305402 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5403 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005404 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 if( pIesLocal->RSN.pwise_cipher_suite_count )
5406 {
5407 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305408 vos_mem_copy(pIeBuf,
5409 pIesLocal->RSN.pwise_cipher_suites,
5410 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5412 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305413 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_cnt, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 pIeBuf += 2;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305415 if( pIesLocal->RSN.akm_suite_cnt )
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 {
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305417 //copy akm_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305418 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305419 pIesLocal->RSN.akm_suite,
5420 pIesLocal->RSN.akm_suite_cnt * 4);
5421 pIeBuf += pIesLocal->RSN.akm_suite_cnt * 4;
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 }
5423 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305424 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305425 pIesLocal->RSN.akm_suite + pIesLocal->RSN.akm_suite_cnt * 4,
Kiet Lam64c1b492013-07-12 13:56:44 +05305426 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5428 }
5429 }
5430 }
5431 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5432 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5433 {
5434 if(pIesLocal->WPA.present)
5435 {
5436 //Calculate the actual length
5437 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5438 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5439 + 2 //auth_suite_count
5440 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5441 // The WPA capabilities follows the Auth Suite (two octects)--
5442 // this field is optional, and we always "send" zero, so just
5443 // remove it. This is consistent with our assumptions in the
5444 // frames compiler; c.f. bug 15234:
5445 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305446
5447 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5448 if ( NULL == pSession->pWpaRsnRspIE )
5449 status = eHAL_STATUS_FAILURE;
5450 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 {
5452 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5453 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5454 pIeBuf = pSession->pWpaRsnRspIE + 2;
5455 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305456 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305458 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5459 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305461 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5462 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5464 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5465 }
5466 }
5467 }
5468#ifdef FEATURE_WLAN_WAPI
5469 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5470 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5471 {
5472 if(pIesLocal->WAPI.present)
5473 {
5474 //Calculate the actual length
5475 nIeLen = 4 //version + akm_suite_count
5476 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5477 + 2 //pwise_cipher_suite_count
5478 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5479 + 6; //gp_cipher_suite + preauth + reserved
5480 if( pIesLocal->WAPI.bkid_count )
5481 {
5482 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5483 }
5484
5485 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305486 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5487 if ( NULL == pSession->pWapiRspIE )
5488 status = eHAL_STATUS_FAILURE;
5489 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 {
5491 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5492 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5493 pIeBuf = pSession->pWapiRspIE + 2;
5494 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305495 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 pIeBuf += 4;
5497 if( pIesLocal->WAPI.akm_suite_count )
5498 {
5499 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305500 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5501 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305503 }
5504 vos_mem_copy(pIeBuf,
5505 &pIesLocal->WAPI.unicast_cipher_suite_count,
5506 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5509 {
5510 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305511 vos_mem_copy( pIeBuf,
5512 pIesLocal->WAPI.unicast_cipher_suites,
5513 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5515 }
lukez3c809222013-05-03 10:23:02 -07005516 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305517 vos_mem_copy(pIeBuf,
5518 pIesLocal->WAPI.multicast_cipher_suite,
5519 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005520 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305521 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305522 vos_mem_copy(pIeBuf,
5523 pIesLocal->WAPI.multicast_cipher_suite + 4,
5524 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005525 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305526 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305528 //bkid_count
5529 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5530 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305532 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5533 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5535 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305536 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 }
5539 }
5540#endif /* FEATURE_WLAN_WAPI */
5541 if( !pIes )
5542 {
5543 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305544 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 }
5546 }
5547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 return (status);
5549}
5550
Jeff Johnson295189b2012-06-20 16:38:30 -07005551static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5552{
5553 v_U8_t bACWeights[WLANTL_MAX_AC];
5554 v_U8_t paramBk, paramBe, paramVi, paramVo;
5555 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5557 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5558 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5559 //This doesn't address the case where the lower AC needs a real higher weight
5560 if( pIEs->WMMParams.present )
5561 {
5562 //no change to the lowest ones
5563 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5564 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5565 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5566 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5567 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5568 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5569 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5570 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5571 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5572 {
5573 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5574 fWeightChange = VOS_TRUE;
5575 }
5576 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5577 {
5578 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5579 fWeightChange = VOS_TRUE;
5580 }
5581 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5582 {
5583 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5584 fWeightChange = VOS_TRUE;
5585 }
5586 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5587 {
5588 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5589 fWeightChange = VOS_TRUE;
5590 }
5591 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5592 {
5593 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5594 fWeightChange = VOS_TRUE;
5595 }
5596 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5597 {
5598 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5599 fWeightChange = VOS_TRUE;
5600 }
5601 if(fWeightChange)
5602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005603 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 bACWeights[2], bACWeights[3]);
5605 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5606 }
5607 }
5608}
Jeff Johnson295189b2012-06-20 16:38:30 -07005609#ifdef WLAN_FEATURE_VOWIFI_11R
5610//Returns whether the current association is a 11r assoc or not
5611tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5612{
5613#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5614 return csrNeighborRoamIs11rAssoc(pMac);
5615#else
5616 return eANI_BOOLEAN_FALSE;
5617#endif
5618}
5619#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005620#ifdef FEATURE_WLAN_ESE
5621//Returns whether the current association is a ESE assoc or not
5622tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005623{
5624#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005625 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005626#else
5627 return eANI_BOOLEAN_FALSE;
5628#endif
5629}
5630#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005631#ifdef FEATURE_WLAN_LFR
5632//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305633tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005634{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305635 tCsrRoamSession *pSession = NULL;
5636
5637 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5638 {
5639 pSession = CSR_GET_SESSION( pMac, sessionId );
5640 if (NULL != pSession->pCurRoamProfile)
5641 {
5642 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5643 {
5644 return eANI_BOOLEAN_FALSE;
5645 }
5646 }
5647 }
5648
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005649#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5650 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5651 {
5652 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5653 }
5654 else
5655#endif
5656 {
5657 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005658 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005659 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005660}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005661
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005662#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005663/* ---------------------------------------------------------------------------
5664
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005665 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005666
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005667 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005668
5669 \param pMac - The handle returned by macOpen.
5670
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005671 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005672
5673---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005674tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005675{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005676 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005677}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005678#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005679
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005680#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5681//Returns whether "FW based BG scan" is currently enabled...or not
5682tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5683{
5684 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5685}
5686#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005687#endif
5688
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005689#if defined(FEATURE_WLAN_ESE)
5690tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005691{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005692 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005693}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005694#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005695
Jeff Johnson295189b2012-06-20 16:38:30 -07005696//Return true means the command can be release, else not
5697static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5698 eCsrRoamCompleteResult Result, void *Context )
5699{
5700 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5701 tSirBssDescription *pSirBssDesc = NULL;
5702 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5703 tCsrScanResult *pScanResult = NULL;
5704 tCsrRoamInfo roamInfo;
5705 sme_QosAssocInfo assocInfo;
5706 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5707 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5708 tDot11fBeaconIEs *pIes = NULL;
5709 tANI_U32 sessionId = pCommand->sessionId;
5710 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5711 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5712 eRoamCmdStatus roamStatus;
5713 eCsrRoamResult roamResult;
5714 eHalStatus status;
5715 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005717
Jeff Johnson32d95a32012-09-10 13:15:23 -07005718 if(!pSession)
5719 {
5720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5721 return eANI_BOOLEAN_FALSE;
5722 }
5723
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005724 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 switch( Result )
5726 {
5727 case eCsrJoinSuccess:
5728 // reset the IDLE timer
5729 // !!
5730 // !! fall through to the next CASE statement here is intentional !!
5731 // !!
5732 case eCsrReassocSuccess:
5733 if(eCsrReassocSuccess == Result)
5734 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305735 roamInfo.reassoc = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5737 }
5738 else
5739 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305740 roamInfo.reassoc = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5742 }
5743 // Success Join Response from LIM. Tell NDIS we are connected and save the
5744 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005745 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305746 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 //always free the memory here
5748 if(pSession->pWpaRsnRspIE)
5749 {
5750 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305751 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 pSession->pWpaRsnRspIE = NULL;
5753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005754#ifdef FEATURE_WLAN_WAPI
5755 if(pSession->pWapiRspIE)
5756 {
5757 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305758 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 pSession->pWapiRspIE = NULL;
5760 }
5761#endif /* FEATURE_WLAN_WAPI */
5762#ifdef FEATURE_WLAN_BTAMP_UT_RF
5763 //Reset counter so no join retry is needed.
5764 pSession->maxRetryCount = 0;
5765 csrRoamStopJoinRetryTimer(pMac, sessionId);
5766#endif
5767 /* This creates problem since we have not saved the connected profile.
5768 So moving this after saving the profile
5769 */
5770 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305771
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305772 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305773 * by last failed secured connection.
5774 * It should be set only for secured connection.
5775 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305776 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5778 {
5779 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5780 }
5781 else
5782 {
5783 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 //Use the last connected bssdesc for reassoc-ing to the same AP.
5786 //NOTE: What to do when reassoc to a different AP???
5787 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5788 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5789 {
5790 pSirBssDesc = pSession->pConnectBssDesc;
5791 if(pSirBssDesc)
5792 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305793 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5794 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 }
5796 }
5797 else
5798 {
5799
5800 if(pCommand->u.roamCmd.pRoamBssEntry)
5801 {
5802 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5803 if(pScanResult != NULL)
5804 {
5805 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5806 //this can be NULL
5807 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305808 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5809 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 }
5811 }
5812 }
5813 if( pSirBssDesc )
5814 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5817 //Save WPA/RSN IE
5818 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005819#ifdef FEATURE_WLAN_ESE
5820 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005821#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305822#ifdef WLAN_FEATURE_VOWIFI_11R
5823 if (pSirBssDesc->mdiePresent)
5824 {
5825 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5826#ifdef FEATURE_WLAN_ESE
5827 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5828 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5829#endif
5830 )
5831 {
5832 // is11Rconnection;
5833 roamInfo.is11rAssoc = VOS_TRUE;
5834 }
5835 else
5836 {
5837 // is11Rconnection;
5838 roamInfo.is11rAssoc = VOS_FALSE;
5839 }
5840 }
5841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5843 // substate change.
5844 // Moving even save profile above so that below mentioned conditon is also met.
5845 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5846 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5848 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5849 // will be dropped for the security context may not be set properly.
5850 //
5851 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5852 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5853 //
5854 // this reordering was done on titan_prod_usb branch and is being replicated here.
5855 //
5856
5857 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5858 !pProfile->bWPSAssociation)
5859 {
5860 // Issue the set Context request to LIM to establish the Unicast STA context
5861 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5862 pProfile->negotiatedUCEncryptionType,
5863 pSirBssDesc, &(pSirBssDesc->bssId),
5864 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005866 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5868 }
5869 // Issue the set Context request to LIM to establish the Broadcast STA context
5870 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5871 pSirBssDesc, &BroadcastMac,
5872 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5873 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305874 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 {
5876 //Need to wait for supplicant authtication
5877 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 //Set the subestate to WaitForKey in case authentiation is needed
5879 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5880
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 if(pProfile->bWPSAssociation)
5882 {
5883 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5884 }
5885 else
5886 {
5887 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5888 }
5889
5890 //Save sessionId in case of timeout
5891 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5892 //This time should be long enough for the rest of the process plus setting key
5893 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5894 {
5895 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005896 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5898 }
5899 }
5900
5901 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5902 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 if(Context)
5904 {
5905 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5906 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5908 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5909#ifdef WLAN_FEATURE_VOWIFI_11R
5910 len += pJoinRsp->parsedRicRspLen;
5911#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005912#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 len += pJoinRsp->tspecIeLen;
5914#endif
5915 if(len)
5916 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305917 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5918 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305920 vos_mem_copy(pSession->connectedInfo.pbFrames,
5921 pJoinRsp->frames, len);
5922 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5923 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5924 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305926 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005927#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005928#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305929 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005930#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305931 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5932 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5933 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5934 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 }
5936 }
5937 if(pCommand->u.roamCmd.fReassoc)
5938 {
5939 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5940 }
5941 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5942 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5943 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5944 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305945 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305946 roamInfo.vht_caps = pJoinRsp->vht_caps;
5947 roamInfo.ht_caps = pJoinRsp->ht_caps;
5948 roamInfo.hs20vendor_ie = pJoinRsp->hs20vendor_ie;
5949 roamInfo.ht_operation = pJoinRsp->ht_operation;
5950 roamInfo.vht_operation = pJoinRsp->vht_operation;
5951
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 }
5953 else
5954 {
5955 if(pCommand->u.roamCmd.fReassoc)
5956 {
5957 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5958 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5959 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5960 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5961 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5962 }
5963 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305964 /* Update the staId from the previous connected profile info
5965 as the reassociation is triggred at SME/HDD */
5966 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5967 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5968 {
5969 roamInfo.staId = pSession->connectedInfo.staId;
5970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005971#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5972 // Indicate SME-QOS with reassoc success event, only after
5973 // copying the frames
5974 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5975#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 roamInfo.pBssDesc = pSirBssDesc;
5977 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5978 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5979#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5980 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5981#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5982 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5984 //It may be better to let QoS do this????
5985 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005987 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5989 pmcStartUapsd( pMac, NULL, NULL );
5990 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305991 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5993 if( pSession->bRefAssocStartCnt > 0 )
5994 {
5995 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005996 //Remove this code once SLM_Sessionization is supported
5997 //BMPS_WORKAROUND_NOT_NEEDED
5998 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005999 {
6000 pMac->roam.configParam.doBMPSWorkaround = 1;
6001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6003 }
6004
6005 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 // reset the PMKID candidate list
6007 csrResetPMKIDCandidateList( pMac, sessionId );
6008 //Update TL's AC weight base on the current EDCA parameters
6009 //These parameters may change in the course of the connection, that sictuation
6010 //is not taken care here. This change is mainly to address a WIFI WMM test where
6011 //BE has a equal or higher TX priority than VI.
6012 //We only do this for infra link
6013 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
6014 {
6015 csrCheckAndUpdateACWeight(pMac, pIes);
6016 }
6017#ifdef FEATURE_WLAN_WAPI
6018 // reset the BKID candidate list
6019 csrResetBKIDCandidateList( pMac, sessionId );
6020#endif /* FEATURE_WLAN_WAPI */
6021 }
6022 else
6023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006024 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 csrScanCancelIdleScan(pMac);
6027 //Not to signal link up because keys are yet to be set.
6028 //The linkup function will overwrite the sub-state that we need to keep at this point.
6029 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
6030 {
6031 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
6032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
6034 //enough to let security and DHCP handshake succeed before entry into BMPS
6035 if (pmcShouldBmpsTimerRun(pMac))
6036 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05306037 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05306038 * until keys are set before going into BMPS.
6039 */
6040 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
6041 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05306042 pMac->pmc.full_power_till_set_key = true;
6043 smsLog(pMac, LOG1,
6044 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 +05306045 }
6046
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
6048 != eHAL_STATUS_SUCCESS)
6049 {
6050 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
6051 }
6052 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
6053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 break;
6055
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 case eCsrStartBssSuccess:
6057 // on the StartBss Response, LIM is returning the Bss Description that we
6058 // are beaconing. Add this Bss Description to our scan results and
6059 // chain the Profile to this Bss Description. On a Start BSS, there was no
6060 // detected Bss description (no partner) so we issued the Start Bss to
6061 // start the Ibss without any Bss description. Lim was kind enough to return
6062 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006063 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05306066 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 if( CSR_IS_IBSS( pProfile ) )
6068 {
6069 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 else if (CSR_IS_INFRA_AP(pProfile))
6072 {
6073 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 else
6076 {
6077 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6078 }
6079 if( !CSR_IS_WDS_STA( pProfile ) )
6080 {
6081 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
6084 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306085 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 roamInfo.pBssDesc = pSirBssDesc;
6087 //We need to associate_complete it first, becasue Associate_start already indicated.
6088 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6089 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
6090 break;
6091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07006094 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 }
6096 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6097 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6098 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6099 if(pSirBssDesc)
6100 {
6101 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306102 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6103 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 }
6105 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306106 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6108 {
6109 vos_log_ibss_pkt_type *pIbssLog;
6110 tANI_U32 bi;
6111
6112 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6113 if(pIbssLog)
6114 {
6115 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6116 {
6117 //We start the IBSS (didn't find any matched IBSS out there)
6118 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6119 }
6120 else
6121 {
6122 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6123 }
6124 if(pSirBssDesc)
6125 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306126 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6128 }
6129 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6130 {
6131 //***U8 is not enough for beacon interval
6132 pIbssLog->beaconInterval = (v_U8_t)bi;
6133 }
6134 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6135 }
6136 }
6137#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6138 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6139 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6141 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6143 csrRoamIssueSetContextReq( pMac, sessionId,
6144 pProfile->negotiatedMCEncryptionType,
6145 pSirBssDesc, &BroadcastMac,
6146 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6147 }
6148 }
6149 else
6150 {
6151 //Keep the state to eCSR_ROAMING_STATE_JOINING
6152 //Need to send join_req.
6153 if(pCommand->u.roamCmd.pRoamBssEntry)
6154 {
6155 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6156 {
6157 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6158 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6159 // Set the roaming substate to 'join attempt'...
6160 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006161 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 }
6163 }
6164 else
6165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006166 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 VOS_ASSERT( 0 );
6168 }
6169 }
6170 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6171 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6172 //trigger the connection start indication in Vista
6173 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6174 {
6175 roamStatus = eCSR_ROAM_IBSS_IND;
6176 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6177 if( CSR_IS_WDS( pProfile ) )
6178 {
6179 roamStatus = eCSR_ROAM_WDS_IND;
6180 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 if( CSR_IS_INFRA_AP( pProfile ) )
6183 {
6184 roamStatus = eCSR_ROAM_INFRA_IND;
6185 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006187
6188 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6189 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6190 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306191 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6193 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006194 //We start the IBSS (didn't find any matched IBSS out there)
6195 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306197 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6198 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006199 //Remove this code once SLM_Sessionization is supported
6200 //BMPS_WORKAROUND_NOT_NEEDED
6201 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006202 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006203 {
6204 pMac->roam.configParam.doBMPSWorkaround = 1;
6205 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006206
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6208 }
6209
6210 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006211
6212 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 {
6214 //need to send stop BSS because we fail to send join_req
6215 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6216 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6217 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 case eCsrStartBssFailure:
6221#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6222 {
6223 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6225 if(pIbssLog)
6226 {
6227 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6228 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6229 }
6230 }
6231#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 roamStatus = eCSR_ROAM_IBSS_IND;
6233 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6234 if( CSR_IS_WDS( pProfile ) )
6235 {
6236 roamStatus = eCSR_ROAM_WDS_IND;
6237 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 if( CSR_IS_INFRA_AP( pProfile ) )
6240 {
6241 roamStatus = eCSR_ROAM_INFRA_IND;
6242 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 if(Context)
6245 {
6246 pSirBssDesc = (tSirBssDescription *)Context;
6247 }
6248 else
6249 {
6250 pSirBssDesc = NULL;
6251 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306252 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 roamInfo.pBssDesc = pSirBssDesc;
6254 //We need to associate_complete it first, becasue Associate_start already indicated.
6255 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6256 csrSetDefaultDot11Mode( pMac );
6257 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 case eCsrSilentlyStopRoaming:
6259 // We are here because we try to start the same IBSS
6260 //No message to PE
6261 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006262 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6264 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306265 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6267 if( roamInfo.pBssDesc )
6268 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306269 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6270 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 }
6272 //Since there is no change in the current state, simply pass back no result otherwise
6273 //HDD may be mistakenly mark to disconnected state.
6274 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6275 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 case eCsrSilentlyStopRoamingSaveState:
6278 //We are here because we try to connect to the same AP
6279 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006280 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306281 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006282
6283 //to aviod resetting the substate to NONE
6284 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6285 //No need to change substate to wai_for_key because there is no state change
6286 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6287 if( roamInfo.pBssDesc )
6288 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306289 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6290 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6293 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6294 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6295 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6296 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6297 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6298 roamInfo.staId = pSession->connectedInfo.staId;
6299 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 pSession->bRefAssocStartCnt--;
6302 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6303 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6304 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6305 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 case eCsrReassocFailure:
6307#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6308 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6309#endif
6310 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006311 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 csrFreeConnectBssDesc(pMac, sessionId);
6313 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6314 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306315 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6317 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6318 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6319 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6320 eCSR_ROAM_WDS_IND,
6321 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6322 //Need to issue stop_bss
6323 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 case eCsrJoinFailure:
6325 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006326 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 default:
6328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006329 smsLog(pMac, LOGW, FL("receives no association indication"));
6330 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006331 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6333 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6334 {
6335 //do not free for the other profiles as we need to send down stop BSS later
6336 csrFreeConnectBssDesc(pMac, sessionId);
6337 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6338 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6339 csrSetDefaultDot11Mode( pMac );
6340 }
6341
6342 switch( pCommand->u.roamCmd.roamReason )
6343 {
6344 // If this transition is because of an 802.11 OID, then we transition
6345 // back to INIT state so we sit waiting for more OIDs to be issued and
6346 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006347 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 case eCsrSmeIssuedAssocToSimilarAP:
6349 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006350 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306352 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6354 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6355 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306356 vos_mem_copy(&roamInfo.bssid,
6357 &pSession->joinFailStatusCode.bssId,
6358 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006359
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 /* Defeaturize this later if needed */
6361#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6362 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6363 if (csrRoamIsHandoffInProgress(pMac))
6364 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 /* Should indicate neighbor roam algorithm about the connect failure here */
6366 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006368#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 if(pSession->bRefAssocStartCnt > 0)
6370 {
6371 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006372 if(eCsrJoinFailureDueToConcurrency == Result)
6373 {
6374 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6375 eCSR_ROAM_ASSOCIATION_COMPLETION,
6376 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6377 }
6378 else
6379 {
6380 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 eCSR_ROAM_ASSOCIATION_COMPLETION,
6382 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006385 else
6386 {
6387 /* bRefAssocStartCnt is not incremented when
6388 * eRoamState == eCsrStopRoamingDueToConcurrency
6389 * in csrRoamJoinNextBss API. so handle this in
6390 * else case by sending assoc failure
6391 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006392 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006393 pCommand->u.scanCmd.roamId,
6394 eCSR_ROAM_ASSOCIATION_FAILURE,
6395 eCSR_ROAM_RESULT_FAILURE);
6396 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006397 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006398#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306399 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6401#endif
6402 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6403 csrScanStartIdleScan(pMac);
6404#ifdef FEATURE_WLAN_BTAMP_UT_RF
6405 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6406 //BT activity and not able to recevie WLAN traffic. Retry the join
6407 if( CSR_IS_WDS_STA(pProfile) )
6408 {
6409 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6410 }
6411#endif
6412 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 case eCsrHddIssuedReassocToSameAP:
6414 case eCsrSmeIssuedReassocToSameAP:
6415 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6416
6417 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6418#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6419 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6420#endif
6421 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6422 csrScanStartIdleScan(pMac);
6423 break;
6424 case eCsrForcedDisassoc:
6425 case eCsrForcedDeauth:
6426 case eCsrSmeIssuedIbssJoinFailure:
6427 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6428
6429 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6430 {
6431 // Notify HDD that IBSS join failed
6432 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6433 }
6434 else
6435 {
6436 csrRoamCallCallback(pMac, sessionId, NULL,
6437 pCommand->u.roamCmd.roamId,
6438 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6439 }
6440#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6441 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6442#endif
6443 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006444 /*
6445 *DelSta not done FW still in conneced state so dont
6446 *issue IMPS req
6447 */
6448 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6449 {
6450 smsLog(pMac, LOGW, FL("FW still in connected state "));
6451 break;
6452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 csrScanStartIdleScan(pMac);
6454 break;
6455 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306456 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 csrRoamCallCallback(pMac, sessionId, NULL,
6458 pCommand->u.roamCmd.roamId,
6459 eCSR_ROAM_IBSS_LEAVE,
6460 eCSR_ROAM_RESULT_IBSS_STOP);
6461 break;
6462 case eCsrForcedDisassocMICFailure:
6463 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6464
6465 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6466#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6467 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6468#endif
6469 csrScanStartIdleScan(pMac);
6470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 case eCsrStopBss:
6472 csrRoamCallCallback(pMac, sessionId, NULL,
6473 pCommand->u.roamCmd.roamId,
6474 eCSR_ROAM_INFRA_IND,
6475 eCSR_ROAM_RESULT_INFRA_STOPPED);
6476 break;
6477 case eCsrForcedDisassocSta:
6478 case eCsrForcedDeauthSta:
6479 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306480 pSession = CSR_GET_SESSION(pMac, sessionId);
6481 if (pSession)
6482 {
6483 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306485 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6486 {
6487 roamInfo.u.pConnectedProfile =
6488 &pSession->connectedProfile;
6489 vos_mem_copy(roamInfo.peerMac,
6490 pCommand->u.roamCmd.peerMac,
6491 sizeof(tSirMacAddr));
6492 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6493 roamInfo.statusCode = eSIR_SME_SUCCESS;
6494 status = csrRoamCallCallback(pMac, sessionId,
6495 &roamInfo, pCommand->u.roamCmd.roamId,
6496 eCSR_ROAM_LOSTLINK,
6497 eCSR_ROAM_RESULT_FORCED);
6498 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306499 }
6500 else
6501 {
6502 smsLog(pMac, LOGE, FL("Inactive session %d"),
6503 sessionId);
6504 return eHAL_STATUS_FAILURE;
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306507 else
6508 {
6509 smsLog(pMac, LOGE, FL("Invalid session"));
6510 return eHAL_STATUS_FAILURE;
6511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 case eCsrLostLink1:
6514 // if lost link roam1 failed, then issue lost link Scan2 ...
6515 csrScanRequestLostLink2(pMac, sessionId);
6516 break;
6517 case eCsrLostLink2:
6518 // if lost link roam2 failed, then issue lost link scan3 ...
6519 csrScanRequestLostLink3(pMac, sessionId);
6520 break;
6521 case eCsrLostLink3:
6522 default:
6523 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6524
6525 //We are done with one round of lostlink roaming here
6526 csrScanHandleFailedLostlink3(pMac, sessionId);
6527 break;
6528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 break;
6530 }
6531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 return ( fReleaseCommand );
6533}
6534
Jeff Johnson295189b2012-06-20 16:38:30 -07006535eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6536{
6537 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 return (status);
6539}
6540
Jeff Johnson295189b2012-06-20 16:38:30 -07006541eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6542{
6543 eHalStatus status = eHAL_STATUS_SUCCESS;
6544 tANI_U32 size = 0;
6545
6546 do
6547 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306548 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6550 {
6551 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306552 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6553 if ( NULL == pDstProfile->BSSIDs.bssid )
6554 status = eHAL_STATUS_FAILURE;
6555 else
6556 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 if(!HAL_STATUS_SUCCESS(status))
6558 {
6559 break;
6560 }
6561 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306562 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6563 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 }
6565 if(pSrcProfile->SSIDs.numOfSSIDs)
6566 {
6567 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306568 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6569 if ( NULL == pDstProfile->SSIDs.SSIDList )
6570 status = eHAL_STATUS_FAILURE;
6571 else
6572 status = eHAL_STATUS_SUCCESS;
6573 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 {
6575 break;
6576 }
6577 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306578 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6579 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 }
6581 if(pSrcProfile->nWPAReqIELength)
6582 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306583 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6584 if ( NULL == pDstProfile->pWPAReqIE )
6585 status = eHAL_STATUS_FAILURE;
6586 else
6587 status = eHAL_STATUS_SUCCESS;
6588
6589 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 {
6591 break;
6592 }
6593 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306594 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6595 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 }
6597 if(pSrcProfile->nRSNReqIELength)
6598 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306599 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6600 if ( NULL == pDstProfile->pRSNReqIE )
6601 status = eHAL_STATUS_FAILURE;
6602 else
6603 status = eHAL_STATUS_SUCCESS;
6604
6605 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 {
6607 break;
6608 }
6609 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306610 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6611 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 }
6613#ifdef FEATURE_WLAN_WAPI
6614 if(pSrcProfile->nWAPIReqIELength)
6615 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306616 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6617 if ( NULL == pDstProfile->pWAPIReqIE )
6618 status = eHAL_STATUS_FAILURE;
6619 else
6620 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 if(!HAL_STATUS_SUCCESS(status))
6622 {
6623 break;
6624 }
6625 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306626 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6627 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 }
6629#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 if(pSrcProfile->nAddIEScanLength)
6631 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306632 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6633 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306635 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306636 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306637 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6638 }
6639 else
6640 {
6641 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6642 FL(" AddIEScanLength is not valid %u"),
6643 pSrcProfile->nAddIEScanLength);
6644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 if(pSrcProfile->nAddIEAssocLength)
6647 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306648 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6649 if ( NULL == pDstProfile->pAddIEAssoc )
6650 status = eHAL_STATUS_FAILURE;
6651 else
6652 status = eHAL_STATUS_SUCCESS;
6653
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 if(!HAL_STATUS_SUCCESS(status))
6655 {
6656 break;
6657 }
6658 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306659 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6660 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 if(pSrcProfile->ChannelInfo.ChannelList)
6663 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306664 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6665 pSrcProfile->ChannelInfo.numOfChannels);
6666 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6667 status = eHAL_STATUS_FAILURE;
6668 else
6669 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 if(!HAL_STATUS_SUCCESS(status))
6671 {
6672 break;
6673 }
6674 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306675 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6676 pSrcProfile->ChannelInfo.ChannelList,
6677 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 pDstProfile->AuthType = pSrcProfile->AuthType;
6680 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6681 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6682 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6683 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6684 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006685#ifdef WLAN_FEATURE_11W
6686 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6687 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6688 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6689#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 pDstProfile->BSSType = pSrcProfile->BSSType;
6691 pDstProfile->phyMode = pSrcProfile->phyMode;
6692 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6693
6694#ifdef FEATURE_WLAN_WAPI
6695 if(csrIsProfileWapi(pSrcProfile))
6696 {
6697 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6698 {
6699 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6700 }
6701 }
6702#endif /* FEATURE_WLAN_WAPI */
6703 pDstProfile->CBMode = pSrcProfile->CBMode;
6704 /*Save the WPS info*/
6705 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006706 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 pDstProfile->privacy = pSrcProfile->privacy;
6710 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6711 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6712 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6713 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6714 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6715 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6716 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6717 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6718 pDstProfile->wps_state = pSrcProfile->wps_state;
6719 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Abhishek Singhe3beee22017-07-31 15:35:40 +05306720 pDstProfile->force_24ghz_in_ht20 =
6721 pSrcProfile->force_24ghz_in_ht20;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05306722 pDstProfile->force_rsne_override = pSrcProfile->force_rsne_override;
Kiet Lam64c1b492013-07-12 13:56:44 +05306723 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6724 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006725#ifdef WLAN_FEATURE_VOWIFI_11R
6726 if (pSrcProfile->MDID.mdiePresent)
6727 {
6728 pDstProfile->MDID.mdiePresent = 1;
6729 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6730 }
6731#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 }while(0);
6733
6734 if(!HAL_STATUS_SUCCESS(status))
6735 {
6736 csrReleaseProfile(pMac, pDstProfile);
6737 pDstProfile = NULL;
6738 }
6739
6740 return (status);
6741}
Jeff Johnson295189b2012-06-20 16:38:30 -07006742eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6743{
6744 eHalStatus status = eHAL_STATUS_SUCCESS;
6745 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6746 do
6747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306748 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 if(pSrcProfile->bssid)
6750 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306751 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6752 if ( NULL == pDstProfile->BSSIDs.bssid )
6753 status = eHAL_STATUS_FAILURE;
6754 else
6755 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 if(!HAL_STATUS_SUCCESS(status))
6757 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306758 smsLog( pMac, LOGE,
6759 FL("failed to allocate memory for BSSID"
6760 "%02x:%02x:%02x:%02x:%02x:%02x"),
6761 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6762 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 break;
6764 }
6765 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306766 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6767 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 }
6769 if(pSrcProfile->SSID.ssId)
6770 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306771 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6772 if ( NULL == pDstProfile->SSIDs.SSIDList )
6773 status = eHAL_STATUS_FAILURE;
6774 else
6775 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 if(!HAL_STATUS_SUCCESS(status))
6777 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306778 smsLog( pMac, LOGE,
6779 FL("failed to allocate memory for SSIDList"
6780 "%02x:%02x:%02x:%02x:%02x:%02x"),
6781 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6782 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 break;
6784 }
6785 pDstProfile->SSIDs.numOfSSIDs = 1;
6786 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6787 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306788 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6789 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006791 if(pSrcProfile->nAddIEAssocLength)
6792 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306793 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6794 if ( NULL == pDstProfile->pAddIEAssoc)
6795 status = eHAL_STATUS_FAILURE;
6796 else
6797 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006798 if(!HAL_STATUS_SUCCESS(status))
6799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006800 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006801 break;
6802 }
6803 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306804 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6805 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006806 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306807 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6808 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6809 status = eHAL_STATUS_FAILURE;
6810 else
6811 status = eHAL_STATUS_SUCCESS;
6812
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 if(!HAL_STATUS_SUCCESS(status))
6814 {
6815 break;
6816 }
6817 pDstProfile->ChannelInfo.numOfChannels = 1;
6818 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 pDstProfile->AuthType.numEntries = 1;
6820 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6821 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6822 pDstProfile->EncryptionType.numEntries = 1;
6823 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6824 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6825 pDstProfile->mcEncryptionType.numEntries = 1;
6826 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6827 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6828 pDstProfile->BSSType = pSrcProfile->BSSType;
6829 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306830 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6831 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306832#ifdef WLAN_FEATURE_11W
6833 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6834 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6835 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6836#endif
6837
Jeff Johnson295189b2012-06-20 16:38:30 -07006838#ifdef WLAN_FEATURE_VOWIFI_11R
6839 if (pSrcProfile->MDID.mdiePresent)
6840 {
6841 pDstProfile->MDID.mdiePresent = 1;
6842 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6843 }
6844#endif
6845
6846 }while(0);
6847
6848 if(!HAL_STATUS_SUCCESS(status))
6849 {
6850 csrReleaseProfile(pMac, pDstProfile);
6851 pDstProfile = NULL;
6852 }
6853
6854 return (status);
6855}
6856
Jeff Johnson295189b2012-06-20 16:38:30 -07006857eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6858 tScanResultHandle hBSSList,
6859 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6860 tANI_BOOLEAN fClearScan)
6861{
6862 eHalStatus status = eHAL_STATUS_SUCCESS;
6863 tSmeCmd *pCommand;
6864
6865 pCommand = csrGetCommandBuffer(pMac);
6866 if(NULL == pCommand)
6867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006868 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 status = eHAL_STATUS_RESOURCES;
6870 }
6871 else
6872 {
6873 if( fClearScan )
6874 {
6875 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306876 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 }
6878 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6879 if(NULL == pProfile)
6880 {
6881 //We can roam now
6882 //Since pProfile is NULL, we need to build our own profile, set everything to default
6883 //We can only support open and no encryption
6884 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6885 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6886 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6887 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6888 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6889 }
6890 else
6891 {
6892 //make a copy of the profile
6893 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6894 if(HAL_STATUS_SUCCESS(status))
6895 {
6896 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6897 }
6898 }
6899 pCommand->command = eSmeCommandRoam;
6900 pCommand->sessionId = (tANI_U8)sessionId;
6901 pCommand->u.roamCmd.hBSSList = hBSSList;
6902 pCommand->u.roamCmd.roamId = roamId;
6903 pCommand->u.roamCmd.roamReason = reason;
6904 //We need to free the BssList when the command is done
6905 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6906 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6908 FL("CSR PERSONA=%d"),
6909 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6911 if( !HAL_STATUS_SUCCESS( status ) )
6912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006913 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 csrReleaseCommandRoam( pMac, pCommand );
6915 }
6916 }
6917
6918 return (status);
6919}
Jeff Johnson295189b2012-06-20 16:38:30 -07006920eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6921 tCsrRoamModifyProfileFields *pMmodProfileFields,
6922 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6923{
6924 eHalStatus status = eHAL_STATUS_SUCCESS;
6925 tSmeCmd *pCommand;
6926
6927 pCommand = csrGetCommandBuffer(pMac);
6928 if(NULL == pCommand)
6929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006930 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 status = eHAL_STATUS_RESOURCES;
6932 }
6933 else
6934 {
6935 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306936 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 if(pProfile)
6938 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 //This is likely trying to reassoc to different profile
6940 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6941 //make a copy of the profile
6942 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6943 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 }
6945 else
6946 {
6947 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6948 //how to update WPA/WPA2 info in roamProfile??
6949 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 if(HAL_STATUS_SUCCESS(status))
6952 {
6953 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6954 }
6955 pCommand->command = eSmeCommandRoam;
6956 pCommand->sessionId = (tANI_U8)sessionId;
6957 pCommand->u.roamCmd.roamId = roamId;
6958 pCommand->u.roamCmd.roamReason = reason;
6959 //We need to free the BssList when the command is done
6960 //For reassoc there is no BSS list, so the boolean set to false
6961 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6962 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6963 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6965 if( !HAL_STATUS_SUCCESS( status ) )
6966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006967 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6969 csrReleaseCommandRoam( pMac, pCommand );
6970 }
6971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 return (status);
6973}
6974
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006975eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6976 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306977// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006978{
6979 eHalStatus status = eHAL_STATUS_SUCCESS;
6980 tSmeCmd *pCommand;
6981
6982 pCommand = csrGetCommandBuffer(pMac);
6983 if(NULL == pCommand)
6984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006985 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006986 status = eHAL_STATUS_RESOURCES;
6987 }
6988 else
6989 {
6990 if(pBssDescription)
6991 {
6992 //copy over the parameters we need later
6993 pCommand->command = eSmeCommandRoam;
6994 pCommand->sessionId = (tANI_U8)sessionId;
6995 pCommand->u.roamCmd.roamReason = reason;
6996 //this is the important parameter
6997 //in this case we are using this field for the "next" BSS
6998 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6999 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
7000 if( !HAL_STATUS_SUCCESS( status ) )
7001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007002 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007003 csrReleaseCommandPreauth( pMac, pCommand );
7004 }
7005 }
7006 else
7007 {
7008 //Return failure
7009 status = eHAL_STATUS_RESOURCES;
7010 }
7011 }
7012 return (status);
7013}
7014
7015eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
7016{
7017 tListElem *pEntry;
7018 tSmeCmd *pCommand;
7019 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7020 if ( pEntry )
7021 {
7022 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7023 if ( (eSmeCommandRoam == pCommand->command) &&
7024 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
7025 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007026 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007027 pCommand->command, pCommand->u.roamCmd.roamReason);
7028 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
7029 csrReleaseCommandPreauth( pMac, pCommand );
7030 }
7031 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007032 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007033 pCommand->command, pCommand->u.roamCmd.roamReason);
7034 }
7035 }
7036 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007037 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007038 }
7039 smeProcessPendingQueue( pMac );
7040 return eHAL_STATUS_SUCCESS;
7041}
7042
Jeff Johnson295189b2012-06-20 16:38:30 -07007043eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7044 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7045{
7046 eHalStatus status = eHAL_STATUS_FAILURE;
7047 tScanResultHandle hBSSList;
7048 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007049 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
7050 if(HAL_STATUS_SUCCESS(status))
7051 {
7052 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7053 if(pRoamId)
7054 {
7055 *pRoamId = roamId;
7056 }
7057 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7058 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7059 if(!HAL_STATUS_SUCCESS(status))
7060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007061 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 csrScanResultPurge(pMac, hBSSList);
7063 }
7064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 return (status);
7066}
7067
Jeff Johnson295189b2012-06-20 16:38:30 -07007068eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7069 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7070{
7071 eHalStatus status = eHAL_STATUS_SUCCESS;
7072 tScanResultHandle hBSSList;
7073 tCsrScanResultFilter *pScanFilter;
7074 tANI_U32 roamId = 0;
7075 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
7076 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 if (NULL == pProfile)
7078 {
7079 smsLog(pMac, LOGP, FL("No profile specified"));
7080 return eHAL_STATUS_FAILURE;
7081 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307082 if(!pSession)
7083 {
7084 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7085 return eHAL_STATUS_FAILURE;
7086 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307087 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7088 "encryType = %d"),
7089 lim_BssTypetoString(pProfile->BSSType),
7090 pProfile->BSSType,
7091 pProfile->AuthType.authType[0],
7092 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 if( CSR_IS_WDS( pProfile ) &&
7094 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
7095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007096 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007097 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 return status;
7099 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307100 /* Reset abortConnection for the fresh connection */
7101 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 csrRoamCancelRoaming(pMac, sessionId);
7103 csrScanRemoveFreshScanCommand(pMac, sessionId);
7104 csrScanCancelIdleScan(pMac);
7105 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307106 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307107
7108 if (!vos_concurrent_open_sessions_running() &&
7109 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307111 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 csrScanDisable(pMac);
7113 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307114
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7116 //Check whether ssid changes
7117 if(csrIsConnStateConnected(pMac, sessionId))
7118 {
7119 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7120 {
7121 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7122 }
7123 }
7124#ifdef FEATURE_WLAN_BTAMP_UT_RF
7125 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7126#endif
Abhishek Singh5de9efd2017-06-15 10:22:39 +05307127
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7129 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007130 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7132 if(pRoamId)
7133 {
7134 roamId = *pRoamId;
7135 }
7136 if(!HAL_STATUS_SUCCESS(status))
7137 {
7138 fCallCallback = eANI_BOOLEAN_TRUE;
7139 }
7140 }
7141 else
7142 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307143 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7144 if ( NULL == pScanFilter )
7145 status = eHAL_STATUS_FAILURE;
7146 else
7147 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 if(HAL_STATUS_SUCCESS(status))
7149 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307150 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 //Try to connect to any BSS
7152 if(NULL == pProfile)
7153 {
7154 //No encryption
7155 pScanFilter->EncryptionType.numEntries = 1;
7156 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7157 }//we don't have a profile
7158 else
7159 {
7160 //Here is the profile we need to connect to
7161 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7162 }//We have a profile
7163 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7164 if(pRoamId)
7165 {
7166 *pRoamId = roamId;
7167 }
7168
7169 if(HAL_STATUS_SUCCESS(status))
7170 {
7171 /*Save the WPS info*/
7172 if(NULL != pProfile)
7173 {
7174 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007175 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 }
7177 else
7178 {
7179 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007180 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 do
7183 {
7184 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 )
7187 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007188 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7190 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7191 if(!HAL_STATUS_SUCCESS(status))
7192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007193 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 fCallCallback = eANI_BOOLEAN_TRUE;
7195 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007196 else
7197 {
7198 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 break;
7201 }
7202 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007203 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 if(HAL_STATUS_SUCCESS(status))
7205 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7207 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7208 if(!HAL_STATUS_SUCCESS(status))
7209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007210 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 csrScanResultPurge(pMac, hBSSList);
7212 fCallCallback = eANI_BOOLEAN_TRUE;
7213 }
7214 }//Have scan result
7215 else if(NULL != pProfile)
7216 {
7217 //Check whether it is for start ibss
7218 if(CSR_IS_START_IBSS(pProfile))
7219 {
7220 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7221 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7222 if(!HAL_STATUS_SUCCESS(status))
7223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007224 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 fCallCallback = eANI_BOOLEAN_TRUE;
7226 }
7227 }
7228 else
7229 {
7230 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007231 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 if(!HAL_STATUS_SUCCESS(status))
7233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007234 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 fCallCallback = eANI_BOOLEAN_TRUE;
7236 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007237 else
7238 {
7239 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 }
7242 }
7243 else
7244 {
7245 fCallCallback = eANI_BOOLEAN_TRUE;
7246 }
7247 } while (0);
7248 if(NULL != pProfile)
7249 {
7250 //we need to free memory for filter if profile exists
7251 csrFreeScanFilter(pMac, pScanFilter);
7252 }
7253 }//Got the scan filter from profile
7254
Kiet Lam64c1b492013-07-12 13:56:44 +05307255 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 }//allocated memory for pScanFilter
7257 }//No Bsslist coming in
7258 //tell the caller if we fail to trigger a join request
7259 if( fCallCallback )
7260 {
7261 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7262 }
7263
7264 return (status);
7265}
Jeff Johnson295189b2012-06-20 16:38:30 -07007266eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7267 tCsrRoamModifyProfileFields modProfileFields,
7268 tANI_U32 *pRoamId)
7269{
7270 eHalStatus status = eHAL_STATUS_SUCCESS;
7271 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7272 tANI_U32 roamId = 0;
7273 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 if (NULL == pProfile)
7275 {
7276 smsLog(pMac, LOGP, FL("No profile specified"));
7277 return eHAL_STATUS_FAILURE;
7278 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307279 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7280 "encryType = %d"),
7281 lim_BssTypetoString(pProfile->BSSType),
7282 pProfile->BSSType,
7283 pProfile->AuthType.authType[0],
7284 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 csrRoamCancelRoaming(pMac, sessionId);
7286 csrScanRemoveFreshScanCommand(pMac, sessionId);
7287 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307288 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 if(csrIsConnStateConnected(pMac, sessionId))
7291 {
7292 if(pProfile)
7293 {
7294 if(pProfile->SSIDs.numOfSSIDs &&
7295 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7296 {
7297 fCallCallback = eANI_BOOLEAN_FALSE;
7298 }
7299 else
7300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007301 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 }
7303 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307304 else if (!vos_mem_compare(&modProfileFields,
7305 &pSession->connectedProfile.modifyProfileFields,
7306 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 {
7308 fCallCallback = eANI_BOOLEAN_FALSE;
7309 }
7310 else
7311 {
7312 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007313 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 }
7315 }
7316 else
7317 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007318 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 if(!fCallCallback)
7321 {
7322 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7323 if(pRoamId)
7324 {
7325 *pRoamId = roamId;
7326 }
7327
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7329 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 }
7331 else
7332 {
7333 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7334 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 return status;
7337}
Jeff Johnson295189b2012-06-20 16:38:30 -07007338eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7339{
7340 eHalStatus status = eHAL_STATUS_FAILURE;
7341 tScanResultHandle hBSSList = NULL;
7342 tCsrScanResultFilter *pScanFilter = NULL;
7343 tANI_U32 roamId;
7344 tCsrRoamProfile *pProfile = NULL;
7345 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007346
7347 if(!pSession)
7348 {
7349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7350 return eHAL_STATUS_FAILURE;
7351 }
7352
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 do
7354 {
7355 if(pSession->pCurRoamProfile)
7356 {
7357 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307358 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307360 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7361 if ( NULL == pProfile )
7362 status = eHAL_STATUS_FAILURE;
7363 else
7364 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 if(!HAL_STATUS_SUCCESS(status))
7366 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307367 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307369 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307371 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7372 if ( NULL == pScanFilter )
7373 status = eHAL_STATUS_FAILURE;
7374 else
7375 status = eHAL_STATUS_SUCCESS;
7376
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 if(!HAL_STATUS_SUCCESS(status))
7378 {
7379 break;
7380 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307381 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7383 if(!HAL_STATUS_SUCCESS(status))
7384 {
7385 break;
7386 }
7387 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7388 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7389 if(HAL_STATUS_SUCCESS(status))
7390 {
7391 //we want to put the last connected BSS to the very beginning, if possible
7392 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7393 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7394 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7395 if(!HAL_STATUS_SUCCESS(status))
7396 {
7397 csrScanResultPurge(pMac, hBSSList);
7398 break;
7399 }
7400 }
7401 else
7402 {
7403 //Do a scan on this profile
7404 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007405 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 if(!HAL_STATUS_SUCCESS(status))
7407 {
7408 break;
7409 }
7410 }
7411 }//We have a profile
7412 else
7413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007414 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 break;
7416 }
7417 }while(0);
7418 if(pScanFilter)
7419 {
7420 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307421 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007422 }
7423 if(NULL != pProfile)
7424 {
7425 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307426 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 return (status);
7429}
Jeff Johnson295189b2012-06-20 16:38:30 -07007430eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7431{
7432 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 if(csrIsConnStateConnected(pMac, sessionId))
7434 {
7435 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7436 if(HAL_STATUS_SUCCESS(status))
7437 {
7438 status = csrRoamJoinLastProfile(pMac, sessionId);
7439 }
7440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007441 return (status);
7442}
7443
Jeff Johnson295189b2012-06-20 16:38:30 -07007444eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7445{
7446 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007447 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 csrRoamCancelRoaming(pMac, sessionId);
7449 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7450 if(csrIsConnStateDisconnected(pMac, sessionId))
7451 {
7452 status = csrRoamJoinLastProfile(pMac, sessionId);
7453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 return (status);
7455}
7456
Jeff Johnson295189b2012-06-20 16:38:30 -07007457eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7458{
7459 eHalStatus status = eHAL_STATUS_SUCCESS;
7460 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7461 eCsrRoamSubState NewSubstate;
7462 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307463
7464 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7465 {
7466 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7467 " eCSR_ROAM_SUBSTATE_NONE"));
7468 csrRoamStopWaitForKeyTimer( pMac );
7469 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007471 // change state to 'Roaming'...
7472 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7473
7474 if ( csrIsConnStateIbss( pMac, sessionId ) )
7475 {
7476 // If we are in an IBSS, then stop the IBSS...
7477 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7478 fComplete = (!HAL_STATUS_SUCCESS(status));
7479 }
7480 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007482 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 -07007483 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7484 //Restore AC weight in case we change it
7485 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7486 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7487 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7488 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7489 {
7490 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7491 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307492 else
7493 {
7494 // If we are in neighbor preauth done state then on receiving
7495 // disassoc or deauth we dont roam instead we just disassoc
7496 // from current ap and then go to disconnected state
7497 // This happens for ESE and 11r FT connections ONLY.
7498#ifdef WLAN_FEATURE_VOWIFI_11R
7499 if (csrRoamIs11rAssoc(pMac) &&
7500 (csrNeighborRoamStatePreauthDone(pMac)))
7501 {
7502 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7503 }
7504#endif
7505#ifdef FEATURE_WLAN_ESE
7506 if (csrRoamIsESEAssoc(pMac) &&
7507 (csrNeighborRoamStatePreauthDone(pMac)))
7508 {
7509 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7510 }
7511#endif
7512#ifdef FEATURE_WLAN_LFR
7513 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7514 (csrNeighborRoamStatePreauthDone(pMac)))
7515 {
7516 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7517 }
7518#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307519#ifdef WLAN_FEATURE_LFR_MBB
7520 csr_stop_preauth_reassoc_mbb_timer(pMac);
7521#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307522 }
7523
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 if( fDisassoc )
7525 {
7526 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307527 if (pMac->roam.configParam.roamDelayStatsEnabled)
7528 {
7529 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 }
7532 else
7533 {
7534 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7535 }
7536 fComplete = (!HAL_STATUS_SUCCESS(status));
7537 }
7538 else if ( csrIsConnStateWds( pMac, sessionId ) )
7539 {
7540 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7541 {
7542 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7543 fComplete = (!HAL_STATUS_SUCCESS(status));
7544 }
7545 //This has to be WDS station
7546 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7547 {
7548
7549 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7550 if( fDisassoc )
7551 {
7552 status = csrRoamIssueDisassociate( pMac, sessionId,
7553 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7554 fComplete = (!HAL_STATUS_SUCCESS(status));
7555 }
7556 }
7557 } else {
7558 // we got a dis-assoc request while not connected to any peer
7559 // just complete the command
7560 fComplete = eANI_BOOLEAN_TRUE;
7561 status = eHAL_STATUS_FAILURE;
7562 }
7563 if(fComplete)
7564 {
7565 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7566 }
7567
7568 if(HAL_STATUS_SUCCESS(status))
7569 {
7570 if ( csrIsConnStateInfra( pMac, sessionId ) )
7571 {
7572 //Set the state to disconnect here
7573 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307574#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7575 //we don't need to run this timer any more
7576 if (VOS_TIMER_STATE_RUNNING ==
7577 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7578 {
7579 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7580 if (status != eHAL_STATUS_SUCCESS)
7581 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7582 }
7583#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 }
7585 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007586 else
7587 {
7588 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 return (status);
7591}
7592
Jeff Johnson295189b2012-06-20 16:38:30 -07007593/* This is been removed from latest code base */
7594/*
7595static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7596{
7597 eHalStatus status;
7598 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7600 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 return ( status );
7602}
7603*/
7604
Jeff Johnson295189b2012-06-20 16:38:30 -07007605eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7606{
7607 eHalStatus status = eHAL_STATUS_SUCCESS;
7608 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307609
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 do
7611 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 pCommand = csrGetCommandBuffer( pMac );
7613 if ( !pCommand )
7614 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007615 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 status = eHAL_STATUS_RESOURCES;
7617 break;
7618 }
7619 //Change the substate in case it is wait-for-key
7620 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7621 {
7622 csrRoamStopWaitForKeyTimer( pMac );
7623 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7624 }
7625 pCommand->command = eSmeCommandRoam;
7626 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307627 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7628 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007629 switch ( reason )
7630 {
7631 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7632 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 case eCSR_DISCONNECT_REASON_DEAUTH:
7635 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7639 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7641 case eCSR_DISCONNECT_REASON_DISASSOC:
7642 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7645 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7648 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 default:
7651 break;
7652 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307653 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 if( !HAL_STATUS_SUCCESS( status ) )
7655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007656 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 csrReleaseCommandRoam( pMac, pCommand );
7658 }
7659 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 return( status );
7661}
7662
Jeff Johnson295189b2012-06-20 16:38:30 -07007663eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7664{
7665 eHalStatus status = eHAL_STATUS_SUCCESS;
7666 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 pCommand = csrGetCommandBuffer( pMac );
7668 if ( NULL != pCommand )
7669 {
7670 //Change the substate in case it is wait-for-key
7671 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7672 {
7673 csrRoamStopWaitForKeyTimer( pMac );
7674 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7675 }
7676 pCommand->command = eSmeCommandRoam;
7677 pCommand->sessionId = (tANI_U8)sessionId;
7678 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7679 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7680 if( !HAL_STATUS_SUCCESS( status ) )
7681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007682 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 csrReleaseCommandRoam( pMac, pCommand );
7684 }
7685 }
7686 else
7687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007688 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 status = eHAL_STATUS_RESOURCES;
7690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 return ( status );
7692}
7693
Jeff Johnson295189b2012-06-20 16:38:30 -07007694eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7695{
7696 eHalStatus status = eHAL_STATUS_SUCCESS;
7697 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007698
7699 if(!pSession)
7700 {
7701 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7702 return eHAL_STATUS_FAILURE;
7703 }
7704
Jeff Johnson295189b2012-06-20 16:38:30 -07007705#ifdef FEATURE_WLAN_BTAMP_UT_RF
7706 //Stop te retry
7707 pSession->maxRetryCount = 0;
7708 csrRoamStopJoinRetryTimer(pMac, sessionId);
7709#endif
7710 //Not to call cancel roaming here
7711 //Only issue disconnect when necessary
7712 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7713 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7714 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7715
7716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007717 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7719 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307720 else
7721 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307722 csrScanAbortScanForSSID(pMac, sessionId);
Mukul Sharma11841b42017-07-05 13:10:09 +05307723 csrScanStartIdleScan(pMac);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307724 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307725 smsLog(pMac, LOGE,
7726 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 return (status);
7729}
7730
Jeff Johnson295189b2012-06-20 16:38:30 -07007731eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7732{
7733 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007734
7735 if(!pSession)
7736 {
7737 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7738 return eHAL_STATUS_FAILURE;
7739 }
7740
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7743
7744 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7745}
7746
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307747void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7748{
7749 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7750 if(!pSession)
7751 {
7752 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7753 return;
7754 }
7755 pSession->abortConnection = TRUE;
7756 return;
7757}
7758
Jeff Johnson295189b2012-06-20 16:38:30 -07007759eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7760 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7761{
7762 eHalStatus status = eHAL_STATUS_SUCCESS;
7763 tDot11fBeaconIEs *pIesTemp = pIes;
7764 tANI_U8 index;
7765 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7766 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007767
7768 if(!pSession)
7769 {
7770 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7771 return eHAL_STATUS_FAILURE;
7772 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007773 if(pConnectProfile->pAddIEAssoc)
7774 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307775 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007776 pConnectProfile->pAddIEAssoc = NULL;
7777 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307778 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7780 pConnectProfile->AuthInfo = pProfile->AuthType;
7781 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7782 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7783 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7784 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7785 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7786 pConnectProfile->BSSType = pProfile->BSSType;
7787 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7788 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007789 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307790 if (!pConnectProfile->beaconInterval)
7791 {
7792 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7793 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307794 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007795 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7796 if(pProfile->nAddIEAssocLength)
7797 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307798 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7799 if ( NULL == pConnectProfile->pAddIEAssoc )
7800 status = eHAL_STATUS_FAILURE;
7801 else
7802 status = eHAL_STATUS_SUCCESS;
7803 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007804 {
7805 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7806 return eHAL_STATUS_FAILURE;
7807 }
7808 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307809 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7810 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007811 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307812
7813#ifdef WLAN_FEATURE_11W
7814 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7815 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7816 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7817#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007818
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 //Save bssid
7820 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7821#ifdef WLAN_FEATURE_VOWIFI_11R
7822 if (pSirBssDesc->mdiePresent)
7823 {
7824 pConnectProfile->MDID.mdiePresent = 1;
7825 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7826 }
7827#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007828 if( NULL == pIesTemp )
7829 {
7830 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7831 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007832#ifdef FEATURE_WLAN_ESE
7833 if ((csrIsProfileESE(pProfile) ||
7834 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307835 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7836 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7837 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7838 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7839#ifdef WLAN_FEATURE_11W
7840 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307841 || (pProfile->negotiatedAuthType ==
7842 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307843#endif
7844 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007845 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007847 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 }
7849#endif
7850 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 if(HAL_STATUS_SUCCESS(status))
7852 {
7853 if(pIesTemp->SSID.present)
7854 {
7855 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307856 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7857 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 }
7859
7860 //Save the bss desc
7861 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307862
7863 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307865 //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 -07007866 pConnectProfile->qap = TRUE;
7867 }
7868 else
7869 {
7870 pConnectProfile->qap = FALSE;
7871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 if ( NULL == pIes )
7873 {
7874 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307875 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 }
7877 }
7878 //Save Qos connection
7879 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7880
7881 if(!HAL_STATUS_SUCCESS(status))
7882 {
7883 csrFreeConnectBssDesc(pMac, sessionId);
7884 }
7885 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7886 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307887 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7888 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7889 pConnectProfile->SSID.ssId,
7890 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 {
7892 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7893 break;
7894 }
7895 pConnectProfile->handoffPermitted = FALSE;
7896 }
7897
7898 return (status);
7899}
7900
Jeff Johnson295189b2012-06-20 16:38:30 -07007901static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7902{
7903 tListElem *pEntry = NULL;
7904 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307905 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 //The head of the active list is the request we sent
7907 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7908 if(pEntry)
7909 {
7910 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7911 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307912 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7914 {
7915 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7916 {
7917#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7918 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7919#endif
7920 }
7921 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307922 if(!pSession)
7923 {
7924 smsLog(pMac, LOGE, FL(" session %d not found "),
7925 pSmeJoinRsp->sessionId);
7926 return;
7927 }
7928 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 }
7930 else
7931 {
7932 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007933 if(!pSession)
7934 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307935 smsLog(pMac, LOGE, FL(" session %d not found "),
7936 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007937 return;
7938 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307939 if (pSession->abortConnection)
7940 {
Abhinav Kumare548f1e2018-07-12 16:40:43 +05307941 smsLog(pMac, LOG1, FL("Disconnection in progess abort Join request"));
7942
7943 if (pSession->bRefAssocStartCnt)
7944 pSession->bRefAssocStartCnt--;
7945 csrRoamCallCallback(pMac, pSession->sessionId,
7946 NULL, roamId,
7947 eCSR_ROAM_ASSOCIATION_COMPLETION,
7948 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307949 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7950 pSession->abortConnection = FALSE;
7951 return;
7952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 //The head of the active list is the request we sent
7954 //Try to get back the same profile and roam again
7955 if(pCommand)
7956 {
7957 roamId = pCommand->u.roamCmd.roamId;
7958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7960 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007961 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007962#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7963 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7964 if (csrRoamIsHandoffInProgress(pMac))
7965 {
7966 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7967 /* Should indicate neighbor roam algorithm about the connect failure here */
7968 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7969 }
7970#endif
7971 if (pCommand)
7972 {
7973 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7974 {
7975 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7976 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7977 csrRoamReissueRoamCommand(pMac);
7978 }
7979 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7980 {
7981 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7982 }
7983 else
7984 {
7985 csrRoam(pMac, pCommand);
7986 }
7987 }
7988 else
7989 {
7990 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7991 }
7992 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7993}
7994
Jeff Johnson295189b2012-06-20 16:38:30 -07007995eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7996 tDot11fBeaconIEs *pIes,
7997 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7998{
7999 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08008000 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
8001 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008002
8003 // Set the roaming substate to 'join attempt'...
8004 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08008006 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 return (status);
8008}
8009
Jeff Johnson295189b2012-06-20 16:38:30 -07008010static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
8011 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
8012{
8013 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 // Set the roaming substate to 'join attempt'...
8015 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
8016
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308017 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8018 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05308019 if (pMac->roam.configParam.roamDelayStatsEnabled)
8020 {
8021 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
8022 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
8023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08008025 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07008026}
8027
Jeff Johnson295189b2012-06-20 16:38:30 -07008028void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
8029{
8030 tListElem *pEntry;
8031 tSmeCmd *pCommand;
8032 tCsrRoamInfo roamInfo;
8033 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308034 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008035
8036 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8037 if(pEntry)
8038 {
8039 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8040 if ( eSmeCommandRoam == pCommand->command )
8041 {
8042 sessionId = pCommand->sessionId;
8043 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008044
8045 if(!pSession)
8046 {
8047 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8048 return;
8049 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05308050 /* While switching between two AP, csr will reissue roam command again
8051 to the nextbss if it was interrupted by the dissconnect req for the
8052 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
8053 so reset the bRefAssocStartCnt.
8054 */
8055 if(pSession->bRefAssocStartCnt > 0)
8056 {
8057 pSession->bRefAssocStartCnt--;
8058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 if( pCommand->u.roamCmd.fStopWds )
8060 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308061 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8063 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8064 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
8067 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8068 eCSR_ROAM_WDS_IND,
8069 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
8071 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8072 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8073 eCSR_ROAM_INFRA_IND,
8074 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
8075 }
8076
Jeff Johnson295189b2012-06-20 16:38:30 -07008077
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
8079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008080 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8082 }
8083 }
8084 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
8085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008086 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8088 }
8089 }
8090 else
8091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008092 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 }
8094 }
8095 else
8096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008097 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 }
8099}
8100
Jeff Johnson295189b2012-06-20 16:38:30 -07008101tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
8102{
8103 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8104 tListElem *pEntry;
8105 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 //alwasy lock active list before locking pending list
8107 csrLLLock( &pMac->sme.smeCmdActiveList );
8108 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8109 if(pEntry)
8110 {
8111 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8112 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8113 {
8114 fRet = eANI_BOOLEAN_TRUE;
8115 }
8116 }
8117 if(eANI_BOOLEAN_FALSE == fRet)
8118 {
8119 csrLLLock(&pMac->sme.smeCmdPendingList);
8120 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8121 while(pEntry)
8122 {
8123 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8124 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8125 {
8126 fRet = eANI_BOOLEAN_TRUE;
8127 break;
8128 }
8129 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8130 }
8131 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8132 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308133 if (eANI_BOOLEAN_FALSE == fRet)
8134 {
8135 csrLLLock(&pMac->roam.roamCmdPendingList);
8136 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8137 while (pEntry)
8138 {
8139 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8140 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8141 {
8142 fRet = eANI_BOOLEAN_TRUE;
8143 break;
8144 }
8145 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8146 }
8147 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 return (fRet);
8151}
8152
Jeff Johnson295189b2012-06-20 16:38:30 -07008153tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8154{
8155 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8156 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8158 {
8159 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8160 {
8161 break;
8162 }
8163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 return ( fRet );
8165}
8166
Jeff Johnson295189b2012-06-20 16:38:30 -07008167tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8168{
8169 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 //alwasy lock active list before locking pending list
8171 csrLLLock( &pMac->sme.smeCmdActiveList );
8172 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8173 if(eANI_BOOLEAN_FALSE == fRet)
8174 {
8175 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8176 }
8177 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 return (fRet);
8179}
8180
Jeff Johnson295189b2012-06-20 16:38:30 -07008181tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8182{
8183 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8184 tListElem *pEntry;
8185 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 //alwasy lock active list before locking pending list
8187 csrLLLock( &pMac->sme.smeCmdActiveList );
8188 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8189 if( pEntry )
8190 {
8191 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8192 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8193 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8194 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8195 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8196 {
8197 fRet = eANI_BOOLEAN_TRUE;
8198 }
8199 }
8200 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 return (fRet);
8202}
Jeff Johnson295189b2012-06-20 16:38:30 -07008203eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8204{
8205 eHalStatus status = eHAL_STATUS_SUCCESS;
8206 tSmeCmd *pCommand = NULL;
8207 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8208 tANI_BOOLEAN fRemoveCmd = FALSE;
8209 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 // Delete the old assoc command. All is setup for reassoc to be serialized
8211 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8212 if ( pEntry )
8213 {
8214 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8215 if ( !pCommand )
8216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008217 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 return eHAL_STATUS_RESOURCES;
8219 }
8220 if ( eSmeCommandRoam == pCommand->command )
8221 {
8222 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8223 {
8224 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8225 }
8226 else
8227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008228 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 }
8230 if (fRemoveCmd == FALSE)
8231 {
8232 // Implies we did not get the serialized assoc command we
8233 // were expecting
8234 pCommand = NULL;
8235 }
8236 }
8237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 if(NULL == pCommand)
8239 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008240 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 return eHAL_STATUS_RESOURCES;
8242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 do
8244 {
8245 //Change the substate in case it is wait-for-key
8246 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8247 {
8248 csrRoamStopWaitForKeyTimer( pMac );
8249 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8250 }
8251 pCommand->command = eSmeCommandRoam;
8252 pCommand->sessionId = (tANI_U8)sessionId;
8253 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8255 if( !HAL_STATUS_SUCCESS( status ) )
8256 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008257 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 csrReleaseCommandRoam( pMac, pCommand );
8259 }
8260 } while( 0 );
8261
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 return( status );
8263}
8264static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8265{
8266 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8267 tCsrScanResult *pScanResult = NULL;
8268 tSirBssDescription *pBssDesc = NULL;
8269 tSmeCmd *pCommand = NULL;
8270 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308271 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 if(NULL == pEntry)
8273 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308274 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 return;
8276 }
8277 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8278 sessionId = pCommand->sessionId;
8279 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008280
8281 if(!pSession)
8282 {
8283 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8284 return;
8285 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308286 smsLog(pMac, LOG1, FL("CFG return value is %d "
8287 " current state is : %d substate is : %d "),
8288 result, pMac->roam.curState[sessionId],
8289 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8291 {
8292 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008293 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8295 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008296 /* If the roaming has stopped, not to continue the roaming command*/
8297 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8298 {
8299 //No need to complete roaming here as it already completes
8300 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8301 pCommand->u.roamCmd.roamReason);
8302 csrSetAbortRoamingCommand( pMac, pCommand );
8303 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 else
8306 {
8307 if ( CCM_IS_RESULT_SUCCESS(result) )
8308 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308309 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 // Successfully set the configuration parameters for the new Bss. Attempt to
8311 // join the roaming Bss.
8312 if(pCommand->u.roamCmd.pRoamBssEntry)
8313 {
8314 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308315 if (!pScanResult)
8316 {
8317 smsLog(pMac, LOGE,
8318 FL("Failed to get base address for pScanResult"));
8319 return;
8320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 pBssDesc = &pScanResult->Result.BssDescriptor;
8322 }
8323 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8324 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 )
8327 {
8328 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8329 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8330 pBssDesc, pCommand->u.roamCmd.roamId )))
8331 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308332 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 //We need to complete the command
8334 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8335 }
8336 }
8337 else
8338 {
8339 if (!pCommand->u.roamCmd.pRoamBssEntry)
8340 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308341 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 //We need to complete the command
8343 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8344 return;
8345 }
8346 // If we are roaming TO an Infrastructure BSS...
8347 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308348 if( !pScanResult->Result.pvIes )
8349 {
8350 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8351 return;
8352 }
8353
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 if ( csrIsInfraBssDesc( pBssDesc ) )
8355 {
8356 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308357 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8359 {
8360 // ..and currently in an Infrastructure connection....
8361 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8362 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308363 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 // ...and the SSIDs are equal, then we Reassoc.
8365 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8366 pIesLocal ) )
8367 // ..and currently in an infrastructure connection
8368 {
8369 // then issue a Reassoc.
8370 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8371 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8372 &pCommand->u.roamCmd.roamProfile );
8373 }
8374 else
8375 {
8376
8377 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8378 // previously associated AP.
8379 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8380 pIesLocal,
8381 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8382 {
8383 //try something else
8384 csrRoam( pMac, pCommand );
8385 }
8386 }
8387 }
8388 else
8389 {
8390 eHalStatus status = eHAL_STATUS_SUCCESS;
8391
8392 /* We need to come with other way to figure out that this is because of HO in BMP
8393 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008394 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 * use join request */
8396#ifdef WLAN_FEATURE_VOWIFI_11R
8397 if (csrRoamIsHandoffInProgress(pMac) &&
8398 csrRoamIs11rAssoc(pMac))
8399 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308400 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8402 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8403 }
8404 else
8405#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008406#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008408 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308410 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 // Now serialize the reassoc command.
8412 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8413 }
8414 else
8415#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008416#ifdef FEATURE_WLAN_LFR
8417 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308418 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008419 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308420 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008421 // Now serialize the reassoc command.
8422 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8423 }
8424 else
8425#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 // else we are not connected and attempting to Join. Issue the
8427 // Join request.
8428 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308429 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8431 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8432 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8433 }
8434 if(!HAL_STATUS_SUCCESS(status))
8435 {
8436 //try something else
8437 csrRoam( pMac, pCommand );
8438 }
8439 }
8440 if( !pScanResult->Result.pvIes )
8441 {
8442 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308443 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 }
8445 }
8446 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8447 else
8448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008449 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 }
8451 }//else
8452 }//if ( WNI_CFG_SUCCESS == result )
8453 else
8454 {
8455 // In the event the configuration failed, for infra let the roam processor
8456 //attempt to join something else...
8457 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8458 {
8459 csrRoam(pMac, pCommand);
8460 }
8461 else
8462 {
8463 //We need to complete the command
8464 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8465 {
8466 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8467 }
8468 else
8469 {
8470 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8471 }
8472 }
8473 }
8474 }//we have active entry
8475}
8476
Jeff Johnson295189b2012-06-20 16:38:30 -07008477static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8478{
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008481 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8483 // join the new one...
8484 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8486 }
8487 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008488 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 /***profHandleLostLinkAfterReset(pAdapter);
8490 // In the event the authenticate fails, let the roam processor attempt to join something else...
8491 roamRoam( pAdapter );***/
8492 }
8493}
8494
Jeff Johnson295189b2012-06-20 16:38:30 -07008495static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8496{
8497 eCsrRoamCompleteResult result;
8498 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8499 tCsrRoamInfo roamInfo;
8500 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308501 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308502 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308503 tANI_U8 nilMac[6] = {0};
8504
8505 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008507 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 /* Defeaturize this part later if needed */
8510#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8511 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8512 * we need the response contents while processing the result in csrRoamProcessResults() */
8513 if (csrRoamIsHandoffInProgress(pMac))
8514 {
8515 /* Need to dig more on indicating events to SME QoS module */
8516 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8517 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308518#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8519 /* Add previous BSSID to blacklist ; this will be in blacklised for
8520 * some period and score of this AP will be reduced if black listed
8521 * to avoid ping pong */
8522 if (pMac->PERroamCandidatesCnt)
8523 {
8524 current_timestamp = jiffies_to_msecs(jiffies);
8525 for (candidateApCnt = 0; candidateApCnt <
8526 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8527 {
8528 /* Find one blank entry */
8529 if (sirCompareMacAddr(nilMac,
8530 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8531 {
8532 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8533 bssAddr,
8534 pNeighborRoamInfo->prevConnProfile.bssid,
8535 sizeof(tSirMacAddr));
8536 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8537 current_timestamp;
8538 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8539 MAC_ADDR_ARRAY(
8540 pNeighborRoamInfo->prevConnProfile.bssid),
8541 candidateApCnt);
8542 break;
8543 }
8544 /* if already in the list */
8545 if (sirCompareMacAddr(pMac->previousRoamApInfo
8546 [candidateApCnt].bssAddr,
8547 pNeighborRoamInfo->prevConnProfile.bssid) &&
8548 ((current_timestamp -
8549 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8550 pMac->PERroamTimeout))
8551 {
8552 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8553 bssAddr,
8554 pNeighborRoamInfo->prevConnProfile.bssid,
8555 sizeof(tSirMacAddr));
8556 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8557 current_timestamp;
8558 break;
8559 } else
8560 {
8561 /* find oldest BSSID entry in the blacklist */
8562 if (max_time <
8563 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8564 {
8565 max_time =
8566 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8567 oldestIndex = candidateApCnt;
8568 }
8569 }
8570 }
8571 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8572 {
8573 smsLog(pMac, LOGW,
8574 "%s: Clearing out oldest roam results bssid="
8575 MAC_ADDRESS_STR,
8576 __func__,
8577 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8578 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8579 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8580 pNeighborRoamInfo->prevConnProfile.bssid,
8581 sizeof(tSirMacAddr));
8582 }
8583 }
8584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 }
8586 else
8587#endif
8588 {
8589 csrRoamComplete( pMac, result, NULL );
8590 }
8591 }
8592 /* Should we handle this similar to handling the join failure? Is it ok
8593 * to call csrRoamComplete() with state as CsrJoinFailure */
8594 else
8595 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008596 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308598 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8599 WLAN_LOG_INDICATOR_HOST_DRIVER,
8600 WLAN_LOG_REASON_ROAM_FAIL,
8601 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008602#ifdef WLAN_FEATURE_VOWIFI_11R
8603 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308604 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8605 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 {
8607 // Inform HDD to turn off FT flag in HDD
8608 if (pNeighborRoamInfo)
8609 {
8610 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8611 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8612 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008613 /*
8614 * Since the above callback sends a disconnect
8615 * to HDD, we should clean-up our state
8616 * machine as well to be in sync with the upper
8617 * layers. There is no need to send a disassoc
8618 * since: 1) we will never reassoc to the current
8619 * AP in LFR, and 2) there is no need to issue a
8620 * disassoc to the AP with which we were trying
8621 * to reassoc.
8622 */
8623 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8624 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 }
8626 }
8627#endif
8628 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8629 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8630 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8631 //The disassoc rsp message will remove the command from active list
8632 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8633 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8634 {
8635 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8636 }
8637 }
8638}
8639
Jeff Johnson295189b2012-06-20 16:38:30 -07008640static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8641{
Jeff Johnson295189b2012-06-20 16:38:30 -07008642#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8643 {
8644 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008645 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8646 if(pIbssLog)
8647 {
8648 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8649 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8650 {
8651 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8652 }
8653 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8654 }
8655 }
8656#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8658 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8659 {
8660 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8661 }
8662 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8663 {
8664 csrRoamReissueRoamCommand(pMac);
8665 }
8666}
8667
Jeff Johnson295189b2012-06-20 16:38:30 -07008668void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8669{
8670 tSirResultCodes statusCode;
8671#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8672 tScanResultHandle hBSSList;
8673 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8674 eHalStatus status;
8675 tCsrRoamInfo roamInfo;
8676 tCsrScanResultFilter *pScanFilter = NULL;
8677 tANI_U32 roamId = 0;
8678 tCsrRoamProfile *pCurRoamProfile = NULL;
8679 tListElem *pEntry = NULL;
8680 tSmeCmd *pCommand = NULL;
8681#endif
8682 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308683 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008684
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 tSirSmeDisassocRsp SmeDisassocRsp;
8686
8687 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8688 sessionId = SmeDisassocRsp.sessionId;
8689 statusCode = SmeDisassocRsp.statusCode;
8690
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008691 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008692
8693 if ( csrIsConnStateInfra( pMac, sessionId ) )
8694 {
8695 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008698
8699 if(!pSession)
8700 {
8701 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8702 return;
8703 }
8704
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8706 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308707 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8709 }
8710 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8711 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8712 {
8713 if ( eSIR_SME_SUCCESS == statusCode )
8714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008715 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8717 }
8718 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8721 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308722 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8723 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008724#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008725 /*
8726 * First ensure if the roam profile is in the scan cache.
8727 * If not, post a reassoc failure and disconnect.
8728 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308729 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8730 if ( NULL == pScanFilter )
8731 status = eHAL_STATUS_FAILURE;
8732 else
8733 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008734 if(HAL_STATUS_SUCCESS(status))
8735 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308736 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008737 status = csrRoamPrepareFilterFromProfile(pMac,
8738 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8739 if(!HAL_STATUS_SUCCESS(status))
8740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008741 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008742 __func__, status);
8743 goto POST_ROAM_FAILURE;
8744 }
8745 else
8746 {
8747 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8748 if (!HAL_STATUS_SUCCESS(status))
8749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008750 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008751 __func__, status);
8752 goto POST_ROAM_FAILURE;
8753 }
8754 }
8755 }
8756 else
8757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008758 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008759 __func__, status);
8760 goto POST_ROAM_FAILURE;
8761 }
8762
8763 /*
8764 * After ensuring that the roam profile is in the scan result list,
8765 * dequeue the command from the active list.
8766 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8768 if ( pEntry )
8769 {
8770 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008771 /* If the head of the queue is Active and it is a ROAM command, remove
8772 * and put this on the Free queue.
8773 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 if ( eSmeCommandRoam == pCommand->command )
8775 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008776
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008777 /*
8778 * we need to process the result first before removing it from active list
8779 * because state changes still happening insides roamQProcessRoamResults so
8780 * no other roam command should be issued.
8781 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8783 if(pCommand->u.roamCmd.fReleaseProfile)
8784 {
8785 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8786 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008789 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 else
8791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008792 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008793 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008794 }
8795 }
8796 else
8797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008798 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 }
8800 }
8801 else
8802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008803 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008805
8806 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8808
Kiet Lam64c1b492013-07-12 13:56:44 +05308809 vos_mem_copy(roamInfo.bssid,
8810 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8811 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008812
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008813 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8814 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008815
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008816 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308817 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8818 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308820 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008821 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8822 //make sure to put it at the head of the cmd queue
8823 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8824 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8825 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8826
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 if(!HAL_STATUS_SUCCESS(status))
8828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008829 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008830 __func__, status);
8831 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 }
8833
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008834 /* Notify sub-modules like QoS etc. that handoff happening */
8835 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308836 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008837 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308838 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308840 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008841 return;
8842 }
8843
8844POST_ROAM_FAILURE:
8845 if (pScanFilter)
8846 {
8847 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308848 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008849 }
8850 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308851 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008852
8853 /* Inform the upper layers that the reassoc failed */
8854 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8855 csrRoamCallCallback(pMac, sessionId,
8856 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8857
8858 /*
8859 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8860 * Upon success, we would re-enter this routine after receiving the disassoc
8861 * response and will fall into the reassoc fail sub-state. And, eventually
8862 * call csrRoamComplete which would remove the roam command from SME active
8863 * queue.
8864 */
8865 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8866 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008868 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008869 __func__, status);
8870 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008872#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008873
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8875 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8876 {
8877 // Disassoc due to Reassoc failure falls into this codepath....
8878 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8879 }
8880 else
8881 {
8882 if ( eSIR_SME_SUCCESS == statusCode )
8883 {
8884 // Successfully disassociated from the 'old' Bss...
8885 //
8886 // We get Disassociate response in three conditions.
8887 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8888 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8889 // Infrastructure network.
8890 // - Third is where we are doing an Infra to Infra roam between networks with different
8891 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8892
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008893 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 }
8895 else
8896 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008897 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 }
8899 //We are not done yet. Get the data and continue roaming
8900 csrRoamReissueRoamCommand(pMac);
8901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008902}
8903
Jeff Johnson295189b2012-06-20 16:38:30 -07008904static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8905{
8906 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008908 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8910 {
8911 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8912 }
8913 else
8914 {
8915 if ( eSIR_SME_SUCCESS == statusCode )
8916 {
8917 // Successfully deauth from the 'old' Bss...
8918 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008919 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 }
8921 else
8922 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008923 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 }
8925 //We are not done yet. Get the data and continue roaming
8926 csrRoamReissueRoamCommand(pMac);
8927 }
8928}
8929
Jeff Johnson295189b2012-06-20 16:38:30 -07008930static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8931{
8932 eCsrRoamCompleteResult result;
8933
8934 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008936 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 result = eCsrStartBssSuccess;
8938 }
8939 else
8940 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008941 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 //Let csrRoamComplete decide what to do
8943 result = eCsrStartBssFailure;
8944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008946}
8947
Jeff Johnson295189b2012-06-20 16:38:30 -07008948/*
8949 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8950 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8951 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8952 For the messages where sender allocates memory for specific structures, then it can be
8953 cast accordingly.
8954*/
8955void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8956{
8957 tSirSmeRsp *pSmeRsp;
8958 tSmeIbssPeerInd *pIbssPeerInd;
8959 tCsrRoamInfo roamInfo;
8960 // TODO Session Id need to be acquired in this function
8961 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308963 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8964 pSmeRsp->messageType, pSmeRsp->messageType,
8965 macTraceGetcsrRoamSubState(
8966 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 pSmeRsp->messageType = (pSmeRsp->messageType);
8968 pSmeRsp->length = (pSmeRsp->length);
8969 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 switch (pSmeRsp->messageType)
8971 {
8972
8973 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8974 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8975 {
8976 //We sent a JOIN_REQ
8977 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8978 }
8979 break;
8980
8981 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8982 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8983 {
8984 //We sent a AUTH_REQ
8985 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8986 }
8987 break;
8988
8989 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8990 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8991 {
8992 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8993 }
8994 break;
8995
8996 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8997 {
8998 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8999 }
9000 break;
9001
9002 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
9003 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
9004 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
9005 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
9006 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
9007 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
9008//HO
9009 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
9010 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309011 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
9012 macTraceGetcsrRoamSubState(
9013 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009014 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05309015 if (pMac->roam.configParam.roamDelayStatsEnabled)
9016 {
9017 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
9018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 }
9020 break;
9021
9022 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
9023 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
9024 {
9025 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
9026 }
9027 break;
9028
9029 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
9030 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
9031 {
9032 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
9033 }
9034 break;
9035
9036 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
9037 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
9038 {
9039 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
9040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
9043 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9044 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009045 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05309046 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9047 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9049 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309050 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9051 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9053 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9054 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9055 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05309056 case eWNI_SME_LOST_LINK_PARAMS_IND:
9057 {
9058 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
9059 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9060 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9061 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9062 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
9063 pRoamInfo = &roamInfo;
9064 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
9065 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
9066 break;
9067 }
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05309068 case eWNI_SME_TRIGGER_SAE:
9069 smsLog(pMac, LOG1, FL("Invoke SAE callback"));
9070 csr_sae_callback(pMac, pSmeRsp);
9071 break;
9072
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309074 smsLog(pMac, LOG1,
9075 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9076 pSmeRsp->messageType, pSmeRsp->messageType,
9077 macTraceGetcsrRoamSubState(
9078 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009079
9080 //If we are connected, check the link status change
9081 if(!csrIsConnStateDisconnected(pMac, sessionId))
9082 {
9083 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
9084 }
9085 break;
9086 }
9087}
9088
Jeff Johnson295189b2012-06-20 16:38:30 -07009089void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
9090{
9091 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 switch (pSirMsg->messageType)
9093 {
9094 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009095 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 csrRoamStatsRspProcessor( pMac, pSirMsg );
9097 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9099 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309100 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9102 tCsrRoamInfo roamInfo;
9103 tCsrRoamInfo *pRoamInfo = NULL;
9104 tANI_U32 sessionId;
9105 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009106 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05309107 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
9110 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9111 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009112
9113 if(!pSession)
9114 {
9115 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9116 return;
9117 }
9118
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9120 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009121 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9122 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9123 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9125 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309126 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9127 sizeof(tSirMacAddr));
9128 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9129 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309131#ifdef WLAN_FEATURE_AP_HT40_24G
9132 pRoamInfo->HT40MHzIntoEnabledSta =
9133 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9134 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9135 pRoamInfo->HT40MHzIntoEnabledSta);
9136#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309137 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309138 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9139 pRoamInfo->chan_info = pUpperLayerAssocCnf->chan_info;
9140 if (pUpperLayerAssocCnf->HTCaps.present)
9141 pRoamInfo->ht_caps = pUpperLayerAssocCnf->HTCaps;
9142 if (pUpperLayerAssocCnf->VHTCaps.present)
9143 pRoamInfo->vht_caps = pUpperLayerAssocCnf->VHTCaps;
9144
Jeff Johnson295189b2012-06-20 16:38:30 -07009145 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9146 {
9147 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9148 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9149 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9150 }
9151 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9152 {
9153 vos_sleep( 100 );
9154 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9155 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9156 }
9157
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 }
9159 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 default:
9161 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9162 break;
9163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009164}
9165
Jeff Johnson295189b2012-06-20 16:38:30 -07009166eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9167 tSirBssDescription *pBssDescription,
9168 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9169 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9170 tANI_U8 keyId, tANI_U16 keyLength,
9171 tANI_U8 *pKey, tANI_U8 paeRole )
9172{
9173 eHalStatus status = eHAL_STATUS_SUCCESS;
9174 tAniEdType edType;
9175
9176 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9177 {
9178 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9179 }
9180
9181 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9182
9183 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9184 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9185 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9186 addKey )
9187 {
9188 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 setKey.encType = EncryptType;
9190 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309191 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 setKey.paeRole = paeRole; //0 for supplicant
9193 setKey.keyId = keyId; // Kye index
9194 setKey.keyLength = keyLength;
9195 if( keyLength )
9196 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309197 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 }
9199 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 return (status);
9202}
9203
Jeff Johnson295189b2012-06-20 16:38:30 -07009204static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9205 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9206{
9207 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9208 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009209#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009211#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009212
9213 do
9214 {
9215 pCommand = csrGetCommandBuffer(pMac);
9216 if(NULL == pCommand)
9217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009218 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 status = eHAL_STATUS_RESOURCES;
9220 break;
9221 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309222 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 pCommand->command = eSmeCommandSetKey;
9224 pCommand->sessionId = (tANI_U8)sessionId;
9225 // validate the key length, Adjust if too long...
9226 // for static WEP the keys are not set thru' SetContextReq
9227 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9228 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9229 {
9230 //KeyLength maybe 0 for static WEP
9231 if( pSetKey->keyLength )
9232 {
9233 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009235 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 break;
9237 }
9238
9239 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309240 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9241 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 }
9243 }
9244 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9245 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9246 {
9247 //KeyLength maybe 0 for static WEP
9248 if( pSetKey->keyLength )
9249 {
9250 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009252 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 break;
9254 }
9255
9256 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309257 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9258 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 }
9260 }
9261 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9262 {
9263 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009265 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 break;
9267 }
9268 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309269 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9270 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 }
9272 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9273 {
9274 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009276 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009277 break;
9278 }
9279 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309280 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9281 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 }
9283#ifdef FEATURE_WLAN_WAPI
9284 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9285 {
9286 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009288 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 break;
9290 }
9291 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309292 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9293 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009294 }
9295#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009296#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9298 {
9299 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009301 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 break;
9303 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009304 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309305 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009306 pSession->eseCckmInfo.reassoc_req_num=1;
9307 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009308 status = eHAL_STATUS_SUCCESS;
9309 break;
9310 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009311#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009312
Jeff Johnson295189b2012-06-20 16:38:30 -07009313#ifdef WLAN_FEATURE_11W
9314 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009315 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009317 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009319 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 break;
9321 }
9322 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309323 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 }
9325#endif
9326 status = eHAL_STATUS_SUCCESS;
9327 pCommand->u.setKeyCmd.roamId = roamId;
9328 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9329 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309330 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9331 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9333 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309334 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 //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
9336
9337 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9338 if( !HAL_STATUS_SUCCESS( status ) )
9339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009340 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 }
9342 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009344 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009345 if ( ( NULL != pCommand ) &&
9346 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009347#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009349#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009350 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 {
9352 csrReleaseCommandSetKey( pMac, pCommand );
9353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 return( status );
9355}
9356
Jeff Johnson295189b2012-06-20 16:38:30 -07009357eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9358 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9359{
9360 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9361 tSmeCmd *pCommand = NULL;
9362 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 do
9364 {
9365 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009367 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 status = eHAL_STATUS_CSR_WRONG_STATE;
9369 break;
9370 }
9371 pCommand = csrGetCommandBuffer(pMac);
9372 if(NULL == pCommand)
9373 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009374 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 status = eHAL_STATUS_RESOURCES;
9376 break;
9377 }
9378 pCommand->command = eSmeCommandRemoveKey;
9379 pCommand->sessionId = (tANI_U8)sessionId;
9380 pCommand->u.removeKeyCmd.roamId = roamId;
9381 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309382 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9383 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9385 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9386 {
9387 //in this case, put it to the end of the Q incase there is a set key pending.
9388 fImediate = eANI_BOOLEAN_FALSE;
9389 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009390 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009392 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9394 if( !HAL_STATUS_SUCCESS( status ) )
9395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009396 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009397 break;
9398 }
9399 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9401 {
9402 csrReleaseCommandRemoveKey( pMac, pCommand );
9403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 return (status );
9405}
9406
Jeff Johnson295189b2012-06-20 16:38:30 -07009407eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9408{
9409 eHalStatus status;
9410 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9411 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9412 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9413 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009414#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9415 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9416 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309417 if(!pSession)
9418 {
9419 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9420 return eHAL_STATUS_FAILURE;
9421 }
lukez3c809222013-05-03 10:23:02 -07009422 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309424 vos_mem_set(&setKeyEvent,
9425 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9427 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309428 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9430 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9431 }
9432 else
9433 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309434 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9436 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9437 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309438 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009439 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 {
9441 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 //It has to be static WEP here
9443 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9444 {
9445 setKeyEvent.keyId = (v_U8_t)defKeyId;
9446 }
9447 }
9448 else
9449 {
9450 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9451 }
9452 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9453 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9454 }
9455#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 if( csrIsSetKeyAllowed(pMac, sessionId) )
9457 {
9458 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9459 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9460 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9461 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9462 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9463 pCommand->u.setKeyCmd.keyRsc);
9464 }
9465 else
9466 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009467 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 //Set this status so the error handling take care of the case.
9469 status = eHAL_STATUS_CSR_WRONG_STATE;
9470 }
9471 if( !HAL_STATUS_SUCCESS(status) )
9472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009473 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009475#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009476 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 {
9478 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9479 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309480 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 }
9482 else
9483 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309484 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 }
9486 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9487 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9488 }
9489#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 return ( status );
9492}
9493
Jeff Johnson295189b2012-06-20 16:38:30 -07009494eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9495{
9496 eHalStatus status;
9497 tpSirSmeRemoveKeyReq pMsg = NULL;
9498 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9499 tANI_U8 *p;
9500 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009501#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9502 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9503 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309504 if(!pSession)
9505 {
9506 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9507 return eHAL_STATUS_FAILURE;
9508 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309509 vos_mem_set(&removeKeyEvent,
9510 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9512 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9513 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309514 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9516 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9517 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9518#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 if( csrIsSetKeyAllowed(pMac, sessionId) )
9520 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309521 pMsg = vos_mem_malloc(wMsgLen);
9522 if ( NULL == pMsg )
9523 status = eHAL_STATUS_FAILURE;
9524 else
9525 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 }
9527 else
9528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009529 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 //Set the error status so error handling kicks in below
9531 status = eHAL_STATUS_CSR_WRONG_STATE;
9532 }
9533 if( HAL_STATUS_SUCCESS( status ) )
9534 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309535 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9537 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 pMsg->sessionId = (tANI_U8)sessionId;
9539 pMsg->transactionId = 0;
9540 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9541 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9542 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309543 vos_mem_copy(p,
9544 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9545 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 p += sizeof(tSirMacAddr);
9547 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309548 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 p += sizeof(tSirMacAddr);
9550 // edType
9551 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9552 p++;
9553 // weptype
9554 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9555 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9556 {
9557 *p = (tANI_U8)eSIR_WEP_STATIC;
9558 }
9559 else
9560 {
9561 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9562 }
9563 p++;
9564 //keyid
9565 *p = pCommand->u.removeKeyCmd.keyId;
9566 p++;
9567 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 status = palSendMBMessage(pMac->hHdd, pMsg);
9569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 if( !HAL_STATUS_SUCCESS( status ) )
9571 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009572 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009573#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9574 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009575 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9577#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 return ( status );
9581}
9582
Jeff Johnson295189b2012-06-20 16:38:30 -07009583eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9584{
9585 eHalStatus status;
9586
9587 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9588 {
9589 status = eHAL_STATUS_CSR_WRONG_STATE;
9590 }
9591 else
9592 {
9593 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 return ( status );
9596}
9597
Jeff Johnson295189b2012-06-20 16:38:30 -07009598/*
9599 Prepare a filter base on a profile for parsing the scan results.
9600 Upon successful return, caller MUST call csrFreeScanFilter on
9601 pScanFilter when it is done with the filter.
9602*/
9603eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9604 tCsrScanResultFilter *pScanFilter)
9605{
9606 eHalStatus status = eHAL_STATUS_SUCCESS;
9607 tANI_U32 size = 0;
9608 tANI_U8 index = 0;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309609 uint8_t i;
Jeff Johnson295189b2012-06-20 16:38:30 -07009610
9611 do
9612 {
9613 if(pProfile->BSSIDs.numOfBSSIDs)
9614 {
9615 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309616 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9617 if ( NULL == pScanFilter->BSSIDs.bssid )
9618 status = eHAL_STATUS_FAILURE;
9619 else
9620 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009621 if(!HAL_STATUS_SUCCESS(status))
9622 {
9623 break;
9624 }
9625 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309626 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 }
9628 if(pProfile->SSIDs.numOfSSIDs)
9629 {
9630 if( !CSR_IS_WDS_STA( pProfile ) )
9631 {
9632 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9633 }
9634 else
9635 {
9636 //For WDS station
9637 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9638 pScanFilter->SSIDs.numOfSSIDs = 1;
9639 }
9640 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309641 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9642 if ( NULL == pScanFilter->SSIDs.SSIDList )
9643 status = eHAL_STATUS_FAILURE;
9644 else
9645 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 if(!HAL_STATUS_SUCCESS(status))
9647 {
9648 break;
9649 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309650 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9651 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 }
9653 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9654 {
9655 pScanFilter->ChannelInfo.numOfChannels = 0;
9656 pScanFilter->ChannelInfo.ChannelList = NULL;
9657 }
9658 else if(pProfile->ChannelInfo.numOfChannels)
9659 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309660 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9661 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9662 pProfile->ChannelInfo.numOfChannels);
9663 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9664 status = eHAL_STATUS_FAILURE;
9665 else
9666 status = eHAL_STATUS_SUCCESS;
9667
Jeff Johnson295189b2012-06-20 16:38:30 -07009668 pScanFilter->ChannelInfo.numOfChannels = 0;
9669 if(HAL_STATUS_SUCCESS(status))
9670 {
9671 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9672 {
9673 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9674 {
9675 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9676 = pProfile->ChannelInfo.ChannelList[index];
9677 pScanFilter->ChannelInfo.numOfChannels++;
9678 }
9679 else
9680 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009681 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 }
9684 }
9685 else
9686 {
9687 break;
9688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 }
9690 else
9691 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309692 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 status = eHAL_STATUS_FAILURE;
9694 break;
9695 }
9696 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309697 if (pProfile->force_rsne_override) {
9698 smsLog(pMac, LOG1, FL("force_rsne_override enabled fill all auth type and enctype"));
9699
9700 pScanFilter->authType.numEntries = eCSR_NUM_OF_SUPPORT_AUTH_TYPE;
9701 for (i = 0; i < pScanFilter->authType.numEntries; i++)
9702 pScanFilter->authType.authType[i] = i;
9703 index = 0;
9704 for (i = 0; i < eCSR_NUM_OF_ENCRYPT_TYPE; i++) {
9705 if (i == eCSR_ENCRYPT_TYPE_TKIP ||
9706 i == eCSR_ENCRYPT_TYPE_AES) {
9707 pScanFilter->
9708 EncryptionType.encryptionType[index] = i;
9709 pScanFilter->
9710 mcEncryptionType.encryptionType[index] = i;
9711 index++;
9712 }
9713 }
9714 pScanFilter->EncryptionType.numEntries = index;
9715 pScanFilter->mcEncryptionType.numEntries = index;
9716 pScanFilter->ignore_pmf_cap = true;
9717 } else {
9718 pScanFilter->authType = pProfile->AuthType;
9719 pScanFilter->EncryptionType = pProfile->EncryptionType;
9720 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 pScanFilter->BSSType = pProfile->BSSType;
9723 pScanFilter->phyMode = pProfile->phyMode;
9724#ifdef FEATURE_WLAN_WAPI
9725 //check if user asked for WAPI with 11n or auto mode, in that case modify
9726 //the phymode to 11g
9727 if(csrIsProfileWapi(pProfile))
9728 {
9729 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9730 {
9731 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9732 }
9733 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9734 {
9735 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9736 }
9737 if(!pScanFilter->phyMode)
9738 {
9739 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9740 }
9741 }
9742#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 /*Save the WPS info*/
9744 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009745 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 if( pProfile->countryCode[0] )
9747 {
9748 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309749 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9750 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 }
9752#ifdef WLAN_FEATURE_VOWIFI_11R
9753 if (pProfile->MDID.mdiePresent)
9754 {
9755 pScanFilter->MDID.mdiePresent = 1;
9756 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9757 }
9758#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309759 vos_mem_copy(pScanFilter->bssid_hint,
9760 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309761
9762#ifdef WLAN_FEATURE_11W
9763 // Management Frame Protection
9764 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9765 pScanFilter->MFPRequired = pProfile->MFPRequired;
9766 pScanFilter->MFPCapable = pProfile->MFPCapable;
9767#endif
9768
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 }while(0);
9770
9771 if(!HAL_STATUS_SUCCESS(status))
9772 {
9773 csrFreeScanFilter(pMac, pScanFilter);
9774 }
9775
9776 return(status);
9777}
9778
Jeff Johnson295189b2012-06-20 16:38:30 -07009779tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9780 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9781{
9782 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9783 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 do
9785 {
9786 // Validate the type is ok...
9787 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9788 pCommand = csrGetCommandBuffer( pMac );
9789 if ( !pCommand )
9790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009791 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009792 break;
9793 }
9794 //Change the substate in case it is waiting for key
9795 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9796 {
9797 csrRoamStopWaitForKeyTimer( pMac );
9798 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9799 }
9800 pCommand->command = eSmeCommandWmStatusChange;
9801 pCommand->sessionId = (tANI_U8)sessionId;
9802 pCommand->u.wmStatusChangeCmd.Type = Type;
9803 if ( eCsrDisassociated == Type )
9804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309805 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9806 pSmeRsp,
9807 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 }
9809 else
9810 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309811 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9812 pSmeRsp,
9813 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 }
9815 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9816 {
9817 fCommandQueued = eANI_BOOLEAN_TRUE;
9818 }
9819 else
9820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009821 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 csrReleaseCommandWmStatusChange( pMac, pCommand );
9823 }
9824
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9826 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 return( fCommandQueued );
9829}
9830
Jeff Johnson295189b2012-06-20 16:38:30 -07009831static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9832{
9833 v_S7_t rssi = 0;
9834 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9835 if(pGetRssiReq)
9836 {
9837 if(NULL != pGetRssiReq->pVosContext)
9838 {
9839 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9840 }
9841 else
9842 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009843 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009844 return;
9845 }
9846
9847 if(NULL != pGetRssiReq->rssiCallback)
9848 {
9849 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9850 }
9851 else
9852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009853 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009854 return;
9855 }
9856 }
9857 else
9858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009859 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 }
9861 return;
9862}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309863
9864static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9865{
9866 tANI_S8 snr = 0;
9867 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9868
9869 if (pGetSnrReq)
9870 {
9871 if (VOS_STATUS_SUCCESS !=
9872 WDA_GetSnr(pGetSnrReq->staId, &snr))
9873 {
9874 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9875 return;
9876 }
9877
9878 if (pGetSnrReq->snrCallback)
9879 {
9880 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9881 pGetSnrReq->pDevContext);
9882 }
9883 else
9884 {
9885 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9886 return;
9887 }
9888 }
9889 else
9890 {
9891 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9892 }
9893 return;
9894}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009895#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009896void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9897{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009898 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9899
Jeff Johnson36d483b2013-04-08 11:08:53 -07009900 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009901 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009902 /* Get roam Rssi request is backed up and passed back to the response,
9903 Extract the request message to fetch callback */
9904 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9905 v_S7_t rssi = pRoamRssiRsp->rssi;
9906
9907 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009908 {
9909 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9910 reqBkp->rssiCallback = NULL;
9911 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009912 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009913 }
9914 else
9915 {
9916 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9917 if (NULL != reqBkp)
9918 {
9919 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009920 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009921 }
9922 }
9923 }
9924 else
9925 {
9926 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9927 }
9928 return;
9929}
9930#endif
9931
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009932
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009933#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009934void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9935{
9936 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9937
9938 if (NULL != pTsmStatsRsp)
9939 {
9940 /* Get roam Rssi request is backed up and passed back to the response,
9941 Extract the request message to fetch callback */
9942 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9943
9944 if (NULL != reqBkp)
9945 {
9946 if (NULL != reqBkp->tsmStatsCallback)
9947 {
9948 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9949 pTsmStatsRsp->staId, reqBkp->pDevContext);
9950 reqBkp->tsmStatsCallback = NULL;
9951 }
9952 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009953 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009954 }
9955 else
9956 {
9957 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9958 if (NULL != reqBkp)
9959 {
9960 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009961 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009962 }
9963 }
9964 }
9965 else
9966 {
9967 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9968 }
9969 return;
9970}
9971
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009972void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009973{
9974 tANI_U32 roamTS2 = 0;
9975 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009976 tpPESession pSessionEntry = NULL;
9977 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009978
9979 if (NULL == pSession)
9980 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009981 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009982 return;
9983 }
9984
9985 roamTS2 = vos_timer_get_system_time();
9986 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009987 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9988 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009989 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009990
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009991 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9992 if (NULL == pSessionEntry)
9993 {
9994 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9995 return;
9996 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009997 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009998 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009999 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010000}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010001#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010002
Jeff Johnsone7245742012-09-05 17:12:55 -070010003static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
10004{
10005 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
10006 if(pTlRssiInd)
10007 {
10008 if(NULL != pTlRssiInd->tlCallback)
10009 {
10010 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -080010011 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -070010012 }
10013 else
10014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010015 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010016 }
10017 }
10018 else
10019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010020 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010021 }
10022 return;
10023}
Jeff Johnson295189b2012-06-20 16:38:30 -070010024
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010025eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
10026{
10027 tpSirResetAPCapsChange pMsg;
10028 tANI_U16 len;
10029 eHalStatus status = eHAL_STATUS_SUCCESS;
10030
10031 /* Create the message and send to lim */
10032 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +053010033 pMsg = vos_mem_malloc(len);
10034 if ( NULL == pMsg )
10035 status = eHAL_STATUS_FAILURE;
10036 else
10037 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010038 if (HAL_STATUS_SUCCESS(status))
10039 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010040 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010041 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
10042 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +053010043 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080010044 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
10045 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010046 status = palSendMBMessage(pMac->hHdd, pMsg);
10047 }
10048 else
10049 {
10050 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
10051 }
10052 return status;
10053}
10054
Jeff Johnson295189b2012-06-20 16:38:30 -070010055void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
10056{
10057 tSirSmeAssocInd *pAssocInd;
10058 tSirSmeDisassocInd *pDisassocInd;
10059 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010060 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
10062 tSirSmeNewBssInfo *pNewBss;
10063 tSmeIbssPeerInd *pIbssPeerInd;
10064 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10065 tSirSmeApNewCaps *pApNewCaps;
10066 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10067 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
10068 tCsrRoamInfo *pRoamInfo = NULL;
10069 tCsrRoamInfo roamInfo;
10070 eHalStatus status;
10071 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
10072 tCsrRoamSession *pSession = NULL;
10073 tpSirSmeSwitchChannelInd pSwitchChnInd;
10074 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +053010075 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -080010076
10077
10078 if (NULL == pSirMsg)
10079 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
10080 return;
10081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 switch( pSirMsg->messageType )
10083 {
10084 case eWNI_SME_ASSOC_IND:
10085 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053010086 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053010087 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
10089 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
10090 if( HAL_STATUS_SUCCESS( status ) )
10091 {
10092 pSession = CSR_GET_SESSION(pMac, sessionId);
10093
Jeff Johnson32d95a32012-09-10 13:15:23 -070010094 if(!pSession)
10095 {
10096 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10097 return;
10098 }
10099
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 pRoamInfo = &roamInfo;
10101
10102 // Required for indicating the frames to upper layer
10103 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
10104 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
10105
10106 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
10107 pRoamInfo->beaconLength = pAssocInd->beaconLength;
10108 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
10109 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10110
10111 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
10112 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
10113 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10114
10115 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
10116 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +053010117 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
10118 sizeof(tSirMacAddr));
10119 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
10120 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +053010122 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053010123#ifdef WLAN_FEATURE_AP_HT40_24G
10124 pRoamInfo->HT40MHzIntoEnabledSta =
10125 pAssocInd->HT40MHzIntoEnabledSta;
10126 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
10127 pRoamInfo->HT40MHzIntoEnabledSta);
10128#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
10132 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010133#ifdef SAP_AUTH_OFFLOAD
10134 if (pMac->sap_auth_offload)
10135 {
10136 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
10137 pRoamInfo->fAuthRequired = FALSE;
10138 }
10139 else
10140 {
10141#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10143 {
10144 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10145 pSession->pConnectBssDesc,
10146 &(pRoamInfo->peerMac),
10147 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10148 pRoamInfo->fAuthRequired = FALSE;
10149 }
10150 else
10151 {
10152 pRoamInfo->fAuthRequired = TRUE;
10153 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010154#ifdef SAP_AUTH_OFFLOAD
10155 }
10156#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10158 if (!HAL_STATUS_SUCCESS(status))
10159 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 /* Send Association completion message to PE */
10162 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10163
10164 /* send a message to CSR itself just to avoid the EAPOL frames going
10165 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10167 {
10168 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010170 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10171 {
10172 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10173 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10174 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 }
10177 }
10178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010181 // Check if AP dis-associated us because of MIC failure. If so,
10182 // then we need to take action immediately and not wait till the
10183 // the WmStatusChange requests is pushed and processed
10184 tSmeCmd *pCommand;
10185
10186 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10187 status = csrRoamGetSessionIdFromBSSID( pMac,
10188 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10189 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010190 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010191 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10192 " for session %d "), sessionId);
10193 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10194 MAC_ADDRESS_STR " "
10195 " reason = %d status = %d "),
10196 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10197 pDisassocInd->reasonCode,
10198 pDisassocInd->statusCode);
10199 // If we are in neighbor preauth done state then on receiving
10200 // disassoc or deauth we dont roam instead we just disassoc
10201 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010202 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010203#ifdef WLAN_FEATURE_VOWIFI_11R
10204 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10205 {
10206 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10207 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010208#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010209#ifdef FEATURE_WLAN_ESE
10210 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010211 {
10212 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010214#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010215#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010216 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10217 {
10218 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10219 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010220#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010221#ifdef WLAN_FEATURE_LFR_MBB
10222 csr_stop_preauth_reassoc_mbb_timer(pMac);
10223#endif
10224
Agarwal Ashish4f616132013-12-30 23:32:50 +053010225 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010226
Agarwal Ashish4f616132013-12-30 23:32:50 +053010227 if (!pSession)
10228 {
10229 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10230 return;
10231 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010232
Agarwal Ashish4f616132013-12-30 23:32:50 +053010233 if ( csrIsConnStateInfra( pMac, sessionId ) )
10234 {
10235 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010237#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010238 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010239#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010240 csrRoamLinkDown(pMac, sessionId);
10241 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10242 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10243 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010244 /*
10245 * STA/P2P client got disassociated so remove any pending deauth
10246 * commands in sme pending list
10247 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010248 pCommand = csrGetCommandBuffer(pMac);
10249 if (NULL == pCommand)
10250 {
10251 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10252 status = eHAL_STATUS_RESOURCES;
10253 return;
10254 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010255 pCommand->command = eSmeCommandRoam;
10256 pCommand->sessionId = (tANI_U8)sessionId;
10257 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10258 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10259 pDisassocInd->peerMacAddr,
10260 sizeof(tSirMacAddr));
10261 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10262 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010263
Agarwal Ashish4f616132013-12-30 23:32:50 +053010264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010265 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010266 else
10267 {
10268 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10269 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10270 }
Kiet Lam82004c62013-11-11 13:24:28 +053010271 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010272 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010274 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10276 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10277 if( HAL_STATUS_SUCCESS( status ) )
10278 {
10279 // If we are in neighbor preauth done state then on receiving
10280 // disassoc or deauth we dont roam instead we just disassoc
10281 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010282 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010283#ifdef WLAN_FEATURE_VOWIFI_11R
10284 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10285 {
10286 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10287 }
10288#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010289#ifdef FEATURE_WLAN_ESE
10290 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 {
10292 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10293 }
10294#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010295#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010296 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010297 {
10298 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10299 }
10300#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010301#ifdef WLAN_FEATURE_LFR_MBB
10302 csr_stop_preauth_reassoc_mbb_timer(pMac);
10303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 pSession = CSR_GET_SESSION( pMac, sessionId );
10305
Jeff Johnson32d95a32012-09-10 13:15:23 -070010306 if(!pSession)
10307 {
10308 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10309 return;
10310 }
10311
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 if ( csrIsConnStateInfra( pMac, sessionId ) )
10313 {
10314 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010316#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10317 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10318#endif
Yeshwanth Sriram Guntuka381bfa82018-11-06 18:29:50 +053010319#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
10320 csrRemoveNeighbourRoamPreauthCommand(pMac);
10321#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 csrRoamLinkDown(pMac, sessionId);
10323 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 }
10325 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010326
10327 case eWNI_SME_DISCONNECT_DONE_IND:
10328 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10329 smsLog( pMac, LOG1,
10330 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10331 pDisConDoneInd->reasonCode);
10332 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10333 {
10334 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10335 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10336 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10337 sizeof(tSirMacAddr));
10338 status = csrRoamCallCallback(pMac,
10339 pDisConDoneInd->sessionId,
10340 &roamInfo, 0,
10341 eCSR_ROAM_LOSTLINK,
10342 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010343 pSession = CSR_GET_SESSION(pMac,
10344 pDisConDoneInd->sessionId);
10345 if (pSession &&
10346 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10347 csrRoamStateChange(pMac,
10348 eCSR_ROAMING_STATE_IDLE,
10349 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010350 }
10351 else
10352 {
10353 smsLog(pMac, LOGE, FL("Inactive session %d"),
10354 pDisConDoneInd->sessionId);
10355 }
10356 break;
10357
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 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 -080010359 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010360
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10362 //Update with the new channel id.
10363 //The channel id is hidden in the statusCode.
10364 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10365 if( HAL_STATUS_SUCCESS( status ) )
10366 {
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010367 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010369 if(!pSession)
10370 {
10371 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10372 return;
10373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10375 if(pSession->pConnectBssDesc)
10376 {
10377 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10378 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010379 pRoamInfo->chan_info.chan_id =
10380 (tANI_U8)pSwitchChnInd->newChannelId;
10381 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10382 eCSR_ROAM_STA_CHANNEL_SWITCH,
10383 eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 }
10385 break;
10386
10387 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010388 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 {
10390 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10391 sessionId = pDeauthRsp->sessionId;
10392 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10393 {
10394 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010395 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10396 {
10397 pRoamInfo = &roamInfo;
10398 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010399 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10400 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010401 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10402 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10403 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10404 }
10405 }
10406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 break;
10408
10409 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010410 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010411 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 {
10413 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10414 sessionId = pDisassocRsp->sessionId;
10415 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10416 {
10417 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10419 {
10420 pRoamInfo = &roamInfo;
10421 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010422 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10423 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10425 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10426 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10427 }
10428 }
10429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010431 case eWNI_SME_LOST_LINK_PARAMS_IND:
10432 {
10433 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10434 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10435 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10436 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10437 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10438 pRoamInfo = &roamInfo;
10439 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10440 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10441 break;
10442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 case eWNI_SME_MIC_FAILURE_IND:
10444 {
10445 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10446 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10447 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010448
10449 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10450 if( HAL_STATUS_SUCCESS( status ) )
10451 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010452 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010453 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10454 pRoamInfo = &roamInfo;
10455 if(pMicInd->info.multicast)
10456 {
10457 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10458 }
10459 else
10460 {
10461 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10462 }
10463 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10464 }
10465
Jeff Johnson295189b2012-06-20 16:38:30 -070010466#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10467 {
lukez3c809222013-05-03 10:23:02 -070010468 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010470 if(!pSession)
10471 {
10472 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10473 return;
10474 }
lukez3c809222013-05-03 10:23:02 -070010475
Kiet Lam64c1b492013-07-12 13:56:44 +053010476 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010477 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10478 secEvent.encryptionModeMulticast =
10479 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10480 secEvent.encryptionModeUnicast =
10481 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10482 secEvent.authMode =
10483 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010484 vos_mem_copy(secEvent.bssid,
10485 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10487 }
10488#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 }
10490 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10492 {
10493 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10494 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010495 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010496
10497 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10498 if( HAL_STATUS_SUCCESS( status ) )
10499 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010500 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010501 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10502 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10503 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10504 }
10505 }
10506 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010507
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10509 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10510 switch( pStatusChangeMsg->statusChangeCode )
10511 {
10512 case eSIR_SME_IBSS_ACTIVE:
10513 sessionId = csrFindIbssSession( pMac );
10514 if( CSR_SESSION_ID_INVALID != sessionId )
10515 {
10516 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010517 if(!pSession)
10518 {
10519 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10520 return;
10521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10523 if(pSession->pConnectBssDesc)
10524 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010525 vos_mem_copy(&roamInfo.bssid,
10526 pSession->pConnectBssDesc->bssId,
10527 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10529 pRoamInfo = &roamInfo;
10530 }
10531 else
10532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010533 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 }
10535 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10536 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10537 }
10538 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 case eSIR_SME_IBSS_INACTIVE:
10540 sessionId = csrFindIbssSession( pMac );
10541 if( CSR_SESSION_ID_INVALID != sessionId )
10542 {
10543 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010544 if(!pSession)
10545 {
10546 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10547 return;
10548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10550 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10551 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10552 }
10553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10555 sessionId = csrFindIbssSession( pMac );
10556 if( CSR_SESSION_ID_INVALID != sessionId )
10557 {
10558 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010559 if(!pSession)
10560 {
10561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10562 return;
10563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 // update the connection state information
10565 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010566#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10567 {
10568 vos_log_ibss_pkt_type *pIbssLog;
10569 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10571 if(pIbssLog)
10572 {
10573 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10574 if(pNewBss)
10575 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010576 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Yeshwanth Sriram Guntuka7231db02018-08-10 15:18:21 +053010577 if(pNewBss->ssId.length >
10578 VOS_LOG_MAX_SSID_SIZE)
10579 pNewBss->ssId.length =
10580 VOS_LOG_MAX_SSID_SIZE;
10581
10582 vos_mem_copy(pIbssLog->ssid,
10583 pNewBss->ssId.ssId,
10584 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 pIbssLog->operatingChannel = pNewBss->channelNumber;
10586 }
10587 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10588 {
10589 //***U8 is not enough for beacon interval
10590 pIbssLog->beaconInterval = (v_U8_t)bi;
10591 }
10592 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10593 }
10594 }
10595#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010597
10598 if ((eCSR_ENCRYPT_TYPE_NONE ==
10599 pSession->connectedProfile.EncryptionType ))
10600 {
10601 csrRoamIssueSetContextReq( pMac, sessionId,
10602 pSession->connectedProfile.EncryptionType,
10603 pSession->pConnectBssDesc,
10604 &Broadcastaddr,
10605 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010607 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10608 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010609 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10610 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 pRoamInfo = &roamInfo;
10612 //This BSSID is th ereal BSSID, let's save it
10613 if(pSession->pConnectBssDesc)
10614 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010615 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10616 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010619 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 // detection by LIM that the capabilities of the associated AP have changed.
10622 case eSIR_SME_AP_CAPS_CHANGED:
10623 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010624 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010625 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10626 if( HAL_STATUS_SUCCESS( status ) )
10627 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010628 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10629 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010630 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010631 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10632 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10633 )
10634 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010635 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10636 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010637 }
10638 else
10639 {
10640 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010641 FL("Skipping csrScanForCapabilityChange as "
10642 "CSR is in state %s and sub-state %s"),
10643 macTraceGetcsrRoamState(
10644 pMac->roam.curState[sessionId]),
10645 macTraceGetcsrRoamSubState(
10646 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010647 /* We ignore the caps change event if CSR is not in full connected state.
10648 * Send one event to PE to reset limSentCapsChangeNtf
10649 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10650 * otherwise lim cannot send any CAPS change events to SME */
10651 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 }
10654 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010655
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 default:
10657 roamStatus = eCSR_ROAM_FAILED;
10658 result = eCSR_ROAM_RESULT_NONE;
10659 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 } // end switch on statusChangeCode
10661 if(eCSR_ROAM_RESULT_NONE != result)
10662 {
10663 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10664 }
10665 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 case eWNI_SME_IBSS_NEW_PEER_IND:
10667 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010668#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10669 {
10670 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010671 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10672 if(pIbssLog)
10673 {
10674 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010675 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10677 }
10678 }
10679#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010680 sessionId = csrFindIbssSession( pMac );
10681 if( CSR_SESSION_ID_INVALID != sessionId )
10682 {
10683 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010684
10685 if(!pSession)
10686 {
10687 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10688 return;
10689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10691 if(pSession->pConnectBssDesc)
10692 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010693 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10694 sizeof(tCsrBssid));
10695 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10696 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10698 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010699 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10700 - sizeof(tSmeIbssPeerInd)));
10701 if ( NULL == roamInfo.pbFrames )
10702 status = eHAL_STATUS_FAILURE;
10703 else
10704 status = eHAL_STATUS_SUCCESS;
10705 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 {
10707 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010708 vos_mem_copy(roamInfo.pbFrames,
10709 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10710 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 }
10712 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10713 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10714 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010715 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10716 if ( NULL == roamInfo.pBssDesc )
10717 status = eHAL_STATUS_FAILURE;
10718 else
10719 status = eHAL_STATUS_SUCCESS;
10720 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010722 vos_mem_copy(roamInfo.pBssDesc,
10723 pSession->pConnectBssDesc,
10724 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 }
10726 if(HAL_STATUS_SUCCESS(status))
10727 {
10728 pRoamInfo = &roamInfo;
10729 }
10730 else
10731 {
10732 if(roamInfo.pbFrames)
10733 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010734 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 }
10736 if(roamInfo.pBssDesc)
10737 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010738 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010739 }
10740 }
10741 }
10742 else
10743 {
10744 pRoamInfo = &roamInfo;
10745 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010746 if ((eCSR_ENCRYPT_TYPE_NONE ==
10747 pSession->connectedProfile.EncryptionType ))
10748 {
10749 csrRoamIssueSetContextReq( pMac, sessionId,
10750 pSession->connectedProfile.EncryptionType,
10751 pSession->pConnectBssDesc,
10752 &(pIbssPeerInd->peerAddr),
10753 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 }
10756 else
10757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010758 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 }
10760 //send up the sec type for the new peer
10761 if (pRoamInfo)
10762 {
10763 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10764 }
10765 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10766 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10767 if(pRoamInfo)
10768 {
10769 if(roamInfo.pbFrames)
10770 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010771 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 }
10773 if(roamInfo.pBssDesc)
10774 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010775 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 }
10777 }
10778 }
10779 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10781 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10782 sessionId = csrFindIbssSession( pMac );
10783 if( CSR_SESSION_ID_INVALID != sessionId )
10784 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010785#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10786 {
10787 vos_log_ibss_pkt_type *pIbssLog;
10788
10789 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10790 if(pIbssLog)
10791 {
10792 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10793 if(pIbssPeerInd)
10794 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010795 vos_mem_copy(pIbssLog->peerMacAddr,
10796 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 }
10798 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10799 }
10800 }
10801#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010802 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010803 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10804 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10805 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010806 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10807 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10809 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10810 }
10811 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 case eWNI_SME_SETCONTEXT_RSP:
10813 {
10814 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10815 tListElem *pEntry;
10816 tSmeCmd *pCommand;
10817
10818 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10819 if ( pEntry )
10820 {
10821 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10822 if ( eSmeCommandSetKey == pCommand->command )
10823 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010824 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010826
10827 if(!pSession)
10828 {
10829 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10830 return;
10831 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010832
10833#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10834 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10835 {
10836 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010837 vos_mem_set(&setKeyEvent,
10838 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 if( pRsp->peerMacAddr[0] & 0x01 )
10840 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010841 setKeyEvent.eventId =
10842 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010843 }
10844 else
10845 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010846 setKeyEvent.eventId =
10847 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010848 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010849 if( pRsp->peerMacAddr[0] & 0x01 )
10850 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010851 pMac->pmc.full_power_till_set_key = false;
10852 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 setKeyEvent.encryptionModeMulticast =
10855 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10856 setKeyEvent.encryptionModeUnicast =
10857 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010858 vos_mem_copy(setKeyEvent.bssid,
10859 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 setKeyEvent.authMode =
10861 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010862 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 {
10864 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10865 }
10866 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10867 }
10868#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10869 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10870 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010871 csrRoamStopWaitForKeyTimer( pMac );
10872
Jeff Johnson295189b2012-06-20 16:38:30 -070010873 //We are done with authentication, whethere succeed or not
10874 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 //We do it here because this linkup function is not called after association
10876 //when a key needs to be set.
10877 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10878 {
10879 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10880 }
10881 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010882 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010884 vos_mem_copy(&roamInfo.peerMac,
10885 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010886 //Make sure we install the GTK before indicating to HDD as authenticated
10887 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010888 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10889 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010890 {
Yathish9f22e662012-12-10 14:21:35 -080010891#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10892 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10893 {
10894 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010895 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010896 if (NULL == pMsg)
10897 {
10898 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10899 return;
10900 }
10901
Yathish9f22e662012-12-10 14:21:35 -080010902 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010903 pMsg->length = pal_cpu_to_be16(sizeof(
10904 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010905 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010906 vos_mem_copy(pMsg->bssid,
10907 pSession->connectedProfile.bssid,
10908 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010909 status = palSendMBMessage(pMac->hHdd, pMsg );
10910 }
10911#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010912 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010913 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010914 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010915 && (pSession->connectState ==
10916 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10917 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010918 && (VOS_P2P_GO_MODE !=
10919 pSession->pCurRoamProfile->csrPersona
10920 && VOS_STA_SAP_MODE !=
10921 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010922 {
10923 tpSirSmeHT40OBSSScanInd pMsg;
10924 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010925 if (NULL == pMsg)
10926 {
10927 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10928 return;
10929 }
10930
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010931 pMsg->messageType =
10932 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10933 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010934 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10935 vos_mem_copy(pMsg->peerMacAddr,
10936 pSession->connectedProfile.bssid,
10937 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010938 status = palSendMBMessage(pMac->hHdd,
10939 pMsg );
10940 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010941 else
10942 {
10943 smsLog( pMac, LOG1,FL("OBSS SCAN"
10944 "Indication not sent to FW"
10945 "channel %d OBSS_SCAN: %d"),
10946 pSession->connectedProfile.
10947 operationChannel,
10948 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10949 smsLog( pMac, LOG1,FL("connectState %d"
Jeff Johnson89477502017-09-19 08:35:23 -070010950 "pCurRoamProfile %pK"),
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010951 pSession->connectState,
10952 pSession->pCurRoamProfile);
10953 }
10954
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010955 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010956 }
10957 else
10958 {
10959 result = eCSR_ROAM_RESULT_NONE;
10960 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010961 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 }
10963 else
10964 {
10965 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010966 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10967 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10968 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010970 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010971 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10972 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010973 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10974 // can go ahead and initiate the TSPEC if any are pending
10975 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010976#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010977 //Send Adjacent AP repot to new AP.
10978 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10979 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010980 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010982#ifdef FEATURE_WLAN_ESE_UPLOAD
10983 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010984#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010985 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010986#endif
10987 pSession->isPrevApInfoValid = FALSE;
10988 }
10989#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010990 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10991 {
10992 csrReleaseCommandSetKey( pMac, pCommand );
10993 }
10994 }
10995 else
10996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010997 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 }
10999 }
11000 else
11001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011002 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 smeProcessPendingQueue( pMac );
11005 }
11006 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 case eWNI_SME_REMOVEKEY_RSP:
11008 {
11009 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
11010 tListElem *pEntry;
11011 tSmeCmd *pCommand;
11012
11013 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11014 if ( pEntry )
11015 {
11016 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11017 if ( eSmeCommandRemoveKey == pCommand->command )
11018 {
11019 sessionId = pCommand->sessionId;
11020 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011021
11022 if(!pSession)
11023 {
11024 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11025 return;
11026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011027#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11028 {
11029 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011030 vos_mem_set(&removeKeyEvent,
11031 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011032 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
11033 removeKeyEvent.encryptionModeMulticast =
11034 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11035 removeKeyEvent.encryptionModeUnicast =
11036 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011037 vos_mem_copy( removeKeyEvent.bssid,
11038 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 removeKeyEvent.authMode =
11040 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070011041 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 {
11043 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
11044 }
11045 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
11046 }
11047#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070011048 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070011049 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011050 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
11051 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 result = eCSR_ROAM_RESULT_NONE;
11053 pRoamInfo = &roamInfo;
11054 }
11055 else
11056 {
11057 result = eCSR_ROAM_RESULT_FAILURE;
11058 }
11059 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
11060 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
11061 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11062 {
11063 csrReleaseCommandRemoveKey( pMac, pCommand );
11064 }
11065 }
11066 else
11067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011068 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011069 }
11070 }
11071 else
11072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011073 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011075 smeProcessPendingQueue( pMac );
11076 }
11077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011078 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011079 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011080 csrRoamStatsRspProcessor( pMac, pSirMsg );
11081 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011082#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011083 case eWNI_SME_GET_ROAM_RSSI_RSP:
11084 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
11085 csrRoamRssiRspProcessor( pMac, pSirMsg );
11086 break;
11087#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011088#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011089 case eWNI_SME_GET_TSM_STATS_RSP:
11090 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
11091 csrTsmStatsRspProcessor( pMac, pSirMsg );
11092 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011093#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070011094 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011095 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 csrUpdateRssi( pMac, pSirMsg );
11097 break;
11098
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011099 case eWNI_SME_GET_SNR_REQ:
11100 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
11101 csrUpdateSnr(pMac, pSirMsg);
11102 break;
11103
Jeff Johnson295189b2012-06-20 16:38:30 -070011104#ifdef WLAN_FEATURE_VOWIFI_11R
11105 case eWNI_SME_FT_PRE_AUTH_RSP:
11106 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
11107 break;
11108#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053011109#ifdef WLAN_FEATURE_LFR_MBB
11110 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
11111 csr_roam_preauth_rsp_mbb_processor(pMac,
11112 (tpSirFTPreAuthRsp)pSirMsg);
11113 break;
11114#endif
11115
Jeff Johnson295189b2012-06-20 16:38:30 -070011116 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11117 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011118 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 -070011119 sessionId = pSmeMaxAssocInd->sessionId;
11120 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011121 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
11122 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11124 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11125 break;
11126
11127 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011128 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011129#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 btampEstablishLogLinkHdlr( pSirMsg );
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011131#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011132 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070011133 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011134 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011135 csrRoamRssiIndHdlr( pMac, pSirMsg );
11136 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011137#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11138 case eWNI_SME_CANDIDATE_FOUND_IND:
11139 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
11140 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
11141 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070011142 case eWNI_SME_HANDOFF_REQ:
11143 smsLog( pMac, LOG2, FL("Handoff Req from self"));
11144 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
11145 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011147
11148 default:
11149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070011151}
11152
Jeff Johnson295189b2012-06-20 16:38:30 -070011153void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
11154 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
11155{
11156 if(pSession)
11157 {
11158 if(pSession->bRefAssocStartCnt)
11159 {
11160 pSession->bRefAssocStartCnt--;
11161 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11162 //Need to call association_completion because there is an assoc_start pending.
11163 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11164 eCSR_ROAM_ASSOCIATION_COMPLETION,
11165 eCSR_ROAM_RESULT_FAILURE);
11166 }
11167 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11168 }
11169 else
11170 {
11171 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11172 }
11173}
11174
11175
11176eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11177{
11178 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11180 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11181 {
11182 status = csrScanRequestLostLink1( pMac, sessionId );
11183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 return(status);
11185}
11186
Jeff Johnson295189b2012-06-20 16:38:30 -070011187//return a boolean to indicate whether roaming completed or continue.
11188tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11189 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11190{
11191 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11192 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11193 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11194 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011195 if(!pSession)
11196 {
11197 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11198 return eANI_BOOLEAN_FALSE;
11199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 //Check whether time is up
11201 if(pSession->fCancelRoaming || fForce ||
11202 ((curTime - pSession->roamingStartTime) > roamTime) ||
11203 eCsrReassocRoaming == pSession->roamingReason ||
11204 eCsrDynamicRoaming == pSession->roamingReason)
11205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011206 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011207 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11208 {
11209 //roaming is cancelled, tell HDD to indicate disconnect
11210 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11211 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11212 //to be eSIR_BEACON_MISSED
11213 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11214 {
11215 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11216 }
11217 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11218 {
11219 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11220 }
11221 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11222 {
11223 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11224 }
11225 else
11226 {
11227 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11228 }
11229 }
11230 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11231 pSession->roamingReason = eCsrNotRoaming;
11232 }
11233 else
11234 {
11235 pSession->roamResult = roamResult;
11236 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11237 {
11238 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11239 pSession->roamingReason = eCsrNotRoaming;
11240 }
11241 else
11242 {
11243 fCompleted = eANI_BOOLEAN_FALSE;
11244 }
11245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 return(fCompleted);
11247}
11248
Jeff Johnson295189b2012-06-20 16:38:30 -070011249void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11250{
11251 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011252
11253 if(!pSession)
11254 {
11255 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11256 return;
11257 }
11258
Jeff Johnson295189b2012-06-20 16:38:30 -070011259 if(CSR_IS_ROAMING(pSession))
11260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011261 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11263 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11264 {
11265 //No need to do anything in here because the handler takes care of it
11266 }
11267 else
11268 {
11269 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11270 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11271 //Roaming is stopped after here
11272 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11273 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011274 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 csrRoamStopRoamingTimer(pMac, sessionId);
11276 }
11277 }
11278}
11279
Jeff Johnson295189b2012-06-20 16:38:30 -070011280void csrRoamRoamingTimerHandler(void *pv)
11281{
11282 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11283 tpAniSirGlobal pMac = pInfo->pMac;
11284 tANI_U32 sessionId = pInfo->sessionId;
11285 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011286
11287 if(!pSession)
11288 {
11289 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11290 return;
11291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011292
11293 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11294 {
11295 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11296 {
11297 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11298 pSession->roamingReason = eCsrNotRoaming;
11299 }
11300 }
11301}
11302
Jeff Johnson295189b2012-06-20 16:38:30 -070011303eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11304{
11305 eHalStatus status;
11306 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011307
11308 if(!pSession)
11309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011310 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011311 return eHAL_STATUS_FAILURE;
11312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011313
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011314 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011316 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011317
11318 return (status);
11319}
11320
Jeff Johnson295189b2012-06-20 16:38:30 -070011321eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11322{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011323 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011324}
11325
Jeff Johnson295189b2012-06-20 16:38:30 -070011326void csrRoamWaitForKeyTimeOutHandler(void *pv)
11327{
11328 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11329 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011330 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011331 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011332
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011333 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011334 macTraceGetNeighbourRoamState(
11335 pMac->roam.neighborRoamInfo.neighborRoamState),
11336 macTraceGetcsrRoamSubState(
11337 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011338
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011339 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011341 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011342 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11343 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011344 //Change the substate so command queue is unblocked.
11345 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11346 pMac->roam.curSubState[pInfo->sessionId] =
11347 eCSR_ROAM_SUBSTATE_NONE;
11348 vos_spin_lock_release(&pMac->roam.roam_state_lock);
11349
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011350#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011351 if (csrNeighborRoamIsHandoffInProgress(pMac))
11352 {
11353 /*
11354 * Enable heartbeat timer when hand-off is in progress
11355 * and Key Wait timer expired.
11356 */
11357 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11358 " (nHBCount=%d)",
11359 pMac->roam.configParam.HeartbeatThresh24);
11360 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11361 pMac->roam.configParam.HeartbeatThresh24,
11362 NULL, eANI_BOOLEAN_FALSE);
11363 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011364#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011365
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011366 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011367
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011368 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011369 {
11370 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11371 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011372 status = sme_AcquireGlobalLock(&pMac->sme);
11373 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011374 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011375 csrRoamDisconnect(pMac, pInfo->sessionId,
11376 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11377 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011378 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011379 }
11380 else
11381 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011382 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11383 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011384 }
11385 }
11386 else
11387 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011388 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011389 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 }
11392
11393}
11394
Jeff Johnson295189b2012-06-20 16:38:30 -070011395eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11396{
11397 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011398#ifdef FEATURE_WLAN_LFR
11399 if (csrNeighborRoamIsHandoffInProgress(pMac))
11400 {
11401 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011402 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11403 macTraceGetNeighbourRoamState(
11404 pMac->roam.neighborRoamInfo.neighborRoamState),
11405 macTraceGetcsrRoamSubState(
11406 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11407 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011408 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11409 }
11410#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011411 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011412 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011413
11414 return (status);
11415}
11416
Jeff Johnson295189b2012-06-20 16:38:30 -070011417eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11418{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011419 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11420 macTraceGetNeighbourRoamState(
11421 pMac->roam.neighborRoamInfo.neighborRoamState),
11422 macTraceGetcsrRoamSubState(
11423 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011424#ifdef FEATURE_WLAN_LFR
11425 if (csrNeighborRoamIsHandoffInProgress(pMac))
11426 {
11427 /*
11428 * Enable heartbeat timer when hand-off is in progress
11429 * and Key Wait timer got stopped for some reason
11430 */
11431 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011432 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011433 pMac->roam.configParam.HeartbeatThresh24);
11434 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11435 pMac->roam.configParam.HeartbeatThresh24,
11436 NULL, eANI_BOOLEAN_FALSE);
11437 }
11438#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011439 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011440}
11441
Jeff Johnson295189b2012-06-20 16:38:30 -070011442void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11443 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11444{
11445 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11446 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011447 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11448 /* To silence the KW tool Null chaeck is added */
11449 if(!pSession)
11450 {
11451 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11452 return;
11453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011454
11455 if(pCommand)
11456 {
11457 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11461 {
11462 //if success, force roaming completion
11463 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11464 }
11465 else
11466 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011467 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011468 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11470 }
11471}
11472
Jeff Johnson295189b2012-06-20 16:38:30 -070011473eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11474{
11475 eHalStatus status = eHAL_STATUS_SUCCESS;
11476 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11477 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11478 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 tCsrRoamInfo roamInfo;
11480 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011481 /* To silence the KW tool Null chaeck is added */
11482 if(!pSession)
11483 {
11484 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11485 return eHAL_STATUS_FAILURE;
11486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011488 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 if ( eWNI_SME_DISASSOC_IND == type )
11490 {
11491 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11492 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11493 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011494 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011495 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11496 sizeof(tSirMacAddr));
11497 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 }
11499 else if ( eWNI_SME_DEAUTH_IND == type )
11500 {
11501 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11502 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11503 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011504 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011505 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11506 sizeof(tSirMacAddr));
11507 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011508 }
11509 else
11510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011511 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011513 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011515 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11516 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11517 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
11518
11519 if (type == eWNI_SME_DEAUTH_IND || type == eWNI_SME_DISASSOC_IND) {
11520 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11521 eCSR_ROAM_LOSTLINK_DETECTED, result);
11522 } else if(!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11523 csrRoamCallCallback(pMac, sessionId, NULL, 0,
11524 eCSR_ROAM_LOSTLINK_DETECTED, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 }
11526
11527 if ( eWNI_SME_DISASSOC_IND == type )
11528 {
11529 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11530 }
11531 else if ( eWNI_SME_DEAUTH_IND == type )
11532 {
11533 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11534 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011535
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011536 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11537 {
Jingxiang Ge6298d0a2018-10-18 16:12:54 +080011538 //remove the connected BSS in infrastructure mode
11539 csrRoamRemoveConnectedBssFromScanCache(pMac,
11540 &pSession->connectedProfile);
11541
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011542 csrScanStartIdleScan(pMac);
11543 }
11544
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 return (status);
11546}
11547
Jeff Johnson295189b2012-06-20 16:38:30 -070011548eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11549{
11550 eHalStatus status = eHAL_STATUS_SUCCESS;
11551 tListElem *pEntry = NULL;
11552 tSmeCmd *pCommand = NULL;
11553 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011554
11555 if(!pSession)
11556 {
11557 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11558 return eHAL_STATUS_FAILURE;
11559 }
11560
Jeff Johnson295189b2012-06-20 16:38:30 -070011561 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 //Only remove the connected BSS in infrastructure mode
11563 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11564 if(pMac->roam.configParam.nRoamingTime)
11565 {
11566 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11567 {
11568 //before starting the lost link logic release the roam command for handoff
11569 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11570 if(pEntry)
11571 {
11572 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11573 }
11574 if(pCommand)
11575 {
11576 if (( eSmeCommandRoam == pCommand->command ) &&
11577 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11578 {
11579 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11580 {
11581 csrReleaseCommandRoam( pMac, pCommand );
11582 }
11583 }
11584 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011585 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011586 }
11587 }
11588 else
11589 {
11590 //We are told not to roam, indicate lostlink
11591 status = eHAL_STATUS_FAILURE;
11592 }
11593
11594 return (status);
11595}
Jeff Johnson295189b2012-06-20 16:38:30 -070011596void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11597{
11598 tListElem *pEntry;
11599 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11601 if ( pEntry )
11602 {
11603 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11604 if ( eSmeCommandWmStatusChange == pCommand->command )
11605 {
11606 // Nothing to process in a Lost Link completion.... It just kicks off a
11607 // roaming sequence.
11608 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11609 {
11610 csrReleaseCommandWmStatusChange( pMac, pCommand );
11611 }
11612 else
11613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011614 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 }
11616
11617 }
11618 else
11619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011620 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011621 }
11622 }
11623 else
11624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011625 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011626 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011627 smeProcessPendingQueue( pMac );
11628}
11629
Jeff Johnson295189b2012-06-20 16:38:30 -070011630void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11631{
11632 eHalStatus status = eHAL_STATUS_FAILURE;
11633 tSirSmeRsp *pSirSmeMsg;
11634 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011635
11636 if(!pSession)
11637 {
11638 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11639 return;
11640 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011641 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11642 pCommand->sessionId,
11643 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 switch ( pCommand->u.wmStatusChangeCmd.Type )
11645 {
11646 case eCsrDisassociated:
11647 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11648 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 case eCsrDeauthenticated:
11651 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11652 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011655 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011656 break;
11657 }
11658 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11659 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11660 {
11661 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11662 {
11663 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011664 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 }
11666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011667 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11668 // command here since there is nothing else to do.
11669 csrRoamWmStatusChangeComplete( pMac );
11670}
11671
Jeff Johnson295189b2012-06-20 16:38:30 -070011672//This function returns band and mode information.
11673//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11674//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011675static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11676 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011677{
Jeff Johnson295189b2012-06-20 16:38:30 -070011678 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11679 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11680 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011682
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 //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 -070011684 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11685 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11686 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11687 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 {
11689 switch( pMac->roam.configParam.uCfgDot11Mode )
11690 {
11691 case eCSR_CFG_DOT11_MODE_11A:
11692 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11693 eBand = eCSR_BAND_5G;
11694 break;
11695 case eCSR_CFG_DOT11_MODE_11B:
11696 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11697 eBand = eCSR_BAND_24;
11698 break;
11699 case eCSR_CFG_DOT11_MODE_11G:
11700 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11701 eBand = eCSR_BAND_24;
11702 break;
11703 case eCSR_CFG_DOT11_MODE_11N:
11704 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011705 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11706 break;
11707#ifdef WLAN_FEATURE_11AC
11708 case eCSR_CFG_DOT11_MODE_11AC:
11709 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11710 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011711 /* If the operating channel is in 2.4 GHz band, check for
11712 * INI item to disable VHT operation in 2.4 GHz band
11713 */
11714 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11715 !pMac->roam.configParam.enableVhtFor24GHz)
11716 {
11717 /* Disable 11AC operation */
11718 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11719 }
11720 else
11721 {
11722 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11723 }
11724 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011725 }
11726 else
11727 {
11728 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11729 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11730 }
11731 break;
11732 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11733 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11734 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011735 /* If the operating channel is in 2.4 GHz band, check for
11736 * INI item to disable VHT operation in 2.4 GHz band
11737 */
11738 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11739 !pMac->roam.configParam.enableVhtFor24GHz)
11740 {
11741 /* Disable 11AC operation */
11742 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11743 }
11744 else
11745 {
11746 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11747 }
11748 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011749 }
11750 else
11751 {
11752 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11753 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11754 }
11755 break;
11756#endif
11757 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011758#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011759 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11760 {
11761 /* If the operating channel is in 2.4 GHz band, check for
11762 * INI item to disable VHT operation in 2.4 GHz band
11763 */
11764 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11765 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011766 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011767 /* Disable 11AC operation */
11768 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011769 }
11770 else
11771 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011772 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11773 }
11774 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11775 }
11776 else
11777 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011778 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11779 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011780 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011781#else
11782 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11783 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11784#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 default:
11787 // Global dot11 Mode setting is 11a/b/g.
11788 // use the channel number to determine the Mode setting.
11789 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11790 {
11791 eBand = pMac->roam.configParam.eBand;
11792 if(eCSR_BAND_24 == eBand)
11793 {
11794 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11795 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11796 }
11797 else
11798 {
11799 //prefer 5GHz
11800 eBand = eCSR_BAND_5G;
11801 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11802 }
11803 }
11804 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11805 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011806 // WiFi tests require IBSS networks to start in 11b mode
11807 // without any change to the default parameter settings
11808 // on the adapter. We use ACU to start an IBSS through
11809 // creation of a startIBSS profile. This startIBSS profile
11810 // has Auto MACProtocol and the adapter property setting
11811 // for dot11Mode is also AUTO. So in this case, let's
11812 // start the IBSS network in 11b mode instead of 11g mode.
11813 // So this is for Auto=profile->MacProtocol && Auto=Global.
11814 // dot11Mode && profile->channel is < 14, then start the IBSS
11815 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011817 // Note: we used to have this start as an 11g IBSS for best
11818 // performance... now to specify that the user will have to
11819 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011820 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11821 eBand = eCSR_BAND_24;
11822 }
11823 else
11824 {
11825 // else, it's a 5.0GHz channel. Set mode to 11a.
11826 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11827 eBand = eCSR_BAND_5G;
11828 }
11829 break;
11830 }//switch
11831 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11832 else
11833 {
11834 //dot11 mode is set, lets pick the band
11835 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11836 {
11837 // channel is Auto also.
11838 eBand = pMac->roam.configParam.eBand;
11839 if(eCSR_BAND_ALL == eBand)
11840 {
11841 //prefer 5GHz
11842 eBand = eCSR_BAND_5G;
11843 }
11844 }
11845 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11846 {
11847 eBand = eCSR_BAND_24;
11848 }
11849 else
11850 {
11851 eBand = eCSR_BAND_5G;
11852 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 if(pBand)
11855 {
11856 *pBand = eBand;
11857 }
11858
11859 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011860 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11862 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011863
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011864 /* 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 +053011865 if (
11866#ifdef SAP_AUTH_OFFLOAD
11867 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11868#endif
11869 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11870 ((pProfile->privacy == 1) &&
11871 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011872 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011873#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011874 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011875#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011876 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11877 {
11878 //We cannot do 11n here
11879 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11880 {
11881 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11882 }
11883 else
11884 {
11885 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11886 }
11887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 return( cfgDot11Mode );
11889}
11890
Jeff Johnson295189b2012-06-20 16:38:30 -070011891eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11892{
11893 eHalStatus status;
11894 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011895
11896 if(!pSession)
11897 {
11898 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11899 return eHAL_STATUS_FAILURE;
11900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011901
11902#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11903 {
11904 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11906 if(pIbssLog)
11907 {
11908 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11909 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11910 }
11911 }
11912#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 // Set the roaming substate to 'stop Bss request'...
11914 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11915
11916 // attempt to stop the Bss (reason code is ignored...)
11917 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011918 if(!HAL_STATUS_SUCCESS(status))
11919 {
11920 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011922 return (status);
11923}
11924
Jeff Johnson295189b2012-06-20 16:38:30 -070011925//pNumChan is a caller allocated space with the sizeof pChannels
11926eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11927{
11928
11929 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11930 (tANI_U8 *)pChannels,
11931 pNumChan));
11932}
11933
Kiran4a17ebe2013-01-31 10:43:43 -080011934tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11935{
11936 tANI_U32 cfgLength = 0;
11937 tANI_U16 cfgId = 0;
11938 tPowerdBm maxTxPwr = 0;
11939 tANI_U8 *pCountryInfo = NULL;
11940 eHalStatus status;
11941 tANI_U8 count = 0;
11942 tANI_U8 firstChannel;
11943 tANI_U8 maxChannels;
11944
11945 if (CSR_IS_CHANNEL_5GHZ(channel))
11946 {
11947 cfgId = WNI_CFG_MAX_TX_POWER_5;
11948 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11949 }
11950 else if (CSR_IS_CHANNEL_24GHZ(channel))
11951 {
11952 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11953 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11954 }
11955 else
11956 return maxTxPwr;
11957
Kiet Lam64c1b492013-07-12 13:56:44 +053011958 pCountryInfo = vos_mem_malloc(cfgLength);
11959 if ( NULL == pCountryInfo )
11960 status = eHAL_STATUS_FAILURE;
11961 else
11962 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011963 if (status != eHAL_STATUS_SUCCESS)
11964 {
11965 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011966 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011967 __FUNCTION__, status);
11968 goto error;
11969 }
11970 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11971 if (status != eHAL_STATUS_SUCCESS)
11972 {
11973 goto error;
11974 }
11975 /* Identify the channel and maxtxpower */
11976 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11977 {
11978 firstChannel = pCountryInfo[count++];
11979 maxChannels = pCountryInfo[count++];
11980 maxTxPwr = pCountryInfo[count++];
11981
11982 if ((channel >= firstChannel) &&
11983 (channel < (firstChannel + maxChannels)))
11984 {
11985 break;
11986 }
11987 }
11988
11989error:
11990 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011991 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011992
11993 return maxTxPwr;
11994}
11995
11996
Jeff Johnson295189b2012-06-20 16:38:30 -070011997tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11998{
11999 tANI_BOOLEAN fValid = FALSE;
12000 tANI_U32 idxValidChannels;
12001 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12002
12003 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
12004 {
12005 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
12006 {
12007 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
12008 {
12009 fValid = TRUE;
12010 break;
12011 }
12012 }
12013 }
12014 pMac->roam.numValidChannels = len;
12015 return fValid;
12016}
12017
Jeff Johnson295189b2012-06-20 16:38:30 -070012018tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
12019{
12020 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
12021 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012022 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
12023 {
12024 if(channel == pMac->scan.base40MHzChannels.channelList[i])
12025 {
12026 fValid = eANI_BOOLEAN_TRUE;
12027 break;
12028 }
12029 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 return (fValid);
12031}
12032
Jeff Johnson295189b2012-06-20 16:38:30 -070012033//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070012034 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012035{
Jeff Johnsone7245742012-09-05 17:12:55 -070012036 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 tANI_U8 centerChn;
12038 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053012039
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
12041 {
12042 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
12043 }
12044 else
12045 {
12046 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
12047 }
12048 //Figure what the other side's CB mode
12049 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
12050 {
12051 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
12052 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053012053 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
12054 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
12055 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
12056 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012057 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
12058 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053012059 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012060 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053012061
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080012062 {
12063 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
12064 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12065 }
12066
12067 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012069 /* This is called during INFRA STA/CLIENT and should use the merged value of
12070 * supported channel width and recommended tx width as per standard
12071 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012072 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070012073 pIes->HTCaps.supportedChannelWidthSet,
12074 pIes->HTInfo.recommendedTxWidthSet,
12075 pIes->HTInfo.secondaryChannelOffset);
12076
12077 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12078 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 else
Jeff Johnsone7245742012-09-05 17:12:55 -070012080 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12081 switch (eRet) {
12082 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12083 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12084 break;
12085 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12086 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12087 break;
12088 case PHY_SINGLE_CHANNEL_CENTERED:
12089 default:
12090 centerChn = primaryChn;
12091 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012093 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012095 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012096 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012098 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12099 {
12100 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12101 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 }
12104 }
12105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 return eRet;
12107}
Jeff Johnson295189b2012-06-20 16:38:30 -070012108tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12109{
12110 tANI_BOOLEAN fFound = FALSE;
12111 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12113 {
12114 if( pCipherList->encryptionType[idx] == encryptionType )
12115 {
12116 fFound = TRUE;
12117 break;
12118 }
12119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 return fFound;
12121}
Jeff Johnson295189b2012-06-20 16:38:30 -070012122tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12123{
12124 tANI_BOOLEAN fFound = FALSE;
12125 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12127 {
12128 if( pAuthList->authType[idx] == authType )
12129 {
12130 fFound = TRUE;
12131 break;
12132 }
12133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 return fFound;
12135}
Jeff Johnson295189b2012-06-20 16:38:30 -070012136tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12137{
12138 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12139 tCsrScanResultFilter *pScanFilter = NULL;
12140 eHalStatus status = eHAL_STATUS_SUCCESS;
12141
12142 if(pProfile1 && pProfile2)
12143 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012144 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12145 if ( NULL == pScanFilter )
12146 status = eHAL_STATUS_FAILURE;
12147 else
12148 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 if(HAL_STATUS_SUCCESS(status))
12150 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012151 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12153 if(HAL_STATUS_SUCCESS(status))
12154 {
12155 fCheck = eANI_BOOLEAN_FALSE;
12156 do
12157 {
12158 tANI_U32 i;
12159 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12160 {
12161 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12162 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12163 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12164 if ( fCheck ) break;
12165 }
12166 if(!fCheck)
12167 {
12168 break;
12169 }
12170 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12171 || pProfile2->BSSType != pProfile1->BSSType
12172 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12173 )
12174 {
12175 fCheck = eANI_BOOLEAN_FALSE;
12176 break;
12177 }
12178#ifdef WLAN_FEATURE_VOWIFI_11R
12179 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12180 {
12181 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12182 {
12183 fCheck = eANI_BOOLEAN_FALSE;
12184 break;
12185 }
12186 }
12187#endif
12188 //Match found
12189 fCheck = eANI_BOOLEAN_TRUE;
12190 }while(0);
12191 csrFreeScanFilter(pMac, pScanFilter);
12192 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012193 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 }
12195 }
12196
12197 return (fCheck);
12198}
12199
Jeff Johnson295189b2012-06-20 16:38:30 -070012200tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12201{
12202 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12203 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 do
12205 {
12206 //Only check for static WEP
12207 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12208 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12209 {
12210 fCheck = eANI_BOOLEAN_TRUE;
12211 break;
12212 }
12213 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12214 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12215 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12216 {
12217 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012218 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12219 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 {
12221 break;
12222 }
12223 }
12224 if( i == CSR_MAX_NUM_KEY)
12225 {
12226 fCheck = eANI_BOOLEAN_TRUE;
12227 }
12228 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012229 return (fCheck);
12230}
12231
Jeff Johnson295189b2012-06-20 16:38:30 -070012232//IBSS
12233
Jeff Johnson295189b2012-06-20 16:38:30 -070012234tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12235{
12236 tANI_U8 channel = 0;
12237 tANI_U32 idx;
12238 tANI_U32 idxValidChannels;
12239 tANI_BOOLEAN fFound = FALSE;
12240 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12241
12242 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12243 {
12244 channel = pMac->roam.configParam.AdHocChannel5G;
12245 if(!csrRoamIsChannelValid(pMac, channel))
12246 {
12247 channel = 0;
12248 }
12249 }
12250 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12251 {
12252 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12253 {
12254 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12255 {
12256 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12257 {
12258 fFound = TRUE;
12259 channel = csrStartIbssChannels50[ idx ];
12260 }
12261 }
12262 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012263 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12264 if (!fFound)
12265 {
12266 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12267 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012268 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012270 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 break;
12272 }
12273 }
12274 }
12275 }//if
12276
12277 return( channel );
12278}
12279
Jeff Johnson295189b2012-06-20 16:38:30 -070012280tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12281{
12282 tANI_U8 channel = 1;
12283 tANI_U32 idx;
12284 tANI_U32 idxValidChannels;
12285 tANI_BOOLEAN fFound = FALSE;
12286 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12287
12288 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12289 {
12290 channel = pMac->roam.configParam.AdHocChannel24;
12291 if(!csrRoamIsChannelValid(pMac, channel))
12292 {
12293 channel = 0;
12294 }
12295 }
12296
12297 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12298 {
12299 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12300 {
12301 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12302 {
12303 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12304 {
12305 fFound = TRUE;
12306 channel = csrStartIbssChannels24[ idx ];
12307 }
12308 }
12309 }
12310 }
12311
12312 return( channel );
12313}
12314
Jeff Johnson295189b2012-06-20 16:38:30 -070012315static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12316 tCsrRoamStartBssParams *pParam )
12317{
12318 eCsrCfgDot11Mode cfgDot11Mode;
12319 eCsrBand eBand;
12320 tANI_U8 channel = 0;
12321 tSirNwType nwType;
12322 tANI_U8 operationChannel = 0;
12323
12324 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12325 {
12326 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12327 }
12328
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012330
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12332 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12333 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12334 )
12335 {
12336 /* This should never happen */
12337 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012338 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 pProfile->csrPersona);
12340 VOS_ASSERT(0);
12341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 switch( cfgDot11Mode )
12343 {
12344 case eCSR_CFG_DOT11_MODE_11G:
12345 nwType = eSIR_11G_NW_TYPE;
12346 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 case eCSR_CFG_DOT11_MODE_11B:
12348 nwType = eSIR_11B_NW_TYPE;
12349 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 case eCSR_CFG_DOT11_MODE_11A:
12351 nwType = eSIR_11A_NW_TYPE;
12352 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 default:
12354 case eCSR_CFG_DOT11_MODE_11N:
12355 case eCSR_CFG_DOT11_MODE_TAURUS:
12356 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12357 if(eCSR_BAND_24 == eBand)
12358 {
12359 nwType = eSIR_11G_NW_TYPE;
12360 }
12361 else
12362 {
12363 nwType = eSIR_11A_NW_TYPE;
12364 }
12365 break;
12366 }
12367
12368 pParam->extendedRateSet.numRates = 0;
12369
12370 switch ( nwType )
12371 {
12372 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012373 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 case eSIR_11A_NW_TYPE:
12375
12376 pParam->operationalRateSet.numRates = 8;
12377
12378 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12379 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12380 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12381 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12382 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12383 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12384 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12385 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12386
12387 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12388 {
12389 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12390 if( 0 == channel &&
12391 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12392 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12393 )
12394 {
12395 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12396 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12397 nwType = eSIR_11B_NW_TYPE;
12398 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12399 pParam->operationalRateSet.numRates = 4;
12400 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12401 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12402 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12403 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12404 }
12405 }
12406 else
12407 {
12408 channel = operationChannel;
12409 }
12410 break;
12411
12412 case eSIR_11B_NW_TYPE:
12413 pParam->operationalRateSet.numRates = 4;
12414 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12415 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12416 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12417 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12419 {
12420 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12421 }
12422 else
12423 {
12424 channel = operationChannel;
12425 }
12426
12427 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 /* For P2P Client and P2P GO, disable 11b rates */
12430 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12431 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12432 )
12433 {
12434 pParam->operationalRateSet.numRates = 8;
12435
12436 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12437 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12438 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12439 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12440 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12441 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12442 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12443 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12444 }
12445 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 {
12447 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12449 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12450 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12451 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12452
12453 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12455 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12456 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12457 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12458 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12459 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12460 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12461 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12462 }
12463
12464 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12465 {
12466 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12467 }
12468 else
12469 {
12470 channel = operationChannel;
12471 }
12472
12473 break;
12474 }
12475 pParam->operationChn = channel;
12476 pParam->sirNwType = nwType;
12477}
12478
Jeff Johnson295189b2012-06-20 16:38:30 -070012479static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12480 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12481{
12482
12483 if( pParam )
12484 {
12485 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012486 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012488 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012489
12490 if( pIes )
12491 {
12492 if(pIes->SuppRates.present)
12493 {
12494 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12495 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012497 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 -070012498 pIes->SuppRates.num_rates);
12499 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12500 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012501 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12502 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012504 if (pIes->ExtSuppRates.present)
12505 {
12506 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012507 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012508 {
12509 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12510 SIR_MAC_RATESET_EID_MAX, resetting to \
12511 SIR_MAC_RATESET_EID_MAX"),
12512 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012513 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012514 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012515 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012516 pIes->ExtSuppRates.rates,
12517 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12518 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 if( pIes->SSID.present )
12520 {
12521 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012522 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12523 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 }
12525 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 }
12527 else
12528 {
12529 pParam->ssId.length = 0;
12530 pParam->operationalRateSet.numRates = 0;
12531 }
12532 }
12533}
12534
Jeff Johnson295189b2012-06-20 16:38:30 -070012535static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12536{
12537 tANI_U8 MaxRate = 0;
12538 tANI_U32 i;
12539 tANI_U8 *pRate;
12540
12541 pRate = pSirRateSet->rate;
12542 for ( i = 0; i < pSirRateSet->numRates; i++ )
12543 {
12544 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12545 }
12546
12547 // Save the max rate in the connected state information...
12548
12549 // modify LastRates variable as well
12550
12551 return;
12552}
12553
Jeff Johnson295189b2012-06-20 16:38:30 -070012554eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12555 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12556{
12557 eHalStatus status = eHAL_STATUS_SUCCESS;
12558 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 // Set the roaming substate to 'Start BSS attempt'...
12560 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012561#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12562 //Need to figure out whether we need to log WDS???
12563 if( CSR_IS_IBSS( pProfile ) )
12564 {
12565 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12567 if(pIbssLog)
12568 {
12569 if(pBssDesc)
12570 {
12571 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012572 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 }
12574 else
12575 {
12576 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12577 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012578 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 if(pProfile->ChannelInfo.numOfChannels == 0)
12580 {
12581 pIbssLog->channelSetting = AUTO_PICK;
12582 }
12583 else
12584 {
12585 pIbssLog->channelSetting = SPECIFIED;
12586 }
12587 pIbssLog->operatingChannel = pParam->operationChn;
12588 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12589 }
12590 }
12591#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12592 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012593 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12594 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012595
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 pParam->privacy = pProfile->privacy;
12597 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12598 pParam->authType = pProfile->csr80211AuthType;
12599 pParam->beaconInterval = pProfile->beaconInterval;
12600 pParam->dtimPeriod = pProfile->dtimPeriod;
12601 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12602 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12603 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12604 {
12605 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12606 {
12607 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12608 }
12609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 pParam->protEnabled = pProfile->protEnabled;
12611 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12612 pParam->ht_protection = pProfile->cfg_protection;
12613 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012614
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12616 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012618
12619#ifdef WLAN_FEATURE_11W
12620 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12621 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12622#endif
12623
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 // When starting an IBSS, start on the channel from the Profile.
12625 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 return (status);
12627}
12628
Jeff Johnson295189b2012-06-20 16:38:30 -070012629static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012630 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012631{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012632 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012633 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012635
12636 if(!pSession)
12637 {
12638 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12639 return;
12640 }
12641
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 if( pBssDesc )
12643 {
12644 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12645 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12646 //The following code has to be do after that.
12647 //For WDS station, use selfMac as the self BSSID
12648 if( CSR_IS_WDS_STA( pProfile ) )
12649 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012650 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12651 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 }
12653 }
12654 else
12655 {
12656 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 //Use the first SSID
12658 if(pProfile->SSIDs.numOfSSIDs)
12659 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012660 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12661 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 }
12663 //For WDS station, use selfMac as the self BSSID
12664 if( CSR_IS_WDS_STA( pProfile ) )
12665 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012666 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12667 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 }
12669 //Use the first BSSID
12670 else if( pProfile->BSSIDs.numOfBSSIDs )
12671 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012672 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12673 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 }
12675 else
12676 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012677 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 }
12679 }
12680 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 //Set operating channel in pProfile which will be used
12682 //in csrRoamSetBssConfigCfg() to determine channel bonding
12683 //mode and will be configured in CFG later
12684 pProfile->operationChannel = Channel;
12685
12686 if(Channel == 0)
12687 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012688 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 }
12690 else
12691 {
12692
12693 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012694 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012695 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012696 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012697 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012698#ifdef WLAN_FEATURE_AP_HT40_24G
12699 if (CSR_IS_INFRA_AP(pProfile))
12700 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12701 else
12702 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12703#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012704 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012705#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012706 }
12707 else
12708 {
12709 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12710 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012711 pBssConfig->cbMode = cbMode;
12712 pSession->bssParams.cbMode = cbMode;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012713 if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
12714 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
12715 else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
12716 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
12717 else
12718 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
12719 smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
12720 pSession->bssParams.orig_ch_width);
Jeff Johnsone7245742012-09-05 17:12:55 -070012721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 }
12723}
12724
Jeff Johnson295189b2012-06-20 16:38:30 -070012725static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12726 tANI_BOOLEAN *pfSameIbss )
12727{
12728 eHalStatus status = eHAL_STATUS_SUCCESS;
12729 tANI_BOOLEAN fSameIbss = FALSE;
12730
12731 if ( csrIsConnStateIbss( pMac, sessionId ) )
12732 {
12733 // Check if any profile parameter has changed ? If any profile parameter
12734 // has changed then stop old BSS and start a new one with new parameters
12735 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12736 {
12737 fSameIbss = TRUE;
12738 }
12739 else
12740 {
12741 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12742 }
12743 }
12744 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12745 {
12746 // Disassociate from the connected Infrastructure network...
12747 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12748 }
12749 else
12750 {
12751 tBssConfigParam *pBssConfig;
12752
Kiet Lam64c1b492013-07-12 13:56:44 +053012753 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12754 if ( NULL == pBssConfig )
12755 status = eHAL_STATUS_FAILURE;
12756 else
12757 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 if(HAL_STATUS_SUCCESS(status))
12759 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012760 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 // there is no Bss description before we start an IBSS so we need to adopt
12762 // all Bss configuration parameters from the Profile.
12763 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12764 if(HAL_STATUS_SUCCESS(status))
12765 {
12766 //save dotMode
12767 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12768 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012769 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012770 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12771 NULL, pBssConfig,
12772 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012774
12775 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 }//Allocate memory
12777 }
12778
12779 if(pfSameIbss)
12780 {
12781 *pfSameIbss = fSameIbss;
12782 }
12783 return( status );
12784}
12785
Jeff Johnson295189b2012-06-20 16:38:30 -070012786static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12787 tSirSmeNewBssInfo *pNewBss )
12788{
12789 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012790
12791 if(!pSession)
12792 {
12793 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12794 return;
12795 }
12796
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 if( pNewBss )
12798 {
12799 // Set the operating channel.
12800 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12801 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012802 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12803 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 return;
12806}
12807
Jeff Johnson295189b2012-06-20 16:38:30 -070012808#ifdef FEATURE_WLAN_WAPI
12809eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12810 tANI_U32 numItems )
12811{
12812 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012813 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012814 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012816 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 return status;
12818 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012819 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 pSession = CSR_GET_SESSION( pMac, sessionId );
12821 if(numItems <= CSR_MAX_BKID_ALLOWED)
12822 {
12823 status = eHAL_STATUS_SUCCESS;
12824 //numItems may be 0 to clear the cache
12825 pSession->NumBkidCache = (tANI_U16)numItems;
12826 if(numItems && pBKIDCache)
12827 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012828 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12829 sizeof(tBkidCacheInfo) * numItems);
12830 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 }
12832 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 return (status);
12834}
Jeff Johnson295189b2012-06-20 16:38:30 -070012835eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12836 tBkidCacheInfo *pBkidCache)
12837{
12838 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012839 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012842 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 return status;
12844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 pSession = CSR_GET_SESSION( pMac, sessionId );
12846 if(pNum && pBkidCache)
12847 {
12848 if(pSession->NumBkidCache == 0)
12849 {
12850 *pNum = 0;
12851 status = eHAL_STATUS_SUCCESS;
12852 }
12853 else if(*pNum >= pSession->NumBkidCache)
12854 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012855 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012857 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 -070012858 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012859 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012861 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12862 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 *pNum = pSession->NumBkidCache;
12864 status = eHAL_STATUS_SUCCESS;
12865 }
12866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012868}
Jeff Johnson295189b2012-06-20 16:38:30 -070012869tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12870{
12871 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012872}
12873#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012874eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012875 tPmkidCacheInfo *pPMKIDCache,
12876 tANI_U32 numItems,
12877 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012878{
12879 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12880 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012881
12882 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012883 {
12884 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12885 return eHAL_STATUS_FAILURE;
12886 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012887
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012888 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012889
12890 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 {
12892#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12893 {
12894 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012895 vos_mem_set(&secEvent,
12896 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012897 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12898 secEvent.encryptionModeMulticast =
12899 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12900 secEvent.encryptionModeUnicast =
12901 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012902 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 secEvent.authMode =
12904 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12905 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12906 }
12907#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012909 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012910 if (numItems && pPMKIDCache)
12911 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012912 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012913 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12914 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012915 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012916 }
12917 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012918 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012919 tPmkidCacheInfo *pmksa;
12920
12921 for (i = 0; i < numItems; i++) {
12922 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012923
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012924 /* Delete the entry if present */
12925 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12926
12927 /* Add entry to the cache */
12928 vos_mem_copy(
12929 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12930 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12931 vos_mem_copy(
12932 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12933 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12934
12935 /* Increment the CSR local cache index */
12936 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12937 pSession->CurCacheIndex++;
12938 else
12939 pSession->CurCacheIndex = 0;
12940
12941 pSession->NumPmkidCache++;
12942 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12943 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 }
12946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 return (status);
12948}
12949
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012950eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012951#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12952 const tANI_U8 *pBSSId,
12953#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012954 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012955#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012956 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012957{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012958 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12959 tANI_BOOLEAN fMatchFound = FALSE;
12960 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012961 tANI_U32 CurIndex;
12962 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012963
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012964 if(!pSession)
12965 {
12966 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12967 return eHAL_STATUS_FAILURE;
12968 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012969
12970 /* Check if there are no entries to delete */
12971 if (0 == pSession->NumPmkidCache) {
12972 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12973 return eHAL_STATUS_SUCCESS;
12974 }
12975
12976 if (!flush_cache) {
12977 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12978 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12979 pBSSId, VOS_MAC_ADDR_SIZE)) {
12980 fMatchFound = 1;
12981
12982 /* Clear this - the matched entry */
12983 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12984 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012985 break;
12986 }
12987 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012988
12989 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12990 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12991 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012992 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012993 else {
12994 /* Match Found */
12995 CurIndex = pSession->CurCacheIndex;
12996 if(Index < CurIndex) {
12997 for(i = Index; i < (CurIndex-1); i++) {
12998 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12999 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
13000 }
13001 pSession->CurCacheIndex--;
13002 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
13003 sizeof(tPmkidCacheInfo));
13004 } else if(Index > CurIndex) {
13005 for(i = Index; i > (CurIndex); i--) {
13006 vos_mem_copy(&pSession->PmkidCacheInfo[i],
13007 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
13008 }
13009 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
13010 sizeof(tPmkidCacheInfo));
13011 }
13012 pSession->NumPmkidCache--;
13013 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013014 } else {
13015 /* Flush the entire cache */
13016 vos_mem_zero(pSession->PmkidCacheInfo,
13017 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
13018 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013019 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013020 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013021
13022 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013023}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013024
Jeff Johnson295189b2012-06-20 16:38:30 -070013025tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
13026{
13027 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
13028}
13029
Jeff Johnson295189b2012-06-20 16:38:30 -070013030eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
13031{
13032 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13033 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013034 tPmkidCacheInfo *pmksa;
13035 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013036
13037 if(!pSession)
13038 {
13039 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13040 return eHAL_STATUS_FAILURE;
13041 }
13042
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 if(pNum && pPmkidCache)
13044 {
13045 if(pSession->NumPmkidCache == 0)
13046 {
13047 *pNum = 0;
13048 status = eHAL_STATUS_SUCCESS;
13049 }
13050 else if(*pNum >= pSession->NumPmkidCache)
13051 {
13052 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
13053 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013054 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 -070013055 pSession->NumPmkidCache);
13056 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13057 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013058
13059 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
13060 pmksa = &pSession->PmkidCacheInfo[i];
13061 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
13062 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
13063 pPmkidCache++;
13064 j++;
13065 }
13066 }
13067
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 *pNum = pSession->NumPmkidCache;
13069 status = eHAL_STATUS_SUCCESS;
13070 }
13071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 return (status);
13073}
13074
Jeff Johnson295189b2012-06-20 16:38:30 -070013075eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13076{
13077 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13078 tANI_U32 len;
13079 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013080
13081 if(!pSession)
13082 {
13083 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13084 return eHAL_STATUS_FAILURE;
13085 }
13086
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 if(pLen)
13088 {
13089 len = *pLen;
13090 *pLen = pSession->nWpaRsnReqIeLength;
13091 if(pBuf)
13092 {
13093 if(len >= pSession->nWpaRsnReqIeLength)
13094 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013095 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13096 pSession->nWpaRsnReqIeLength);
13097 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 }
13099 }
13100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 return (status);
13102}
13103
Jeff Johnson295189b2012-06-20 16:38:30 -070013104eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13105{
13106 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13107 tANI_U32 len;
13108 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013109
13110 if(!pSession)
13111 {
13112 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13113 return eHAL_STATUS_FAILURE;
13114 }
13115
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 if(pLen)
13117 {
13118 len = *pLen;
13119 *pLen = pSession->nWpaRsnRspIeLength;
13120 if(pBuf)
13121 {
13122 if(len >= pSession->nWpaRsnRspIeLength)
13123 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013124 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13125 pSession->nWpaRsnRspIeLength);
13126 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 }
13128 }
13129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013130 return (status);
13131}
Jeff Johnson295189b2012-06-20 16:38:30 -070013132#ifdef FEATURE_WLAN_WAPI
13133eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13134{
13135 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13136 tANI_U32 len;
13137 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013138
13139 if(!pSession)
13140 {
13141 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13142 return eHAL_STATUS_FAILURE;
13143 }
13144
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 if(pLen)
13146 {
13147 len = *pLen;
13148 *pLen = pSession->nWapiReqIeLength;
13149 if(pBuf)
13150 {
13151 if(len >= pSession->nWapiReqIeLength)
13152 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013153 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13154 pSession->nWapiReqIeLength);
13155 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 }
13157 }
13158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 return (status);
13160}
Jeff Johnson295189b2012-06-20 16:38:30 -070013161eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13162{
13163 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13164 tANI_U32 len;
13165 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013166
13167 if(!pSession)
13168 {
13169 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13170 return eHAL_STATUS_FAILURE;
13171 }
13172
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 if(pLen)
13174 {
13175 len = *pLen;
13176 *pLen = pSession->nWapiRspIeLength;
13177 if(pBuf)
13178 {
13179 if(len >= pSession->nWapiRspIeLength)
13180 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013181 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13182 pSession->nWapiRspIeLength);
13183 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 }
13185 }
13186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 return (status);
13188}
13189#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013190eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13191{
13192 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13193 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013194
13195 if(!pSession)
13196 {
13197 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13198 return (retStatus);
13199 }
13200
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 if(CSR_IS_ROAMING(pSession))
13202 {
13203 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13204 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 return (retStatus);
13207}
13208
Jeff Johnson295189b2012-06-20 16:38:30 -070013209//This function remove the connected BSS from te cached scan result
13210eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13211 tCsrRoamConnectedProfile *pConnProfile)
13212{
13213 eHalStatus status = eHAL_STATUS_FAILURE;
13214 tCsrScanResultFilter *pScanFilter = NULL;
13215 tListElem *pEntry;
13216 tCsrScanResult *pResult;
13217 tDot11fBeaconIEs *pIes;
13218 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13220 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13221 {
13222 do
13223 {
13224 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013225 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13226 if ( NULL == pScanFilter )
13227 status = eHAL_STATUS_FAILURE;
13228 else
13229 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013231 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13232 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13233 if ( NULL == pScanFilter->BSSIDs.bssid )
13234 status = eHAL_STATUS_FAILURE;
13235 else
13236 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013238 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13239 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13241 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13242 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013243 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13244 if ( NULL == pScanFilter->SSIDs.SSIDList )
13245 status = eHAL_STATUS_FAILURE;
13246 else
13247 status = eHAL_STATUS_SUCCESS;
13248 if (!HAL_STATUS_SUCCESS(status)) break;
13249 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13250 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 }
13252 pScanFilter->authType.numEntries = 1;
13253 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13254 pScanFilter->BSSType = pConnProfile->BSSType;
13255 pScanFilter->EncryptionType.numEntries = 1;
13256 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13257 pScanFilter->mcEncryptionType.numEntries = 1;
13258 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13259 //We ignore the channel for now, BSSID should be enough
13260 pScanFilter->ChannelInfo.numOfChannels = 0;
13261 //Also ignore the following fields
13262 pScanFilter->uapsd_mask = 0;
13263 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013264 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 pScanFilter->countryCode[0] = 0;
13266 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 csrLLLock(&pMac->scan.scanResultList);
13268 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13269 while( pEntry )
13270 {
13271 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13272 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13273 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13274 pScanFilter, NULL, NULL, NULL, &pIes);
13275 //Release the IEs allocated by csrMatchBSS is needed
13276 if( !pResult->Result.pvIes )
13277 {
13278 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013279 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 }
13281 if(fMatch)
13282 {
13283 //We found the one
13284 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13285 {
13286 //Free the memory
13287 csrFreeScanResultEntry( pMac, pResult );
13288 }
13289 break;
13290 }
13291 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13292 }//while
13293 csrLLUnlock(&pMac->scan.scanResultList);
13294 }while(0);
13295 if(pScanFilter)
13296 {
13297 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013298 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 }
13300 }
13301 return (status);
13302}
13303
Jeff Johnson295189b2012-06-20 16:38:30 -070013304//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013305eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13306{
13307 eHalStatus status = eHAL_STATUS_SUCCESS;
13308 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13310 {
13311 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13312 {
13313 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13314 {
13315 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013316 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013317 status = eHAL_STATUS_CSR_WRONG_STATE;
13318 break;
13319 }
13320 if( csrIsConnStateInfra( pMac, sessionId ) )
13321 {
13322 if( chnId &&
13323 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013325 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13327 status = eHAL_STATUS_CSR_WRONG_STATE;
13328 break;
13329 }
13330 }
13331 }
13332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 return ( status );
13334}
13335
Jeff Johnson295189b2012-06-20 16:38:30 -070013336static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13337{
13338 eHalStatus status = eHAL_STATUS_SUCCESS;
13339 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13340 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013341
13342 if(!pSession)
13343 {
13344 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13345 return eHAL_STATUS_FAILURE;
13346 }
13347
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 if ( csrIsConnStateIbss( pMac, sessionId ) )
13349 {
13350 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13351 }
13352 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13353 {
13354 // Disassociate from the connected Infrastructure network...
13355 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13356 }
13357 else
13358 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13360 //Otherwise we need to add code to handle the
13361 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13362 //send stop_bss to PE, before we can continue.
13363 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013364 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013366 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13367 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 // there is no Bss description before we start an WDS so we need
13369 // to adopt all Bss configuration parameters from the Profile.
13370 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13371 if(HAL_STATUS_SUCCESS(status))
13372 {
13373 //Save profile for late use
13374 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013375 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13376 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013378 vos_mem_set(pSession->pCurRoamProfile,
13379 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013383 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013384 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13385 NULL, &bssConfig,
13386 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 }
13388 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013389
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 return( status );
13391}
13392
Jeff Johnson295189b2012-06-20 16:38:30 -070013393////////////////////Mail box
13394
Jeff Johnson295189b2012-06-20 16:38:30 -070013395//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13396//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013397static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13398 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13400{
13401 tCsrChannelSet channelGroup;
13402 tSirMacCapabilityInfo *pAP_capabilityInfo;
13403 tAniBool fTmp;
13404 tANI_BOOLEAN found = FALSE;
13405 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013406 tANI_S8 pwrLimit = 0;
13407 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13409 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13410 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13411 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 // 802.11h
13413 //We can do this because it is in HOST CPU order for now.
13414 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013415 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13416 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13417 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 fTmp = (tAniBool)pal_cpu_to_be32(1);
13419 }
13420 else
13421 fTmp = (tAniBool)0;
13422
13423 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013424 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013426 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013427 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 // This is required for 11k test VoWiFi Ent: Test 2.
13429 // We need the power capabilities for Assoc Req.
13430 // This macro is provided by the halPhyCfg.h. We pick our
13431 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013432 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13433 if (0 != pwrLimit)
13434 {
13435 *pBuf++ = pwrLimit;
13436 }
13437 else
13438 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013439 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 size = sizeof(pMac->roam.validChannelList);
13442 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013443 {
13444 tANI_U8 *actualSize = pBuf++;
13445 *actualSize = 0;
13446
13447 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013449 /* Only add 5ghz channels*/
13450 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13451 {
13452 *actualSize +=1;
13453 *pBuf++ = pMac->roam.validChannelList[ i ];
13454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 }
13456 }
13457 else
13458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013459 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 *pBuf++ = 0; //tSirSupChnl->numChnl
13461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 //Check whether it is ok to enter UAPSD
13463#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13464 if( btcIsReadyForUapsd(pMac) )
13465#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13466 {
13467 *pBuf++ = uapsdMask;
13468 }
13469#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13470 else
13471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013472 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 *pBuf++ = 0;
13474 }
13475#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13476
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013478 vos_mem_copy(pBuf, pBssDescription,
13479 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13481}
13482
Jeff Johnson295189b2012-06-20 16:38:30 -070013483/*
13484 * The communication between HDD and LIM is thru mailbox (MB).
13485 * Both sides will access the data structure "tSirSmeJoinReq".
13486 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13487 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13488 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13489 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13490 */
13491eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013492 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013493{
13494 eHalStatus status = eHAL_STATUS_SUCCESS;
13495 tSirSmeJoinReq *pMsg;
13496 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013497 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 tANI_U16 msgLen, wTmp, ieLen;
13499 tSirMacRateSet OpRateSet;
13500 tSirMacRateSet ExRateSet;
13501 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13502 tANI_U32 dwTmp;
13503 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013504 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013505 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013506 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013507
13508 if(!pSession)
13509 {
13510 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13511 return eHAL_STATUS_FAILURE;
13512 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013513 /* To satisfy klockworks */
13514 if (NULL == pBssDescription)
13515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013516 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013517 return eHAL_STATUS_FAILURE;
13518 }
13519
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 do {
13521 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13522 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013523 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13525 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13526 // IE fields, but the length field in the bssDescription needs to be interpreted to
13527 // determine length of the IE fields.
13528 //
13529 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13530 // add in the length from the bssDescription (then add the size of the 'length' field
13531 // itself because that is NOT included in the length field).
13532 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13533 pBssDescription->length + sizeof( pBssDescription->length ) +
13534 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 +053013535 pMsg = vos_mem_malloc(msgLen);
13536 if (NULL == pMsg)
13537 status = eHAL_STATUS_FAILURE;
13538 else
13539 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013541 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013542 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 pMsg->length = pal_cpu_to_be16(msgLen);
13544 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 // sessionId
13546 *pBuf = (tANI_U8)sessionId;
13547 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 // transactionId
13549 *pBuf = 0;
13550 *( pBuf + 1 ) = 0;
13551 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 // ssId
13553 if( pIes->SSID.present && pIes->SSID.num_ssid )
13554 {
13555 // ssId len
13556 *pBuf = pIes->SSID.num_ssid;
13557 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013558 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 pBuf += pIes->SSID.num_ssid;
13560 }
13561 else
13562 {
13563 *pBuf = 0;
13564 pBuf++;
13565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013567 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13568 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 pBuf += sizeof(tSirMacAddr);
13570 // bsstype
13571 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13572 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013573 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 pBuf += sizeof(tSirBssType);
13575 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013576 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13577 if (pBssDescription->channelId <= 14 &&
13578 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13579 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13580 {
13581 //Need to disable VHT operation in 2.4 GHz band
13582 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13583 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013584 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13585 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13586
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013587 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 //Persona
13590 *pBuf = (tANI_U8)pProfile->csrPersona;
13591 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013592 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13593 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013594 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13595 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013596 //CBMode
13597 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13598 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013599 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13600 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013601
13602 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013603 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13604 pProfile->csrPersona, pSession->bssParams.cbMode,
13605 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013606
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 // uapsdPerAcBitmask
13608 *pBuf = pProfile->uapsd_mask;
13609 pBuf++;
13610
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013611
13612
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013613 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013614 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 {
13616 // OperationalRateSet
13617 if (OpRateSet.numRates) {
13618 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 pBuf += OpRateSet.numRates;
13621 } else *pBuf++ = 0;
13622 // ExtendedRateSet
13623 if (ExRateSet.numRates) {
13624 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013625 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pBuf += ExRateSet.numRates;
13627 } else *pBuf++ = 0;
13628 }
13629 else
13630 {
13631 *pBuf++ = 0;
13632 *pBuf++ = 0;
13633 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013634
13635 //rateBitmap
13636 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13637 pBuf += sizeof(tANI_U16);
13638
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 // rsnIE
13640 if ( csrIsProfileWpa( pProfile ) )
13641 {
13642 // Insert the Wpa IE into the join request
13643 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13644 (tCsrWpaIe *)( wpaRsnIE ) );
13645 }
13646 else if( csrIsProfileRSN( pProfile ) )
13647 {
13648 // Insert the RSN IE into the join request
13649 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13650 (tCsrRSNIe *)( wpaRsnIE ) );
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +053013651 pMsg->force_rsne_override =
13652 pProfile->force_rsne_override;
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 }
13654#ifdef FEATURE_WLAN_WAPI
13655 else if( csrIsProfileWapi( pProfile ) )
13656 {
13657 // Insert the WAPI IE into the join request
13658 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13659 (tCsrWapiIe *)( wpaRsnIE ) );
13660 }
13661#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 else
13663 {
13664 ieLen = 0;
13665 }
13666 //remember the IE for future use
13667 if( ieLen )
13668 {
13669 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013671 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 -070013672 ieLen = DOT11F_IE_RSN_MAX_LEN;
13673 }
13674#ifdef FEATURE_WLAN_WAPI
13675 if( csrIsProfileWapi( pProfile ) )
13676 {
13677 //Check whether we need to allocate more memory
13678 if(ieLen > pSession->nWapiReqIeLength)
13679 {
13680 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13681 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013682 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013684 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13685 if (NULL == pSession->pWapiReqIE)
13686 status = eHAL_STATUS_FAILURE;
13687 else
13688 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 if(!HAL_STATUS_SUCCESS(status)) break;
13690 }
13691 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013692 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013694 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013696 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 pBuf += ieLen;
13698 }
13699 else//should be WPA/WPA2 otherwise
13700#endif /* FEATURE_WLAN_WAPI */
13701 {
13702 //Check whether we need to allocate more memory
13703 if(ieLen > pSession->nWpaRsnReqIeLength)
13704 {
13705 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13706 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013707 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013708 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013709 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13710 if (NULL == pSession->pWpaRsnReqIE)
13711 status = eHAL_STATUS_FAILURE;
13712 else
13713 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 if(!HAL_STATUS_SUCCESS(status)) break;
13715 }
13716 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013717 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013721 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pBuf += ieLen;
13723 }
13724 }
13725 else
13726 {
13727 //free whatever old info
13728 pSession->nWpaRsnReqIeLength = 0;
13729 if(pSession->pWpaRsnReqIE)
13730 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013731 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 pSession->pWpaRsnReqIE = NULL;
13733 }
13734#ifdef FEATURE_WLAN_WAPI
13735 pSession->nWapiReqIeLength = 0;
13736 if(pSession->pWapiReqIE)
13737 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013738 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 pSession->pWapiReqIE = NULL;
13740 }
13741#endif /* FEATURE_WLAN_WAPI */
13742 //length is two bytes
13743 *pBuf = 0;
13744 *(pBuf + 1) = 0;
13745 pBuf += 2;
13746 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013747#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013748 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013750 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 //length is two bytes
13752 *pBuf = 0;
13753 *(pBuf + 1) = 0;
13754 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013755 }
13756 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013758 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013759 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013760 {
13761 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013762#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013763 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013764 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013765 pSession->suppCckmIeInfo.cckmIe, ieLen);
13766#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013767 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013768 pSession,
13769 pProfile,
13770 pBssDescription,
13771 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pSession->nWpaRsnReqIeLength,
13773 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013774#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013775 }
13776 else
13777 {
13778 ieLen = 0;
13779 }
13780 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13781 if( ieLen )
13782 {
13783 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13784 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013785 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013786 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013787 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013788 pBuf += ieLen;
13789 }
13790 else
13791 {
13792 //Indicate you have no CCKM IE
13793 //length is two bytes
13794 *pBuf = 0;
13795 *(pBuf + 1) = 0;
13796 pBuf += 2;
13797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013799#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013801 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 {
13803 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013804 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013806 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013808 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013810 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013811 pBuf += ieLen;
13812 }
13813 else
13814 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013815 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 *pBuf = 0;
13818 *(pBuf + 1) = 0;
13819 pBuf += 2;
13820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 // addIEAssoc
13822 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13823 {
13824 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 if(ieLen > pSession->nAddIEAssocLength)
13826 {
13827 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013828 {
13829 vos_mem_free(pSession->pAddIEAssoc);
13830 }
13831 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13832 if (NULL == pSession->pAddIEAssoc)
13833 status = eHAL_STATUS_FAILURE;
13834 else
13835 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013839 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013841 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013843 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 pBuf += ieLen;
13845 }
13846 else
13847 {
13848 pSession->nAddIEAssocLength = 0;
13849 if(pSession->pAddIEAssoc)
13850 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013851 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 pSession->pAddIEAssoc = NULL;
13853 }
13854 *pBuf = 0;
13855 *(pBuf + 1) = 0;
13856 pBuf += 2;
13857 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013858
13859 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013860 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013861 //Unmask any AC in reassoc that is ACM-set
13862 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13863 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013865 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13866 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013867#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013868 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013869#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013870 }
13871 else
13872 {
13873 uapsd_mask = 0;
13874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 }
13876 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013877
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013879 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013880 pBuf += sizeof(tANI_U32);
13881
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013883 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013884 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013885#ifdef WLAN_FEATURE_11W
13886 //MgmtEncryption
13887 if (pProfile->MFPEnabled)
13888 {
13889 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13890 }
13891 else
13892 {
13893 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13894 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013895 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013896 pBuf += sizeof(tANI_U32);
13897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013898#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013899 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013900 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013901#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013902 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013903 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013904#endif
13905 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013906 {
13907 // is11Rconnection;
13908 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013909 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013910 pBuf += sizeof(tAniBool);
13911 }
13912 else
13913 {
13914 // is11Rconnection;
13915 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013916 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013917 pBuf += sizeof(tAniBool);
13918 }
13919#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013920#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013921
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013922 // isESEFeatureIniEnabled
13923 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013924 {
13925 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013926 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013927 pBuf += sizeof(tAniBool);
13928 }
13929 else
13930 {
13931 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013932 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013933 pBuf += sizeof(tAniBool);
13934 }
13935
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013936 /* A profile can not be both ESE and 11R. But an 802.11R AP
13937 * may be advertising support for ESE as well. So if we are
13938 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013939 * If we are associating explictly 11R only then we will get
13940 * 11R.
13941 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013942 if ((csrIsProfileESE(pProfile) ||
13943 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013944 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13945 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13946 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13947 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13948#ifdef WLAN_FEATURE_11W
13949 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013950 || (pProfile->negotiatedAuthType ==
13951 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013952#endif
13953 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013954 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013955 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013956 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013957 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013958 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013959 pBuf += sizeof(tAniBool);
13960 }
13961 else
13962 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013963 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013964 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013965 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013966 pBuf += sizeof(tAniBool);
13967 }
13968
13969 if (eWNI_SME_JOIN_REQ == messageType)
13970 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013971 tESETspecInfo eseTspec;
13972 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013973 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013974 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13975 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13976 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013977 }
13978 else if (eWNI_SME_REASSOC_REQ == messageType)
13979 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013980 if ((csrIsProfileESE(pProfile) ||
13981 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013982 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13983 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13984 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13985 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13986#ifdef WLAN_FEATURE_11W
13987 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013988 || (pProfile->negotiatedAuthType ==
13989 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013990#endif
13991 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013992 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013994 tESETspecInfo eseTspec;
13995 // ESE Tspec information
13996 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13997 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13998 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014001 if (eseTspec.numTspecs) {
14002 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
14003 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014005 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070014006 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014007 else
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014009 tESETspecInfo eseTspec;
14010 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014012 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14013 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
14014 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 }
14016 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014017#endif // FEATURE_WLAN_ESE
14018#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014020 if (pMac->roam.configParam.isFastTransitionEnabled
14021#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053014022 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014023#endif
14024 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014026 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014027 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014028 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 }
14030 else
14031 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014032 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014033 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014034 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 }
14036#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070014037#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053014038 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070014039 {
14040 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014041 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014042 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014043 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014044 }
14045 else
14046 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014047 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014048 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014049 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014050 }
14051#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014052
14053 // txLdpcIniFeatureEnabled
14054 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
14055 pBuf++;
14056
Kiran4a17ebe2013-01-31 10:43:43 -080014057 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
14058 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
14059 {
14060 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
14061 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
14062 csrApplyPower2Current(pMac);
14063 }
14064
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014065#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014066 // txBFIniFeatureEnabled
14067 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14068 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014069
14070 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014071 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014072 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014073 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14074 if (pIes->VHTCaps.numSoundingDim)
14075 txBFCsnValue = CSR_ROAM_MIN
14076 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014077 }
14078 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014079 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014080
14081 /* Only enable MuBf if no other MuBF session exist
14082 * and FW and HOST is MuBF capable.
14083 */
14084 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14085 {
14086 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14087 pBuf++;
14088 }
14089 else
14090 {
14091 *pBuf = 0;
14092 pBuf++;
14093 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014094#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014095 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14096 pBuf++;
14097
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014098 // WME
14099 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14100 {
14101 //WME enabled
14102 dwTmp = pal_cpu_to_be32(TRUE);
14103 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14104 pBuf += sizeof(tAniBool);
14105 }
14106 else
14107 {
14108 dwTmp = pal_cpu_to_be32(FALSE);
14109 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14110 pBuf += sizeof(tAniBool);
14111 }
14112
14113 // QOS
14114 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14115 {
14116 //QOS enabled
14117 dwTmp = pal_cpu_to_be32(TRUE);
14118 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14119 pBuf += sizeof(tAniBool);
14120 }
14121 else
14122 {
14123 dwTmp = pal_cpu_to_be32(FALSE);
14124 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14125 pBuf += sizeof(tAniBool);
14126 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014127 //BssDesc
14128 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14129 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014130
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014131 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014132 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14133 pMsg = NULL;
14134
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014135 if(!HAL_STATUS_SUCCESS(status))
14136 {
14137 break;
14138 }
14139 else
14140 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014141#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014142 if (eWNI_SME_JOIN_REQ == messageType)
14143 {
14144 //Tush-QoS: notify QoS module that join happening
14145 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14146 }
14147 else if (eWNI_SME_REASSOC_REQ == messageType)
14148 {
14149 //Tush-QoS: notify QoS module that reassoc happening
14150 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014152#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014155
14156 if (pMsg != NULL)
14157 {
14158 vos_mem_free( pMsg );
14159 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014160 pMac->roam.roamSession[sessionId].connect_req_start_time =
14161 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014162
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014164}
14165
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014166#ifdef WLAN_FEATURE_LFR_MBB
14167/**
14168 * csr_prepare_reassoc_req () - Prepares reassoc request
14169 * @mac: MAC context
14170 * @session_id: session id
14171 * @pbss_description: bss description
14172 * @ies: pointer to beacon IE's
14173 * @reassoc_req: pointer to reassociation request
14174 *
14175 *Return: None
14176 */
14177eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14178 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14179 tSirSmeJoinReq **reassoc_req)
14180{
14181 eHalStatus status = eHAL_STATUS_SUCCESS;
14182 tSirSmeJoinReq *csr_join_req;
14183 tANI_U8 *buf;
14184 v_U8_t acm_mask = 0, uapsd_mask;
14185 tANI_U16 msg_len, w_tmp, ie_len;
14186 tSirMacRateSet op_rate_set;
14187 tSirMacRateSet ex_rate_set;
14188 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14189 tANI_U32 dw_tmp;
14190 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14191 tANI_U32 uc_dot11_mode = 0;
14192 tANI_U8 tx_bf_csn_value = 0;
14193 tANI_U16 rate_bitmap = 0;
14194 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014195 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014196
14197 if(!session) {
14198 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14199 return eHAL_STATUS_FAILURE;
14200 }
14201
14202 if (NULL == bss_description) {
14203 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14204 return eHAL_STATUS_FAILURE;
14205 }
14206
14207 smsLog(mac, LOG1,
14208 FL("session_id %d"), session_id);
14209
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014210 profile = vos_mem_malloc(sizeof(*profile));
14211 if (NULL == profile) {
14212 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14213 return eHAL_STATUS_RESOURCES;
14214 }
14215
14216 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014217 if(!HAL_STATUS_SUCCESS(status)) {
14218 smsLog(mac, LOGE, FL("Profile copy failed"));
14219 return eHAL_STATUS_FAILURE;
14220 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014221
14222 do {
14223 /*
14224 * There are a number of variable length fields to consider.
14225 * First, the tSirSmeJoinReq includes a single bssDescription.
14226 * bssDescription includes a single tANI_U32 for the IE fields,
14227 * but the length field in the bssDescription needs to be
14228 * interpreted to determine length of the IE fields.
14229 * So, take the size of the JoinReq, subtract the size of the
14230 * bssDescription and add in the length from the bssDescription
14231 * (then add the size of the 'length' field itself because that is
14232 * NOT included in the length field). msgLen =
14233 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14234 * pBssDescription->length + sizeof( pBssDescription->length ) +
14235 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14236 * add in the size of the WPA IE that we may build.
14237 */
14238
14239 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14240 bss_description->length + sizeof(bss_description->length) +
14241 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14242
14243 csr_join_req = vos_mem_malloc(msg_len);
14244 if (NULL == csr_join_req)
14245 status = eHAL_STATUS_FAILURE;
14246 else
14247 status = eHAL_STATUS_SUCCESS;
14248 if (!HAL_STATUS_SUCCESS(status)) break;
14249
14250 vos_mem_set(csr_join_req, msg_len, 0);
14251 *reassoc_req = csr_join_req;
14252
14253 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14254 csr_join_req->length = pal_cpu_to_be16(msg_len);
14255 buf = &csr_join_req->sessionId;
14256
14257 /* session_id */
14258 *buf = (tANI_U8)session_id;
14259 buf++;
14260
14261 /* transactionId */
14262 *buf = 0;
14263 *(buf + 1) = 0;
14264 buf += sizeof(tANI_U16);
14265
14266 /* ssId */
14267 if(ies->SSID.present && ies->SSID.num_ssid)
14268 {
14269 /* ssId len */
14270 *buf = ies->SSID.num_ssid;
14271 buf++;
14272 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14273 buf += ies->SSID.num_ssid;
14274 }
14275 else
14276 {
14277 *buf = 0;
14278 buf++;
14279 }
14280
14281 /* selfMacAddr */
14282 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14283 sizeof(tSirMacAddr));
14284 buf += sizeof(tSirMacAddr);
14285
14286 /* bsstype */
14287 dw_tmp =
14288 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14289 /* Override BssType for BTAMP */
14290 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14291 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14292 buf += sizeof(tSirBssType);
14293
14294 /* dot11mode */
14295 uc_dot11_mode =
14296 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14297 if (bss_description->channelId <= 14 &&
14298 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14299 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14300 {
14301 /* Need to disable VHT operation in 2.4 GHz band */
14302 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14303 }
14304 *buf = (tANI_U8)uc_dot11_mode;
14305 buf++;
14306
14307 /* Persona */
14308 *buf = (tANI_U8)profile->csrPersona;
14309 buf++;
14310 *buf = (tANI_U8)profile->bOSENAssociation;
14311 buf++;
14312 *buf = (tANI_U8)profile->bWPSAssociation;
14313 buf++;
14314
14315 /* CBMode */
14316 *buf = (tANI_U8)session->bssParams.cbMode;
14317 buf++;
14318
14319 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14320 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14321 session->bssParams.cbMode);
14322
14323 /* uapsdPerAcBitmask */
14324 *buf = profile->uapsd_mask;
14325 buf++;
14326
14327
14328 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14329 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14330 if (HAL_STATUS_SUCCESS(status))
14331 {
14332 /* OperationalRateSet */
14333 if (op_rate_set.numRates) {
14334 *buf++ = op_rate_set.numRates;
14335 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14336 buf += op_rate_set.numRates;
14337 } else *buf++ = 0;
14338
14339 /* ExtendedRateSet */
14340 if (ex_rate_set.numRates) {
14341 *buf++ = ex_rate_set.numRates;
14342 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14343 buf += ex_rate_set.numRates;
14344 } else *buf++ = 0;
14345 }
14346 else
14347 {
14348 *buf++ = 0;
14349 *buf++ = 0;
14350 }
14351
14352 /* rateBitmap */
14353 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14354 buf += sizeof(tANI_U16);
14355
14356 profile->negotiatedAuthType =
14357 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14358 profile->negotiatedUCEncryptionType =
14359 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14360
14361 /* rsnIE */
14362 if ( csrIsProfileWpa(profile))
14363 {
14364 /* Insert the Wpa IE into the join request */
14365 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14366 (tCsrWpaIe *)(wpa_rsn_ie));
14367 }
14368 else if( csrIsProfileRSN(profile))
14369 {
14370 /* Insert the RSN IE into the join request */
14371 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14372 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14373 }
14374#ifdef FEATURE_WLAN_WAPI
14375 else if( csrIsProfileWapi(profile))
14376 {
14377 /* Insert the WAPI IE into the join request */
14378 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14379 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14380 }
14381#endif
14382 else
14383 {
14384 ie_len = 0;
14385 }
14386 /* remember the IE for future use */
14387 if(ie_len)
14388 {
14389 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14390 {
14391 smsLog(mac, LOGE,
14392 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14393 ie_len, DOT11F_IE_RSN_MAX_LEN);
14394 ie_len = DOT11F_IE_RSN_MAX_LEN;
14395 }
14396#ifdef FEATURE_WLAN_WAPI
14397 if( csrIsProfileWapi(profile))
14398 {
14399 /* Check whether we need to allocate more memory */
14400 if(ie_len > session->nWapiReqIeLength)
14401 {
14402 if(session->pWapiReqIE && session->nWapiReqIeLength)
14403 {
14404 vos_mem_free(session->pWapiReqIE);
14405 }
14406 session->pWapiReqIE = vos_mem_malloc(ie_len);
14407 if (NULL == session->pWapiReqIE)
14408 status = eHAL_STATUS_FAILURE;
14409 else
14410 status = eHAL_STATUS_SUCCESS;
14411 if(!HAL_STATUS_SUCCESS(status)) break;
14412 }
14413 session->nWapiReqIeLength = ie_len;
14414 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14415 w_tmp = pal_cpu_to_be16(ie_len);
14416 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14417 buf += sizeof(tANI_U16);
14418 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14419 buf += ie_len;
14420 }
14421 else /* should be WPA/WPA2 otherwise */
14422#endif
14423 {
14424 /* Check whether we need to allocate more memory */
14425 if(ie_len > session->nWpaRsnReqIeLength)
14426 {
14427 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14428 {
14429 vos_mem_free(session->pWpaRsnReqIE);
14430 }
14431 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14432 if (NULL == session->pWpaRsnReqIE)
14433 status = eHAL_STATUS_FAILURE;
14434 else
14435 status = eHAL_STATUS_SUCCESS;
14436 if(!HAL_STATUS_SUCCESS(status)) break;
14437 }
14438 session->nWpaRsnReqIeLength = ie_len;
14439 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14440 w_tmp = pal_cpu_to_be16(ie_len);
14441 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14442 buf += sizeof(tANI_U16);
14443 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14444 buf += ie_len;
14445 }
14446 }
14447 else
14448 {
14449 /* free whatever old info */
14450 session->nWpaRsnReqIeLength = 0;
14451 if(session->pWpaRsnReqIE)
14452 {
14453 vos_mem_free(session->pWpaRsnReqIE);
14454 session->pWpaRsnReqIE = NULL;
14455 }
14456#ifdef FEATURE_WLAN_WAPI
14457 session->nWapiReqIeLength = 0;
14458 if(session->pWapiReqIE)
14459 {
14460 vos_mem_free(session->pWapiReqIE);
14461 session->pWapiReqIE = NULL;
14462 }
14463#endif
14464 /* length is two bytes */
14465 *buf = 0;
14466 *(buf + 1) = 0;
14467 buf += 2;
14468 }
14469#ifdef FEATURE_WLAN_ESE
14470 if(eWNI_SME_JOIN_REQ == message_type)
14471 {
14472 /*
14473 * Never include the cckmIE in an Join Request
14474 * length is two bytes
14475 */
14476 *buf = 0;
14477 *(buf + 1) = 0;
14478 buf += 2;
14479 }
14480 else if(eWNI_SME_REASSOC_REQ == message_type)
14481 {
14482 /* cckmIE */
14483 if( csrIsProfileESE(profile))
14484 {
14485 /* Insert the CCKM IE into the join request */
14486#ifdef FEATURE_WLAN_ESE_UPLOAD
14487 ie_len = session->suppCckmIeInfo.cckmIeLen;
14488 vos_mem_copy((void *) (wpa_rsn_ie),
14489 session->suppCckmIeInfo.cckmIe, ie_len);
14490#else
14491 ie_len = csrConstructEseCckmIe(mac,
14492 session,
14493 profile,
14494 bss_description,
14495 session->pWpaRsnReqIE,
14496 session->nWpaRsnReqIeLength,
14497 (void *)(wpa_rsn_ie));
14498#endif
14499 }
14500 else
14501 {
14502 ie_len = 0;
14503 }
14504 /*
14505 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14506 * message buffer
14507 */
14508 if(ie_len)
14509 {
14510 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14511 w_tmp = pal_cpu_to_be16(ie_len);
14512 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14513 buf += sizeof(tANI_U16);
14514 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14515 buf += ie_len;
14516 }
14517 else
14518 {
14519 /* Indicate you have no CCKM IE length is two bytes */
14520 *buf = 0;
14521 *(buf + 1) = 0;
14522 buf += 2;
14523 }
14524 }
14525#endif
14526 /* addIEScan */
14527 if (profile->nAddIEScanLength)
14528 {
14529 ie_len = profile->nAddIEScanLength;
14530 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14531 session->nAddIEScanLength = ie_len;
14532 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14533 w_tmp = pal_cpu_to_be16(ie_len);
14534 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14535 buf += sizeof(tANI_U16);
14536 vos_mem_copy(buf, profile->addIEScan, ie_len);
14537 buf += ie_len;
14538 }
14539 else
14540 {
14541 memset(session->addIEScan, 0, session->nAddIEScanLength);
14542 session->nAddIEScanLength = 0;
14543 *buf = 0;
14544 *(buf + 1) = 0;
14545 buf += 2;
14546 }
14547 /* addIEAssoc */
14548 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14549 {
14550 ie_len = profile->nAddIEAssocLength;
14551 if(ie_len > session->nAddIEAssocLength)
14552 {
14553 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14554 {
14555 vos_mem_free(session->pAddIEAssoc);
14556 }
14557 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14558 if (NULL == session->pAddIEAssoc)
14559 status = eHAL_STATUS_FAILURE;
14560 else
14561 status = eHAL_STATUS_SUCCESS;
14562 if(!HAL_STATUS_SUCCESS(status)) break;
14563 }
14564 session->nAddIEAssocLength = ie_len;
14565 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14566 w_tmp = pal_cpu_to_be16(ie_len);
14567 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14568 buf += sizeof(tANI_U16);
14569 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14570 buf += ie_len;
14571 }
14572 else
14573 {
14574 session->nAddIEAssocLength = 0;
14575 if(session->pAddIEAssoc)
14576 {
14577 vos_mem_free(session->pAddIEAssoc);
14578 session->pAddIEAssoc = NULL;
14579 }
14580 *buf = 0;
14581 *(buf + 1) = 0;
14582 buf += 2;
14583 }
14584
14585 if(eWNI_SME_REASSOC_REQ == message_type )
14586 {
14587 /*Unmask any AC in reassoc that is ACM-set */
14588 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14589 if( uapsd_mask && (NULL != bss_description))
14590 {
14591 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14592 {
14593#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14594 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14595#endif
14596 }
14597 else
14598 {
14599 uapsd_mask = 0;
14600 }
14601 }
14602 }
14603
14604 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14605 profile->negotiatedUCEncryptionType));
14606 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14607 buf += sizeof(tANI_U32);
14608
14609 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14610 profile->negotiatedMCEncryptionType));
14611 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14612 buf += sizeof(tANI_U32);
14613#ifdef WLAN_FEATURE_11W
14614 /* MgmtEncryption */
14615 if (profile->MFPEnabled)
14616 {
14617 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14618 }
14619 else
14620 {
14621 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14622 }
14623 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14624 buf += sizeof(tANI_U32);
14625#endif
14626#ifdef WLAN_FEATURE_VOWIFI_11R
14627 profile->MDID.mdiePresent = bss_description->mdiePresent;
14628 if (csrIsProfile11r(profile)
14629#ifdef FEATURE_WLAN_ESE
14630 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14631 (ies->ESEVersion.present) &&
14632 (mac->roam.configParam.isEseIniFeatureEnabled))
14633#endif
14634 )
14635 {
14636 /* is11Rconnection */
14637 dw_tmp = pal_cpu_to_be32(TRUE);
14638 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14639 buf += sizeof(tAniBool);
14640 }
14641 else
14642 {
14643 /* is11Rconnection */
14644 dw_tmp = pal_cpu_to_be32(FALSE);
14645 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14646 buf += sizeof(tAniBool);
14647 }
14648#endif
14649#ifdef FEATURE_WLAN_ESE
14650
14651 /* isESEFeatureIniEnabled */
14652 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14653 {
14654 dw_tmp = pal_cpu_to_be32(TRUE);
14655 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14656 buf += sizeof(tAniBool);
14657 }
14658 else
14659 {
14660 dw_tmp = pal_cpu_to_be32(FALSE);
14661 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14662 buf += sizeof(tAniBool);
14663 }
14664
14665 /* A profile can not be both ESE and 11R. But an 802.11R AP
14666 * may be advertising support for ESE as well. So if we are
14667 * associating Open or explicitly ESE then we will get ESE.
14668 * If we are associating explictly 11R only then we will get
14669 * 11R.
14670 */
14671 if ((csrIsProfileESE(profile) ||
14672 ((ies->ESEVersion.present)
14673 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14674 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14675 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14676 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14677#ifdef WLAN_FEATURE_11W
14678 || (profile->negotiatedAuthType ==
14679 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14680 || (profile->negotiatedAuthType ==
14681 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14682#endif
14683 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14684 && (mac->roam.configParam.isEseIniFeatureEnabled))
14685 {
14686 /* isESEconnection */
14687 dw_tmp = pal_cpu_to_be32(TRUE);
14688 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14689 buf += sizeof(tAniBool);
14690 }
14691 else
14692 {
14693 /* isESEconnection */
14694 dw_tmp = pal_cpu_to_be32(FALSE);
14695 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14696 buf += sizeof(tAniBool);
14697 }
14698
14699 if (eWNI_SME_JOIN_REQ == message_type)
14700 {
14701 tESETspecInfo eseTspec;
14702 /*
14703 * ESE-Tspec IEs in the ASSOC request is presently not supported
14704 * so nullify the TSPEC parameters
14705 */
14706 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14707 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14708 buf += sizeof(tESETspecInfo);
14709 }
14710 else if (eWNI_SME_REASSOC_REQ == message_type)
14711 {
14712 if ((csrIsProfileESE(profile) ||
14713 ((ies->ESEVersion.present)
14714 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14715 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14716 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14717 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14718#ifdef WLAN_FEATURE_11W
14719 || (profile->negotiatedAuthType ==
14720 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14721 || (profile->negotiatedAuthType ==
14722 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14723#endif
14724 || (profile->negotiatedAuthType ==
14725 eCSR_AUTH_TYPE_RSN_PSK))))
14726 && (mac->roam.configParam.isEseIniFeatureEnabled))
14727 {
14728 tESETspecInfo eseTspec;
14729 /* ESE Tspec information */
14730 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14731 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14732 (tTspecInfo *) &eseTspec.tspec[0]);
14733 *buf = eseTspec.numTspecs;
14734 buf += sizeof(tANI_U8);
14735 // Copy the TSPEC information only if present
14736 if (eseTspec.numTspecs) {
14737 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14738 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14739 }
14740 buf += sizeof(eseTspec.tspec);
14741 }
14742 else
14743 {
14744 tESETspecInfo eseTspec;
14745 /*
14746 * ESE-Tspec IEs in the ASSOC request is presently
14747 * not supported so nullify the TSPEC parameters
14748 */
14749 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14750 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14751 buf += sizeof(tESETspecInfo);
14752 }
14753 }
14754#endif
14755#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14756 /* Fill in isFastTransitionEnabled */
14757 if (mac->roam.configParam.isFastTransitionEnabled
14758#ifdef FEATURE_WLAN_LFR
14759 || csrRoamIsFastRoamEnabled(mac, session_id)
14760#endif
14761 )
14762 {
14763 dw_tmp = pal_cpu_to_be32(TRUE);
14764 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14765 buf += sizeof(tAniBool);
14766 }
14767 else
14768 {
14769 dw_tmp = pal_cpu_to_be32(FALSE);
14770 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14771 buf += sizeof(tAniBool);
14772 }
14773#endif
14774#ifdef FEATURE_WLAN_LFR
14775 if(csrRoamIsFastRoamEnabled(mac, session_id))
14776 {
14777 /* legacy fast roaming enabled */
14778 dw_tmp = pal_cpu_to_be32(TRUE);
14779 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14780 buf += sizeof(tAniBool);
14781 }
14782 else
14783 {
14784 dw_tmp = pal_cpu_to_be32(FALSE);
14785 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14786 buf += sizeof(tAniBool);
14787 }
14788#endif
14789
14790 /* txLdpcIniFeatureEnabled */
14791 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14792 buf++;
14793
14794 if ((csrIs11hSupported(mac)) &&
14795 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14796 (ies->Country.present) &&\
14797 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14798 {
14799 csrSaveToChannelPower2G_5G(mac,
14800 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14801 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14802 csrApplyPower2Current(mac);
14803 }
14804
14805#ifdef WLAN_FEATURE_11AC
14806 /* txBFIniFeatureEnabled */
14807 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14808 buf++;
14809
14810 /* txBFCsnValue */
14811 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14812 {
14813 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14814 if (ies->VHTCaps.numSoundingDim)
14815 tx_bf_csn_value = CSR_ROAM_MIN
14816 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14817 }
14818 *buf = tx_bf_csn_value;
14819 buf++;
14820
14821 /* Only enable MuBf if no other MuBF session exist
14822 * and FW and HOST is MuBF capable.
14823 */
14824 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14825 {
14826 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14827 buf++;
14828 }
14829 else
14830 {
14831 *buf = 0;
14832 buf++;
14833 }
14834#endif
14835 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14836 buf++;
14837
14838 /* WME */
14839 if(mac->roam.roamSession[session_id].fWMMConnection)
14840 {
14841 /* WME enabled */
14842 dw_tmp = pal_cpu_to_be32(TRUE);
14843 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14844 buf += sizeof(tAniBool);
14845 }
14846 else
14847 {
14848 dw_tmp = pal_cpu_to_be32(FALSE);
14849 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14850 buf += sizeof(tAniBool);
14851 }
14852
14853 /* QOS */
14854 if(mac->roam.roamSession[session_id].fQOSConnection)
14855 {
14856 /* QOS enabled */
14857 dw_tmp = pal_cpu_to_be32(TRUE);
14858 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14859 buf += sizeof(tAniBool);
14860 }
14861 else
14862 {
14863 dw_tmp = pal_cpu_to_be32(FALSE);
14864 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14865 buf += sizeof(tAniBool);
14866 }
14867 /* BssDesc */
14868 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14869 (tANI_U8)profile->uapsd_mask);
14870 } while( 0 );
14871
14872 smsLog(mac, LOG1, FL("status %d"), status);
14873
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014874 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014875 return status;
14876}
14877#endif
14878
Jeff Johnson295189b2012-06-20 16:38:30 -070014879//
14880eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14881{
14882 eHalStatus status = eHAL_STATUS_SUCCESS;
14883 tSirSmeDisassocReq *pMsg;
14884 tANI_U8 *pBuf;
14885 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14887 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14888 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014890 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14891 if (NULL == pMsg)
14892 status = eHAL_STATUS_FAILURE;
14893 else
14894 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014896 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14898 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 pBuf = &pMsg->sessionId;
14900 // sessionId
14901 *pBuf++ = (tANI_U8)sessionId;
14902 // transactionId
14903 *pBuf = 0;
14904 *( pBuf + 1 ) = 0;
14905 pBuf += sizeof(tANI_U16);
14906
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014907 if ( (pSession->pCurRoamProfile != NULL) &&
14908 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14909 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 {
14911 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014912 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14913 sizeof( tSirMacAddr ));
14914 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014917 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14918 //perMacAddr is passed as bssId for softAP
14919 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 pBuf = pBuf + sizeof ( tSirMacAddr );
14921 }
14922 else
14923 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014925 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14926 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053014928 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
14929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 if(!HAL_STATUS_SUCCESS(status))
14933 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014934 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 break;
14936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 // reasonCode
14938 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014939 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
14940 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 if(!HAL_STATUS_SUCCESS(status))
14942 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014943 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 break;
14945 }
14946 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14948 Here we should not send the disassoc over the air to the AP */
14949 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14950#ifdef WLAN_FEATURE_VOWIFI_11R
14951 && csrRoamIs11rAssoc(pMac)
14952#endif
14953 )
14954 {
14955 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14956 }
14957 pBuf += sizeof(tANI_U8);
14958 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 return( status );
14961}
Jeff Johnson295189b2012-06-20 16:38:30 -070014962eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14963{
14964 eHalStatus status = eHAL_STATUS_SUCCESS;
14965 tSirSmeTkipCntrMeasReq *pMsg;
14966 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 do
14968 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014969 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14970 if ( NULL == pMsg )
14971 status = eHAL_STATUS_FAILURE;
14972 else
14973 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014975 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14977 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 pBuf = &pMsg->sessionId;
14979 // sessionId
14980 *pBuf++ = (tANI_U8)sessionId;
14981 // transactionId
14982 *pBuf = 0;
14983 *( pBuf + 1 ) = 0;
14984 pBuf += sizeof(tANI_U16);
14985 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014986 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14987 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 pBuf = pBuf + sizeof ( tSirMacAddr );
14989 // bEnable
14990 *pBuf = (tANI_BOOLEAN)bEnable;
14991 if(!HAL_STATUS_SUCCESS(status))
14992 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014993 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 break;
14995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 return( status );
14999}
Jeff Johnson295189b2012-06-20 16:38:30 -070015000eHalStatus
15001csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
15002 VOS_MODULE_ID modId, tSirMacAddr bssId,
15003 void *pUsrContext, void *pfnSapEventCallback,
15004 tANI_U8 *pAssocStasBuf )
15005{
15006 eHalStatus status = eHAL_STATUS_SUCCESS;
15007 tSirSmeGetAssocSTAsReq *pMsg;
15008 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15009 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 do
15011 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015012 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
15013 if ( NULL == pMsg )
15014 status = eHAL_STATUS_FAILURE;
15015 else
15016 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015018 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 pBuf = (tANI_U8 *)&pMsg->bssId;
15021 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015022 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015023 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015024 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 // modId
15026 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015027 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015030 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
15031 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015033 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
15034 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080015036 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
15037 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015038 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015039 status = palSendMBMessage( pMac->hHdd, pMsg );
15040 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 return( status );
15042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015043eHalStatus
15044csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
15045 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
15046 {
15047 eHalStatus status = eHAL_STATUS_SUCCESS;
15048 tSirSmeGetWPSPBCSessionsReq *pMsg;
15049 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080015050
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 do
15052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015053 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
15054 if ( NULL == pMsg )
15055 status = eHAL_STATUS_FAILURE;
15056 else
15057 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015058 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015059 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015060 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070015062 VOS_ASSERT(pBuf);
15063
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015066 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15067 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015069 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15070 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015072 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015074 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015075 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015076 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015077 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015080 return( status );
15081}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015082
15083eHalStatus
15084csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15085{
15086 tpSirChangeBIParams pMsg;
15087 tANI_U16 len = 0;
15088 eHalStatus status = eHAL_STATUS_SUCCESS;
15089 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15090
15091 if(!pSession)
15092 {
15093 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15094 return eHAL_STATUS_FAILURE;
15095 }
15096
15097 //NO need to update the Beacon Params if update beacon parameter flag is not set
15098 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15099 return eHAL_STATUS_SUCCESS;
15100
15101 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15102
15103 /* Create the message and send to lim */
15104 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015105 pMsg = vos_mem_malloc(len);
15106 if ( NULL == pMsg )
15107 status = eHAL_STATUS_FAILURE;
15108 else
15109 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015110 if(HAL_STATUS_SUCCESS(status))
15111 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015112 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015113 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15114 pMsg->length = len;
15115
15116 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015117 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15118 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015119 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15120 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015121 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015122 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015123 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15124 status = palSendMBMessage(pMac->hHdd, pMsg);
15125 }
15126 return status;
15127}
15128
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015129#ifdef WLAN_FEATURE_AP_HT40_24G
15130eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15131{
15132 tpSirSetHT2040Mode pMsg;
15133 tANI_U16 len = 0;
15134 eHalStatus status = eHAL_STATUS_SUCCESS;
15135 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15136
15137 if(!pSession)
15138 {
15139 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15140 return eHAL_STATUS_FAILURE;
15141 }
15142
15143 /* Create the message and send to lim */
15144 len = sizeof(tSirSetHT2040Mode);
15145 pMsg = vos_mem_malloc(len);
15146
15147 if ( NULL == pMsg )
15148 {
15149 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15150 status = eHAL_STATUS_FAILURE;
15151 }
15152 else
15153 status = eHAL_STATUS_SUCCESS;
15154
15155 if(HAL_STATUS_SUCCESS(status))
15156 {
15157 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15158 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15159 pMsg->length = len;
15160
15161 // bssId
15162 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15163 sizeof(tSirMacAddr));
15164
15165 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15166 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15167 MAC_ADDR_ARRAY(pMsg->bssId));
15168
15169 pMsg->sessionId = sessionId;
15170 pMsg->cbMode = cbMode;
15171
15172 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15173 sessionId, cbMode);
15174
15175 status = palSendMBMessage(pMac->hHdd, pMsg);
15176 }
15177 return status;
15178}
15179#endif
15180
Jeff Johnson295189b2012-06-20 16:38:30 -070015181eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15182{
15183 eHalStatus status = eHAL_STATUS_SUCCESS;
15184 tSirSmeDeauthReq *pMsg;
15185 tANI_U8 *pBuf;
15186 tANI_U16 wTmp;
15187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15188 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15189 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015190 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015191 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15192 if ( NULL == pMsg )
15193 status = eHAL_STATUS_FAILURE;
15194 else
15195 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015197 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015198 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15199 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15200 //sessionId
15201 pBuf = &pMsg->sessionId;
15202 *pBuf++ = (tANI_U8)sessionId;
15203
15204 //tansactionId
15205 *pBuf = 0;
15206 *(pBuf + 1 ) = 0;
15207 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015210 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15211 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015212 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15213 sizeof( pMsg->peerMacAddr ) );
15214 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 pBuf = pBuf + sizeof(tSirMacAddr);
15216 }
15217 else
15218 {
15219 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015220 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15221 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015223 }
15224 if(!HAL_STATUS_SUCCESS(status))
15225 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015226 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 break;
15228 }
15229 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015230 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15231 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 pBuf = pBuf + sizeof(tSirMacAddr);
15233 if(!HAL_STATUS_SUCCESS(status))
15234 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015235 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 break;
15237 }
15238 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015239 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15240 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 if(!HAL_STATUS_SUCCESS(status))
15242 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015243 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 break;
15245 }
15246 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015247 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015248 return( status );
15249}
15250
Jeff Johnson295189b2012-06-20 16:38:30 -070015251eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15252{
15253 eHalStatus status = eHAL_STATUS_SUCCESS;
15254 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015256 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15257 if ( NULL == pMsg )
15258 status = eHAL_STATUS_FAILURE;
15259 else
15260 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015261 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015262 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015263 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15264 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15265 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015266 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015267 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15268 sizeof(pMsg->peerMacAddr));
15269 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 if(!HAL_STATUS_SUCCESS(status))
15271 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015272 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 break;
15274 }
15275//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015276 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15277 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 if(!HAL_STATUS_SUCCESS(status))
15279 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015280 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 break;
15282 }
15283//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 return( status );
15287}
15288
Jeff Johnson295189b2012-06-20 16:38:30 -070015289eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15290{
15291 eHalStatus status = eHAL_STATUS_SUCCESS;
15292 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015294 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15295 if ( NULL == pMsg )
15296 status = eHAL_STATUS_FAILURE;
15297 else
15298 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015300 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015301 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15302 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15303 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015304 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015305 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15306 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 if(!HAL_STATUS_SUCCESS(status))
15308 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015309 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 break;
15311 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015312 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15313 sizeof(pMsg->peerMacAddr));
15314 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 if(!HAL_STATUS_SUCCESS(status))
15316 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015317 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 break;
15319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015322 return( status );
15323}
Jeff Johnson295189b2012-06-20 16:38:30 -070015324eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15325{
15326 eHalStatus status = eHAL_STATUS_SUCCESS;
15327 tSirSmeAssocCnf *pMsg;
15328 tANI_U8 *pBuf;
15329 tSirResultCodes statusCode;
15330 tANI_U16 wTmp;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015331 vos_msg_t msg;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015332
15333 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15334 "HalStatus : %d"),
15335 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015337 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15338 if ( NULL == pMsg )
15339 status = eHAL_STATUS_FAILURE;
15340 else
15341 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015342 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015343 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15345 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 pBuf = (tANI_U8 *)&pMsg->statusCode;
15347 if(HAL_STATUS_SUCCESS(Halstatus))
15348 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15349 else
15350 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015351 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 pBuf += sizeof(tSirResultCodes);
15353 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015354 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15355 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 pBuf += sizeof (tSirMacAddr);
15357 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015358 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15359 sizeof(tSirMacAddr));
15360 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 pBuf += sizeof (tSirMacAddr);
15362 // aid
15363 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015364 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015365 pBuf += sizeof (tANI_U16);
15366 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015367 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15368 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015369 pBuf += sizeof (tSirMacAddr);
15370 // alternateChannelId
15371 *pBuf = 11;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015372 msg.type = pMsg->messageType;
15373 msg.bodyval = 0;
15374 msg.bodyptr = pMsg;
15375 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 if(!HAL_STATUS_SUCCESS(status))
15377 {
15378 //pMsg is freed by palSendMBMessage
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015379 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 break;
15381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 return( status );
15384}
Jeff Johnson295189b2012-06-20 16:38:30 -070015385eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15386 tpSirSmeAssocInd pAssocInd,
15387 eHalStatus Halstatus,
15388 tANI_U8 sessionId)
15389{
15390 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15392 tANI_U8 *pBuf;
15393 tSirResultCodes statusCode;
15394 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015396 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15397 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15398 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015399
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15401 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15402
15403 pMsg->sessionId = sessionId;
15404
15405 pBuf = (tANI_U8 *)&pMsg->statusCode;
15406 if(HAL_STATUS_SUCCESS(Halstatus))
15407 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15408 else
15409 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015410 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 pBuf += sizeof(tSirResultCodes);
15412 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015413 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 pBuf += sizeof (tSirMacAddr);
15415 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015416 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15417 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 pBuf += sizeof (tSirMacAddr);
15419 // StaId
15420 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015421 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 pBuf += sizeof (tANI_U16);
15423 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015424 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 pBuf += sizeof (tSirMacAddr);
15426 // alternateChannelId
15427 *pBuf = 11;
15428 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015429 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 //Wmm
15431 *pBuf = pAssocInd->wmmEnabledSta;
15432 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015434 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015435 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015437 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 //reassocReq
15440 *pBuf = pAssocInd->reassocReq;
15441 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015442#ifdef WLAN_FEATURE_AP_HT40_24G
15443 // 40 MHz Intolerant
15444 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15445 pBuf += sizeof (tANI_U8);
15446#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015447 *pBuf = pAssocInd->rate_flags;
15448 pBuf += sizeof (uint32_t);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053015449
15450 pBuf = (tANI_U8 *)&pMsg->chan_info;
15451 vos_mem_copy((void *)pBuf, &pAssocInd->chan_info,
15452 sizeof(tSirSmeChanInfo));
15453
15454 pBuf = (tANI_U8 *)&pMsg->ch_width;
15455 *pBuf = pAssocInd->ch_width;
15456
15457 if (pAssocInd->HTCaps.present) {
15458 pBuf = (tANI_U8 *)&pMsg->HTCaps;
15459 vos_mem_copy(pBuf, &pAssocInd->HTCaps, sizeof(pMsg->HTCaps));
15460 }
15461
15462 if (pAssocInd->VHTCaps.present) {
15463 pBuf = (tANI_U8 *)&pMsg->VHTCaps;
15464 vos_mem_copy(pBuf, &pAssocInd->VHTCaps, sizeof(pMsg->VHTCaps));
15465 }
15466
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15468 msgQ.bodyptr = pMsg;
15469 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015472 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015473}
Jeff Johnson295189b2012-06-20 16:38:30 -070015474
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015475eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15477 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15478 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15479 tANI_U8 *pKeyRsc )
15480{
15481 tSirSmeSetContextReq *pMsg;
15482 tANI_U16 msgLen;
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015483 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 tAniEdType tmpEdType;
15485 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015486 tANI_U8 *pBuf = NULL;
15487 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015489 vos_msg_t msg;
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015490 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15491 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015492 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015493 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15495 // key set. Since we only support upto one key, we always allocate memory for 1 key
15496 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15497 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15498 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15499 ( sizeof( pMsg->keyMaterial.key ) );
15500
Kiet Lam64c1b492013-07-12 13:56:44 +053015501 pMsg = vos_mem_malloc(msgLen);
15502 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15503 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015504 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15505 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 //sessionId
15507 pBuf = &pMsg->sessionId;
15508 *pBuf = (tANI_U8)sessionId;
15509 pBuf++;
15510 // transactionId
15511 *pBuf = 0;
15512 *(pBuf + 1) = 0;
15513 pBuf += sizeof(tANI_U16);
15514 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015515 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015516
15517 pBuf += sizeof(tSirMacAddr);
15518
15519 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015520 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15521 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015522
15523 pBuf += sizeof(tSirMacAddr);
15524
15525 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015526 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15527 // in the tSirKeyMaterial keyMaterial; field).
15528 //
15529 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15530 // shorter than this max size. Is LIM interpreting this ok ?
15531 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 -070015532 // set pMsg->keyMaterial.edType
15533 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015534 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015535 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015536 // set the pMsg->keyMaterial.numKeys field
15537 *p = numKeys;
15538 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 // set pSirKey->keyId = keyId;
15540 *p = keyId;
15541 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 // set pSirKey->unicast = (tANI_U8)fUnicast;
15543 *p = (tANI_U8)fUnicast;
15544 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 // set pSirKey->keyDirection = aniKeyDirection;
15546 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015547 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 p += sizeof(tAniKeyDirection);
15549 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015550 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 // set pSirKey->paeRole
15553 *p = paeRole; // 0 is Supplicant
15554 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015555 // set pSirKey->keyLength = keyLength;
15556 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015558 vos_mem_copy(p, pKey, keyLength);
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015559 msg.type = pMsg->messageType;
15560 msg.bodyptr = pMsg;
15561 msg.bodyval = 0;
15562 if (fUnicast)
15563 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
15564 else
15565 status = vos_mq_post_message(VOS_MQ_ID_PE, &msg);
15566 if (!VOS_IS_STATUS_SUCCESS(status)) {
15567 vos_mem_free(pMsg);
15568 return eHAL_STATUS_FAILURE;
15569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 } while( 0 );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015571 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015572}
15573
Jeff Johnson295189b2012-06-20 16:38:30 -070015574eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15575 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15576{
15577 eHalStatus status;
15578 tSirSmeStartBssReq *pMsg;
15579 tANI_U8 *pBuf = NULL;
15580 tANI_U8 *wTmpBuf = NULL;
15581 tANI_U16 msgLen, wTmp;
15582 tANI_U32 dwTmp;
15583 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015584 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015585 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015586 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015587
15588 if(!pSession)
15589 {
15590 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15591 return eHAL_STATUS_FAILURE;
15592 }
15593
Jeff Johnson295189b2012-06-20 16:38:30 -070015594 do {
15595 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15596 pSession->joinFailStatusCode.reasonCode = 0;
15597 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015598 pMsg = vos_mem_malloc(msgLen);
15599 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15600 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015604 //sessionId
15605 *pBuf = (tANI_U8)sessionId;
15606 pBuf++;
15607 // transactionId
15608 *pBuf = 0;
15609 *(pBuf + 1) = 0;
15610 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015612 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015613 pBuf += sizeof(tSirMacAddr);
15614 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015615 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015616 pBuf += sizeof(tSirMacAddr);
15617 // beaconInterval
15618 if( pBssDesc && pBssDesc->beaconInterval )
15619 {
15620 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 else if(pParam->beaconInterval)
15623 {
15624 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15625 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 else
15627 {
15628 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15629 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015630 if(csrIsconcurrentsessionValid (pMac, sessionId,
15631 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015632 == eHAL_STATUS_SUCCESS )
15633 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015634 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015635 pParam->bssPersona);
15636 //Update the beacon Interval
15637 pParam->beaconInterval = wTmp;
15638 }
15639 else
15640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015641 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015642 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015643 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015644 return status;
15645 }
15646
Kiet Lam64c1b492013-07-12 13:56:44 +053015647 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 pBuf += sizeof(tANI_U16);
15649 // dot11mode
15650 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15651 pBuf += 1;
15652 // bssType
15653 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015654 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 pBuf += sizeof(tSirBssType);
15656 // ssId
15657 if( pParam->ssId.length )
15658 {
15659 // ssId len
15660 *pBuf = pParam->ssId.length;
15661 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015662 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015663 pBuf += pParam->ssId.length;
15664 }
15665 else
15666 {
15667 *pBuf = 0;
15668 pBuf++;
15669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 // set the channel Id
15671 *pBuf = pParam->operationChn;
15672 pBuf++;
15673 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015674 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015675 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015676 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015677
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 // Set privacy
15679 *pBuf = pParam->privacy;
15680 pBuf++;
15681
15682 //Set Uapsd
15683 *pBuf = pParam->ApUapsdEnable;
15684 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015685 //Set SSID hidden
15686 *pBuf = pParam->ssidHidden;
15687 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15689 pBuf++;
15690
15691 //Ht protection Enable/Disable
15692 *pBuf = (tANI_U8)pParam->protEnabled;
15693 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015694 //Enable Beacons to Receive for OBSS protection Enable/Disable
15695 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15696 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015697 //set cfg related to protection
15698 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015699 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 // Set Auth type
15702 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015703 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015704 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015705 // Set DTIM
15706 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015707 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015709 // Set wps_state
15710 *pBuf = pParam->wps_state;
15711 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015712 // set isCoalesingInIBSSAllowed
15713 *pBuf = pMac->isCoalesingInIBSSAllowed;
15714 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015715 //Persona
15716 *pBuf = (tANI_U8)pParam->bssPersona;
15717 pBuf++;
15718
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015719 //txLdpcIniFeatureEnabled
15720 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15721 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015722
Chet Lanctot8cecea22014-02-11 19:09:36 -080015723#ifdef WLAN_FEATURE_11W
15724 // Set MFP capable/required
15725 *pBuf = (tANI_U8)pParam->mfpCapable;
15726 pBuf++;
15727 *pBuf = (tANI_U8)pParam->mfpRequired;
15728 pBuf++;
15729#endif
15730
krunal soni4f087d22013-07-29 16:32:26 -070015731 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015732 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15733 {
15734 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015735 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015736 break;
15737 }
15738 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015739 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015740 pBuf += sizeof(tANI_U16);
15741 if( wTmp )
15742 {
15743 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015744 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015745 pBuf += wTmp;
15746 }
15747 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015748 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015749 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15751 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015752 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15753 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 pBuf += pParam->operationalRateSet.numRates ;
15755 *pBuf++ = pParam->extendedRateSet.numRates;
15756 if(0 != pParam->extendedRateSet.numRates)
15757 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015758 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15759 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015760 pBuf += pParam->extendedRateSet.numRates;
15761 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015762#ifdef WLAN_FEATURE_AP_HT40_24G
15763 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15764#endif
krunal sonie9002db2013-11-25 14:24:17 -080015765
Jeff Johnson295189b2012-06-20 16:38:30 -070015766 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15767 pMsg->length = pal_cpu_to_be16(msgLen);
15768
15769 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015770 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015771 return( status );
15772}
15773
Jeff Johnson295189b2012-06-20 16:38:30 -070015774eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15775{
15776 eHalStatus status = eHAL_STATUS_FAILURE;
15777 tSirSmeStopBssReq *pMsg;
15778 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15779 tANI_U8 *pBuf;
15780 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015781
15782 if(!pSession)
15783 {
15784 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15785 return eHAL_STATUS_FAILURE;
15786 }
15787
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015788 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15789 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15790 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15791 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15792 pBuf = &pMsg->sessionId;
15793 //sessionId
15794 *pBuf = (tANI_U8)sessionId;
15795 pBuf++;
15796 // transactionId
15797 *pBuf = 0;
15798 pBuf += sizeof(tANI_U16);
15799 //reason code
15800 *pBuf = 0;
15801 pBuf += sizeof(tSirResultCodes);
15802 // bssid
15803 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15804 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15805 {
15806 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15807 sizeof(tSirMacAddr));
15808 }
15809 else
15810 {
15811 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15812 sizeof(tSirMacAddr));
15813 }
15814 pBuf += sizeof(tSirMacAddr);
15815 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15816 pMsg->length = pal_cpu_to_be16(msgLen);
15817 status = palSendMBMessage( pMac->hHdd, pMsg );
15818
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 return( status );
15820}
15821
Jeff Johnson295189b2012-06-20 16:38:30 -070015822eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15823 tCsrRoamModifyProfileFields *pModProfileFields,
15824 tANI_U32 *pRoamId, v_BOOL_t fForce)
15825{
Jeff Johnson295189b2012-06-20 16:38:30 -070015826 eHalStatus status = eHAL_STATUS_FAILURE;
15827 tANI_U32 roamId = 0;
15828 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015829 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015830 (fForce || (!vos_mem_compare( &pModProfileFields,
15831 &pSession->connectedProfile.modifyProfileFields,
15832 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 {
15834 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15835 if(pRoamId)
15836 {
15837 *pRoamId = roamId;
15838 }
15839
Jeff Johnson295189b2012-06-20 16:38:30 -070015840 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15841 eCsrSmeIssuedReassocToSameAP, roamId,
15842 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 return status;
15845}
Jeff Johnson295189b2012-06-20 16:38:30 -070015846static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15847{
15848 eHalStatus status = eHAL_STATUS_SUCCESS;
15849 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015850 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15852 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15853 return (status);
15854}
Jeff Johnson295189b2012-06-20 16:38:30 -070015855eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15856{
15857 eHalStatus status = eHAL_STATUS_SUCCESS;
15858 tListElem *pEntry = NULL;
15859 tSmeCmd *pCommand = NULL;
15860 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015861 do
15862 {
15863 if(pMsg == NULL)
15864 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015865 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015866 status = eHAL_STATUS_FAILURE;
15867 break;
15868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15870 if(pEntry)
15871 {
15872 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15873 if(eSmeCommandAddStaSession == pCommand->command)
15874 {
15875 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015876 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015877 if (pRsp->status == eSIR_FAILURE) {
15878 VOS_ASSERT( 0 );
15879 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015881 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015882 //Remove this command out of the active list
15883 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15884 {
15885 //Now put this command back on the avilable command list
15886 csrReleaseCommand(pMac, pCommand);
15887 }
15888 smeProcessPendingQueue( pMac );
15889 }
15890 else
15891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015892 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 -070015893 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 status = eHAL_STATUS_FAILURE;
15895 break;
15896 }
15897 }
15898 else
15899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015900 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 -070015901 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 status = eHAL_STATUS_FAILURE;
15903 break;
15904 }
15905 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015906 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015907}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015908eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15909 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015910{
15911 tSirSmeAddStaSelfReq *pMsg;
15912 tANI_U16 msgLen;
15913 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015914 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015915 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015916 pMsg = vos_mem_malloc(msgLen);
15917 if ( NULL == pMsg ) break;
15918 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15920 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015921 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015922 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015923 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15924
15925 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
15926
Arif Hussain24bafea2013-11-15 15:10:03 -080015927 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
15928 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015929 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 return( status );
15932}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015933eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
15934 tANI_U32 sessionId,
15935 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070015936{
15937 eHalStatus status = eHAL_STATUS_SUCCESS;
15938 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 pCommand = csrGetCommandBuffer(pMac);
15940 if(NULL == pCommand)
15941 {
15942 status = eHAL_STATUS_RESOURCES;
15943 }
15944 else
15945 {
15946 pCommand->command = eSmeCommandAddStaSession;
15947 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053015948 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
15949 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015950 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015951 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
15952 if( !HAL_STATUS_SUCCESS( status ) )
15953 {
15954 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015955 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015956 }
15957 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015958 return (status);
15959}
Jeff Johnson295189b2012-06-20 16:38:30 -070015960eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15961{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015962 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070015963}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015964eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
15965 csrRoamCompleteCallback callback,
15966 void *pContext, tANI_U8 *pSelfMacAddr,
15967 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070015968{
15969 eHalStatus status = eHAL_STATUS_SUCCESS;
15970 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053015971 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015972 *pbSessionId = CSR_SESSION_ID_INVALID;
15973 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15974 {
15975 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15976 {
15977 pSession = CSR_GET_SESSION( pMac, i );
15978 status = eHAL_STATUS_SUCCESS;
15979 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15980 pSession->sessionId = (tANI_U8)i;
15981 pSession->callback = callback;
15982 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015983 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015984 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015985 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15986 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015987 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015988 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015990 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015991 break;
15992 }
15993#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015994 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15995 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015996 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015997 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015999 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016000 break;
16001 }
16002#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016003 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 break;
16005 }
16006 }
16007 if( CSR_ROAM_SESSION_MAX == i )
16008 {
16009 //No session is available
16010 status = eHAL_STATUS_RESOURCES;
16011 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 return ( status );
16013}
Jeff Johnson295189b2012-06-20 16:38:30 -070016014eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
16015{
16016 eHalStatus status = eHAL_STATUS_SUCCESS;
16017 tListElem *pEntry = NULL;
16018 tSmeCmd *pCommand = NULL;
16019 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 do
16021 {
16022 if(pMsg == NULL)
16023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016024 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016025 status = eHAL_STATUS_FAILURE;
16026 break;
16027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016028 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
16029 if(pEntry)
16030 {
16031 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16032 if(eSmeCommandDelStaSession == pCommand->command)
16033 {
16034 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016036 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016037 //This session is done.
16038 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 if(pCommand->u.delStaSessionCmd.callback)
16040 {
16041
16042 status = sme_ReleaseGlobalLock( &pMac->sme );
16043 if ( HAL_STATUS_SUCCESS( status ) )
16044 {
16045 pCommand->u.delStaSessionCmd.callback(
16046 pCommand->u.delStaSessionCmd.pContext);
16047 status = sme_AcquireGlobalLock( &pMac->sme );
16048 if (! HAL_STATUS_SUCCESS( status ) )
16049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016050 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 return status;
16052 }
16053 }
16054 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016055 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016056 }
16057 }
16058
16059 //Remove this command out of the active list
16060 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
16061 {
16062 //Now put this command back on the avilable command list
16063 csrReleaseCommand(pMac, pCommand);
16064 }
16065 smeProcessPendingQueue( pMac );
16066 }
16067 else
16068 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016069 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 -070016070 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 status = eHAL_STATUS_FAILURE;
16072 break;
16073 }
16074 }
16075 else
16076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016077 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 -070016078 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016079 status = eHAL_STATUS_FAILURE;
16080 break;
16081 }
16082 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016083 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016084}
Jeff Johnson295189b2012-06-20 16:38:30 -070016085eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16086{
16087 tSirSmeDelStaSelfReq *pMsg;
16088 tANI_U16 msgLen;
16089 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016090 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16092 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016093 pMsg = vos_mem_malloc(msgLen);
16094 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16095 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016096 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16097 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016099 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16100 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016101 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016102 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 return( status );
16104}
Jeff Johnson295189b2012-06-20 16:38:30 -070016105eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016106 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016107 tSirMacAddr sessionMacAddr,
16108 csrRoamSessionCloseCallback callback,
16109 void *pContext)
16110{
16111 eHalStatus status = eHAL_STATUS_SUCCESS;
16112 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016113 pCommand = csrGetCommandBuffer(pMac);
16114 if(NULL == pCommand)
16115 {
16116 status = eHAL_STATUS_RESOURCES;
16117 }
16118 else
16119 {
16120 pCommand->command = eSmeCommandDelStaSession;
16121 pCommand->sessionId = (tANI_U8)sessionId;
16122 pCommand->u.delStaSessionCmd.callback = callback;
16123 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016124 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16125 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016126 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016127 if( !HAL_STATUS_SUCCESS( status ) )
16128 {
16129 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016130 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016131 }
16132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016133 return (status);
16134}
Jeff Johnson295189b2012-06-20 16:38:30 -070016135eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16136{
16137 return csrSendMBDelSelfStaReqMsg( pMac,
16138 pCommand->u.delStaSessionCmd.selfMacAddr );
16139}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016140static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16141 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016142{
16143 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16144 tListElem *pEntry, *pNext;
16145 tSmeCmd *pCommand;
16146 tDblLinkList localList;
16147
16148 vos_mem_zero(&localList, sizeof(tDblLinkList));
16149 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16150 {
16151 smsLog(pMac, LOGE, FL(" failed to open list"));
16152 return;
16153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016154 csrLLLock(pList);
16155 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16156 while(pEntry != NULL)
16157 {
16158 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16159 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016160
16161 if (!flush_all &&
16162 csr_is_disconnect_full_power_cmd(pCommand)) {
16163 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16164 pEntry = pNext;
16165 continue;
16166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016167 if(pCommand->sessionId == sessionId)
16168 {
16169 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16170 {
16171 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16172 }
16173 }
16174 pEntry = pNext;
16175 }
16176 csrLLUnlock(pList);
16177
16178 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16179 {
16180 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16181 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16182 }
16183 csrLLClose(&localList);
16184}
16185
Jeff Johnson295189b2012-06-20 16:38:30 -070016186void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16187{
16188 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16189 {
16190 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016191 csrRoamStop(pMac, sessionId);
16192 csrFreeConnectBssDesc(pMac, sessionId);
16193 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16194 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016195 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016196#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016197 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016198#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016199 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016200 csrInitSession(pMac, sessionId);
16201 }
16202}
16203
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016204void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16205 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016206{
16207 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016208 &pMac->sme.smeCmdPendingList,
16209 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016210 if (pMac->fScanOffload)
16211 {
16212 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016213 &pMac->sme.smeScanCmdPendingList,
16214 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016215 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016216 purgeCsrSessionCmdList(pMac, sessionId,
16217 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016218}
16219
Jeff Johnson295189b2012-06-20 16:38:30 -070016220eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016221 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016222 csrRoamSessionCloseCallback callback,
16223 void *pContext )
16224{
16225 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016226 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16227 {
16228 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16229 if(fSync)
16230 {
16231 csrCleanupSession(pMac, sessionId);
16232 }
16233 else
mukul sharmabab477d2015-06-11 17:14:55 +053016234 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016235 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016236 /* If bPurgeList is FALSE, it means HDD already free all the
16237 * cmd and later queue few essential cmd. Now sme should process
16238 * the cmd in pending queue order only.Hence we should
16239 * avoid DEL_SELF_STA as high priority cmd.
16240 */
16241 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016242 pSession->selfMacAddr, callback, pContext);
16243 }
16244 }
16245 else
16246 {
16247 status = eHAL_STATUS_INVALID_PARAMETER;
16248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016249 return ( status );
16250}
16251
Jeff Johnson295189b2012-06-20 16:38:30 -070016252static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16253{
16254 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016255
16256 if(!pSession)
16257 {
16258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16259 return;
16260 }
16261
Jeff Johnson295189b2012-06-20 16:38:30 -070016262 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16263 pSession->sessionId = CSR_SESSION_ID_INVALID;
16264 pSession->callback = NULL;
16265 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016266 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16267 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16268 csrFreeRoamProfile( pMac, sessionId );
16269 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16270 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16271 csrFreeConnectBssDesc(pMac, sessionId);
16272 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016273 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16274 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016275 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016276 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016277 pSession->pWpaRsnReqIE = NULL;
16278 }
16279 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016280 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016282 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016283 pSession->pWpaRsnRspIE = NULL;
16284 }
16285 pSession->nWpaRsnRspIeLength = 0;
16286#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016287 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016288 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016289 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016290 pSession->pWapiReqIE = NULL;
16291 }
16292 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016293 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016295 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016296 pSession->pWapiRspIE = NULL;
16297 }
16298 pSession->nWapiRspIeLength = 0;
16299#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016300 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016301 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016302 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 }
16304 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016305
Kiet Lam64c1b492013-07-12 13:56:44 +053016306 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016307 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016308 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016311 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016312}
16313
Jeff Johnson295189b2012-06-20 16:38:30 -070016314eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16315{
16316 eHalStatus status = eHAL_STATUS_FAILURE;
16317 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16319 {
16320 if( CSR_IS_SESSION_VALID( pMac, i ) )
16321 {
16322 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16323 {
16324 //Found it
16325 status = eHAL_STATUS_SUCCESS;
16326 *pSessionId = i;
16327 break;
16328 }
16329 }
16330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 return( status );
16332}
16333
Jeff Johnson295189b2012-06-20 16:38:30 -070016334//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16335//session because for IBSS, the bssid changes.
16336static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16337{
16338 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16339 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016340 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16341 {
16342 if( CSR_IS_SESSION_VALID( pMac, i ) )
16343 {
16344 pSession = CSR_GET_SESSION( pMac, i );
16345 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16346 {
16347 //Found it
16348 nRet = i;
16349 break;
16350 }
16351 }
16352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016353 return (nRet);
16354}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016355void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016356{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016357 VOS_STATUS status = VOS_STATUS_SUCCESS;
16358
16359 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016360 profile info from pmac global structure */
16361
Arif Hussain24bafea2013-11-15 15:10:03 -080016362 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16363 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016364 /* Check for user misconfig of RSSI trigger threshold */
16365 pMac->roam.configParam.vccRssiThreshold =
16366 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16367 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16368 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 /* Check for user misconfig of UL MAC Loss trigger threshold */
16370 pMac->roam.configParam.vccUlMacLossThreshold =
16371 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16372 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016373#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16374 {
16375 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016376 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016377 /* Indicate the neighbor roal algorithm about the connect indication */
16378 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16379 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016380
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016381 /* Making sure we are roaming force fully to 5GHz AP only once and
16382 * only when we connected to 2.4GH AP only during initial association.
16383 */
16384 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16385 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16386 SIR_BAND_2_4_GHZ)
16387 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016388 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016389 status = vos_timer_start(
16390 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16391 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016392 if ( status != VOS_STATUS_SUCCESS )
16393 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016394 smsLog(pMac, LOGE,
16395 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16396 status);
16397 //Send RSO start because in case 5G roaming
16398 //host have not enabled at initial connection
16399 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016400 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016401 else
16402 {
16403 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16404 __func__);
16405 }
16406 }
16407 /*
16408 * Making ini value to false here only so we just roam to
16409 * only once for whole driver load to unload tenure
16410 * This feature is only applicable for first connection only
16411 */
16412 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16413 {
16414 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16415 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 }
16418#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016419}
16420
Jeff Johnson295189b2012-06-20 16:38:30 -070016421static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16422{
16423 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016424
16425 if(!pSession)
16426 {
16427 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16428 return;
16429 }
16430
Jeff Johnson295189b2012-06-20 16:38:30 -070016431 //Only to handle the case for Handover on infra link
16432 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16433 {
16434 return;
16435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016436 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16437 csrRoamDeregStatisticsReq(pMac);
16438 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16439#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16440 /* Indicate the neighbor roal algorithm about the disconnect indication */
16441 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16442#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016443
16444 //Remove this code once SLM_Sessionization is supported
16445 //BMPS_WORKAROUND_NOT_NEEDED
16446 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016447 csrIsInfraApStarted( pMac ) &&
16448 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016449 {
16450 pMac->roam.configParam.doBMPSWorkaround = 0;
16451 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016452}
16453
Jeff Johnson295189b2012-06-20 16:38:30 -070016454void csrRoamTlStatsTimerHandler(void *pv)
16455{
16456 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16457 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16459
Jeff Johnsone7245742012-09-05 17:12:55 -070016460 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16461
Jeff Johnson295189b2012-06-20 16:38:30 -070016462#if 0
16463 // TODO Persession .???
16464 //req TL for stats
16465 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16466 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016467 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 }
16469 else
16470 {
16471 //save in SME
16472 csrRoamSaveStatsFromTl(pMac, tlStats);
16473 }
16474#endif
16475 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16476 {
16477 if(pMac->roam.tlStatsReqInfo.periodicity)
16478 {
16479 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016480 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16481 pMac->roam.tlStatsReqInfo.periodicity);
16482 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016484 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016485 return;
16486 }
16487 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16488 }
16489 }
16490}
Jeff Johnson295189b2012-06-20 16:38:30 -070016491void csrRoamPeStatsTimerHandler(void *pv)
16492{
16493 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16494 eHalStatus status;
16495 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16496 VOS_STATUS vosStatus;
16497 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 pPeStatsReqListEntry->timerRunning = FALSE;
16499 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16500 {
16501 // If we entered here, meaning the timer could not be successfully
16502 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16503
16504 /* Destroy the timer */
16505 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16506 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016508 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016509 }
16510
16511 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016512 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 pPeStatsReqListEntry = NULL;
16514 }
16515 else
16516 {
16517 if(!pPeStatsReqListEntry->rspPending)
16518 {
16519 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16520 pPeStatsReqListEntry->staId);
16521 if(!HAL_STATUS_SUCCESS(status))
16522 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016523 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016524 }
16525 else
16526 {
16527 pPeStatsReqListEntry->rspPending = TRUE;
16528 }
16529 }
16530
16531 //send down a req
16532 if(pPeStatsReqListEntry->periodicity &&
16533 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16534 {
16535 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16536 if(ePMC_FULL_POWER == powerState)
16537 {
16538 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16539 {
16540 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16541 }
16542 }
16543 else
16544 {
16545 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16546 {
16547 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16548 }
16549 }
16550 //start timer
16551 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16552 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016554 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016555 return;
16556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016557 pPeStatsReqListEntry->timerRunning = TRUE;
16558
16559 }
16560
16561 }
16562}
Jeff Johnson295189b2012-06-20 16:38:30 -070016563void csrRoamStatsClientTimerHandler(void *pv)
16564{
16565 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016566 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16567 {
16568#if 0
16569 // TODO Stats fix for multisession
16570 //start the timer
16571 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16572
16573 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016575 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016576 }
16577#endif
16578 }
16579#if 0
16580 //send up the stats report
16581 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16582 pStaEntry->staId, pStaEntry->pContext);
16583#endif
16584}
16585
16586
16587
Jeff Johnson295189b2012-06-20 16:38:30 -070016588eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16589{
16590 tAniGetPEStatsReq *pMsg;
16591 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016592 tSirMsgQ msgQ;
16593
Kiet Lam64c1b492013-07-12 13:56:44 +053016594 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16595 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016596 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016597 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016598 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016599 }
16600 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016601 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016602 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16603 pMsg->staId = staId;
16604 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016605
16606 msgQ.type = WDA_GET_STATISTICS_REQ;
16607 msgQ.reserved = 0;
16608 msgQ.bodyptr = pMsg;
16609 msgQ.bodyval = 0;
16610 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016611 if(!HAL_STATUS_SUCCESS(status))
16612 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016613 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016614 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016616 return status;
16617}
Jeff Johnson295189b2012-06-20 16:38:30 -070016618void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16619{
16620 tAniGetPEStatsRsp *pSmeStatsRsp;
16621 eHalStatus status = eHAL_STATUS_FAILURE;
16622 tListElem *pEntry = NULL;
16623 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16624 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16625 tANI_U32 tempMask = 0;
16626 tANI_U8 counter = 0;
16627 tANI_U8 *pStats = NULL;
16628 tANI_U32 length = 0;
16629 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016630 v_S7_t rssi = 0, snr = 0;
16631 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016632 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016633 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016634 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16635 if(pSmeStatsRsp->rc)
16636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016637 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016638 goto post_update;
16639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016640 tempMask = pSmeStatsRsp->statsMask;
16641 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016642 /* subtract all statistics from this length, and after processing the entire
16643 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16644 * in this 'stats' message.
16645 */
16646 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 //new stats info from PE, fill up the stats strucutres in PMAC
16648 while(tempMask)
16649 {
16650 if(tempMask & 1)
16651 {
16652 switch(counter)
16653 {
16654 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016655 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016656 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16657 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 pStats += sizeof(tCsrSummaryStatsInfo);
16659 length -= sizeof(tCsrSummaryStatsInfo);
16660 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016661 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016662 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016663 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16664 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016665 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16666 length -= sizeof(tCsrGlobalClassAStatsInfo);
16667 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016669 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016670 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16671 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016672 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16673 length -= sizeof(tCsrGlobalClassBStatsInfo);
16674 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016675 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016676 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016677 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16678 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016679 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16680 length -= sizeof(tCsrGlobalClassCStatsInfo);
16681 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016682 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016683 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016684 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16685 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016686 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016687 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16688 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016689 }
16690 else
16691 {
16692 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016693 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016694 VOS_ASSERT( 0 );
16695 }
16696 if(!HAL_STATUS_SUCCESS(status))
16697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016698 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016699 }
16700 pStats += sizeof(tCsrPerStaStatsInfo);
16701 length -= sizeof(tCsrPerStaStatsInfo);
16702 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016703 case eCsrPerPktStats:
16704 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16705 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16706 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16707 {
16708 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16709 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16710 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016711 /* for reserved bytes */
16712 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16713 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016714 }
16715 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016717 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016719 }
16720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016721 tempMask >>=1;
16722 counter++;
16723 }
16724 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16725 if (length != 0)
16726 {
16727 pRssi = (tANI_U32*)pStats;
16728 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016729 pStats += sizeof(tANI_U32);
16730 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016731 }
16732 else
16733 {
16734 /* If riva is not sending rssi, continue to use the hack */
16735 rssi = RSSI_HACK_BMPS;
16736 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016737 /* send positive value of rssi to wifi_hal */
16738 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016739 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016741
16742 if (length != 0)
16743 {
16744 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016745 pStats += sizeof(tANI_U32);
16746 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016747 }
16748 else
16749 {
16750 linkCapacity = 0;
16751 }
16752
16753 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016754
16755 if (length != 0)
16756 {
16757 pSnr = (tANI_U32*)pStats;
16758 snr = (v_S7_t)*pSnr;
16759 }
16760 else
16761 {
16762 snr = SNR_HACK_BMPS;
16763 }
16764
16765 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016766post_update:
16767 //make sure to update the pe stats req list
16768 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16769 if(pEntry)
16770 {
16771 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16772 pPeStaEntry->rspPending = FALSE;
16773
16774 }
16775 //check the one timer cases
16776 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16777 if(pEntry)
16778 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016780 if(pTempStaEntry->timerExpired)
16781 {
16782 //send up the stats report
16783 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16784 pTempStaEntry->staId, pTempStaEntry->pContext);
16785 //also remove from the client list
16786 csrRoamRemoveStatListEntry(pMac, pEntry);
16787 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016788 }
16789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016790}
Jeff Johnson295189b2012-06-20 16:38:30 -070016791tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16792{
16793 tListElem *pEntry = NULL;
16794 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 if(!pEntry)
16797 {
16798 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016799 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016800 return NULL;
16801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 while( pEntry )
16803 {
16804 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 if(pTempStaEntry->statsMask == statsMask)
16806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016807 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016808 break;
16809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016810 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16811 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016812 return pEntry;
16813}
16814
Jeff Johnson295189b2012-06-20 16:38:30 -070016815tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16816 tANI_BOOLEAN update)
16817{
16818 tListElem *pEntry;
16819 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016820 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016821 if(!pEntry)
16822 {
16823 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016824 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016825 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016826 return NULL;
16827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016828 while( pEntry )
16829 {
16830 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016831 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16832 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016834 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 if(update)
16836 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016837 pTempStaEntry->periodicity = pStaEntry->periodicity;
16838 pTempStaEntry->callback = pStaEntry->callback;
16839 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016840 }
16841 break;
16842 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016845 return pEntry;
16846}
Jeff Johnson295189b2012-06-20 16:38:30 -070016847tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16848{
16849 tListElem *pEntry;
16850 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016851 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 if(!pEntry)
16853 {
16854 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016855 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016856 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016857 return NULL;
16858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016859 while( pEntry )
16860 {
16861 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016862 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016864 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 break;
16866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016867 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 return pEntry;
16870}
Jeff Johnson295189b2012-06-20 16:38:30 -070016871eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16872 csrRoamLinkQualityIndCallback callback,
16873 void *pContext)
16874{
16875 pMac->roam.linkQualityIndInfo.callback = callback;
16876 pMac->roam.linkQualityIndInfo.context = pContext;
16877 if( NULL == callback )
16878 {
16879 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16880 }
16881 else
16882 {
16883 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 /* do we need to invoke the callback to notify client of initial value ?? */
16885 }
16886 return eHAL_STATUS_SUCCESS;
16887}
Jeff Johnson295189b2012-06-20 16:38:30 -070016888void csrRoamVccTrigger(tpAniSirGlobal pMac)
16889{
16890 eCsrRoamLinkQualityInd newVccLinkQuality;
16891 tANI_U32 ul_mac_loss = 0;
16892 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16894 /*-------------------------------------------------------------------------
16895 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 Check for a change in link quality and notify client if necessary
16897 -------------------------------------------------------------------------*/
16898 ul_mac_loss_trigger_threshold =
16899 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016900 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016901 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016902 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16904 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016905 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016906 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16907 }
16908 else
16909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016910 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016911 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016913 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16914 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016917 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016918 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016920 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 newVccLinkQuality );
16922
16923 /* we now invoke the callback once to notify client of initial value */
16924 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16925 pMac->roam.linkQualityIndInfo.context );
16926 //event: EVENT_WLAN_VCC
16927 }
16928 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016929 pMac->roam.vccLinkQuality = newVccLinkQuality;
16930
Jeff Johnson295189b2012-06-20 16:38:30 -070016931}
Jeff Johnson295189b2012-06-20 16:38:30 -070016932VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
16933 v_U8_t rssiNotification,
16934 void * context)
16935{
16936 tpAniSirGlobal pMac = PMAC_STRUCT( context );
16937 eCsrRoamLinkQualityInd newVccLinkQuality;
16938 // TODO : Session info unavailable
16939 tANI_U32 sessionId = 0;
16940 VOS_STATUS status = VOS_STATUS_SUCCESS;
16941 /*-------------------------------------------------------------------------
16942 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 Check for a change in link quality and notify client if necessary
16944 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016945 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 pMac->roam.configParam.vccRssiThreshold);
16947 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
16948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016949 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070016950 return VOS_STATUS_SUCCESS;
16951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016952 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
16953 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016954 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070016955 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16956 }
16957 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
16958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016959 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16961 }
16962 else
16963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016964 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070016965 //Set to this so the code below won't do anything
16966 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016967 VOS_ASSERT(0);
16968 }
16969
Jeff Johnson295189b2012-06-20 16:38:30 -070016970 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16971 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016972 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016973 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016975 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016976 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016977 /* we now invoke the callback once to notify client of initial value */
16978 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16979 pMac->roam.linkQualityIndInfo.context );
16980 //event: EVENT_WLAN_VCC
16981 }
16982 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016983 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016984 return status;
16985}
Jeff Johnson295189b2012-06-20 16:38:30 -070016986tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16987 tDblLinkList *pStaList,
16988 tCsrStatsClientReqInfo *pStaEntry)
16989{
16990 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016991 //if same entity requested for same set of stats with different periodicity &
16992 // callback update it
16993 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16994 {
16995
Kiet Lam64c1b492013-07-12 13:56:44 +053016996 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16997 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016998 {
16999 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017000 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070017001 return NULL;
17002 }
17003
Jeff Johnson295189b2012-06-20 16:38:30 -070017004 pNewStaEntry->callback = pStaEntry->callback;
17005 pNewStaEntry->pContext = pStaEntry->pContext;
17006 pNewStaEntry->periodicity = pStaEntry->periodicity;
17007 pNewStaEntry->requesterId = pStaEntry->requesterId;
17008 pNewStaEntry->statsMask = pStaEntry->statsMask;
17009 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
17010 pNewStaEntry->pMac = pStaEntry->pMac;
17011 pNewStaEntry->staId = pStaEntry->staId;
17012 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
17013
17014 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
17015 }
17016 return pNewStaEntry;
17017}
17018
Jeff Johnson295189b2012-06-20 16:38:30 -070017019tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
17020 tDblLinkList *pStaList,
17021 tCsrPeStatsReqInfo *pStaEntry)
17022{
17023 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053017024 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
17025 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017026 {
17027 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017028 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070017029 return NULL;
17030 }
17031
Jeff Johnson295189b2012-06-20 16:38:30 -070017032 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
17033 pNewStaEntry->numClient = pStaEntry->numClient;
17034 pNewStaEntry->periodicity = pStaEntry->periodicity;
17035 pNewStaEntry->statsMask = pStaEntry->statsMask;
17036 pNewStaEntry->pMac = pStaEntry->pMac;
17037 pNewStaEntry->staId = pStaEntry->staId;
17038 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
17039 pNewStaEntry->rspPending = pStaEntry->rspPending;
17040
17041 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 return pNewStaEntry;
17043}
Jeff Johnson295189b2012-06-20 16:38:30 -070017044eHalStatus csrGetRssi(tpAniSirGlobal pMac,
17045 tCsrRssiCallback callback,
17046 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17047{
17048 eHalStatus status = eHAL_STATUS_SUCCESS;
17049 vos_msg_t msg;
17050 tANI_U32 sessionId;
17051
17052 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017053 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017054 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17055 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070017056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017057 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017058 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017060 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17061
17062 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
17063 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17064 pMsg->sessionId = sessionId;
17065 pMsg->staId = staId;
17066 pMsg->rssiCallback = callback;
17067 pMsg->pDevContext = pContext;
17068 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070017069 msg.type = eWNI_SME_GET_RSSI_REQ;
17070 msg.bodyptr = pMsg;
17071 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017072 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017074 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017075 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017076 status = eHAL_STATUS_FAILURE;
17077 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017078 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017079 return status;
17080}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017081
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017082eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17083 tCsrSnrCallback callback,
17084 tANI_U8 staId, tCsrBssid bssId,
17085 void *pContext)
17086{
17087 eHalStatus status = eHAL_STATUS_SUCCESS;
17088 vos_msg_t msg;
17089 tANI_U32 sessionId;
17090
17091 tAniGetSnrReq *pMsg;
17092
17093 smsLog(pMac, LOG2, FL("called"));
17094
17095 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17096 if (NULL == pMsg )
17097 {
17098 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17099 return status;
17100 }
17101
17102 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17103
17104 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17105 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17106 pMsg->sessionId = sessionId;
17107 pMsg->staId = staId;
17108 pMsg->snrCallback = callback;
17109 pMsg->pDevContext = pContext;
17110 msg.type = eWNI_SME_GET_SNR_REQ;
17111 msg.bodyptr = pMsg;
17112 msg.reserved = 0;
17113
17114 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17115 {
17116 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17117 vos_mem_free((v_VOID_t *)pMsg);
17118 status = eHAL_STATUS_FAILURE;
17119 }
17120
17121 smsLog(pMac, LOG2, FL("returned"));
17122 return status;
17123}
17124
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017125#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017126eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17127 tCsrRssiCallback callback,
17128 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17129{
17130 eHalStatus status = eHAL_STATUS_SUCCESS;
17131 tAniGetRssiReq *pMsg;
17132
Kiet Lam64c1b492013-07-12 13:56:44 +053017133 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17134 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017135 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017136 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017137 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017138 }
17139 // need to initiate a stats request to PE
17140 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17141 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17142 pMsg->staId = staId;
17143 pMsg->rssiCallback = callback;
17144 pMsg->pDevContext = pContext;
17145 pMsg->pVosContext = pVosContext;
17146 status = palSendMBMessage(pMac->hHdd, pMsg );
17147 if(!HAL_STATUS_SUCCESS(status))
17148 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017149 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017150 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017151 status = eHAL_STATUS_FAILURE;
17152 }
17153 return status;
17154}
17155#endif
17156
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017157
17158
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017159#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017160eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17161 tCsrTsmStatsCallback callback,
17162 tANI_U8 staId,
17163 tCsrBssid bssId,
17164 void *pContext,
17165 void* pVosContext,
17166 tANI_U8 tid)
17167{
17168 eHalStatus status = eHAL_STATUS_SUCCESS;
17169 tAniGetTsmStatsReq *pMsg = NULL;
17170
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017171 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17172 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017173 {
17174 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017175 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017176 }
17177 // need to initiate a stats request to PE
17178 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17179 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17180 pMsg->staId = staId;
17181 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017182 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017183 pMsg->tsmStatsCallback = callback;
17184 pMsg->pDevContext = pContext;
17185 pMsg->pVosContext = pVosContext;
17186 status = palSendMBMessage(pMac->hHdd, pMsg );
17187 if(!HAL_STATUS_SUCCESS(status))
17188 {
17189 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17190 //pMsg is freed by palSendMBMessage
17191 status = eHAL_STATUS_FAILURE;
17192 }
17193 return status;
17194}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017195#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017196
17197
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017198/* ---------------------------------------------------------------------------
17199 \fn csrGetTLSTAState
17200 \helper function to get teh TL STA State whenever the function is called.
17201
17202 \param staId - The staID to be passed to the TL
17203 to get the relevant TL STA State
17204 \return the state as tANI_U16
17205 ---------------------------------------------------------------------------*/
17206tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17207{
17208 WLANTL_STAStateType tlSTAState;
17209 tlSTAState = WLANTL_STA_INIT;
17210
17211 //request TL for STA State
17212 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17213 {
17214 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17215 }
17216
17217 return tlSTAState;
17218}
17219
Jeff Johnson295189b2012-06-20 16:38:30 -070017220eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17221 tANI_U32 statsMask,
17222 tCsrStatsCallback callback,
17223 tANI_U32 periodicity, tANI_BOOLEAN cache,
17224 tANI_U8 staId, void *pContext)
17225{
17226 tCsrStatsClientReqInfo staEntry;
17227 tCsrStatsClientReqInfo *pStaEntry = NULL;
17228 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17229 tListElem *pEntry = NULL;
17230 tANI_BOOLEAN found = FALSE;
17231 eHalStatus status = eHAL_STATUS_SUCCESS;
17232 tANI_BOOLEAN insertInClientList = FALSE;
17233 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017234 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017235
17236 if( csrIsAllSessionDisconnected(pMac) )
17237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017238 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017239 return eHAL_STATUS_FAILURE;
17240 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017241
17242 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17243 {
17244 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17245 return eHAL_STATUS_FAILURE;
17246 }
17247
Jeff Johnson295189b2012-06-20 16:38:30 -070017248 if((!statsMask) && (!callback))
17249 {
17250 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017251 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017252 return eHAL_STATUS_FAILURE;
17253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017254 //for the search list method for deregister
17255 staEntry.requesterId = requesterId;
17256 staEntry.statsMask = statsMask;
17257 //requester wants to deregister or just an error
17258 if((statsMask) && (!callback))
17259 {
17260 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17261 if(!pEntry)
17262 {
17263 //msg
17264 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017265 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017266 return eHAL_STATUS_FAILURE;
17267 }
17268 else
17269 {
17270 //clean up & return
17271 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017272 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017273 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017274 pStaEntry->pPeStaEntry->numClient--;
17275 //check if we need to delete the entry from peStatsReqList too
17276 if(!pStaEntry->pPeStaEntry->numClient)
17277 {
17278 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017280 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017281
Jeff Johnson295189b2012-06-20 16:38:30 -070017282 //check if we need to stop the tl stats timer too
17283 pMac->roam.tlStatsReqInfo.numClient--;
17284 if(!pMac->roam.tlStatsReqInfo.numClient)
17285 {
17286 if(pMac->roam.tlStatsReqInfo.timerRunning)
17287 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017288 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17289 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017291 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017292 return eHAL_STATUS_FAILURE;
17293 }
17294 }
17295 pMac->roam.tlStatsReqInfo.periodicity = 0;
17296 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17297 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017298 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017299 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017300 vos_timer_stop(&pStaEntry->timer);
17301 // Destroy the vos timer
17302 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17303 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17304 {
17305 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017308 csrRoamRemoveStatListEntry(pMac, pEntry);
17309 pStaEntry = NULL;
17310 return eHAL_STATUS_SUCCESS;
17311 }
17312 }
17313
17314 if(cache && !periodicity)
17315 {
17316 //return the cached stats
17317 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17318 }
17319 else
17320 {
17321 //add the request in the client req list
17322 staEntry.callback = callback;
17323 staEntry.pContext = pContext;
17324 staEntry.periodicity = periodicity;
17325 staEntry.pPeStaEntry = NULL;
17326 staEntry.staId = staId;
17327 staEntry.pMac = pMac;
17328 staEntry.timerExpired = FALSE;
17329
17330
Jeff Johnson295189b2012-06-20 16:38:30 -070017331 //if periodic report requested with non cached result from PE/TL
17332 if(periodicity)
17333 {
17334
17335 //if looking for stats from PE
17336 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17337 {
17338
17339 //check if same request made already & waiting for rsp
17340 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17341 periodicity, &found, staId);
17342 if(!pPeStaEntry)
17343 {
17344 //bail out, maxed out on number of req for PE
17345 return eHAL_STATUS_FAILURE;
17346 }
17347 else
17348 {
17349 staEntry.pPeStaEntry = pPeStaEntry;
17350 }
17351
17352 }
17353 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17354 if(statsMask & (1 << eCsrGlobalClassDStats))
17355 {
17356 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17357 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017358 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017359 }
17360 else
17361 {
17362
17363 //update periodicity
17364 if(pMac->roam.tlStatsReqInfo.periodicity)
17365 {
17366 pMac->roam.tlStatsReqInfo.periodicity =
17367 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17368 }
17369 else
17370 {
17371 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17372 }
17373 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17374 {
17375 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17376 }
17377
17378 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17379 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017380 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017381 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017382 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017383 //req TL for class D stats
17384 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017386 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017387 }
17388 else
17389 {
17390 //save in SME
17391 csrRoamSaveStatsFromTl(pMac, pTlStats);
17392 }
17393 vos_mem_free(pTlStats);
17394 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017395 }
17396 else
17397 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017398 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017399 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017400
Jeff Johnson295189b2012-06-20 16:38:30 -070017401 if(pMac->roam.tlStatsReqInfo.periodicity)
17402 {
17403 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017404 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17405 pMac->roam.tlStatsReqInfo.periodicity);
17406 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017408 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017409 return eHAL_STATUS_FAILURE;
17410 }
17411 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17412 }
17413 }
17414 }
17415 pMac->roam.tlStatsReqInfo.numClient++;
17416 }
17417
17418 insertInClientList = TRUE;
17419 }
17420 //if one time report requested with non cached result from PE/TL
17421 else if(!cache && !periodicity)
17422 {
17423 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17424 {
17425 //send down a req
17426 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17427 if(!HAL_STATUS_SUCCESS(status))
17428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017429 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017430 }
17431 //so that when the stats rsp comes back from PE we respond to upper layer
17432 //right away
17433 staEntry.timerExpired = TRUE;
17434 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017435 }
17436 if(statsMask & (1 << eCsrGlobalClassDStats))
17437 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017438 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017439 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017440 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017441 //req TL for class D stats
17442 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017444 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017445 }
17446 else
17447 {
17448 //save in SME
17449 csrRoamSaveStatsFromTl(pMac, pTlStats);
17450 }
17451 vos_mem_free(pTlStats);
17452 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017453 }
17454 else
17455 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017456 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017458
17459 }
17460 //if looking for stats from TL only
17461 if(!insertInClientList)
17462 {
17463 //return the stats
17464 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017467 if(insertInClientList)
17468 {
17469 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17470 if(!pStaEntry)
17471 {
17472 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017473 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017474 return eHAL_STATUS_FAILURE;
17475 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017476 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017477 //Init & start timer if needed
17478 if(periodicity)
17479 {
17480 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17481 csrRoamStatsClientTimerHandler, pStaEntry );
17482 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017484 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017485 return eHAL_STATUS_FAILURE;
17486 }
17487 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17488 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017490 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017491 return eHAL_STATUS_FAILURE;
17492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017495 }
17496 return eHAL_STATUS_SUCCESS;
17497}
17498
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017499#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17500
17501static tSirRetStatus
17502csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17503 tANI_U8* pBD,
17504 tANI_U8 type,
17505 tANI_U8 subType,
17506 tSirMacAddr peerAddr,
17507 tSirMacAddr selfMacAddr)
17508{
17509 tSirRetStatus statusCode = eSIR_SUCCESS;
17510 tpSirMacMgmtHdr pMacHdr;
17511
17512 /* Prepare MAC management header */
17513 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17514
17515 /* Prepare FC */
17516 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17517 pMacHdr->fc.type = type;
17518 pMacHdr->fc.subType = subType;
17519
17520 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017521 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17522 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017523
17524 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17525
17526 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017527 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17528 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017529 return statusCode;
17530} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17531
17532static tSirRetStatus
17533csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17534 tANI_U8 nChannelNum,
17535 tANI_U32 dot11mode,
17536 tSirMacAddr selfMacAddr,
17537 tANI_U8 *pFrame,
17538 tANI_U16 *pusLen)
17539{
17540 tDot11fProbeRequest pr;
17541 tANI_U32 nStatus, nBytes, nPayload;
17542 tSirRetStatus nSirStatus;
17543 /*Bcast tx*/
17544 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17545 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17546
17547
Kiet Lam64c1b492013-07-12 13:56:44 +053017548 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017549
17550 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17551
17552 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17553 {
17554 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17555 }
17556
17557
17558 if (IS_DOT11_MODE_HT(dot11mode))
17559 {
17560 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17561 }
17562
17563
17564 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17565 if ( DOT11F_FAILED( nStatus ) )
17566 {
17567 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17568 "Failed to calculate the packed size f"
17569 "or a Probe Request (0x%08x).\n", nStatus );
17570
17571
17572 nPayload = sizeof( tDot11fProbeRequest );
17573 }
17574 else if ( DOT11F_WARNED( nStatus ) )
17575 {
17576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17577 "There were warnings while calculating"
17578 "the packed size for a Probe Request ("
17579 "0x%08x).\n", nStatus );
17580 }
17581
17582 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17583
17584 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017585 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017586
17587
17588 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017589 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017590
17591 if ( eSIR_SUCCESS != nSirStatus )
17592 {
17593 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17594 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17595 nSirStatus );
17596 return nSirStatus;
17597 }
17598
17599
17600 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17601 sizeof( tSirMacMgmtHdr ),
17602 nPayload, &nPayload );
17603 if ( DOT11F_FAILED( nStatus ) )
17604 {
17605 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17606 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17607 return eSIR_FAILURE;
17608 }
17609 else if ( DOT11F_WARNED( nStatus ) )
17610 {
17611 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017612 "There were warnings while packing a Probe Request (0x%08x).\n",
17613 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017614 }
17615
17616 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17617 return eSIR_SUCCESS;
17618}
17619
Mukul Sharmad68cda62015-03-20 21:25:41 +053017620/*
17621 * Below Table describe whether RSO command can be send down to fimrware or not.
17622 * Host check it on the basis of previous RSO command sent down to firmware.
17623||===========================================================================||
17624|| New cmd | LAST SENT COMMAND ---> ||
17625||====|======================================================================||
17626|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17627|| --------------------------------------------------------------------------||
17628|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017629|| RSO_STOP | YES | NO | YES | YES ||
17630|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017631|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17632||===========================================================================||
17633*/
17634
17635#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17636#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17637#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17638#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17639
17640#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17641#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017642 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017643#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17644 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017645#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017646 RSO_START_BIT)
17647
17648tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17649{
17650 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17651 tANI_U8 desiredMask = 0;
17652 switch(command)
17653 {
17654 case ROAM_SCAN_OFFLOAD_START:
17655 desiredMask = RSO_START_ALLOW_MASK;
17656 break;
17657 case ROAM_SCAN_OFFLOAD_STOP:
17658 desiredMask = RSO_STOP_ALLOW_MASK;
17659 break;
17660 case ROAM_SCAN_OFFLOAD_RESTART:
17661 desiredMask = RSO_RESTART_ALLOW_MASK;
17662 break;
17663 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17664 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17665 break;
17666 default:
17667 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17668 FL("Wrong RSO command %d, not allowed"), command);
17669 return 0;/*Cmd Not allowed*/
17670 }
17671 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17672}
17673
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017674eCsrBand GetCurrentBand(tANI_U8 channel)
17675{
17676 tSirRFBand Rfband;
17677 eCsrBand band;
17678
17679 Rfband = GetRFBand(channel);
17680
17681 if (Rfband == SIR_BAND_5_GHZ)
17682 band = eCSR_BAND_5G;
17683 else if (Rfband == SIR_BAND_2_4_GHZ)
17684 band = eCSR_BAND_24;
17685 else if (Rfband == SIR_BAND_UNKNOWN)
17686 band = eCSR_BAND_MAX;
17687
17688 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17689 "channel %d Rfband %d band %d", channel, Rfband, band);
17690
17691 return band;
17692}
17693
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017694eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17695{
17696 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017697 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017698 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017699 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017700 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017701 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017702 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017703 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017704 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017705 eHalStatus status = eHAL_STATUS_SUCCESS;
17706 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017707 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017708 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017709 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017710 tSirBssDescription *pBssDesc = NULL;
17711 tDot11fBeaconIEs *pIes = NULL;
17712 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017713 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017714
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017715 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17716
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017717 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017718 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017719 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017720 return eHAL_STATUS_FAILURE;
17721 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017722
17723 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17724 {
17725 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17726 return eHAL_STATUS_FAILURE;
17727 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017728
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017729 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17730 * It is important to ensure that the command is passed down to the FW only
17731 * if the Infra Station is in a connected state.A connected station could also be
17732 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17733 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17734 * irrespective of whichever state we are in.*/
17735 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17736 (command != ROAM_SCAN_OFFLOAD_STOP))
17737 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017738 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17739 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17740 macTraceGetNeighbourRoamState(
17741 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017742 return eHAL_STATUS_FAILURE;
17743 }
17744
Mukul Sharmad68cda62015-03-20 21:25:41 +053017745 if (!CsrIsRSOCommandAllowed(pMac, command))
17746 {
17747 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17748 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17749 command, pNeighborRoamInfo->lastSentCmd);
17750 return eHAL_STATUS_FAILURE;
17751 }
17752
Abhishek Singh3e915632014-11-01 17:14:50 +053017753 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17754 * Also there are cases where pNeighborRoamInfo->currAPbssid
17755 * is set to 0 during disconnect and so we might return without stopping
17756 * the roam scan. So no need to find the session if command is
17757 * ROAM_SCAN_OFFLOAD_STOP.
17758 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017759 status = csrRoamGetSessionIdFromBSSID(pMac,
17760 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17761 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017762 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017763 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017764 if ( !HAL_STATUS_SUCCESS( status ) )
17765 {
17766 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17767 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17768 return eHAL_STATUS_FAILURE;
17769 }
17770 pSession = CSR_GET_SESSION( pMac, sessionId );
17771 if (NULL == pSession)
17772 {
17773 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080017774 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053017775 return eHAL_STATUS_FAILURE;
17776 }
17777 pBssDesc = pSession->pConnectBssDesc;
17778 if (pBssDesc == NULL)
17779 {
17780 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17781 "%s: pBssDesc not found for current session", __func__);
17782 return eHAL_STATUS_FAILURE;
17783 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017784
17785 operationChannel = pSession->connectedProfile.operationChannel;
17786 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17787 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017788 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017789 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17790 if (NULL == pRequestBuf)
17791 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017792 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17793 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17794 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017795 }
17796
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017797#ifdef FEATURE_WLAN_DIAG_SUPPORT
17798 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17799 eSIR_SUCCESS, eSIR_SUCCESS);
17800#endif
17801
Abhishek Singh3e915632014-11-01 17:14:50 +053017802 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17803 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17804 * host driver reloads, but Riva still up and running*/
17805 pRequestBuf->Command = command;
17806 if(command == ROAM_SCAN_OFFLOAD_STOP)
17807 {
17808 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017809 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017810 /*For a STOP Command, there is no need to
17811 * go through filling up all the below parameters
17812 * since they are not required for the STOP command*/
17813 goto send_roam_scan_offload_cmd;
17814 }
17815 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017816 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017817 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17818 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017819 sizeof(tCsrBssid));
17820 pRequestBuf->ConnectedNetwork.ssId.length =
17821 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17822 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17823 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17824 pRequestBuf->ConnectedNetwork.ssId.length);
17825 pRequestBuf->ConnectedNetwork.authentication =
17826 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17827 pRequestBuf->ConnectedNetwork.encryption =
17828 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17829 pRequestBuf->ConnectedNetwork.mcencryption =
17830 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017831 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17832 {
17833 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017834 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017835 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17836 }
17837 else
17838 {
17839 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017840
17841 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17842 {
17843 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17844 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17845 vos_mem_free(pRequestBuf);
17846 return eHAL_STATUS_FAILURE;
17847 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017848 if(NULL == pIes)
17849 {
17850 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17851 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017852 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017853 return eHAL_STATUS_FAILURE;
17854 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017855 if (pIes->SuppRates.present)
17856 {
17857 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17858 /*Check for both basic rates and extended rates.*/
17859 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17860 {
17861 /*Check if the Rate is Mandatory or Not*/
17862 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17863 && (pIes->SuppRates.rates[i] & 0x80))
17864 {
17865 /*Retrieve the actual data rate*/
17866 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17867 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17868 if (minRate == 0)
17869 minRate = dataRate;
17870 else
17871 minRate = (minRate < dataRate) ? minRate:dataRate;
17872 }
17873 }
17874
17875 if (pIes->ExtSuppRates.present)
17876 {
17877 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17878 {
17879 /*Check if the Rate is Mandatory or Not*/
17880 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17881 && (pIes->ExtSuppRates.rates[i] & 0x80))
17882 {
17883 /*Retrieve the actual data rate*/
17884 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17885 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17886 if (minRate == 0)
17887 minRate = dataRate;
17888 else
17889 minRate = (minRate < dataRate) ? minRate:dataRate;
17890 }
17891 }
17892 }
17893 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17894 }
17895 else
17896 {
17897 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17898 "%s: Supp Rates not present in pIes", __func__);
17899 vos_mem_free(pRequestBuf);
17900 return eHAL_STATUS_FAILURE;
17901 }
17902 if (NULL != pIes)
17903 {
17904 vos_mem_free(pIes);
17905 pIes = NULL;
17906 }
17907 switch (minRate)
17908 {
17909 case 1:
17910 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
17911 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
17912 break;
17913 case 2:
17914 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
17915 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
17916 break;
17917 case 5:
17918 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
17919 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
17920 break;
17921 case 6:
17922 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17923 {
17924 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
17925 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
17926 }
17927 else
17928 {
17929 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
17930 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
17931 }
17932 break;
17933 case 11:
17934 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
17935 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
17936 break;
17937 case 12:
17938 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17939 {
17940 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
17941 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
17942 }
17943 else
17944 {
17945 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
17946 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
17947 }
17948 break;
17949 case 24:
17950 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
17951 {
17952 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
17953 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
17954 }
17955 else
17956 {
17957 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
17958 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
17959 }
17960 break;
17961 default:
17962 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
17963 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17964 break;
17965 }
17966 }
17967 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17968 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
17969 operationChannel, minRate,
17970 pRequestBuf->RxSensitivityThreshold,
17971 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017972 pRequestBuf->RoamRssiDiff =
17973 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017974 pRequestBuf->StartScanReason = reason;
17975 pRequestBuf->NeighborScanTimerPeriod =
17976 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
17977 pRequestBuf->NeighborRoamScanRefreshPeriod =
17978 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
17979 pRequestBuf->NeighborScanChannelMinTime =
17980 pNeighborRoamInfo->cfgParams.minChannelScanTime;
17981 pRequestBuf->NeighborScanChannelMaxTime =
17982 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
17983 pRequestBuf->EmptyRefreshScanPeriod =
17984 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080017985 /* MAWC feature */
17986 pRequestBuf->MAWCEnabled =
17987 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017988
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017989#ifdef FEATURE_WLAN_ESE
17990 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017991#endif
17992 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017993#ifdef FEATURE_WLAN_ESE
17994 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017995 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17996 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017997 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17998#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017999 currChannelListInfo->numOfChannels == 0)
18000 {
18001
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018002 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
18003 * Give Preference to INI Channels.*/
18004 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
18005 {
18006 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
18007 /*The INI channels need to be filtered with respect to the current
18008 * band that is supported.*/
18009 eBand = pMac->roam.configParam.bandCapability;
18010 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018011 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018012 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18013 "Invalid band, No operation carried out (Band %d)", eBand);
18014 vos_mem_free(pRequestBuf);
18015 return eHAL_STATUS_FAILURE;
18016 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018017
18018 if (pMac->roam.configParam.nRoamIntraBand)
18019 {
18020 eBand = GetCurrentBand(operationChannel);
18021 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18022 "Current Band %d", eBand);
18023 }
18024
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018025 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
18026 {
18027 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18028 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18029 (eCSR_BAND_ALL == eBand))
18030 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018031 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
18032 ((pMac->roam.configParam.allowDFSChannelRoam) ||
18033 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
18034 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018035 {
18036 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
18037 }
18038 }
18039 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018040 }
18041 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18042 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018043 }
18044 else
18045 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018046 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018047
18048 if (pMac->roam.configParam.nRoamIntraBand)
18049 {
18050 Rfband = GetCurrentBand(operationChannel);
18051 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18052 "Current Band %d", Rfband);
18053 }
18054
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018055 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
18056 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018057 if(((eCSR_BAND_24 == Rfband) &&
18058 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18059 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18060 || (eCSR_BAND_ALL == Rfband))
18061 {
18062 /* Allow DFS channels only if the DFS channel roam flag is
18063 * enabled
18064 */
18065 if(*ChannelList && ((pMac->roam.configParam.
18066 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
18067 && (num_channels < SIR_ROAM_MAX_CHANNELS))
18068 {
18069 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
18070 = *ChannelList;
18071 }
18072 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018073 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018074 }
18075 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18076 /* If the profile changes as to what it was earlier, inform the FW through
18077 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
18078 * for the earlier profile and try to learn them afresh.*/
18079 if (reason == REASON_FLUSH_CHANNEL_LIST)
18080 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18081 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018082 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18083 (pMac->roam.configParam.nRoamIntraBand))
18084 pRequestBuf->ChannelCacheType =
18085 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018086 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018087 pRequestBuf->ChannelCacheType =
18088 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018089 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018090 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018091 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018092#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018093 else
18094 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018095 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018096 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018097 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018098 if (currChannelListInfo->numOfChannels != 0)
18099 {
18100 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018101
18102 if (pMac->roam.configParam.nRoamIntraBand)
18103 {
18104 Rfband = GetCurrentBand(operationChannel);
18105 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18106 "Current Band %d", Rfband);
18107 }
18108
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018109 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018110 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018111 if(((eCSR_BAND_24 == Rfband) &&
18112 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18113 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18114 || (eCSR_BAND_ALL == Rfband))
18115 {
18116 if(*ChannelList && ((pMac->roam.configParam.
18117 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18118 {
18119 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018120 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018121 }
18122 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018123 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018124 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018125 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018126 if (pMac->roam.configParam.nRoamIntraBand)
18127 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18128 else
18129 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018130 }
18131 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018132#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018133 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18134 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018135 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018136 if (j < sizeof(ChannelCacheStr))
18137 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018138 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18139 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018140 }
18141 else
18142 {
18143 break;
18144 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018145 }
18146 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18147 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18148 pRequestBuf->ChannelCacheType,
18149 pRequestBuf->ConnectedNetwork.ChannelCount,
18150 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018151 num_channels = 0;
18152 ChannelList = NULL;
18153
18154 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018155 host_channels = sizeof(pMac->roam.validChannelList);
18156 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018157 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018158 ChannelList = pMac->roam.validChannelList;
18159 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018160 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018161 else
18162 {
18163 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18164 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018165 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018166 return eHAL_STATUS_FAILURE;
18167 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018168
18169 if (pMac->roam.configParam.nRoamIntraBand)
18170 {
18171 Rfband = GetCurrentBand(operationChannel);
18172 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18173 Rfband);
18174 }
18175
Srinivas Girigowda56076852013-08-20 14:00:50 -070018176 for(i=0; i<pMac->roam.numValidChannels; i++)
18177 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018178 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18179 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18180 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018181 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018182 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18183 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18184 {
18185 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18186 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018187 }
18188 ChannelList++;
18189 }
18190 pRequestBuf->ValidChannelCount = num_channels;
18191
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018192 pRequestBuf->MDID.mdiePresent =
18193 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18194 pRequestBuf->MDID.mobilityDomain =
18195 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018196 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18197
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018198 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018199 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18200 * where RFS is the RF Switching time. It is twice RFS to consider the
18201 * time to go off channel and return to the home channel. */
18202 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18203 {
18204 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18205 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18206 " Hence enforcing home away time to disable (0)",
18207 __func__, pRequestBuf->HomeAwayTime,
18208 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18209 pRequestBuf->HomeAwayTime = 0;
18210 }
18211 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018212
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018213 pRequestBuf->WeakZoneRssiThresholdForRoam =
18214 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018215 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18216 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18217 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18218 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18219 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18220
18221 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18222 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018223send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018224 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018225 msg.reserved = 0;
18226 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018227 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18228 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018229 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18230 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018231 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18232 vos_mem_free(pRequestBuf);
18233 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018234 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018235 else
18236 {
18237 if (ROAM_SCAN_OFFLOAD_START == command)
18238 bRoamScanOffloadStarted = VOS_TRUE;
18239 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18240 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018241
18242 /*update the last sent cmd*/
18243 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018244 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018245
18246 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 +053018247
18248 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018249 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18250 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018251 {
18252
18253 /* PER ROAM SCAN */
18254 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18255 if (!PERRoamReqBuf)
18256 {
18257 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18258 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18259 return eHAL_STATUS_FAILURE;
18260 }
18261 /* PER Roam Config */
18262 PERRoamReqBuf->rateUpThreshold =
18263 pMac->roam.configParam.rateUpThreshold;
18264 PERRoamReqBuf->rateDownThreshold =
18265 pMac->roam.configParam.rateDownThreshold;
18266 PERRoamReqBuf->waitPeriodForNextPERScan =
18267 pMac->roam.configParam.waitPeriodForNextPERScan;
18268 PERRoamReqBuf->PERtimerThreshold =
18269 pMac->roam.configParam.PERtimerThreshold;
18270 PERRoamReqBuf->isPERRoamCCAEnabled =
18271 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018272 PERRoamReqBuf->PERRoamFullScanThreshold =
18273 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018274 PERRoamReqBuf->PERroamTriggerPercent =
18275 pMac->roam.configParam.PERroamTriggerPercent;
18276 PERRoamReqBuf->sessionId = sessionId;
18277
18278 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18279 PERroamScanConfigMsg.reserved = 0;
18280 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18281 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18282 &PERroamScanConfigMsg))) {
18283 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18284 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18285 vos_mem_free(PERRoamReqBuf);
18286 return eHAL_STATUS_FAILURE;
18287 }
18288 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18289 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18290 PERRoamReqBuf->rateUpThreshold,
18291 PERRoamReqBuf->rateDownThreshold,
18292 PERRoamReqBuf->waitPeriodForNextPERScan,
18293 PERRoamReqBuf->PERtimerThreshold);
18294 }
18295
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018296 return status;
18297}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018298
18299eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18300{
18301 switch(reason)
18302 {
18303 case 0:
18304 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18305 break;
18306 case REASON_OS_REQUESTED_ROAMING_NOW:
18307 csrNeighborRoamProceedWithHandoffReq(pMac);
18308 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018309 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18310 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18311 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018312 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018313 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 -070018314 }
18315 return eHAL_STATUS_SUCCESS;
18316}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018317#endif
18318
Jeff Johnson295189b2012-06-20 16:38:30 -070018319tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18320 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18321{
18322 tANI_BOOLEAN found = FALSE;
18323 eHalStatus status = eHAL_STATUS_SUCCESS;
18324 tCsrPeStatsReqInfo staEntry;
18325 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18326 tListElem *pStaEntry = NULL;
18327 VOS_STATUS vosStatus;
18328 tPmcPowerState powerState;
18329 *pFound = FALSE;
18330
18331 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18332 if(pStaEntry)
18333 {
18334 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18335 if(pTempStaEntry->periodicity)
18336 {
18337 pTempStaEntry->periodicity =
18338 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18339 }
18340 else
18341 {
18342 pTempStaEntry->periodicity = periodicity;
18343 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018344 pTempStaEntry->numClient++;
18345 found = TRUE;
18346 }
18347 else
18348 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018349 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018350 staEntry.numClient = 1;
18351 staEntry.periodicity = periodicity;
18352 staEntry.pMac = pMac;
18353 staEntry.rspPending = FALSE;
18354 staEntry.staId = staId;
18355 staEntry.statsMask = statsMask;
18356 staEntry.timerRunning = FALSE;
18357 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18358 if(!pTempStaEntry)
18359 {
18360 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018361 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018362 return NULL;
18363 }
18364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018365 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18366 if(ePMC_FULL_POWER == powerState)
18367 {
18368 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18369 {
18370 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18371 }
18372 }
18373 else
18374 {
18375 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18376 {
18377 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18378 }
18379 }
18380 if(!pTempStaEntry->timerRunning)
18381 {
18382 //send down a req in case of one time req, for periodic ones wait for timer to expire
18383 if(!pTempStaEntry->rspPending &&
18384 !pTempStaEntry->periodicity)
18385 {
18386 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18387 if(!HAL_STATUS_SUCCESS(status))
18388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018389 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018390 }
18391 else
18392 {
18393 pTempStaEntry->rspPending = TRUE;
18394 }
18395 }
18396 if(pTempStaEntry->periodicity)
18397 {
18398 if(!found)
18399 {
18400
18401 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18402 csrRoamPeStatsTimerHandler, pTempStaEntry );
18403 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018405 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018406 return NULL;
18407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018408 }
18409 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018410 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018411 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18412 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018414 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018415 return NULL;
18416 }
18417 pTempStaEntry->timerRunning = TRUE;
18418 }
18419 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018420 *pFound = found;
18421 return pTempStaEntry;
18422}
18423
Jeff Johnson295189b2012-06-20 16:38:30 -070018424/*
18425 pStaEntry is no longer invalid upon the return of this function.
18426*/
18427static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18428{
18429 if(pEntry)
18430 {
18431 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18432 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018433 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018434 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018435 }
18436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018437
18438void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18439{
18440 tListElem *pEntry;
18441 tCsrPeStatsReqInfo *pTempStaEntry;
18442 VOS_STATUS vosStatus;
18443 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018444 if(!pEntry)
18445 {
18446 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018447 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018448 return;
18449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018450 while( pEntry )
18451 {
18452 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018453 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18454 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018455 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018456 if(pTempStaEntry->timerRunning)
18457 {
18458 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18459 /* If we are not able to stop the timer here, just remove
18460 * the entry from the linked list. Destroy the timer object
18461 * and free the memory in the timer CB
18462 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018463 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018464 {
18465 /* the timer is successfully stopped */
18466 pTempStaEntry->timerRunning = FALSE;
18467
18468 /* Destroy the timer */
18469 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18470 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018472 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018473 }
18474 }
18475 else
18476 {
18477 // the timer could not be stopped. Hence destroy and free the
18478 // memory for the PE stat entry in the timer CB.
18479 pTempStaEntry->timerStopFailed = TRUE;
18480 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018482
18483 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18484 {
18485 // Only free the memory if we could stop the timer successfully
18486 if(!pTempStaEntry->timerStopFailed)
18487 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018488 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018489 pTempStaEntry = NULL;
18490 }
18491 break;
18492 }
18493
18494 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18495 }
18496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018497 return;
18498}
18499
18500
Jeff Johnsone7245742012-09-05 17:12:55 -070018501void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018502{
18503
Jeff Johnsone7245742012-09-05 17:12:55 -070018504 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18505 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18506 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18507 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18508 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18509 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18510 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018511 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018512 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18513 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18514 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18515 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18516 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18517 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018518 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018519 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18520 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018521
18522}
18523
Jeff Johnson295189b2012-06-20 16:38:30 -070018524void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18525 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18526{
18527 tANI_U8 stats[500];
18528 tANI_U8 *pStats = NULL;
18529 tANI_U32 tempMask = 0;
18530 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018531 if(!callback)
18532 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018533 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018534 return;
18535 }
18536 if(!statsMask)
18537 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018538 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018539 return;
18540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018541 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018542 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018543 while(tempMask)
18544 {
18545 if(tempMask & 1)
18546 {
18547 //new stats info from PE, fill up the stats strucutres in PMAC
18548 switch(counter)
18549 {
18550 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018551 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018552 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18553 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018554 pStats += sizeof(tCsrSummaryStatsInfo);
18555 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018556 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018557 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018558 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18559 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018560 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018561 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018562 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018563 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018564 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18565 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018566 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018568 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018569 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018570 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18571 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018572 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018573 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018574 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018575 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018576 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18577 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018578 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018579 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018580 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018581 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018582 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18583 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018584 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018585 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018586 case eCsrPerPktStats:
18587 smsLog( pMac, LOG2, FL("PerPkt stats"));
18588 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18589 sizeof(tPerTxPacketFrmFw));
18590 pStats += sizeof(tPerTxPacketFrmFw);
18591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018592 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018593 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018594 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018595 }
18596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018597 tempMask >>=1;
18598 counter++;
18599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018600 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018601}
18602
Jeff Johnson295189b2012-06-20 16:38:30 -070018603eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18604{
18605 tListElem *pEntry = NULL;
18606 tListElem *pPrevEntry = NULL;
18607 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18608 eHalStatus status = eHAL_STATUS_SUCCESS;
18609 VOS_STATUS vosStatus;
18610 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018611 if(!pEntry)
18612 {
18613 //list empty
18614 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018615 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018616 return status;
18617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018618 while( pEntry )
18619 {
18620 if(pPrevEntry)
18621 {
18622 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18623 //send up the stats report
18624 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18625 pTempStaEntry->staId, pTempStaEntry->pContext);
18626 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18627 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018628 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018629 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18630 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018631 pTempStaEntry->pPeStaEntry->numClient--;
18632 //check if we need to delete the entry from peStatsReqList too
18633 if(!pTempStaEntry->pPeStaEntry->numClient)
18634 {
18635 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018638 //check if we need to stop the tl stats timer too
18639 pMac->roam.tlStatsReqInfo.numClient--;
18640 if(!pMac->roam.tlStatsReqInfo.numClient)
18641 {
18642 if(pMac->roam.tlStatsReqInfo.timerRunning)
18643 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018644 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18645 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018647 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018648 //we will continue
18649 }
18650 }
18651 pMac->roam.tlStatsReqInfo.periodicity = 0;
18652 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018654 if (pTempStaEntry->periodicity)
18655 {
18656 //While creating StaEntry in csrGetStatistics,
18657 //Initializing and starting timer only when periodicity is set.
18658 //So Stop and Destroy timer only when periodicity is set.
18659
Jeff Johnsone7245742012-09-05 17:12:55 -070018660 vos_timer_stop( &pTempStaEntry->timer );
18661 // Destroy the vos timer...
18662 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18663 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018665 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018667 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018668
Jeff Johnson295189b2012-06-20 16:38:30 -070018669
18670 pPrevEntry = pEntry;
18671 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18672 }
18673 //the last one
18674 if(pPrevEntry)
18675 {
18676 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18677 //send up the stats report
18678 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18679 pTempStaEntry->staId, pTempStaEntry->pContext);
18680 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018682 return status;
18683
18684}
18685
Jeff Johnson295189b2012-06-20 16:38:30 -070018686eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18687 tRequestFullPowerReason *pReason,
18688 tANI_BOOLEAN *pfNeedPower )
18689{
18690 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18691 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18692 tPmcState pmcState;
18693 eHalStatus status = eHAL_STATUS_SUCCESS;
18694 // TODO : Session info unavailable
18695 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018696 if( pfNeedPower )
18697 {
18698 *pfNeedPower = eANI_BOOLEAN_FALSE;
18699 }
18700 //We only handle CSR commands
18701 if( !(eSmeCsrCommandMask & pCommand->command) )
18702 {
18703 return eHAL_STATUS_SUCCESS;
18704 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018705 //Check PMC state first
18706 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018707 switch( pmcState )
18708 {
18709 case REQUEST_IMPS:
18710 case IMPS:
18711 if( eSmeCommandScan == pCommand->command )
18712 {
18713 switch( pCommand->u.scanCmd.reason )
18714 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018715#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18716 case eCsrScanGetLfrResult:
18717#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018718 case eCsrScanGetResult:
18719 case eCsrScanBGScanAbort:
18720 case eCsrScanBGScanEnable:
18721 case eCsrScanGetScanChnInfo:
18722 //Internal process, no need for full power
18723 fNeedFullPower = eANI_BOOLEAN_FALSE;
18724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018725 default:
18726 //Other scans are real scan, ask for power
18727 fNeedFullPower = eANI_BOOLEAN_TRUE;
18728 break;
18729 } //switch
18730 }
18731 else
18732 {
18733 //ask for power for roam and status change
18734 fNeedFullPower = eANI_BOOLEAN_TRUE;
18735 }
18736 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018737 case REQUEST_BMPS:
18738 case BMPS:
18739 case REQUEST_START_UAPSD:
18740 case UAPSD:
18741 //We treat WOWL same as BMPS
18742 case REQUEST_ENTER_WOWL:
18743 case WOWL:
18744 if( eSmeCommandRoam == pCommand->command )
18745 {
18746 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18747 tCsrScanResult *pScanResult;
18748 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018749 switch ( pCommand->u.roamCmd.roamReason )
18750 {
18751 case eCsrForcedDisassoc:
18752 case eCsrForcedDisassocMICFailure:
18753 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18754 fNeedFullPower = eANI_BOOLEAN_TRUE;
18755 break;
18756 case eCsrSmeIssuedDisassocForHandoff:
18757 case eCsrForcedDeauth:
18758 case eCsrHddIssuedReassocToSameAP:
18759 case eCsrSmeIssuedReassocToSameAP:
18760 fNeedFullPower = eANI_BOOLEAN_TRUE;
18761 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018762 case eCsrCapsChange:
18763 fNeedFullPower = eANI_BOOLEAN_TRUE;
18764 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018765 case eCsrForcedDisassocSta:
18766 case eCsrForcedDeauthSta:
18767 fNeedFullPower = eANI_BOOLEAN_FALSE;
18768 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018769 default:
18770 //Check whether the profile is already connected. If so, no need for full power
18771 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18772 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18773 {
18774 //Only need to check the first one
18775 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18776 if( pEntry )
18777 {
18778 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18779#if 0
18780 // TODO : Session Specific info pConnectBssDesc
18781 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18782 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18783 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18784 {
18785 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18786 // with Authenticating first. To force this, stop the current association (Disassociate) and
18787 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18788 // a new Association.
18789 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18790 {
18791 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18792 {
18793 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18794 //No need for full power
18795 //Set the flag so the code later can avoid to do the above
18796 //check again.
18797 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18798 break;
18799 }
18800 }
18801 }
18802#endif
18803 }
18804 }
18805 //If we are here, full power is needed
18806 fNeedFullPower = eANI_BOOLEAN_TRUE;
18807 break;
18808 }
18809 }
18810 else if( eSmeCommandWmStatusChange == pCommand->command )
18811 {
18812 //need full power for all
18813 fNeedFullPower = eANI_BOOLEAN_TRUE;
18814 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18815 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018816#ifdef FEATURE_WLAN_TDLS
18817 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18818 {
18819 //TDLS link is getting established. need full power
18820 fNeedFullPower = eANI_BOOLEAN_TRUE;
18821 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18822 }
18823#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018824 else if (eSmeCommandDelStaSession == pCommand->command)
18825 {
18826 //need full power for all
18827 fNeedFullPower = eANI_BOOLEAN_TRUE;
18828 }
18829
Jeff Johnson295189b2012-06-20 16:38:30 -070018830 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018831 case REQUEST_STOP_UAPSD:
18832 case REQUEST_EXIT_WOWL:
18833 if( eSmeCommandRoam == pCommand->command )
18834 {
18835 fNeedFullPower = eANI_BOOLEAN_TRUE;
18836 switch ( pCommand->u.roamCmd.roamReason )
18837 {
18838 case eCsrForcedDisassoc:
18839 case eCsrForcedDisassocMICFailure:
18840 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18841 break;
18842 default:
18843 break;
18844 }
18845 }
18846 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018847 case STOPPED:
18848 case REQUEST_STANDBY:
18849 case STANDBY:
18850 case LOW_POWER:
18851 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018852 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18853 " stopped/standby state %s (%d)" ),
18854 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018855 status = eHAL_STATUS_FAILURE;
18856 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018857 case FULL_POWER:
18858 case REQUEST_FULL_POWER:
18859 default:
18860 //No need to ask for full power. This has to be FULL_POWER state
18861 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018862 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018863 if( pReason )
18864 {
18865 *pReason = reason;
18866 }
18867 if( pfNeedPower )
18868 {
18869 *pfNeedPower = fNeedFullPower;
18870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018871 return ( status );
18872}
18873
Jeff Johnson295189b2012-06-20 16:38:30 -070018874static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18875{
18876 eHalStatus status = eHAL_STATUS_SUCCESS;
18877 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18878 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018879 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018880 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18881 {
18882 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018884 return ( status );
18885}
18886
Jeff Johnson295189b2012-06-20 16:38:30 -070018887tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18888{
18889 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018890 if( pCmd )
18891 {
18892 pMac->roam.sPendingCommands++;
18893 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018894 return ( pCmd );
18895}
18896
Jeff Johnson295189b2012-06-20 16:38:30 -070018897void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18898{
18899 if (pMac->roam.sPendingCommands > 0)
18900 {
18901 //All command allocated through csrGetCommandBuffer need to
18902 //decrement the pending count when releasing.
18903 pMac->roam.sPendingCommands--;
18904 smeReleaseCommand( pMac, pCommand );
18905 }
18906 else
18907 {
18908 smsLog(pMac, LOGE, FL( "no pending commands"));
18909 VOS_ASSERT(0);
18910 }
18911}
18912
Jeff Johnson295189b2012-06-20 16:38:30 -070018913//Return SUCCESS is the command is queued, failed
18914eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
18915{
18916 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053018917
18918 if (!SME_IS_START(pMac))
18919 {
18920 smsLog( pMac, LOGE, FL("Sme in stop state"));
18921 return eHAL_STATUS_FAILURE;
18922 }
18923
Jeff Johnson295189b2012-06-20 16:38:30 -070018924 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
18925 {
18926 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
18927 pCommand->u.scanCmd.reason);
18928 return eHAL_STATUS_CSR_WRONG_STATE;
18929 }
18930
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018931 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
18932 {
18933 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
18934 &pCommand->Link, LL_ACCESS_LOCK);
18935 // process the command queue...
18936 smeProcessPendingQueue(pMac);
18937 status = eHAL_STATUS_SUCCESS;
18938 goto end;
18939 }
18940
Jeff Johnson295189b2012-06-20 16:38:30 -070018941 //We can call request full power first before putting the command into pending Q
18942 //because we are holding SME lock at this point.
18943 status = csrRequestFullPower( pMac, pCommand );
18944 if( HAL_STATUS_SUCCESS( status ) )
18945 {
18946 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070018947 //make sure roamCmdPendingList is not empty first
18948 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
18949 if( fNoCmdPending )
18950 {
18951 smePushCommand( pMac, pCommand, fHighPriority );
18952 }
18953 else
18954 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018955 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070018956 //no list lock is needed since SME lock is held
18957 if( !fHighPriority )
18958 {
18959 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18960 }
18961 else {
18962 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18963 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018965 }
18966 else if( eHAL_STATUS_PMC_PENDING == status )
18967 {
18968 //no list lock is needed since SME lock is held
18969 if( !fHighPriority )
18970 {
18971 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18972 }
18973 else {
18974 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
18975 }
18976 //Let caller know the command is queue
18977 status = eHAL_STATUS_SUCCESS;
18978 }
18979 else
18980 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018981 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070018982 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018983 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070018984 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053018985end:
Jeff Johnson295189b2012-06-20 16:38:30 -070018986 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070018987}
Jeff Johnson295189b2012-06-20 16:38:30 -070018988eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
18989{
18990 eHalStatus status = eHAL_STATUS_SUCCESS;
18991 tSirUpdateAPWPSIEsReq *pMsg;
18992 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
18993
18994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18995 if (NULL == pSession)
18996 {
18997 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
18998 return eHAL_STATUS_FAILURE;
18999 }
19000
Jeff Johnson295189b2012-06-20 16:38:30 -070019001 do
19002 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019003 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
19004 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19005 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070019006 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
19007
19008 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070019009 VOS_ASSERT(pBuf);
19010
Jeff Johnson295189b2012-06-20 16:38:30 -070019011 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070019012 // transactionId
19013 *pBuf = 0;
19014 *( pBuf + 1 ) = 0;
19015 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070019016 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019017 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19018 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019019 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019020 //sessionId
19021 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019022 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019023 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070019024 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070019025 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019026 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019027 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019028 return ( status );
19029}
Jeff Johnson295189b2012-06-20 16:38:30 -070019030eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
19031{
19032 eHalStatus status = eHAL_STATUS_SUCCESS;
19033 tSirUpdateAPWPARSNIEsReq *pMsg;
19034 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070019035 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19036 if (NULL == pSession)
19037 {
19038 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
19039 return eHAL_STATUS_FAILURE;
19040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019041 do
19042 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019043 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
19044 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19045 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070019046 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070019047 pBuf = (tANI_U8 *)&pMsg->transactionId;
19048 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070019049 // transactionId
19050 *pBuf = 0;
19051 *( pBuf + 1 ) = 0;
19052 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070019053 VOS_ASSERT(pBuf);
19054
Jeff Johnson295189b2012-06-20 16:38:30 -070019055 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019056 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19057 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019058 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019059 // sessionId
19060 *pBuf++ = (tANI_U8)sessionId;
19061
19062 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019063 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070019064 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070019065 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019066 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019067 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019068 return ( status );
19069}
Jeff Johnson295189b2012-06-20 16:38:30 -070019070
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019071tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
19072 tpSirBssDescription pBssDescription)
19073{
19074 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19075 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19076 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
19077 eHalStatus status;
19078 tDot11fBeaconIEs *ies_local = NULL;
19079 tANI_U32 dot11mode = 0;
19080
19081 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19082
19083 /* Get IE's */
19084 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19085 if (!HAL_STATUS_SUCCESS(status)) {
19086 smsLog(pMac, LOGE,
19087 FL("csrGetParsedBssDescriptionIEs failed"));
19088 return 0;
19089 }
19090 if(ies_local == NULL) {
19091 smsLog(pMac, LOGE,
19092 FL("ies_local is NULL"));
19093 return 0;
19094 }
19095
19096 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19097 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19098 uCfgDot11Mode = cfgDot11Mode;
19099 else
19100 {
19101 smsLog(pMac, LOGE, "Can not find match phy mode");
19102 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19103 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19104 else
19105 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19106 }
19107
19108 /* dot11mode */
19109 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19110 smsLog(pMac, LOG1,
19111 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19112
19113 if (pBssDescription->channelId <= 14 &&
19114 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19115 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19116 {
19117 /* Need to disable VHT operation in 2.4 GHz band */
19118 dot11mode = WNI_CFG_DOT11_MODE_11N;
19119 }
19120 vos_mem_free(ies_local);
19121 return dot11mode;
19122}
19123
Jeff Johnson295189b2012-06-20 16:38:30 -070019124#ifdef WLAN_FEATURE_VOWIFI_11R
19125//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19126eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19127{
19128 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19129 tpSirFTPreAuthReq pftPreAuthReq;
19130 tANI_U16 auth_req_len = 0;
19131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019132 auth_req_len = sizeof(tSirFTPreAuthReq);
19133 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019134 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019135 {
19136 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19137 return eHAL_STATUS_RESOURCES;
19138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019139 // Save the SME Session ID here. We need it while processing the preauth response
19140 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019141 vos_mem_zero(pftPreAuthReq, auth_req_len);
19142
19143 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19144 sizeof(pBssDescription->length) + pBssDescription->length);
19145
19146 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19147
19148 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019149 pftPreAuthReq->dot11mode =
19150 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19151 if (!pftPreAuthReq->dot11mode)
19152 {
19153 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19154 vos_mem_free(pftPreAuthReq);
19155 return eHAL_STATUS_FAILURE;
19156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019157
Kiet Lam64c1b492013-07-12 13:56:44 +053019158 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19159 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19160 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19161 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019162
Jeff Johnson295189b2012-06-20 16:38:30 -070019163#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019164 if (csrRoamIs11rAssoc(pMac) &&
19165 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019166 {
19167 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019168 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19169 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019170 }
19171 else
19172#endif
19173 {
19174 pftPreAuthReq->ft_ies_length = 0;
19175 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019176 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19177 sizeof(pBssDescription->length) + pBssDescription->length);
19178 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019179 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19180}
Jeff Johnson295189b2012-06-20 16:38:30 -070019181/*--------------------------------------------------------------------------
19182 * This will receive and process the FT Pre Auth Rsp from the current
19183 * associated ap.
19184 *
19185 * This will invoke the hdd call back. This is so that hdd can now
19186 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19187 ------------------------------------------------------------------------*/
19188void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19189{
19190 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19191 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019192#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019193 tCsrRoamInfo roamInfo;
19194#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019195 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019196
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019197#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019198 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019199 if (status != eHAL_STATUS_SUCCESS) {
19200 /*
19201 * Bail out if pre-auth was not even processed.
19202 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019203 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19204 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019205 return;
19206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019208 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19209 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19210 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019211 // Implies a success
19212 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019213 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19214 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019215 /* No need to notify qos module if this is a non 11r & ESE roam*/
19216 if (csrRoamIs11rAssoc(pMac)
19217#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19218 || csrRoamIsESEAssoc(pMac)
19219#endif
19220 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019221 {
19222 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19223 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019224 if (pMac->roam.configParam.roamDelayStatsEnabled)
19225 {
19226 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019228 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19229 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019230 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19231 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019232 if (pMac->roam.configParam.roamDelayStatsEnabled)
19233 {
19234 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019236 if (eHAL_STATUS_SUCCESS != status)
19237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019238 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019239 return;
19240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019241 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019242 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19243 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019244 if (csrRoamIs11rAssoc(pMac))
19245 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19246 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19247
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019248#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19249 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019250 {
19251 /* read TSF */
19252 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19253
19254 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019255 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019256 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19257 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019258#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019259#ifdef FEATURE_WLAN_LFR
19260 // If Legacy Fast Roaming is enabled, signal the supplicant
19261 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019262 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019263 {
19264 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019265 vos_mem_copy((void *)&roamInfo.bssid,
19266 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019267 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19268 }
19269
19270#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019271
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019272 // If its an Open Auth, FT IEs are not provided by supplicant
19273 // Hence populate them here
19274 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19275 pMac->ft.ftSmeContext.addMDIE = FALSE;
19276 if( csrRoamIs11rAssoc(pMac) &&
19277 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19278 {
19279 tANI_U16 ft_ies_length;
19280 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19281
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019282 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19283 connectedProfile.MDID.mdiePresent)
19284 pMac->ft.ftSmeContext.addMDIE = TRUE;
19285
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019286 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19287 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19288 {
19289 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19290 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19291 }
19292
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019293 if (!ft_ies_length)
19294 {
19295 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19296 return;
19297 }
19298
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019299 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19300 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19301 {
19302 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19303 }
19304 else
19305 {
19306 // Copy the RIC IEs to reassoc IEs
19307 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19308 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19309 pFTPreAuthRsp->ric_ies_length);
19310 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19311 pMac->ft.ftSmeContext.addMDIE = TRUE;
19312 }
19313 }
19314
Jeff Johnson295189b2012-06-20 16:38:30 -070019315 // Done with it, init it.
19316 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19317}
19318#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019319
Jeff Johnson295189b2012-06-20 16:38:30 -070019320#ifdef FEATURE_WLAN_BTAMP_UT_RF
19321void csrRoamJoinRetryTimerHandler(void *pv)
19322{
19323 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19324 tpAniSirGlobal pMac = pInfo->pMac;
19325 tANI_U32 sessionId = pInfo->sessionId;
19326 tCsrRoamSession *pSession;
19327
19328 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019330 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019331 pSession = CSR_GET_SESSION( pMac, sessionId );
19332 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19333 {
19334 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019336 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019337 }
19338 }
19339 }
19340}
Jeff Johnson295189b2012-06-20 16:38:30 -070019341eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19342{
19343 eHalStatus status = eHAL_STATUS_FAILURE;
19344 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19345
19346 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019348 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019349 pSession->maxRetryCount--;
19350 pSession->joinRetryTimerInfo.pMac = pMac;
19351 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019352 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19353 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019355 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019356 }
19357 }
19358 else
19359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019360 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019361 pSession->maxRetryCount);
19362 }
19363
19364 return (status);
19365}
Jeff Johnson295189b2012-06-20 16:38:30 -070019366eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19367{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019368 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019369 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19370 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019371 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019372 }
19373
19374 return eHAL_STATUS_SUCCESS;
19375}
19376#endif
19377
19378
19379/*
19380 pBuf points to the beginning of the message
19381 LIM packs disassoc rsp as below,
19382 messageType - 2 bytes
19383 messageLength - 2 bytes
19384 sessionId - 1 byte
19385 transactionId - 2 bytes (tANI_U16)
19386 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19387 peerMacAddr - 6 bytes
19388 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19389*/
19390static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19391{
19392 if(pBuf && pRsp)
19393 {
19394 pBuf += 4; //skip type and length
19395 pRsp->sessionId = *pBuf++;
19396 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19397 pBuf += 2;
19398 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19399 pBuf += 4;
19400 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19401 }
19402}
19403
Jeff Johnsond13512a2012-07-17 11:42:19 -070019404eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19405{
19406 static uNvTables nvTables;
19407 eHalStatus status = eHAL_STATUS_SUCCESS;
19408 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19409
19410 /* read the country code from NV and use it */
19411 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19412 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019413 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19414 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019415 return status;
19416 }
19417 else
19418 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019419 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019420 status = eHAL_STATUS_FAILURE;
19421 return status;
19422 }
19423}
19424
19425eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19426{
Kiet Lam64c1b492013-07-12 13:56:44 +053019427 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019428 return eHAL_STATUS_SUCCESS;
19429}
schang86c22c42013-03-13 18:41:24 -070019430
19431eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19432{
19433 tSirSetTxPowerReq *pMsg = NULL;
19434 eHalStatus status = eHAL_STATUS_SUCCESS;
19435 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19436
19437 if (!pSession)
19438 {
19439 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19440 return eHAL_STATUS_FAILURE;
19441 }
19442
Kiet Lam64c1b492013-07-12 13:56:44 +053019443 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19444 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19445 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19446 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19447 pMsg->length = sizeof(tSirSetTxPowerReq);
19448 pMsg->mwPower = mW;
19449 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19450 sizeof(tSirMacAddr));
19451 status = palSendMBMessage(pMac->hHdd, pMsg);
19452 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019453 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019454 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19455 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019456 }
19457 return status;
19458}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019459
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019460eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19461{
19462 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19463 eHalStatus status = eHAL_STATUS_SUCCESS;
19464 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19465
19466 if (!pSession)
19467 {
19468 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19469 return eHAL_STATUS_FAILURE;
19470 }
19471 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19472 {
19473 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019474
19475 if( NULL == pMsg )
19476 {
19477 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19478 return eHAL_STATUS_FAILURE;
19479 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019480 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19481 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019482 pMsg->length =
19483 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019484 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019485 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19486 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019487 status = palSendMBMessage(pMac->hHdd, pMsg);
19488 if (!HAL_STATUS_SUCCESS(status))
19489 {
19490 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19491 //pMsg is freed by palSendMBMessage
19492 }
19493 }
19494 else
19495 {
19496 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19497 status = eHAL_STATUS_FAILURE;
19498 }
19499 return status;
19500}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019501/* Returns whether a session is in VOS_STA_MODE...or not */
19502tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19503{
19504 tCsrRoamSession *pSession = NULL;
19505 pSession = CSR_GET_SESSION ( pMac, sessionId );
19506 if(!pSession)
19507 {
19508 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19509 return eANI_BOOLEAN_FALSE;
19510 }
19511 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19512 {
19513 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19514 return eANI_BOOLEAN_FALSE;
19515 }
19516 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19517 {
19518 return eANI_BOOLEAN_FALSE;
19519 }
19520 /* There is a possibility that the above check may fail,because
19521 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19522 * when it is connected.So,we may sneak through the above check even
19523 * if we are not a STA mode INFRA station. So, if we sneak through
19524 * the above condition, we can use the following check if we are
19525 * really in STA Mode.*/
19526
19527 if ( NULL != pSession->pCurRoamProfile )
19528 {
19529 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19530 {
19531 return eANI_BOOLEAN_TRUE;
19532 } else {
19533 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19534 return eANI_BOOLEAN_FALSE;
19535 }
19536 }
19537
19538 return eANI_BOOLEAN_FALSE;
19539}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019540
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019541/**
19542 * csr_set_src_handoff_request() - Set handoff source to
19543 * SME handoff request
19544 * @pHandoffInfo: Pointer to Handoff info
19545 * @pMsg: Pointer to SME handoff request message
19546 *
19547 * Return: None
19548 */
19549#ifndef QCA_WIFI_ISOC
19550static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19551 tCsrHandoffRequest *pHandoffInfo)
19552{
19553 pMsg->handoff_src = pHandoffInfo->src;
19554}
19555#else
19556static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19557 tCsrHandoffRequest *pHandoffInfo)
19558{
19559}
19560#endif
19561
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019562#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19563eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19564 tCsrHandoffRequest *pHandoffInfo)
19565{
19566 eHalStatus status = eHAL_STATUS_SUCCESS;
19567 vos_msg_t msg;
19568
19569 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019570 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19571 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019572 {
19573 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019574 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019575 }
19576 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19577 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19578 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19579 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019580 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019581 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019582 pHandoffInfo->bssid,
19583 6);
19584 msg.type = eWNI_SME_HANDOFF_REQ;
19585 msg.bodyptr = pMsg;
19586 msg.reserved = 0;
19587 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19588 {
19589 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019590 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019591 status = eHAL_STATUS_FAILURE;
19592 }
19593 return status;
19594}
19595#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019596
Abhishek Singh00b71972016-01-07 10:51:04 +053019597#ifdef WLAN_FEATURE_RMC
19598eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19599{
19600 tSirSetRMCReq *pMsg = NULL;
19601 eHalStatus status = eHAL_STATUS_SUCCESS;
19602 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19603
19604 if (!pSession)
19605 {
19606 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19607 return eHAL_STATUS_FAILURE;
19608 }
19609
19610 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19611 if (NULL != pMsg)
19612 {
19613 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19614 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19615 pMsg->msgLen = sizeof(tSirSetRMCReq);
19616 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19617 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19618
19619 status = palSendMBMessage(pMac->hHdd, pMsg);
19620 if (!HAL_STATUS_SUCCESS(status))
19621 {
19622 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19623 //pMsg is freed by palSendMBMessage
19624 }
19625 }
19626 else
19627 {
19628 return eHAL_STATUS_FAILURE;
19629 }
19630 return status;
19631}
19632
19633eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19634{
19635 tSirSetRMCReq *pMsg = NULL;
19636 eHalStatus status = eHAL_STATUS_SUCCESS;
19637 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19638
19639 if (!pSession)
19640 {
19641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19642 return eHAL_STATUS_FAILURE;
19643 }
19644
19645 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19646 if (NULL != pMsg)
19647 {
19648 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19649 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19650 pMsg->msgLen = sizeof(tSirSetRMCReq);
19651 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19652 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19653
19654 status = palSendMBMessage(pMac->hHdd, pMsg);
19655 if (!HAL_STATUS_SUCCESS(status))
19656 {
19657 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19658 //pMsg is freed by palSendMBMessage
19659 }
19660 }
19661 else
19662 {
19663 return eHAL_STATUS_FAILURE;
19664 }
19665 return status;
19666}
19667
19668#endif /* WLAN_FEATURE_RMC */
19669
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019670
19671#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019672/* ---------------------------------------------------------------------------
19673 \fn csrSetCCKMIe
19674 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19675 data structure and this IE will be packed inside reassociation request
19676 \param pMac - pMac global structure
19677 \param sessionId - Current session id
19678 \param pCckmIe - pointer to CCKM IE data
19679 \param ccKmIeLen - length of the CCKM IE
19680 \- return Success or failure
19681 -------------------------------------------------------------------------*/
19682VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19683 const tANI_U8 *pCckmIe,
19684 const tANI_U8 ccKmIeLen)
19685{
19686 eHalStatus status = eHAL_STATUS_SUCCESS;
19687 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19688
19689 if (!pSession)
19690 {
19691 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19692 return eHAL_STATUS_FAILURE;
19693 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019694 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019695 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19696 return status;
19697}
19698
19699/* ---------------------------------------------------------------------------
19700 \fn csrRoamReadTSF
19701 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19702 probe response reception from the hand off AP to arrive at the latest TSF value.
19703 \param pMac - pMac global structure
19704 \param pTimestamp - output TSF timestamp
19705 \- return Success or failure
19706 -------------------------------------------------------------------------*/
19707VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19708{
19709 eHalStatus status = eHAL_STATUS_SUCCESS;
19710 tCsrNeighborRoamBSSInfo handoffNode;
19711 tANI_U32 timer_diff = 0;
19712 tANI_U32 timeStamp[2];
19713 tpSirBssDescription pBssDescription = NULL;
19714
19715 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19716 pBssDescription = handoffNode.pBssDescription;
19717
19718 // Get the time diff in milli seconds
19719 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19720 // Convert msec to micro sec timer
19721 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19722
19723 timeStamp[0] = pBssDescription->timeStamp[0];
19724 timeStamp[1] = pBssDescription->timeStamp[1];
19725
19726 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19727
Kiet Lamf2f201e2013-11-16 21:24:16 +053019728 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019729 sizeof (tANI_U32) * 2);
19730 return status;
19731}
19732
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019733#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019734
Agarwal Ashish738843c2014-09-25 12:27:56 +053019735/* ---------------------------------------------------------------------------
19736 \fn csrDisableDfsChannel
19737 \brief This function will call csrApplyChannelPowerCountryInfo to
19738 \ to trim the list on basis of NO_DFS flag.
19739 \param pMac - pMac global structure
19740 \- return void
19741 -------------------------------------------------------------------------*/
19742void csrDisableDfsChannel(tpAniSirGlobal pMac)
19743{
19744 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19745 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19746}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019747
19748/* ---------------------------------------------------------------------------
19749 \fn csrGetStaticUapsdMask
19750 \brief This function will get the static uapsd settings for an existing
19751 \ Infra session.
19752 \param pMac - pMac global structure
19753 \- return void
19754 -------------------------------------------------------------------------*/
19755void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19756{
19757 tANI_S8 sessionId;
19758 tCsrRoamSession *pSession = NULL;
19759
19760 *staticUapsdMask = 0;
19761 sessionId = csrGetInfraSessionId(pMac);
19762 if(sessionId == -1)
19763 smsLog(pMac, LOGE, FL("Valid session not present."));
19764 else
19765 pSession = CSR_GET_SESSION(pMac, sessionId);
19766
19767 if(!pSession || !pSession->pCurRoamProfile)
19768 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019769 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019770 else
19771 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19772}
19773
Abhishek Singh02605092017-10-25 14:06:12 +053019774VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19775 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19776{
19777 VOS_STATUS status = VOS_STATUS_SUCCESS;
19778 struct sir_ecsa_ie_req *msg;
19779
19780 msg = vos_mem_malloc(sizeof(*msg));
19781 if (!msg) {
19782 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19783 return VOS_STATUS_E_NOMEM;
19784 }
19785
19786 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19787 msg->len = sizeof(*msg);
19788
19789 msg->new_chan = new_chan;
19790 msg->cb_mode = cb_mode;
19791 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19792
19793 status = palSendMBMessage(mac_ctx->hHdd, msg);
19794 if (!VOS_IS_STATUS_SUCCESS(status))
19795 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019796 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019797 return status;
19798}
19799
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019800VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19801 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19802{
19803 VOS_STATUS status = VOS_STATUS_SUCCESS;
19804 struct sir_channel_chanege_req *msg;
19805 tCsrRoamStartBssParams param;
19806
19807 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19808
19809 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19810
19811 msg = vos_mem_malloc(sizeof(*msg));
19812 if (!msg) {
19813 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19814 return VOS_STATUS_E_NOMEM;
19815 }
19816
19817 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19818 msg->len = sizeof(*msg);
19819
19820 msg->new_chan = new_chan;
19821 msg->cb_mode = cb_mode;
19822 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19823 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19824 mac_ctx->roam.configParam.uCfgDot11Mode);
19825 if (IS_24G_CH(msg->new_chan) &&
19826 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19827 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19828 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19829 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19830
19831 vos_mem_copy(&msg->operational_rateset,
19832 &param.operationalRateSet, sizeof(msg->operational_rateset));
19833 vos_mem_copy(&msg->extended_rateset,
19834 &param.extendedRateSet, sizeof(msg->extended_rateset));
19835
19836 status = palSendMBMessage(mac_ctx->hHdd, msg);
19837 if (!VOS_IS_STATUS_SUCCESS(status))
19838 smsLog(mac_ctx, LOGE,
19839 FL(" channel switch req fauiled status %d "), status);
19840 return status;
19841}