blob: d8ef1310f675082ef296dce68f801515eb5fba0e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
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"
61#include "logDump.h"
62#include "smeQosInternal.h"
63#include "wlan_qct_tl.h"
64#include "smeInside.h"
65#include "vos_diag_core_event.h"
66#include "vos_diag_core_log.h"
67#include "csrApi.h"
68#include "pmc.h"
69#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053070#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
72#include "csrNeighborRoam.h"
73#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080074#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
75#include "csrEse.h"
76#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053077#ifdef DEBUG_ROAM_DELAY
78#include "vos_utils.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#define CSR_NUM_IBSS_START_CHANNELS_50 4
81#define CSR_NUM_IBSS_START_CHANNELS_24 3
82#define CSR_DEF_IBSS_START_CHANNEL_50 36
83#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080084#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070085#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
86/*---------------------------------------------------------------------------
87 OBIWAN recommends [8 10]% : pick 9%
88---------------------------------------------------------------------------*/
89#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070090/*---------------------------------------------------------------------------
91 OBIWAN recommends -85dBm
92---------------------------------------------------------------------------*/
93#define CSR_VCC_RSSI_THRESHOLD 80
94#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
95#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
96#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
97#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070098//We use constatnt 4 here
99//This macro returns true when higher AC parameter is bigger than lower AC for a difference
100//The bigger the number, the less chance of TX
101//It must put lower AC as the first parameter.
102#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700103//Flag to send/do not send disassoc frame over the air
104#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700106#define MAX_CB_VALUE_IN_INI (2)
107
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700108#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
109static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
110#endif
111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112/*--------------------------------------------------------------------------
113 Static Type declarations
114 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800115static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117/*--------------------------------------------------------------------------
118 Type declarations
119 ------------------------------------------------------------------------*/
120#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700121int diagAuthTypeFromCSRType(eCsrAuthType authType)
122{
123 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 switch(authType)
125 {
126 case eCSR_AUTH_TYPE_SHARED_KEY:
127 n = AUTH_SHARED;
128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 case eCSR_AUTH_TYPE_WPA:
130 n = AUTH_WPA_EAP;
131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 case eCSR_AUTH_TYPE_WPA_PSK:
133 n = AUTH_WPA_PSK;
134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530136#ifdef WLAN_FEATURE_11W
137 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 n = AUTH_WPA2_EAP;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700142#ifdef WLAN_FEATURE_11W
143 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 n = AUTH_WPA2_PSK;
146 break;
147#ifdef FEATURE_WLAN_WAPI
148 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
149 n = AUTH_WAPI_CERT;
150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
152 n = AUTH_WAPI_PSK;
153 break;
154#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 default:
156 break;
157 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 return (n);
159}
Jeff Johnson295189b2012-06-20 16:38:30 -0700160int diagEncTypeFromCSRType(eCsrEncryptionType encType)
161{
162 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 switch(encType)
164 {
165 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
166 case eCSR_ENCRYPT_TYPE_WEP40:
167 n = ENC_MODE_WEP40;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP104:
171 n = ENC_MODE_WEP104;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_TKIP:
174 n = ENC_MODE_TKIP;
175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 case eCSR_ENCRYPT_TYPE_AES:
177 n = ENC_MODE_AES;
178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#ifdef FEATURE_WLAN_WAPI
180 case eCSR_ENCRYPT_TYPE_WPI:
181 n = ENC_MODE_SMS4;
182 break;
183#endif /* FEATURE_WLAN_WAPI */
184 default:
185 break;
186 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 return (n);
188}
Jeff Johnson295189b2012-06-20 16:38:30 -0700189#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
191static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700192static void initConfigParam(tpAniSirGlobal pMac);
193static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
194 eCsrRoamCompleteResult Result, void *Context );
195static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
196 tCsrRoamProfile *pProfile,
197 tANI_BOOLEAN *pfSameIbss );
198static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
199static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700200 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
201static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700202eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
203static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
204eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
205eHalStatus csrRoamClose(tpAniSirGlobal pMac);
206void csrRoamMICErrorTimerHandler(void *pv);
207void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
208tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
209
210static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
211static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
212static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
214eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
215static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700217static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
219eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
220 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
221 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
222 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
223 tANI_U8 *pKeyRsc );
224static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
225 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
226 tCsrRoamProfile *pProfile );
227void csrRoamStatisticsTimerHandler(void *pv);
228void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700229static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
230VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
231 v_U8_t rssiNotification,
232 void * context);
233static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
234void csrRoamVccTrigger(tpAniSirGlobal pMac);
235eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
236/*
237 pStaEntry is no longer invalid upon the return of this function.
238*/
239static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700242tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
243 tDblLinkList *pStaList,
244 tCsrStatsClientReqInfo *pStaEntry);
245void csrRoamStatsClientTimerHandler(void *pv);
246tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
247 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
248void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
249 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700250void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251void csrRoamTlStatsTimerHandler(void *pv);
252void csrRoamPeStatsTimerHandler(void *pv);
253tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
254void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
255tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
256eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
257static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
258static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
259static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
260static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
261 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
262//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
263static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
264void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
265#ifdef FEATURE_WLAN_BTAMP_UT_RF
266void csrRoamJoinRetryTimerHandler(void *pv);
267#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530268void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700269extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700272void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274//Initialize global variables
275static void csrRoamInitGlobals(tpAniSirGlobal pMac)
276{
277 if(pMac)
278 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800279 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
280 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 }
282 return;
283}
284
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
286{
287 if(pMac)
288 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800289 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 }
291 return;
292}
Jeff Johnson295189b2012-06-20 16:38:30 -0700293eHalStatus csrOpen(tpAniSirGlobal pMac)
294{
295 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530296#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 static uNvTables nvTables;
298 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 tANI_U32 i;
302
303 do
304 {
305 /* Initialize CSR Roam Globals */
306 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
308 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
309
310 initConfigParam(pMac);
311 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
312 break;
313 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
314 break;
315 pMac->roam.nextRoamId = 1; //Must not be 0
316 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
317 break;
318 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
319 break;
320 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
321 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530322
323#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
325 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
326 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530327 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
328 WNI_CFG_COUNTRY_CODE_LEN);
329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 }
331 else
332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800333 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 //hardcoded for now
335 pMac->scan.countryCodeDefault[0] = 'U';
336 pMac->scan.countryCodeDefault[1] = 'S';
337 pMac->scan.countryCodeDefault[2] = 'I';
338 //status = eHAL_STATUS_SUCCESS;
339 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700340 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530341
342 if (!('0' == pMac->scan.countryCodeDefault[0] &&
343 '0' == pMac->scan.countryCodeDefault[1]))
344 {
345 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
346 &regId, COUNTRY_NV);
347 }
348 else
349 {
350 regId = REGDOMAIN_WORLD;
351 }
Abhishek Singha306a442013-11-07 18:39:01 +0530352 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530355 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
356 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return (status);
362}
363
Mihir Shetee1093ba2014-01-21 20:13:32 +0530364/* --------------------------------------------------------------------------
365 \fn csrInitChannels
366 \brief This function must be called to initialize CSR channel lists
367 \return eHalStatus
368 ----------------------------------------------------------------------------*/
369eHalStatus csrInitChannels(tpAniSirGlobal pMac)
370{
371 eHalStatus status = eHAL_STATUS_SUCCESS;
372 static uNvTables nvTables;
373 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530374 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530375
376 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
377 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
378 {
379 vos_mem_copy(pMac->scan.countryCodeDefault,
380 nvTables.defaultCountryTable.countryCode,
381 WNI_CFG_COUNTRY_CODE_LEN);
382 }
383 else
384 {
385 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
386 //hardcoded for now
387 pMac->scan.countryCodeDefault[0] = 'U';
388 pMac->scan.countryCodeDefault[1] = 'S';
389 pMac->scan.countryCodeDefault[2] = 'I';
390 }
391 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
392
Mihir Shetee1093ba2014-01-21 20:13:32 +0530393 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
394 pMac->scan.domainIdDefault = regId;
395 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
396 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
397 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530398 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
399 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530400 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
401 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530402 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530403 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530404
405 return status;
406}
407
Mihir Shete04206452014-11-20 17:50:58 +0530408#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530409eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530410{
411 eHalStatus status = eHAL_STATUS_SUCCESS;
412 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530413 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530414
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530415 /* In case of driver load ; driver need to get channel
416 * list with default Countrycode.
417 * In case of SSR; driver need to get channel list
418 * with old country code. 0 is for init and
419 * 1 is for reinit
420 */
421 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530422 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530423 case INIT:
424 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
425 WNI_CFG_COUNTRY_CODE_LEN);
426 if (!('0' == cc[0] &&
427 '0' == cc[1]))
428 {
429 csrGetRegulatoryDomainForCountry(pMac, cc,
430 &regId, COUNTRY_NV);
431 }
432 else
433 {
434 return status;
435 }
436 pMac->scan.domainIdDefault = regId;
437 break;
438 case REINIT:
439 vos_getCurrentCountryCode(&cc[0]);
440 status = csrGetRegulatoryDomainForCountry(pMac,
441 cc, &regId, COUNTRY_QUERY);
442 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530443 }
444 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530445 pMac->scan.domainIdCurrent = regId;
446 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530447 WNI_CFG_COUNTRY_CODE_LEN);
448 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530449
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530450 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
451 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
452 pMac->scan.countryCodeCurrent[1]);
453
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530454 /* reset info based on new cc, and we are done */
455 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
456 csrScanFilterResults(pMac);
457
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530458 return status;
459}
Mihir Shete04206452014-11-20 17:50:58 +0530460#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
463{
464 eHalStatus status = eHAL_STATUS_SUCCESS;
465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
466 v_REGDOMAIN_t regId;
467 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 if(NULL == apCntryCode)
469 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530470 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return eHAL_STATUS_FAILURE;
472 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530473 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 /* To get correct Regulatory domain from NV table
475 * 2 character Country code should be used
476 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700477 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
478/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700480
481 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800483 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700484 return eHAL_STATUS_FAILURE;
485 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700486*/
Kiet Lam6c583332013-10-14 05:37:09 +0530487 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
488 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 if (status != eHAL_STATUS_SUCCESS)
490 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700491 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 return status;
493 }
Abhishek Singha306a442013-11-07 18:39:01 +0530494 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 if (status != eHAL_STATUS_SUCCESS)
496 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700497 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 return status;
499 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 pMac->scan.domainIdDefault = regId;
501 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530503 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
504
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530506 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 /* If 2 bytes country code, 3rd byte must be filled with space */
509 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
510 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530513 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
514 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 return status;
517}
Jeff Johnson295189b2012-06-20 16:38:30 -0700518eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
519{
520 eHalStatus status = eHAL_STATUS_SUCCESS;
521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
522 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530523 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
524 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
526 {
527 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
528 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
529 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
530 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
531 }
532 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
533
534 return status;
535}
Jeff Johnson295189b2012-06-20 16:38:30 -0700536eHalStatus csrClose(tpAniSirGlobal pMac)
537{
538 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800539
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 csrRoamClose(pMac);
541 csrScanClose(pMac);
542 csrLLClose(&pMac->roam.statsClientReqList);
543 csrLLClose(&pMac->roam.peStatsReqList);
544 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 /* DeInit Globals */
546 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 return (status);
548}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800550eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530551{
552 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800553 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530554 tANI_U32 numChan = 0;
555 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530556 vos_msg_t msg;
557 tANI_U8 i;
558
Atul Mittalb849d5a2014-07-29 12:08:39 +0530559 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530560 numChan = sizeof(pMac->roam.validChannelList);
561
562 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
563 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
564 {
565 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
566 return eHAL_STATUS_FAILED_ALLOC;
567 }
568
569 bufLen = sizeof(tSirUpdateChanList) +
570 (sizeof(tSirUpdateChanParam) * (numChan - 1));
571
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530572 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
573 if (!pChanList)
574 {
575 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
576 "Failed to allocate memory for tSirUpdateChanList");
577 return eHAL_STATUS_FAILED_ALLOC;
578 }
579
580 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
581 msg.reserved = 0;
582 msg.bodyptr = pChanList;
583 pChanList->numChan = numChan;
584 for (i = 0; i < pChanList->numChan; i++)
585 {
Agarwal Ashish738843c2014-09-25 12:27:56 +0530586 pChanList->chanParam[i].chanId = pMac->roam.validChannelList[i];
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800587 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
588 pScan->defaultPowerTable[i].chanId);
589 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
590 NV_CHANNEL_DFS)
591 pChanList->chanParam[i].dfsSet = VOS_TRUE;
592 else
593 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530594 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
595 "%s Supported Channel: %d\n", __func__, pChanList->chanParam[i].chanId);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530596 }
Sachin Ahujacb64fc82015-01-12 17:01:05 +0530597 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530598 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
599 {
600 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
601 "%s: Failed to post msg to WDA", __func__);
602 vos_mem_free(pChanList);
603 return eHAL_STATUS_FAILURE;
604 }
605
606 return eHAL_STATUS_SUCCESS;
607}
608
Jeff Johnson295189b2012-06-20 16:38:30 -0700609eHalStatus csrStart(tpAniSirGlobal pMac)
610{
611 eHalStatus status = eHAL_STATUS_SUCCESS;
612 tANI_U32 i;
613
614 do
615 {
616 //save the global vos context
617 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
618 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
620
621 status = csrRoamStart(pMac);
622 if(!HAL_STATUS_SUCCESS(status)) break;
623 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
624 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
625 if(!HAL_STATUS_SUCCESS(status)) break;
626 pMac->roam.sPendingCommands = 0;
627 csrScanEnable(pMac);
628#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
629 status = csrNeighborRoamInit(pMac);
630#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
631 pMac->roam.tlStatsReqInfo.numClient = 0;
632 pMac->roam.tlStatsReqInfo.periodicity = 0;
633 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
634 //init the link quality indication also
635 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
636 if(!HAL_STATUS_SUCCESS(status))
637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800638 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 break;
640 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530641
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643#if defined(ANI_LOGDUMP)
644 csrDumpInit(pMac);
645#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 return (status);
647}
648
Kiet Lama72a2322013-11-15 11:18:11 +0530649eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700650{
651 tANI_U32 sessionId;
652 tANI_U32 i;
653
654 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
655 {
656 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
657 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 csrScanDisable(pMac);
659 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
660 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
662
663#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
664 csrNeighborRoamClose(pMac);
665#endif
666 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 // deregister from PMC since we register during csrStart()
668 // (ignore status since there is nothing we can do if it fails)
669 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 //Reset the domain back to the deault
671 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800672 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
675 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530676 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
678 }
679
Kiet Lama72a2322013-11-15 11:18:11 +0530680#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
681 /* When HAL resets all the context information
682 * in HAL is lost, so we might need to send the
683 * scan offload request again when it comes
684 * out of reset for scan offload to be functional
685 */
686 if (HAL_STOP_TYPE_SYS_RESET == stopType)
687 {
688 bRoamScanOffloadStarted = VOS_FALSE;
689 }
690#endif
691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 return (eHAL_STATUS_SUCCESS);
693}
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695eHalStatus csrReady(tpAniSirGlobal pMac)
696{
697 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 csrScanGetSupportedChannels( pMac );
699 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
700 //use it to init the background scan list
701 csrInitBGScanChannelList(pMac);
702 /* HDD issues the init scan */
703 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800704 /* If the gScanAgingTime is set to '0' then scan results aging timeout
705 based on timer feature is not enabled*/
706 if(0 != pMac->scan.scanResultCfgAgingTime )
707 {
708 csrScanStartResultCfgAgingTimer(pMac);
709 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 //Store the AC weights in TL for later use
711 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 status = csrInitChannelList( pMac );
713 if ( ! HAL_STATUS_SUCCESS( status ) )
714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800715 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 status );
717 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 return (status);
719}
Jeff Johnson295189b2012-06-20 16:38:30 -0700720void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
721{
722 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
724 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
725}
Jeff Johnson295189b2012-06-20 16:38:30 -0700726void csrSetGlobalCfgs( tpAniSirGlobal pMac )
727{
Jeff Johnsone7245742012-09-05 17:12:55 -0700728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
730 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
731 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
732 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
733 NULL, eANI_BOOLEAN_FALSE);
734 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700735 /* 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
736 * Once session is established we will use the session related params stored in PE session for CB mode
737 */
738 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
740
741 //Update the operating mode to configured value during initialization,
742 //So that client can advertise full capabilities in Probe request frame.
743 csrSetDefaultDot11Mode( pMac );
744}
745
Jeff Johnson295189b2012-06-20 16:38:30 -0700746eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
747{
748 eHalStatus status = eHAL_STATUS_SUCCESS;
749 tANI_U32 i;
750 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 do
752 {
753 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
754 {
755 pSession = CSR_GET_SESSION( pMac, i );
756 pSession->roamingTimerInfo.pMac = pMac;
757 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
758 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
760 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530761 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
762 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530764 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800766 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 break;
768 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530769 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
770 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
771 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800773 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 return eHAL_STATUS_FAILURE;
775 }
776 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 return (status);
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780eHalStatus csrRoamClose(tpAniSirGlobal pMac)
781{
782 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
784 {
785 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
786 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530787 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
788 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
789 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
790 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 return (eHAL_STATUS_SUCCESS);
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794eHalStatus csrRoamStart(tpAniSirGlobal pMac)
795{
796 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 return (eHAL_STATUS_SUCCESS);
798}
799
Jeff Johnson295189b2012-06-20 16:38:30 -0700800void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
801{
802 csrRoamStopRoamingTimer(pMac, sessionId);
803 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
804 csrRoamDeregStatisticsReq(pMac);
805}
Jeff Johnson295189b2012-06-20 16:38:30 -0700806eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
807{
808 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800809 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 {
811 status = eHAL_STATUS_SUCCESS;
812 *pState = pMac->roam.roamSession[sessionId].connectState;
813 }
814 return (status);
815}
816
Jeff Johnson295189b2012-06-20 16:38:30 -0700817eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
818{
819 eHalStatus status = eHAL_STATUS_FAILURE;
820 tANI_U32 size = 0;
821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700822
823 if(!pSession)
824 {
825 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
826 return eHAL_STATUS_FAILURE;
827 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700828
829 if(pProfile)
830 {
831 if(pSession->pConnectBssDesc)
832 {
833 do
834 {
835 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
836 if(size)
837 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530838 pProfile->pBssDesc = vos_mem_malloc(size);
839 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530841 vos_mem_copy(pProfile->pBssDesc,
842 pSession->pConnectBssDesc, size);
843 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 }
845 else
846 break;
847 }
848 else
849 {
850 pProfile->pBssDesc = NULL;
851 }
852 pProfile->AuthType = pSession->connectedProfile.AuthType;
853 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
854 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
855 pProfile->BSSType = pSession->connectedProfile.BSSType;
856 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
857 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530858 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
859 sizeof(tCsrBssid));
860 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
861 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700862#ifdef WLAN_FEATURE_VOWIFI_11R
863 if (pSession->connectedProfile.MDID.mdiePresent)
864 {
865 pProfile->MDID.mdiePresent = 1;
866 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
867 }
868 else
869 {
870 pProfile->MDID.mdiePresent = 0;
871 pProfile->MDID.mobilityDomain = 0;
872 }
873#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800874#ifdef FEATURE_WLAN_ESE
875 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
876 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800878 vos_mem_copy (pProfile->eseCckmInfo.krk,
879 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530880 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800881 pProfile->eseCckmInfo.reassoc_req_num=
882 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
883 pProfile->eseCckmInfo.krk_plumbed =
884 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 }
886#endif
887 }while(0);
888 }
889 }
890
891 return (status);
892}
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
895{
896 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700897
898 if((csrIsConnStateConnected(pMac, sessionId)) ||
899 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 {
901 if(pProfile)
902 {
903 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
904 }
905 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 return (status);
907}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700908
Jeff Johnson295189b2012-06-20 16:38:30 -0700909eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
910{
911 eHalStatus status = eHAL_STATUS_SUCCESS;
912
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530915 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700918 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530919 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700920 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530921 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
924 return (status);
925}
926
Jeff Johnson295189b2012-06-20 16:38:30 -0700927static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
928{
929 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 if( pConnectedInfo->pbFrames )
931 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530932 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 pConnectedInfo->pbFrames = NULL;
934 }
935 pConnectedInfo->nBeaconLength = 0;
936 pConnectedInfo->nAssocReqLength = 0;
937 pConnectedInfo->nAssocRspLength = 0;
938 pConnectedInfo->staId = 0;
939#ifdef WLAN_FEATURE_VOWIFI_11R
940 pConnectedInfo->nRICRspLength = 0;
941#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800942#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 pConnectedInfo->nTspecIeLength = 0;
944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 return ( status );
946}
947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948
949
Jeff Johnsone7245742012-09-05 17:12:55 -0700950
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700951void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
952{
953 csrReinitPreauthCmd(pMac, pCommand);
954 csrReleaseCommand( pMac, pCommand );
955}
956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
958{
959 csrReinitRoamCmd(pMac, pCommand);
960 csrReleaseCommand( pMac, pCommand );
961}
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
964{
965 csrReinitScanCmd(pMac, pCommand);
966 csrReleaseCommand( pMac, pCommand );
967}
968
Jeff Johnson295189b2012-06-20 16:38:30 -0700969void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
970{
971 csrReinitWmStatusChangeCmd(pMac, pCommand);
972 csrReleaseCommand( pMac, pCommand );
973}
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
976{
Kiet Lam64c1b492013-07-12 13:56:44 +0530977 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978}
979
Jeff Johnson295189b2012-06-20 16:38:30 -0700980void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
981{
Kiet Lam64c1b492013-07-12 13:56:44 +0530982 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700983}
984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
986{
987 csrReinitSetKeyCmd(pMac, pCommand);
988 csrReleaseCommand( pMac, pCommand );
989}
Jeff Johnson295189b2012-06-20 16:38:30 -0700990void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
991{
992 csrReinitRemoveKeyCmd(pMac, pCommand);
993 csrReleaseCommand( pMac, pCommand );
994}
Jeff Johnson295189b2012-06-20 16:38:30 -0700995void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
996{
997
998 if( eSmeCsrCommandMask & pCommand->command )
999 {
1000 switch (pCommand->command)
1001 {
1002 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001003 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001004 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1005 __func__, pCommand->u.scanCmd.reason,
1006 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 if (NULL != pCommand->u.scanCmd.callback)
1008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001009 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1011 }
1012 csrReleaseCommandScan( pMac, pCommand );
1013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 case eSmeCommandRoam:
1015 csrReleaseCommandRoam( pMac, pCommand );
1016 break;
1017
1018 case eSmeCommandWmStatusChange:
1019 csrReleaseCommandWmStatusChange( pMac, pCommand );
1020 break;
1021
1022 case eSmeCommandSetKey:
1023 csrReleaseCommandSetKey( pMac, pCommand );
1024 break;
1025
1026 case eSmeCommandRemoveKey:
1027 csrReleaseCommandRemoveKey( pMac, pCommand );
1028 break;
1029
1030 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001031 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 csrReleaseCommand( pMac, pCommand );
1033 break;
1034 }
1035 }
1036}
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1039{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301040 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1041 macTraceGetcsrRoamSubState(NewSubstate),
1042 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1045 {
1046 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->roam.curSubState[sessionId] = NewSubstate;
1049}
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1052{
1053 eCsrRoamState PreviousState;
1054
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301055 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1056 macTraceGetcsrRoamState(NewRoamState),
1057 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001058
1059 PreviousState = pMac->roam.curState[sessionId];
1060
1061 if ( NewRoamState != pMac->roam.curState[sessionId] )
1062 {
1063 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1064 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1065 {
1066 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1067 }
1068
1069 pMac->roam.curState[sessionId] = NewRoamState;
1070 }
1071 return( PreviousState );
1072}
1073
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001074void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001075{
1076 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 if(catOffset)
1078 {
1079 pMac->roam.configParam.bCatRssiOffset = catOffset;
1080 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1081 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001082 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 -07001083 }
1084 }
1085}
1086
Jeff Johnson295189b2012-06-20 16:38:30 -07001087static void initConfigParam(tpAniSirGlobal pMac)
1088{
1089 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301091 pMac->roam.configParam.channelBondingMode24GHz =
1092 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1093 pMac->roam.configParam.channelBondingMode5GHz =
1094 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1096 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1097 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1098 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1099 pMac->roam.configParam.HeartbeatThresh24 = 40;
1100 pMac->roam.configParam.HeartbeatThresh50 = 40;
1101 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1102 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1103 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001104 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 pMac->roam.configParam.RTSThreshold = 2346;
1106 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1107 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1108 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1109 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1110 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1111 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1112 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1113 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1114 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1115 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1116 {
1117 pMac->roam.configParam.BssPreferValue[i] = i;
1118 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001119 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1121 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1122 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1124 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301125 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1127 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1128 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1129 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001130 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1131 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001132 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001133#ifdef WLAN_AP_STA_CONCURRENCY
1134 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1135 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1136 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1137 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1138 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001139 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1140 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001141#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1143 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1144 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1145 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001146#ifdef WLAN_FEATURE_VOWIFI_11R
1147 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001149#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1150 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1151 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1152 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1153 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1154 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1155 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1156 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1157 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1158 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1159 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1160 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001161 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301162 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001164#ifdef WLAN_FEATURE_11AC
1165 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1166#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001167
1168 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1169 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001170
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001171 //Remove this code once SLM_Sessionization is supported
1172 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001173 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
Jeff Johnsone7245742012-09-05 17:12:55 -07001175}
Jeff Johnson295189b2012-06-20 16:38:30 -07001176eCsrBand csrGetCurrentBand(tHalHandle hHal)
1177{
1178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1179 return pMac->roam.configParam.bandCapability;
1180}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001181
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001182
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001183#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001184/*
1185 This function flushes the roam scan cache
1186*/
1187eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1188{
1189 eHalStatus status = eHAL_STATUS_SUCCESS;
1190 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1191
1192 /* Free up the memory first (if required) */
1193 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1194 {
1195 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1196 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1197 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1198 }
1199 return status;
1200}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001201#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001202
1203
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001204#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001206 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001208eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001209{
1210 eHalStatus status = eHAL_STATUS_SUCCESS;
1211 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1212
1213 /* Free up the memory first (if required) */
1214 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1215 {
1216 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1217 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001218 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001219 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001220 return status;
1221}
1222
1223
1224
1225/*
1226 This function flushes the roam scan cache and creates fresh cache
1227 based on the input channel list
1228*/
1229eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1230 const tANI_U8 *pChannelList,
1231 const tANI_U8 numChannels)
1232{
1233 eHalStatus status = eHAL_STATUS_SUCCESS;
1234 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1235
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1237
1238 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1239 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1240
1241 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1242 {
1243 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1244 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1245 return eHAL_STATUS_RESOURCES;
1246 }
1247
1248 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301249 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1250 pChannelList,
1251 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001252 return status;
1253}
1254
1255/* This function modifies the bgscan channel list set via config ini or
1256 runtime, whenever the band changes.
1257 if the band is auto, then no operation is performed on the channel list
1258 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1259 if the band is 5G, then make sure channel list contains only 5G valid channels
1260*/
1261eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1262 eCsrBand eBand)
1263{
1264 eHalStatus status = eHAL_STATUS_SUCCESS;
1265 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1266 tANI_U8 outNumChannels = 0;
1267 tANI_U8 inNumChannels = 0;
1268 tANI_U8 *inPtr = NULL;
1269 tANI_U8 i = 0;
1270 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1271
1272 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1273
1274 {
1275 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1276 "No update required for channel list "
1277 "either cfg.ini channel list is not set up or "
1278 "auto band (Band %d)", eBand);
1279 return status;
1280 }
1281
1282 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1283 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1284 if (eCSR_BAND_24 == eBand)
1285 {
1286 for (i = 0; i < inNumChannels; i++)
1287 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001288 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001289 {
1290 ChannelList[outNumChannels++] = inPtr[i];
1291 }
1292 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001293 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001294 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001295 }
1296 else if (eCSR_BAND_5G == eBand)
1297 {
1298 for (i = 0; i < inNumChannels; i++)
1299 {
1300 /* Add 5G Non-DFS channel */
1301 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001302 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001303 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1304 {
1305 ChannelList[outNumChannels++] = inPtr[i];
1306 }
1307 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001308 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001309 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001310 }
1311 else if (eCSR_BAND_ALL == eBand)
1312 {
1313 for (i = 0; i < inNumChannels; i++)
1314 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001315 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001316 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1317 {
1318 ChannelList[outNumChannels++] = inPtr[i];
1319 }
1320 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001321 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001322 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001323 }
1324 else
1325 {
1326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1327 "Invalid band, No operation carried out (Band %d)", eBand);
1328 status = eHAL_STATUS_INVALID_PARAMETER;
1329 }
1330
1331 return status;
1332}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001333#endif
1334
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001335#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001336/* This function modifies the roam scan channel list as per AP neighbor
1337 report; AP neighbor report may be empty or may include only other AP
1338 channels; in any case, we merge the channel list with the learned occupied
1339 channels list.
1340 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1341 if the band is 5G, then make sure channel list contains only 5G valid channels
1342*/
1343eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1344 tANI_U8 *pChannelList,
1345 tANI_U8 numChannels,
1346 const eCsrBand eBand)
1347{
1348 eHalStatus status = eHAL_STATUS_SUCCESS;
1349 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1350 tANI_U8 outNumChannels = 0;
1351 tANI_U8 inNumChannels = numChannels;
1352 tANI_U8 *inPtr = pChannelList;
1353 tANI_U8 i = 0;
1354 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1355 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1356 tANI_U8 mergedOutputNumOfChannels = 0;
1357 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1358
1359 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1360 * report Channels. This increases the chances of the DUT to get a candidate AP while
1361 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1362 if (pMac->scan.occupiedChannels.numChannels)
1363 {
1364 csrNeighborRoamMergeChannelLists(pMac,
1365 &pMac->scan.occupiedChannels.channelList[0],
1366 pMac->scan.occupiedChannels.numChannels,
1367 inPtr,
1368 inNumChannels,
1369 &mergedOutputNumOfChannels);
1370 inNumChannels = mergedOutputNumOfChannels;
1371 }
1372
1373 if (eCSR_BAND_24 == eBand)
1374 {
1375 for (i = 0; i < inNumChannels; i++)
1376 {
1377 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1378 {
1379 ChannelList[outNumChannels++] = inPtr[i];
1380 }
1381 }
1382 }
1383 else if (eCSR_BAND_5G == eBand)
1384 {
1385 for (i = 0; i < inNumChannels; i++)
1386 {
1387 /* Add 5G Non-DFS channel */
1388 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1389 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1390 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1391 {
1392 ChannelList[outNumChannels++] = inPtr[i];
1393 }
1394 }
1395 }
1396 else if (eCSR_BAND_ALL == eBand)
1397 {
1398 for (i = 0; i < inNumChannels; i++)
1399 {
1400 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1401 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1402 {
1403 ChannelList[outNumChannels++] = inPtr[i];
1404 }
1405 }
1406 }
1407 else
1408 {
1409 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1410 "Invalid band, No operation carried out (Band %d)", eBand);
1411 return eHAL_STATUS_INVALID_PARAMETER;
1412 }
1413
1414 /* if roaming within band is enabled, then select only the
1415 in band channels .
1416 This is required only if the band capability is set to ALL,
1417 E.g., if band capability is only 2.4G then all the channels in the
1418 list are already filtered for 2.4G channels, hence ignore this check*/
1419
1420 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1421 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301422 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001423 pMac,
1424 ChannelList,
1425 outNumChannels,
1426 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301427 &outNumChannels,
1428 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301429 vos_mem_copy(ChannelList,
1430 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001431 }
1432
1433 /* Prepare final roam scan channel list */
1434 if(outNumChannels)
1435 {
1436 /* Clear the channel list first */
1437 if (NULL != currChannelListInfo->ChannelList)
1438 {
1439 vos_mem_free(currChannelListInfo->ChannelList);
1440 currChannelListInfo->ChannelList = NULL;
1441 currChannelListInfo->numOfChannels = 0;
1442 }
1443
1444 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1445 if (NULL == currChannelListInfo->ChannelList)
1446 {
1447 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1448 "Failed to allocate memory for roam scan channel list");
1449 currChannelListInfo->numOfChannels = 0;
1450 return VOS_STATUS_E_RESOURCES;
1451 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301452 vos_mem_copy(currChannelListInfo->ChannelList,
1453 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001454 }
1455 return status;
1456}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001457#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001458
Jeff Johnson295189b2012-06-20 16:38:30 -07001459eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1460{
1461 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1462 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1464 (eBand == eCSR_BAND_24))
1465 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001466 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001468 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001469 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 pMac->roam.configParam.uCfgDot11Mode, eBand);
1471 return eHAL_STATUS_INVALID_PARAMETER;
1472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1474 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1475 (eBand == eCSR_BAND_5G))
1476 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001477 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001480 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 pMac->roam.configParam.uCfgDot11Mode, eBand);
1482 return eHAL_STATUS_INVALID_PARAMETER;
1483 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001485 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001486 pMac->roam.configParam.eBand = eBand;
1487 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001489#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001490 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1491 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001492#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 status = csrInitGetChannels( pMac );
1494 if (eHAL_STATUS_SUCCESS == status)
1495 csrInitChannelList( hHal );
1496 return status;
1497}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001498
1499
Jeff Johnsone7245742012-09-05 17:12:55 -07001500/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1501 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1502 * Ideally we should have kept the ini value and enum value same and representing the same
1503 * cb values as in 11n standard i.e.
1504 * Set to 1 (SCA) if the secondary channel is above the primary channel
1505 * Set to 3 (SCB) if the secondary channel is below the primary channel
1506 * Set to 0 (SCN) if no secondary channel is present
1507 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1508 * 0 - secondary none
1509 * 1 - secondary LOW
1510 * 2 - secondary HIGH
1511 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1512 * The enum values are as follows:
1513 * PHY_SINGLE_CHANNEL_CENTERED = 0
1514 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1515 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1516 */
1517ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1518{
1519
1520 ePhyChanBondState phyCbState;
1521 switch (cbIniValue) {
1522 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301523 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001524 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1525 break;
1526 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301527 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001528 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1529 break;
1530 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301531 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001532 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1533 break;
1534#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301535 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1536 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001537 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301538 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001539 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1540 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301541 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1542 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1543 break;
1544 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001545 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1546 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301547 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001548 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301549 break;
1550 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001551 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1552 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301553 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001554 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301555 break;
1556#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001557 default:
1558 // If an invalid value is passed, disable CHANNEL BONDING
1559 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1560 break;
1561 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301562
Jeff Johnsone7245742012-09-05 17:12:55 -07001563 return phyCbState;
1564}
1565
1566v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1567{
1568
1569 v_U32_t cbIniValue;
1570 switch (phyCbState) {
1571 // secondary none
1572 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301573 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001574 break;
1575 // secondary LOW
1576 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301577 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001578 break;
1579 // secondary HIGH
1580 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301581 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001582 break;
1583#ifdef WLAN_FEATURE_11AC
1584 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301585 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 break;
1587 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301588 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 break;
1590 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301591 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001592 break;
1593 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301594 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 break;
1596 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301597 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001598 break;
1599 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301600 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001601 break;
1602 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301603 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001604 break;
1605#endif
1606 default:
1607 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301608 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001609 break;
1610 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301611
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 return cbIniValue;
1613}
Jeff Johnson295189b2012-06-20 16:38:30 -07001614
1615eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1616{
1617 eHalStatus status = eHAL_STATUS_SUCCESS;
1618
1619 if(pParam)
1620 {
1621 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1622 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1623 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1624 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1625 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1626 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1627
1628 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001629 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1630
Jeff Johnsone7245742012-09-05 17:12:55 -07001631 /* channelBondingMode5GHz plays a dual role right now
1632 * 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
1633 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1634 */
1635 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001637 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001638 }
1639 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1640 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001642 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001643 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301644#ifdef WLAN_FEATURE_AP_HT40_24G
1645 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1646#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1649 pMac->roam.configParam.phyMode = pParam->phyMode;
1650 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1651 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1652 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1653 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1654 pMac->roam.configParam.TxRate = pParam->TxRate;
1655 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1656 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1657 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1658 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1659 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001660 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 //if HDD passed down non zero values then only update,
1662 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301663 if (pParam->nInitialDwellTime)
1664 {
1665 pMac->roam.configParam.nInitialDwellTime =
1666 pParam->nInitialDwellTime;
1667 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001668 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 {
1670 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301671 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1672 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001674 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 {
1676 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301677 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1678 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001680 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
1682 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301683 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1684 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001686 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 {
1688 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301689 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1690 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301692 if (pParam->nOBSSScanWidthTriggerInterval)
1693 {
1694 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1695 pParam->nOBSSScanWidthTriggerInterval;
1696 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1697 pParam->nOBSSScanWidthTriggerInterval);
1698 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001699 if (pParam->nActiveMaxChnTimeBtc)
1700 {
1701 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1702 }
1703 if (pParam->nActiveMinChnTimeBtc)
1704 {
1705 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1706 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001707#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001708 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001709 {
1710 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1711 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001712 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001713 {
1714 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1715 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001716 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001717 {
1718 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1719 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001720 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001721 {
1722 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1723 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001724 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001725 {
1726 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1727 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001728 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001729 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001730 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1731 }
1732 if (pParam->nNumP2PChanCombinedConc)
1733 {
1734 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001735 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001738 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 {
1740 //Change the unit from second to microsecond
1741 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1743 {
1744 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1745 }
1746 else
1747 {
1748 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1749 }
1750 }
1751 else
1752 {
1753 pMac->roam.configParam.impsSleepTime = 0;
1754 }
1755 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1757 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 //if HDD passed down non zero values for age params, then only update,
1759 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001760 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 {
1762 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 if(pParam->scanAgeTimeNCNPS)
1765 {
1766 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 if(pParam->scanAgeTimeNCPS)
1769 {
1770 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 if(pParam->scanAgeTimeCNPS)
1773 {
1774 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1775 }
1776 if(pParam->scanAgeTimeCPS)
1777 {
1778 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1779 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301780 if (pParam->initialScanSkipDFSCh)
1781 {
1782 pMac->roam.configParam.initialScanSkipDFSCh =
1783 pParam->initialScanSkipDFSCh;
1784 }
1785
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001786 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1788 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1789 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1790 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1791 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1793 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1795 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1796 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1797 //Assign this before calling CsrInit11dInfo
1798 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 if( csrIs11dSupported( pMac ) )
1800 {
1801 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1802 }
1803 else
1804 {
1805 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1806 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001807
1808 /* Initialize the power + channel information if 11h is enabled.
1809 If 11d is enabled this information has already been initialized */
1810 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1811 {
1812 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1813 }
1814
1815
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301816#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301817 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1818 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001819 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001820#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001821#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001823 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001824 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001825 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001826 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001827 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001828 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001829 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001830 pMac->roam.configParam.nProbes = pParam->nProbes;
1831 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001832#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001833#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1834 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001835 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001836#endif
1837#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001838 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001839 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001840#endif
1841
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001842#ifdef FEATURE_WLAN_ESE
1843 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001844#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001845#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301846 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1847 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001848 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1849 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1850 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1851 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1852 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1853 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1854 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1855 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301856 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 {
1858 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001859 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 -07001860 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1861 {
1862 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 }
1865#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1867 pMac->scan.fValidateList = pParam->fValidateList;
1868 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1869 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001870 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001872 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301873 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001874 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1875 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1876 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1877 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1878 * single session
1879 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001880 //Remove this code once SLM_Sessionization is supported
1881 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001882 pMac->roam.configParam.doBMPSWorkaround = 0;
1883
Jeff Johnsone7245742012-09-05 17:12:55 -07001884#ifdef WLAN_FEATURE_11AC
1885 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001886 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001887 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001888 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301889 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1890 if ( pParam->enableTxBF )
1891 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1892 else
1893 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001894#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001895 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001896
1897 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001898 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001899 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1900 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301901 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301902 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301903#ifdef WLAN_FEATURE_AP_HT40_24G
1904 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
1905#endif
1906
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 }
1908
1909 return status;
1910}
1911
Jeff Johnson295189b2012-06-20 16:38:30 -07001912eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1913{
1914 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 if(pParam)
1916 {
1917 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1918 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1919 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1920 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1921 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1922 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001923 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301924#ifdef WLAN_FEATURE_AP_HT40_24G
1925 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
1926#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001927 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1929 pParam->phyMode = pMac->roam.configParam.phyMode;
1930 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1931 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1932 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1933 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1934 pParam->TxRate = pMac->roam.configParam.TxRate;
1935 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1936 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1937 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1938 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1939 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1941 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1942 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1943 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001944 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1945 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1946 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001947#ifdef WLAN_AP_STA_CONCURRENCY
1948 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1949 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1950 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1951 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1952 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001953 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1954 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001955#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 //Change the unit from microsecond to second
1957 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1958 pParam->eBand = pMac->roam.configParam.eBand;
1959 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1960 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1961 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1962 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1963 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1964 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1965 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1966 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1967 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1968 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1969 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1970 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1971 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1973 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1974 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1975 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1977 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1978 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1979 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1980 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001981 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001982 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001983 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001984 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05301985 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07001986#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301987 vos_mem_copy(&pParam->neighborRoamConfig,
1988 &pMac->roam.configParam.neighborRoamConfig,
1989 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001990#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001991#ifdef WLAN_FEATURE_11AC
1992 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001993 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001994 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001995 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301996 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1997 if ( pParam->enableTxBF )
1998 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1999 else
2000 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002001#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002002#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302003 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2004 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002005#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002006#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002007 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2008 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2009 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2010 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2011 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002012 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002013 pParam->nProbes = pMac->roam.configParam.nProbes;
2014 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002015#endif
2016#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2017 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2018 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
2019#endif
2020#ifdef FEATURE_WLAN_LFR
2021 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2022#endif
2023
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002024#ifdef FEATURE_WLAN_ESE
2025 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002026#endif
2027#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302028 vos_mem_copy(&pParam->neighborRoamConfig,
2029 &pMac->roam.configParam.neighborRoamConfig,
2030 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002031 {
2032 int i;
2033 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2034 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2035 {
2036 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2037 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002038 }
2039#endif
2040
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002041 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002042
krunal soni5afa96c2013-09-06 22:19:02 -07002043 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002044 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07002045
krunal sonie9002db2013-11-25 14:24:17 -08002046 pParam->isCoalesingInIBSSAllowed =
2047 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302048 pParam->allowDFSChannelRoam =
2049 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302050 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302052#ifdef WLAN_FEATURE_AP_HT40_24G
2053 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002055
2056 status = eHAL_STATUS_SUCCESS;
2057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 return (status);
2059}
2060
Jeff Johnson295189b2012-06-20 16:38:30 -07002061eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2062{
2063 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2064 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2065 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2066 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 do
2068 {
2069 if(eCSR_BAND_24 == eBand)
2070 {
2071 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2072 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2073 }
2074 if(eCSR_BAND_5G == eBand)
2075 {
2076 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2077 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2078 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2079 )
2080 {
2081 break;
2082 }
2083 }
2084 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2085 {
2086 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2087 }
2088 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2089 {
2090 newPhyMode = eCSR_DOT11_MODE_AUTO;
2091 }
2092 else
2093 {
2094 //Check for dual band and higher capability first
2095 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2096 {
2097 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2098 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2099 }
2100 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2101 {
2102 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2103 if(eCSR_BAND_24 == eBand) break;
2104 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2105 eBand = eCSR_BAND_5G;
2106 }
2107 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2108 {
2109 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2110 if(eCSR_BAND_5G == eBand) break;
2111 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2112 eBand = eCSR_BAND_24;
2113 }
2114 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2115 {
2116 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2117 if(eCSR_BAND_5G == eBand) break;
2118 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2119 eBand = eCSR_BAND_24;
2120 }
2121 else if(eCSR_DOT11_MODE_11n & phyMode)
2122 {
2123 newPhyMode = eCSR_DOT11_MODE_11n;
2124 }
2125 else if(eCSR_DOT11_MODE_abg & phyMode)
2126 {
2127 newPhyMode = eCSR_DOT11_MODE_abg;
2128 }
2129 else if(eCSR_DOT11_MODE_11a & phyMode)
2130 {
2131 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2132 {
2133 if(eCSR_BAND_ALL == eBand)
2134 {
2135 newPhyMode = eCSR_DOT11_MODE_abg;
2136 }
2137 else
2138 {
2139 //bad setting
2140 break;
2141 }
2142 }
2143 else
2144 {
2145 newPhyMode = eCSR_DOT11_MODE_11a;
2146 eBand = eCSR_BAND_5G;
2147 }
2148 }
2149 else if(eCSR_DOT11_MODE_11g & phyMode)
2150 {
2151 newPhyMode = eCSR_DOT11_MODE_11g;
2152 eBand = eCSR_BAND_24;
2153 }
2154 else if(eCSR_DOT11_MODE_11b & phyMode)
2155 {
2156 newPhyMode = eCSR_DOT11_MODE_11b;
2157 eBand = eCSR_BAND_24;
2158 }
2159 else
2160 {
2161 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002162 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 newPhyMode = eCSR_DOT11_MODE_AUTO;
2164 }
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 //Done validating
2167 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 //Now we need to check whether a restart is needed.
2169 if(eBand != pMac->roam.configParam.eBand)
2170 {
2171 fRestartNeeded = eANI_BOOLEAN_TRUE;
2172 break;
2173 }
2174 if(newPhyMode != pMac->roam.configParam.phyMode)
2175 {
2176 fRestartNeeded = eANI_BOOLEAN_TRUE;
2177 break;
2178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 if(HAL_STATUS_SUCCESS(status))
2181 {
2182 pMac->roam.configParam.eBand = eBand;
2183 pMac->roam.configParam.phyMode = newPhyMode;
2184 if(pfRestartNeeded)
2185 {
2186 *pfRestartNeeded = fRestartNeeded;
2187 }
2188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 return (status);
2190}
2191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2193{
2194 tANI_U8 Index;
2195 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 // for dual band NICs, don't need to trim the channel list....
2197 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2198 {
2199 // 2.4 GHz band operation requires the channel list to be trimmed to
2200 // the 2.4 GHz channels only...
2201 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2202 {
2203 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2204 Index++ )
2205 {
2206 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2207 {
2208 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2209 cChannels++;
2210 }
2211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2213 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2214 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2215 // only if we need to.
2216 //
2217 // The amount of memory to clear is the number of channesl that we trimmed
2218 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2219
2220 if ( pChannelList->numChannels > cChannels )
2221 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302222 vos_mem_set(&pChannelList->channelList[ cChannels ],
2223 sizeof( pChannelList->channelList[ 0 ] ) *
2224 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 }
2226
2227 pChannelList->numChannels = cChannels;
2228 }
2229 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2230 {
2231 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2232 {
2233 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2234 {
2235 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2236 cChannels++;
2237 }
2238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2240 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2241 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2242 // only if we need to.
2243 //
2244 // The amount of memory to clear is the number of channesl that we trimmed
2245 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2246 if ( pChannelList->numChannels > cChannels )
2247 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302248 vos_mem_set(&pChannelList->channelList[ cChannels ],
2249 sizeof( pChannelList->channelList[ 0 ] ) *
2250 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 }
2252
2253 pChannelList->numChannels = cChannels;
2254 }
2255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002256}
Jeff Johnson295189b2012-06-20 16:38:30 -07002257#define INFRA_AP_DEFAULT_CHANNEL 6
2258eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2259{
2260 tANI_U8 index= 0;
2261 eHalStatus status = eHAL_STATUS_FAILURE;
2262 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2263 {
2264 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2265 status = eHAL_STATUS_SUCCESS;
2266 break;
2267 }
2268 }
2269 return status;
2270}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002271
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002272
Jeff Johnson295189b2012-06-20 16:38:30 -07002273eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2274{
2275 eHalStatus status = eHAL_STATUS_SUCCESS;
2276 tANI_U8 num20MHzChannelsFound = 0;
2277 VOS_STATUS vosStatus;
2278 tANI_U8 Index = 0;
2279 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002280
Jeff Johnson295189b2012-06-20 16:38:30 -07002281
2282 //TODO: this interface changed to include the 40MHz channel list
2283 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2284 // Read the scan channel list (including the power limit) from EEPROM
2285 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2286 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2287 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002289 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 status = eHAL_STATUS_FAILURE;
2291 }
2292 else
2293 {
2294 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2295 {
2296 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2297 }
2298 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2299 // Move the channel list to the global data
2300 // structure -- this will be used as the scan list
2301 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2302 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2306 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2307 {
2308 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2309 }
2310 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2311 {
2312 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2313 }
2314 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 return (status);
2317}
Jeff Johnson295189b2012-06-20 16:38:30 -07002318eHalStatus csrInitChannelList( tHalHandle hHal )
2319{
2320 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2321 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2323 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002324 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2325 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002327 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302328 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 return (status);
2330}
Jeff Johnson295189b2012-06-20 16:38:30 -07002331eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2332 tCsrUpdateConfigParam *pUpdateConfigParam)
2333{
2334 eHalStatus status = eHAL_STATUS_FAILURE;
2335 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2337 status = CsrInit11dInfo(pMac, ps11dinfo);
2338 return status;
2339}
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2342{
2343 eHalStatus status = eHAL_STATUS_FAILURE;
2344 tANI_U8 index;
2345 tANI_U32 count=0;
2346 tSirMacChanInfo *pChanInfo;
2347 tSirMacChanInfo *pChanInfoStart;
2348 tANI_BOOLEAN applyConfig = TRUE;
2349
Mihir Shetebc866f62014-02-13 16:08:53 +05302350 pMac->scan.currentCountryRSSI = -128;
2351
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 if(!ps11dinfo)
2353 {
2354 return (status);
2355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2357 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302358 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2359 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2360 ps11dinfo->Channels.channelList,
2361 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 }
2363 else
2364 {
2365 //No change
2366 return (eHAL_STATUS_SUCCESS);
2367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302369
2370 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2371 WNI_CFG_COUNTRY_CODE_LEN);
2372
2373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 //Tush: at csropen get this initialized with default, during csr reset if this
2375 // already set with some value no need initilaize with default again
2376 if(0 == pMac->scan.countryCodeCurrent[0])
2377 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302378 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2379 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302382 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2383 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302385 vos_mem_set(pChanInfo,
2386 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2387 0);
2388
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002390 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2391 {
2392 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2393 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2394 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2395 pChanInfo++;
2396 count++;
2397 }
2398 if(count)
2399 {
2400 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2401 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302402 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002403 }
2404 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2405 if( HAL_STATUS_SUCCESS(status) )
2406 {
2407 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2408 {
2409 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2410 {
2411 applyConfig = FALSE;
2412 }
2413 }
2414
2415 if(TRUE == applyConfig)
2416 {
2417 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002418 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002419 }
2420
2421 }
2422 return (status);
2423}
2424/* Initialize the Channel + Power List in the local cache and in the CFG */
2425eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2426{
2427 tANI_U8 index;
2428 tANI_U32 count=0;
2429 tSirMacChanInfo *pChanInfo;
2430 tSirMacChanInfo *pChanInfoStart;
2431
2432 if(!ps11dinfo || !pMac)
2433 {
2434 return eHAL_STATUS_FAILURE;
2435 }
2436
Kiet Lam64c1b492013-07-12 13:56:44 +05302437 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2438 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002439 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302440 vos_mem_set(pChanInfo,
2441 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2442 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002443 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
2445 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2446 {
2447 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2448 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2449 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2450 pChanInfo++;
2451 count++;
2452 }
2453 if(count)
2454 {
2455 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2456 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302457 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459
Jeff Johnsone7245742012-09-05 17:12:55 -07002460 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002461}
2462
2463//pCommand may be NULL
2464//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2465void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2466{
2467 tListElem *pEntry, *pNextEntry;
2468 tSmeCmd *pDupCommand;
2469 tDblLinkList localList;
2470
2471 vos_mem_zero(&localList, sizeof(tDblLinkList));
2472 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2473 {
2474 smsLog(pMac, LOGE, FL(" failed to open list"));
2475 return;
2476 }
2477 csrLLLock( &pMac->sme.smeCmdPendingList );
2478 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2479 while( pEntry )
2480 {
2481 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2482 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 // Remove the previous command if..
2484 // - the new roam command is for the same RoamReason...
2485 // - the new roam command is a NewProfileList.
2486 // - the new roam command is a Forced Dissoc
2487 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2488 if (
2489 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2490 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002491 /* This peermac check is requried for Softap/GO scenarios
2492 * For STA scenario below OR check will suffice as pCommand will
2493 * always be NULL for STA scenarios
2494 */
2495 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2497 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2498 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2499 ||
2500 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002501 ( (sessionId == pDupCommand->sessionId) &&
2502 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 ((eCsrForcedDisassoc == eRoamReason) ||
2504 (eCsrHddIssued == eRoamReason))
2505 )
2506 )
2507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002508 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 // Remove the 'stale' roam command from the pending list...
2510 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2511 {
2512 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2513 }
2514 }
2515 pEntry = pNextEntry;
2516 }
2517 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2518
2519 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2520 {
2521 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2522 //Tell caller that the command is cancelled
2523 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2524 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2525 csrReleaseCommandRoam(pMac, pDupCommand);
2526 }
2527 csrLLClose(&localList);
2528}
Jeff Johnson295189b2012-06-20 16:38:30 -07002529eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2530 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2531{
2532 eHalStatus status = eHAL_STATUS_SUCCESS;
2533#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2534 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2535#endif
2536 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2538 {
2539 pSession = CSR_GET_SESSION( pMac, sessionId );
2540 }
2541 else
2542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002543 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 VOS_ASSERT(0);
2545 return eHAL_STATUS_FAILURE;
2546 }
krunal soni587bf012014-02-04 12:35:11 -08002547
2548 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2549 {
2550 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2551 return eHAL_STATUS_FAILURE;
2552 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002553
krunal soni587bf012014-02-04 12:35:11 -08002554 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2555
krunal soni7f7d2c92014-02-06 15:08:43 -08002556 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002558 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002560 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2561 /*
2562 * Decrement bRefAssocStartCnt for FT reassoc failure.
2563 * Reason: For FT reassoc failures, we first call
2564 * csrRoamCallCallback before notifying a failed roam
2565 * completion through csrRoamComplete. The latter in
2566 * turn calls csrRoamProcessResults which tries to
2567 * once again call csrRoamCallCallback if bRefAssocStartCnt
2568 * is non-zero. Since this is redundant for FT reassoc
2569 * failure, decrement bRefAssocStartCnt.
2570 */
2571 pSession->bRefAssocStartCnt--;
2572 }
2573
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 if(NULL != pSession->callback)
2575 {
2576 if( pRoamInfo )
2577 {
2578 pRoamInfo->sessionId = (tANI_U8)sessionId;
2579 }
2580
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302581 /* avoid holding the global lock when making the roaming callback, original change came
2582 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2583 is possible on other OS ports where the callback may need to take locks to protect
2584 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2586 that may actually depend on the lock being held */
2587 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2588 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2589 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2590 }
2591 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2592 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2593#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302594 vos_mem_set(&connectionStatus,
2595 sizeof(vos_event_wlan_status_payload_type), 0);
2596
krunal soni7f7d2c92014-02-06 15:08:43 -08002597 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 {
2599 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2600 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2601 if(NULL != pRoamInfo->pBssDesc)
2602 {
2603 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2604 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2607 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2608 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302609 vos_mem_copy(connectionStatus.ssid,
2610 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2611
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2613 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2616 {
2617 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2618 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2619 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 if(eCSR_ROAM_RESULT_FORCED == u2)
2622 {
2623 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2624 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2625 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2628 {
2629 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2630 connectionStatus.reason = eCSR_REASON_DISASSOC;
2631 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2634 {
2635 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2636 connectionStatus.reason = eCSR_REASON_DEAUTH;
2637 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002639#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2640
2641 return (status);
2642}
Jeff Johnson295189b2012-06-20 16:38:30 -07002643// Returns whether handoff is currently in progress or not
2644tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2645{
2646#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2647 return csrNeighborRoamIsHandoffInProgress(pMac);
2648#else
2649 return eANI_BOOLEAN_FALSE;
2650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002651}
Jeff Johnson295189b2012-06-20 16:38:30 -07002652eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2653 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2654{
2655 eHalStatus status = eHAL_STATUS_SUCCESS;
2656 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2657 tANI_U16 reasonCode;
2658 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002659
2660 if(!pSession)
2661 {
2662 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2663 return eHAL_STATUS_FAILURE;
2664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002665
2666 //Restore AC weight in case we change it
2667 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2668 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002669 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 -07002670 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2671 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2672 }
2673
2674 if ( fMICFailure )
2675 {
2676 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2677 }
2678 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2679 {
2680 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002681 }
2682 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 {
2684 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002686#ifdef WLAN_FEATURE_VOWIFI_11R
2687 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2688 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2689 {
2690 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302691 vos_mem_copy(&bssId,
2692 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2693 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002694 }
2695 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002696#endif
2697 if(pSession->pConnectBssDesc)
2698 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302699 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002701
Jeff Johnson295189b2012-06-20 16:38:30 -07002702
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302703 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2704 " subState = %s reason=%d"),
2705 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2706 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002707
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2709
2710 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2711
2712 if(HAL_STATUS_SUCCESS(status))
2713 {
2714 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002715#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2716 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2717 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2718 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002719 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2721 }
2722#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002723 }
2724 else
2725 {
2726 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2727 }
2728
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 return (status);
2730}
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
Jeff Johnson295189b2012-06-20 16:38:30 -07002732/* ---------------------------------------------------------------------------
2733 \fn csrRoamIssueDisassociateStaCmd
2734 \brief csr function that HDD calls to disassociate a associated station
2735 \param sessionId - session Id for Soft AP
2736 \param pPeerMacAddr - MAC of associated station to delete
2737 \param reason - reason code, be one of the tSirMacReasonCodes
2738 \return eHalStatus
2739 ---------------------------------------------------------------------------*/
2740eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2741 tANI_U32 sessionId,
2742 tANI_U8 *pPeerMacAddr,
2743 tANI_U32 reason)
2744{
2745 eHalStatus status = eHAL_STATUS_SUCCESS;
2746 tSmeCmd *pCommand;
2747
2748 do
2749 {
2750 pCommand = csrGetCommandBuffer( pMac );
2751 if ( !pCommand )
2752 {
2753 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2754 status = eHAL_STATUS_RESOURCES;
2755 break;
2756 }
2757 pCommand->command = eSmeCommandRoam;
2758 pCommand->sessionId = (tANI_U8)sessionId;
2759 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2760 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2761 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2762 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2763 if( !HAL_STATUS_SUCCESS( status ) )
2764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002765 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 csrReleaseCommandRoam( pMac, pCommand );
2767 }
2768 }while(0);
2769
2770 return status;
2771}
2772
2773
Jeff Johnson295189b2012-06-20 16:38:30 -07002774/* ---------------------------------------------------------------------------
2775 \fn csrRoamIssueDeauthSta
2776 \brief csr function that HDD calls to delete a associated station
2777 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302778 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 \return eHalStatus
2780 ---------------------------------------------------------------------------*/
2781eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302782 tANI_U32 sessionId,
2783 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002784{
2785 eHalStatus status = eHAL_STATUS_SUCCESS;
2786 tSmeCmd *pCommand;
2787
2788 do
2789 {
2790 pCommand = csrGetCommandBuffer( pMac );
2791 if ( !pCommand )
2792 {
2793 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2794 status = eHAL_STATUS_RESOURCES;
2795 break;
2796 }
2797 pCommand->command = eSmeCommandRoam;
2798 pCommand->sessionId = (tANI_U8)sessionId;
2799 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302800 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2801 sizeof(tSirMacAddr));
2802 pCommand->u.roamCmd.reason =
2803 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2805 if( !HAL_STATUS_SUCCESS( status ) )
2806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002807 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 csrReleaseCommandRoam( pMac, pCommand );
2809 }
2810 }while(0);
2811
2812 return status;
2813}
Jeff Johnson295189b2012-06-20 16:38:30 -07002814eHalStatus
2815csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2816 tANI_BOOLEAN bEnable )
2817{
2818 eHalStatus status = eHAL_STATUS_FAILURE;
2819 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2820 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 if (!pSession)
2822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002823 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return (status);
2825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 if (pSession->pConnectBssDesc)
2827 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302828 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 }
2830 else
2831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002832 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 return (status);
2834 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002835 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2836 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2838 return (status);
2839}
Jeff Johnson295189b2012-06-20 16:38:30 -07002840eHalStatus
2841csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2842 VOS_MODULE_ID modId, void *pUsrContext,
2843 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2844{
2845 eHalStatus status = eHAL_STATUS_SUCCESS;
2846 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2847 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 if (!pSession)
2849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002850 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 return (status);
2852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 if(pSession->pConnectBssDesc)
2854 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302855 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 }
2857 else
2858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002859 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 return (status);
2861 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002862 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2863 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2865 return (status);
2866}
Jeff Johnson295189b2012-06-20 16:38:30 -07002867eHalStatus
2868csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2869 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2870{
2871 eHalStatus status = eHAL_STATUS_SUCCESS;
2872 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2873 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2874
2875 if (!pSession)
2876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002877 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 return (status);
2879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 if(pSession->pConnectBssDesc)
2881 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302882 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 }
2884 else
2885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002886 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 return (status);
2888 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002889 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2890 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002891
2892 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2893
2894 return (status);
2895}
Jeff Johnson295189b2012-06-20 16:38:30 -07002896eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2897{
2898 eHalStatus status = eHAL_STATUS_SUCCESS;
2899 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2900 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002901
2902 if (!pSession)
2903 {
2904 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2905 return eHAL_STATUS_FAILURE;
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
2908 if(pSession->pConnectBssDesc)
2909 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302910 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002912 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2913 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2915
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302916 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302917 if(HAL_STATUS_SUCCESS(status))
2918 {
2919 csrRoamLinkDown(pMac, sessionId);
2920 }
2921 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002922 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302923 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2924 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002925 }
2926
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 return (status);
2928}
2929
Jeff Johnson295189b2012-06-20 16:38:30 -07002930eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2931{
2932 eHalStatus status = eHAL_STATUS_SUCCESS;
2933 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2934 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002935
2936 if(!pSession)
2937 {
2938 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2939 return eHAL_STATUS_FAILURE;
2940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002941
2942 // If no BSS description was found in this connection (happens with start IBSS), then
2943 // nix the BSS description that we keep around for the connected BSS) and get out...
2944 if(NULL == pBssDesc)
2945 {
2946 csrFreeConnectBssDesc(pMac, sessionId);
2947 }
2948 else
2949 {
2950 size = pBssDesc->length + sizeof( pBssDesc->length );
2951 if(NULL != pSession->pConnectBssDesc)
2952 {
2953 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2954 {
2955 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2956 csrFreeConnectBssDesc(pMac, sessionId);
2957 }
2958 }
2959 if(NULL == pSession->pConnectBssDesc)
2960 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302961 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302963 if (NULL == pSession->pConnectBssDesc)
2964 status = eHAL_STATUS_FAILURE;
2965 else
2966 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 return (status);
2969}
2970
Jeff Johnson295189b2012-06-20 16:38:30 -07002971eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2972 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2973 tDot11fBeaconIEs *pIes)
2974{
2975 eHalStatus status = eHAL_STATUS_SUCCESS;
2976 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302978 if (pIes == NULL)
2979 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002980
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 do
2982 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302983 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2984 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 //get qos
2986 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2987 //get SSID
2988 if(pIes->SSID.present)
2989 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302990 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2992 }
2993 else
2994 pBssConfig->SSID.length = 0;
2995 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002997 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 //Return failed if profile doesn't have an SSID either.
2999 if(pProfile->SSIDs.numOfSSIDs == 0)
3000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003001 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 status = eHAL_STATUS_FAILURE;
3003 break;
3004 }
3005 }
3006 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3007 {
3008 pBssConfig->eBand = eCSR_BAND_5G;
3009 }
3010 else
3011 {
3012 pBssConfig->eBand = eCSR_BAND_24;
3013 }
3014 //phymode
3015 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3016 {
3017 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3018 }
3019 else
3020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003021 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 //force it
3023 if(eCSR_BAND_24 == pBssConfig->eBand)
3024 {
3025 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3026 }
3027 else
3028 {
3029 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3030 }
3031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 //Qos
3033 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3034 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3035 {
3036 //Joining BSS is not 11n capable and WMM is disabled on client.
3037 //Disable QoS and WMM
3038 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3039 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303040
3041 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303042 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303043 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3044 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3045 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3046 {
3047 //Joining BSS is 11n capable and WMM is disabled on AP.
3048 //Assume all HT AP's are QOS AP's and enable WMM
3049 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3050 }
3051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 //auth type
3053 switch( pProfile->negotiatedAuthType )
3054 {
3055 default:
3056 case eCSR_AUTH_TYPE_WPA:
3057 case eCSR_AUTH_TYPE_WPA_PSK:
3058 case eCSR_AUTH_TYPE_WPA_NONE:
3059 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3060 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 case eCSR_AUTH_TYPE_SHARED_KEY:
3063 pBssConfig->authType = eSIR_SHARED_KEY;
3064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 case eCSR_AUTH_TYPE_AUTOSWITCH:
3066 pBssConfig->authType = eSIR_AUTO_SWITCH;
3067 break;
3068 }
3069 //short slot time
3070 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3071 {
3072 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3073 }
3074 else
3075 {
3076 pBssConfig->uShortSlotTime = 0;
3077 }
3078 if(pBssConfig->BssCap.ibss)
3079 {
3080 //We don't support 11h on IBSS
3081 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3082 }
3083 else
3084 {
3085 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3086 }
3087 //power constraint
3088 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3089 //heartbeat
3090 if ( CSR_IS_11A_BSS( pBssDesc ) )
3091 {
3092 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3093 }
3094 else
3095 {
3096 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3097 }
3098 //Join timeout
3099 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003100 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 if ( pBssDesc->beaconInterval )
3102 {
3103 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003104 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 }
3106 else
3107 {
3108 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3109 }
3110 //validate CB
3111 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303112 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3113 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 return (status);
3116}
3117
Jeff Johnson295189b2012-06-20 16:38:30 -07003118static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3119 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3120{
3121 eHalStatus status = eHAL_STATUS_SUCCESS;
3122 tANI_U8 operationChannel = 0;
3123 tANI_U8 qAPisEnabled = FALSE;
3124 //SSID
3125 pBssConfig->SSID.length = 0;
3126 if(pProfile->SSIDs.numOfSSIDs)
3127 {
3128 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303129 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3130 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 }
3132 else
3133 {
3134 //SSID must present
3135 return eHAL_STATUS_FAILURE;
3136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 //Settomg up the capabilities
3138 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3139 {
3140 pBssConfig->BssCap.ibss = 1;
3141 }
3142 else
3143 {
3144 pBssConfig->BssCap.ess = 1;
3145 }
3146 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3147 {
3148 pBssConfig->BssCap.privacy = 1;
3149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 pBssConfig->eBand = pMac->roam.configParam.eBand;
3151 //phymode
3152 if(pProfile->ChannelInfo.ChannelList)
3153 {
3154 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3157 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 //QOS
3159 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 if ( pBssConfig->BssCap.ess == 1 )
3161 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 /*For Softap case enable WMM*/
3163 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3164 qAPisEnabled = TRUE;
3165 }
3166 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3168 qAPisEnabled = TRUE;
3169 } else {
3170 qAPisEnabled = FALSE;
3171 }
3172 } else {
3173 qAPisEnabled = TRUE;
3174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3176 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3177 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3178 )
3179 {
3180 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3181 } else {
3182 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3183 }
3184
3185 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003186 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 {
3188 default:
3189 case eCSR_AUTH_TYPE_WPA:
3190 case eCSR_AUTH_TYPE_WPA_PSK:
3191 case eCSR_AUTH_TYPE_WPA_NONE:
3192 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3193 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 case eCSR_AUTH_TYPE_SHARED_KEY:
3196 pBssConfig->authType = eSIR_SHARED_KEY;
3197 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 case eCSR_AUTH_TYPE_AUTOSWITCH:
3199 pBssConfig->authType = eSIR_AUTO_SWITCH;
3200 break;
3201 }
3202 //short slot time
3203 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3204 {
3205 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3206 }
3207 else
3208 {
3209 pBssConfig->uShortSlotTime = 0;
3210 }
3211 //power constraint. We don't support 11h on IBSS
3212 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3213 pBssConfig->uPowerLimit = 0;
3214 //heartbeat
3215 if ( eCSR_BAND_5G == pBssConfig->eBand )
3216 {
3217 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3218 }
3219 else
3220 {
3221 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3222 }
3223 //Join timeout
3224 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003225
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 return (status);
3227}
Jeff Johnson295189b2012-06-20 16:38:30 -07003228static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3229{
3230 eHalStatus status = eHAL_STATUS_FAILURE;
3231 tDot11fBeaconIEs *pIes = NULL;
3232
3233 do
3234 {
3235 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3236 {
3237 //err msg
3238 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003239 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 break;
3241 }
3242 //check if the AP is QAP & it supports APSD
3243 if( CSR_IS_QOS_BSS(pIes) )
3244 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303245 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 }
3247 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303248
3249 if (NULL != pIes)
3250 {
3251 vos_mem_free(pIes);
3252 }
3253
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 return status;
3255}
3256
Jeff Johnson295189b2012-06-20 16:38:30 -07003257void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3258{
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3260 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3261 // See !!Note: below in this function...
3262 tANI_U32 PrivacyEnabled = 0;
3263 tANI_U32 RsnEnabled = 0;
3264 tANI_U32 WepDefaultKeyId = 0;
3265 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3266 tANI_U32 Key0Length = 0;
3267 tANI_U32 Key1Length = 0;
3268 tANI_U32 Key2Length = 0;
3269 tANI_U32 Key3Length = 0;
3270
3271 // Reserve for the biggest key
3272 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3273 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3274 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3275 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3276
3277 switch ( pProfile->negotiatedUCEncryptionType )
3278 {
3279 case eCSR_ENCRYPT_TYPE_NONE:
3280
3281 // for NO encryption, turn off Privacy and Rsn.
3282 PrivacyEnabled = 0;
3283 RsnEnabled = 0;
3284
3285 // WEP key length and Wep Default Key ID don't matter in this case....
3286
3287 // clear out the WEP keys that may be hanging around.
3288 Key0Length = 0;
3289 Key1Length = 0;
3290 Key2Length = 0;
3291 Key3Length = 0;
3292
3293 break;
3294
3295 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303296 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
3298 // Privacy is ON. NO RSN for Wep40 static key.
3299 PrivacyEnabled = 1;
3300 RsnEnabled = 0;
3301
3302 // Set the Wep default key ID.
3303 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 // Wep key size if 5 bytes (40 bits).
3305 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3306
3307 // set encryption keys in the CFG database or clear those that are not present in this profile.
3308 if ( pProfile->Keys.KeyLength[0] )
3309 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303310 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3311 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3313 }
3314 else
3315 {
3316 Key0Length = 0;
3317 }
3318
3319 if ( pProfile->Keys.KeyLength[1] )
3320 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303321 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3322 WNI_CFG_WEP_KEY_LENGTH_5);
3323 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 }
3325 else
3326 {
3327 Key1Length = 0;
3328 }
3329
3330 if ( pProfile->Keys.KeyLength[2] )
3331 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303332 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3333 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3335 }
3336 else
3337 {
3338 Key2Length = 0;
3339 }
3340
3341 if ( pProfile->Keys.KeyLength[3] )
3342 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303343 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3344 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3346 }
3347 else
3348 {
3349 Key3Length = 0;
3350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 break;
3352
3353 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303354 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
3356 // Privacy is ON. NO RSN for Wep40 static key.
3357 PrivacyEnabled = 1;
3358 RsnEnabled = 0;
3359
3360 // Set the Wep default key ID.
3361 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3362
3363 // Wep key size if 13 bytes (104 bits).
3364 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3365
3366 // set encryption keys in the CFG database or clear those that are not present in this profile.
3367 if ( pProfile->Keys.KeyLength[0] )
3368 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303369 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3370 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3372 }
3373 else
3374 {
3375 Key0Length = 0;
3376 }
3377
3378 if ( pProfile->Keys.KeyLength[1] )
3379 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303380 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3381 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3383 }
3384 else
3385 {
3386 Key1Length = 0;
3387 }
3388
3389 if ( pProfile->Keys.KeyLength[2] )
3390 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303391 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3392 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3394 }
3395 else
3396 {
3397 Key2Length = 0;
3398 }
3399
3400 if ( pProfile->Keys.KeyLength[3] )
3401 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303402 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3403 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3405 }
3406 else
3407 {
3408 Key3Length = 0;
3409 }
3410
3411 break;
3412
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 case eCSR_ENCRYPT_TYPE_TKIP:
3414 case eCSR_ENCRYPT_TYPE_AES:
3415#ifdef FEATURE_WLAN_WAPI
3416 case eCSR_ENCRYPT_TYPE_WPI:
3417#endif /* FEATURE_WLAN_WAPI */
3418 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3419 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3420 PrivacyEnabled = (0 != fPrivacy);
3421
3422 // turn on RSN enabled for WPA associations
3423 RsnEnabled = 1;
3424
3425 // WEP key length and Wep Default Key ID don't matter in this case....
3426
3427 // clear out the static WEP keys that may be hanging around.
3428 Key0Length = 0;
3429 Key1Length = 0;
3430 Key2Length = 0;
3431 Key3Length = 0;
3432
3433 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 default:
3435 PrivacyEnabled = 0;
3436 RsnEnabled = 0;
3437 break;
3438 }
3439
3440 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3441 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3442 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3443 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3444 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3445 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3446 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3447 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3448}
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3451{
3452 tANI_U32 len = 0;
3453 if(pSSID->length <= WNI_CFG_SSID_LEN)
3454 {
3455 len = pSSID->length;
3456 }
3457 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3458}
3459
Jeff Johnson295189b2012-06-20 16:38:30 -07003460eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3461{
3462 eHalStatus status = eHAL_STATUS_SUCCESS;
3463 tANI_U32 QoSEnabled;
3464 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 // set the CFG enable/disable variables based on the qosType being configured...
3466 switch( qosType )
3467 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3469 QoSEnabled = FALSE;
3470 WmeEnabled = TRUE;
3471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3473 QoSEnabled = FALSE;
3474 WmeEnabled = TRUE;
3475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3477 QoSEnabled = FALSE;
3478 WmeEnabled = TRUE;
3479 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3481 QoSEnabled = TRUE;
3482 WmeEnabled = FALSE;
3483 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 case eCSR_MEDIUM_ACCESS_11e_HCF:
3485 QoSEnabled = TRUE;
3486 WmeEnabled = FALSE;
3487 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 default:
3489 case eCSR_MEDIUM_ACCESS_DCF:
3490 QoSEnabled = FALSE;
3491 WmeEnabled = FALSE;
3492 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 }
3494 //save the WMM setting for later use
3495 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303496 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 return (status);
3498}
Jeff Johnson295189b2012-06-20 16:38:30 -07003499static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303500 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003501{
3502 eHalStatus status = eHAL_STATUS_FAILURE;
3503 int i;
3504 eCsrCfgDot11Mode cfgDot11Mode;
3505 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303506 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303507 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3508 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003510
3511 if( NULL != pIes )
3512 {
3513 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 // Originally, we thought that for 11a networks, the 11a rates are always
3515 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3516 // appear in the Operational Rate set. Consequently, in either case, we
3517 // would blindly put the rates we support into our Operational Rate set
3518 // (including the basic rates, which we have already verified are
3519 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 // However, it turns out that this is not always the case. Some AP's
3521 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3522 // too. Now, we're a little more careful:
3523 pDstRate = pOpRateSet->rate;
3524 if(pIes->SuppRates.present)
3525 {
3526 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3527 {
3528 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3529 {
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303530 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003532 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 }
3534 }
3535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3537 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3538 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3539 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3540 {
3541 // If there are Extended Rates in the beacon, we will reflect those
3542 // extended rates that we support in out Extended Operational Rate
3543 // set:
3544 pDstRate = pExRateSet->rate;
3545 if(pIes->ExtSuppRates.present)
3546 {
3547 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3548 {
3549 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3550 {
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303551 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[ i ], rateBitmap))
3552 {
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303553 csrAddRateBitmap(pIes->ExtSuppRates.rates[ i ], &rateBitmap);
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303554 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3555 pExRateSet->numRates++;
3556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 }
3558 }
3559 }
3560 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303561 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 }//Parsing BSSDesc
3563 else
3564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003565 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 }
3567 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3568 return status;
3569}
3570
3571static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3572 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3573{
3574 int i;
3575 tANI_U8 *pDstRate;
3576 eCsrCfgDot11Mode cfgDot11Mode;
3577 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3578 tANI_U32 OperationalRatesLength = 0;
3579 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3580 tANI_U32 ExtendedOperationalRatesLength = 0;
3581 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3582 tANI_U32 ProprietaryOperationalRatesLength = 0;
3583 tANI_U32 PropRatesEnable = 0;
3584 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3585 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 if( NULL != pIes )
3588 {
3589 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 // Originally, we thought that for 11a networks, the 11a rates are always
3591 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3592 // appear in the Operational Rate set. Consequently, in either case, we
3593 // would blindly put the rates we support into our Operational Rate set
3594 // (including the basic rates, which we have already verified are
3595 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 // However, it turns out that this is not always the case. Some AP's
3597 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3598 // too. Now, we're a little more careful:
3599 pDstRate = OperationalRates;
3600 if(pIes->SuppRates.present)
3601 {
3602 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3603 {
3604 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3605 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3606 {
3607 *pDstRate++ = pIes->SuppRates.rates[ i ];
3608 OperationalRatesLength++;
3609 }
3610 }
3611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3613 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3614 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3615 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3616 {
3617 // If there are Extended Rates in the beacon, we will reflect those
3618 // extended rates that we support in out Extended Operational Rate
3619 // set:
3620 pDstRate = ExtendedOperationalRates;
3621 if(pIes->ExtSuppRates.present)
3622 {
3623 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3624 {
3625 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3626 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3627 {
3628 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3629 ExtendedOperationalRatesLength++;
3630 }
3631 }
3632 }
3633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 // Enable proprietary MAC features if peer node is Airgo node and STA
3635 // user wants to use them
3636 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3637 {
3638 PropRatesEnable = 1;
3639 }
3640 else
3641 {
3642 PropRatesEnable = 0;
3643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 // For ANI network companions, we need to populate the proprietary rate
3645 // set with any proprietary rates we found in the beacon, only if user
3646 // allows them...
3647 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3648 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3649 {
3650 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3651 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3652 {
3653 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3654 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303655 vos_mem_copy(ProprietaryOperationalRates,
3656 pIes->Airgo.PropSuppRates.rates,
3657 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 }
3659 else {
3660 // No proprietary modes...
3661 ProprietaryOperationalRatesLength = 0;
3662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 /* Get MCS Rate */
3664 pDstRate = MCSRateIdxSet;
3665 if ( pIes->HTCaps.present )
3666 {
3667 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3668 {
3669 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3670 {
3671 MCSRateLength++;
3672 *pDstRate++ = i;
3673 }
3674 }
3675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 // Set the operational rate set CFG variables...
3677 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3678 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3679 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3680 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3681 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3682 ProprietaryOperationalRates,
3683 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3684 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3685 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3686 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3687 }//Parsing BSSDesc
3688 else
3689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003690 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 }
3692}
3693
Jeff Johnson295189b2012-06-20 16:38:30 -07003694static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3695 tCsrRoamProfile *pProfile )
3696{
3697 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3698 { 8,
3699 { SIR_MAC_RATE_6,
3700 SIR_MAC_RATE_9,
3701 SIR_MAC_RATE_12,
3702 SIR_MAC_RATE_18,
3703 SIR_MAC_RATE_24,
3704 SIR_MAC_RATE_36,
3705 SIR_MAC_RATE_48,
3706 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3708 { 4,
3709 { SIR_MAC_RATE_1,
3710 SIR_MAC_RATE_2,
3711 SIR_MAC_RATE_5_5,
3712 SIR_MAC_RATE_11 } } };
3713
3714
3715 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3716 { SIR_MAC_RATE_72,
3717 SIR_MAC_RATE_96,
3718 SIR_MAC_RATE_108 } };
3719 eCsrCfgDot11Mode cfgDot11Mode;
3720 eCsrBand eBand;
3721 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3722 tANI_U32 OperationalRatesLength = 0;
3723 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3724 tANI_U32 ExtendedOperationalRatesLength = 0;
3725 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3726 tANI_U32 ProprietaryOperationalRatesLength = 0;
3727 tANI_U32 PropRatesEnable = 0;
3728 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 if(pProfile->ChannelInfo.ChannelList)
3730 {
3731 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3735 // networks, the 11b rates appear in the Operational Rate set. In either case,
3736 // we can blindly put the rates we support into our Operational Rate set
3737 // (including the basic rates, which we have already verified are supported
3738 // earlier in the roaming decision).
3739 if ( eCSR_BAND_5G == eBand )
3740 {
3741 // 11a rates into the Operational Rate Set.
3742 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3743 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303744 vos_mem_copy(OperationalRates,
3745 DefaultSupportedRates11a.supportedRateSet.rate,
3746 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003747
3748 // Nothing in the Extended rate set.
3749 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 // populate proprietary rates if user allows them
3751 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3752 {
3753 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3754 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303755 vos_mem_copy(ProprietaryOperationalRates,
3756 DefaultSupportedPropRates.propRate,
3757 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 }
3759 else
3760 {
3761 // No proprietary modes
3762 ProprietaryOperationalRatesLength = 0;
3763 }
3764 }
3765 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3766 {
3767 // 11b rates into the Operational Rate Set.
3768 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3769 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303770 vos_mem_copy(OperationalRates,
3771 DefaultSupportedRates11b.supportedRateSet.rate,
3772 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 // Nothing in the Extended rate set.
3774 ExtendedOperationalRatesLength = 0;
3775 // No proprietary modes
3776 ProprietaryOperationalRatesLength = 0;
3777 }
3778 else
3779 {
3780 // 11G
3781
3782 // 11b rates into the Operational Rate Set.
3783 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3784 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303785 vos_mem_copy(OperationalRates,
3786 DefaultSupportedRates11b.supportedRateSet.rate,
3787 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003788
3789 // 11a rates go in the Extended rate set.
3790 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3791 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303792 vos_mem_copy(ExtendedOperationalRates,
3793 DefaultSupportedRates11a.supportedRateSet.rate,
3794 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003795
3796 // populate proprietary rates if user allows them
3797 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3798 {
3799 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3800 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303801 vos_mem_copy(ProprietaryOperationalRates,
3802 DefaultSupportedPropRates.propRate,
3803 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
3805 else
3806 {
3807 // No proprietary modes
3808 ProprietaryOperationalRatesLength = 0;
3809 }
3810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3812 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3813 {
3814 PropRatesEnable = 1;
3815 }
3816 else
3817 {
3818 PropRatesEnable = 0;
3819 }
3820
3821 // Set the operational rate set CFG variables...
3822 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3823 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3824 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3825 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3826 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3827 ProprietaryOperationalRates,
3828 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3829 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003830}
Jeff Johnson295189b2012-06-20 16:38:30 -07003831void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3832{
3833 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003834
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3836 tANI_U32 sessionId;
3837 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 if(NULL == pEntry)
3839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003840 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 return;
3842 }
3843 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3844 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303845 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3846 " current state : %d sub state : %d "),
3847 result, pMac->roam.curState[sessionId],
3848 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3850 {
3851 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3852 }
3853}
3854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3856tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3857{
3858 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3859 {
3860 return (WNI_CFG_PHY_MODE_11B);
3861 }
3862 else
3863 {
3864 if(eCSR_BAND_24 == band)
3865 return (WNI_CFG_PHY_MODE_11G);
3866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 return (WNI_CFG_PHY_MODE_11A);
3868}
Jeff Johnson295189b2012-06-20 16:38:30 -07003869
Jeff Johnsone7245742012-09-05 17:12:55 -07003870
3871#ifdef WLAN_FEATURE_11AC
3872ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3873{
3874 switch ( aniCBMode )
3875 {
3876 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3877 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3878 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3879 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3880 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3881 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3882 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3883 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3884 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003885 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003886 return PHY_SINGLE_CHANNEL_CENTERED;
3887 }
3888}
3889#endif
3890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891//pIes may be NULL
3892eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3893 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303894 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003895{
3896 eHalStatus status = eHAL_STATUS_SUCCESS;
3897 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3898 tANI_U8 channel = 0;
3899 //Make sure we have the domain info for the BSS we try to connect to.
3900 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303901 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303903 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 {
3905 //Make sure the 11d info from this BSSDesc can be applied
3906 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303907 if (VOS_TRUE == resetCountry)
3908 {
3909 csrApplyCountryInformation(pMac, FALSE);
3910 }
3911 else
3912 {
3913 csrApplyCountryInformation(pMac, TRUE);
3914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 }
Kiran4a17ebe2013-01-31 10:43:43 -08003916 if ((csrIs11dSupported (pMac)) && pIes)
3917 {
3918 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003919 {
Kiran4a17ebe2013-01-31 10:43:43 -08003920 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003921 }
3922 else
3923 {
3924 //Let's also update the below to make sure we don't update CC while
3925 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303926 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003927 pBssDesc->bssId, sizeof(tSirMacAddr));
3928 }
Kiran4a17ebe2013-01-31 10:43:43 -08003929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 //Qos
3932 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3933 //SSID
3934 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3935 //fragment threshold
3936 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3937 //RTS threshold
3938 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3939
3940 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 //Auth type
3942 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3943 //encryption type
3944 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3945 //short slot time
3946 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 //11d
3948 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3949 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3950 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 /*//11h
3952 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3953 */
3954 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3955 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003956
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003957 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 {
3959 channel = pProfile->operationChannel;
3960 }
3961 else
3962 {
3963 if(pBssDesc)
3964 {
3965 channel = pBssDesc->channelId;
3966 }
3967 }
3968 if(0 != channel)
3969 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303970 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3971 !pMac->roam.configParam.channelBondingMode24GHz &&
3972 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3973 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303975 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3976 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3977 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 }
3979 else
3980 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003981 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 }
3983 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003984#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003985 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3986 // in function csrConvertCBIniValueToPhyCBState()
3987 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3988 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003989 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003990 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003991 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003992 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303993 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003994 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003995 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003996 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003997 }
3998 else
3999#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4001 //Rate
4002 //Fixed Rate
4003 if(pBssDesc)
4004 {
4005 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4006 }
4007 else
4008 {
4009 csrSetCfgRateSetFromProfile(pMac, pProfile);
4010 }
4011 //Make this the last CFG to set. The callback will trigger a join_req
4012 //Join time out
4013 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4014
4015 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 return (status);
4017}
4018
Jeff Johnson295189b2012-06-20 16:38:30 -07004019eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4020 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4021{
4022 eHalStatus status;
4023 tBssConfigParam *pBssConfig;
4024 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004025
4026 if(!pSession)
4027 {
4028 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4029 return eHAL_STATUS_FAILURE;
4030 }
4031
Kiet Lam64c1b492013-07-12 13:56:44 +05304032 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4033 if ( NULL == pBssConfig )
4034 status = eHAL_STATUS_FAILURE;
4035 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304037 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4039 if(HAL_STATUS_SUCCESS(status))
4040 {
4041 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004042 /* This will allow to pass cbMode during join req */
4043 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 //For IBSS, we need to prepare some more information
4045 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 )
4048 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004049 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 }
4051 // If we are in an IBSS, then stop the IBSS...
4052 ////Not worry about WDS connection for now
4053 if ( csrIsConnStateIbss( pMac, sessionId ) )
4054 {
4055 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4056 }
4057 else
4058 {
4059 // if we are in an Infrastructure association....
4060 if ( csrIsConnStateInfra( pMac, sessionId ) )
4061 {
4062 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4063 // across SSIDs (roaming to a new SSID)... //
4064 //Not worry about WDS connection for now
4065 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304066 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 {
4068 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304069 status = csrRoamIssueDisassociate( pMac, sessionId,
4070 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304072 else
4073 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4075 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304076 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304078 // Set parameters for this Bss.
4079 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4080 pBssDesc, pBssConfig,
4081 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304085 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 {
4087 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4088 // Nothing to stop.
4089 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304091 )
4092 {
4093 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4094 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4095 // Set parameters for this Bss.
4096 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4097 pBssDesc, pBssConfig,
4098 pIes, is11rRoamingFlag);
4099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 }
4101 }
4102 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304103 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 return (status);
4106}
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4109 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4110{
4111 eCsrJoinState eRoamState = eCsrContinueRoaming;
4112 eHalStatus status;
4113 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4114 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4115 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004116
4117 if(!pSession)
4118 {
4119 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4120 return (eCsrStopRoaming);
4121 }
4122
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 if( CSR_IS_WDS_STA( pProfile ) )
4124 {
4125 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4126 if( !HAL_STATUS_SUCCESS( status ) )
4127 {
4128 eRoamState = eCsrStopRoaming;
4129 }
4130 }
4131 else
4132 {
4133 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4134 {
4135 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4136 return (eCsrStopRoaming);
4137 }
4138 if ( csrIsInfraBssDesc( pBssDesc ) )
4139 {
4140 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4141 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4142 // have changed and handle the changes (without disturbing the current association).
4143
4144 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4145 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4146 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4147 )
4148 {
4149 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4150 // with Authenticating first. To force this, stop the current association (Disassociate) and
4151 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4152 // a new Association.
4153 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4154 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004155 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4157 {
4158 eRoamState = eCsrReassocToSelfNoCapChange;
4159 }
4160 else
4161 {
4162 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304164 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4166 if(HAL_STATUS_SUCCESS(status))
4167 {
4168 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004169 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304171 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4172 pBssDesc, &bssConfig,
4173 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 if(!HAL_STATUS_SUCCESS(status))
4175 {
4176 eRoamState = eCsrStopRoaming;
4177 }
4178 }
4179 else
4180 {
4181 eRoamState = eCsrStopRoaming;
4182 }
4183 }//same profile
4184 }
4185 else
4186 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304187 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4189 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304190 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4191 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304195 }
4196 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 {
4198 // 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 -07004199 // stop the existing network before attempting to join the new network...
4200 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4201 {
4202 eRoamState = eCsrStopRoaming;
4203 }
4204 }
4205 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304206 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 {
4208 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4209 {
4210 eRoamState = eCsrStopRoaming;
4211 }
4212 }
4213 if( pIesLocal && !pScanResult->pvIes )
4214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304215 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 }
4217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 return( eRoamState );
4219}
4220
Jeff Johnson295189b2012-06-20 16:38:30 -07004221eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4222 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4223{
4224 eHalStatus status = eHAL_STATUS_SUCCESS;
4225 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304226 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 roamInfo.pBssDesc = pBssDesc;
4228 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4229 return (status);
4230}
Jeff Johnson295189b2012-06-20 16:38:30 -07004231//In case no matching BSS is found, use whatever default we can find
4232static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4233{
4234 //Need to get all negotiated types in place first
4235 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004236 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 {
4238 default:
4239 case eCSR_AUTH_TYPE_WPA:
4240 case eCSR_AUTH_TYPE_WPA_PSK:
4241 case eCSR_AUTH_TYPE_WPA_NONE:
4242 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4243 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4244 break;
4245
4246 case eCSR_AUTH_TYPE_SHARED_KEY:
4247 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4248 break;
4249
4250 case eCSR_AUTH_TYPE_AUTOSWITCH:
4251 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4252 break;
4253 }
4254 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4255 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4256 //In this case, the multicast encryption needs to follow the uncast ones.
4257 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4258 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4259}
4260
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004261
4262static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4263{
4264 switch(pCommand->u.roamCmd.roamReason)
4265 {
4266 case eCsrLostLink1:
4267 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4268 break;
4269 case eCsrLostLink2:
4270 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4271 break;
4272 case eCsrLostLink3:
4273 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4274 break;
4275 default:
4276 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4277 pCommand->u.roamCmd.roamReason);
4278 break;
4279 }
4280}
4281
Jeff Johnson295189b2012-06-20 16:38:30 -07004282static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4283{
4284 eHalStatus status;
4285 tCsrScanResult *pScanResult = NULL;
4286 eCsrJoinState eRoamState = eCsrStopRoaming;
4287 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4288 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4289 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4290#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4291 v_U8_t acm_mask = 0;
4292#endif
4293 tANI_U32 sessionId = pCommand->sessionId;
4294 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4295 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4296 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004297
4298 if(!pSession)
4299 {
4300 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4301 return (eCsrStopRoaming);
4302 }
4303
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 do
4305 {
4306 // Check for Cardbus eject condition, before trying to Roam to any BSS
4307 //***if( !balIsCardPresent(pAdapter) ) break;
4308
Kiet Lam64c1b492013-07-12 13:56:44 +05304309 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304310 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 if(NULL != pBSSList)
4312 {
4313 // When handling AP's capability change, continue to associate to
4314 // same BSS and make sure pRoamBssEntry is not Null.
4315 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4316 {
4317 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4318 {
4319 //Try the first BSS
4320 pCommand->u.roamCmd.pLastRoamBss = NULL;
4321 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4322 }
4323 else
4324 {
4325 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4326 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4327 {
4328 //Done with all the BSSs
4329 //In this case, will tell HDD the completion
4330 break;
4331 }
4332 else
4333 {
4334 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304335 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4337 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4338 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4339 pRoamInfo = &roamInfo;
4340 }
4341 }
4342 while(pCommand->u.roamCmd.pRoamBssEntry)
4343 {
4344 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 /*If concurrency enabled take the concurrent connected channel first. */
4346 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304347 if (vos_concurrent_open_sessions_running() &&
4348 !csrIsValidMcConcurrentSession(pMac, sessionId,
4349 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 {
4351 concurrentChannel =
4352 csrGetConcurrentOperationChannel(pMac);
4353 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004354 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 if ((concurrentChannel) &&
4356 (concurrentChannel ==
4357 pScanResult->Result.BssDescriptor.channelId))
4358 {
4359 //make this 0 because we do not want the
4360 //below check to pass as we don't want to
4361 //connect on other channel
4362 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4363 FL("Concurrent channel match =%d"),
4364 concurrentChannel);
4365 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 }
4367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004368
4369 if (!concurrentChannel)
4370 {
4371
4372 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4373 sessionId, &pScanResult->Result.BssDescriptor,
4374 pCommand->u.roamCmd.roamId)))
4375 {
4376 //Ok to roam this
4377 break;
4378 }
4379 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004380 else
4381 {
4382 eRoamState = eCsrStopRoamingDueToConcurrency;
4383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4385 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4386 {
4387 //Done with all the BSSs
4388 fDone = eANI_BOOLEAN_TRUE;
4389 break;
4390 }
4391 }
4392 if(fDone)
4393 {
4394 break;
4395 }
4396 }
4397 }
4398 //We have something to roam, tell HDD when it is infra.
4399 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4400 //For WDS, the indication is eCSR_ROAM_WDS_IND
4401 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4402 {
4403 if(pRoamInfo)
4404 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004405 if(pSession->bRefAssocStartCnt)
4406 {
4407 pSession->bRefAssocStartCnt--;
4408 //Complete the last association attemp because a new one is about to be tried
4409 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4410 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004412 }
4413 }
4414 /* If the roaming has stopped, not to continue the roaming command*/
4415 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4416 {
4417 //No need to complete roaming here as it already completes
4418 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4419 pCommand->u.roamCmd.roamReason);
4420 eRoamState = eCsrStopRoaming;
4421 csrSetAbortRoamingCommand(pMac, pCommand);
4422 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304424 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 if(pScanResult)
4426 {
4427 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4429 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004430 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 fDone = eANI_BOOLEAN_TRUE;
4432 eRoamState = eCsrStopRoaming;
4433 break;
4434 }
4435 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4436 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4437 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4438 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4439 CSR_IS_QOS_BSS(pIesLocal) &&
4440 CSR_IS_UAPSD_BSS(pIesLocal) )
4441 {
4442#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4444 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 }
4447 else
4448 {
4449 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4450 }
4451 if( pIesLocal && !pScanResult->Result.pvIes)
4452 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304453 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 }
4455 }
4456 else
4457 {
4458 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4459 }
4460 roamInfo.pProfile = pProfile;
4461 pSession->bRefAssocStartCnt++;
4462 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4463 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4466 {
4467 // If this is a start IBSS profile, then we need to start the IBSS.
4468 if ( CSR_IS_START_IBSS(pProfile) )
4469 {
4470 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 // Attempt to start this IBSS...
4472 csrRoamAssignDefaultParam( pMac, pCommand );
4473 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4474 if(HAL_STATUS_SUCCESS(status))
4475 {
4476 if ( fSameIbss )
4477 {
4478 eRoamState = eCsrStartIbssSameIbss;
4479 }
4480 else
4481 {
4482 eRoamState = eCsrContinueRoaming;
4483 }
4484 }
4485 else
4486 {
4487 //it somehow fail need to stop
4488 eRoamState = eCsrStopRoaming;
4489 }
4490 break;
4491 }
4492 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 )
4495 {
4496 // Attempt to start this WDS...
4497 csrRoamAssignDefaultParam( pMac, pCommand );
4498 /* For AP WDS, we dont have any BSSDescription */
4499 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4500 if(HAL_STATUS_SUCCESS(status))
4501 {
4502 eRoamState = eCsrContinueRoaming;
4503 }
4504 else
4505 {
4506 //it somehow fail need to stop
4507 eRoamState = eCsrStopRoaming;
4508 }
4509 }
4510 else
4511 {
4512 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004513 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 eRoamState = eCsrStopRoaming;
4515 break;
4516 }
4517 }
4518 else //We have BSS
4519 {
4520 //Need to assign these value because they are used in csrIsSameProfile
4521 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004522 /* The OSEN IE doesn't provide the cipher suite.
4523 * Therefore set to constant value of AES */
4524 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4525 {
4526 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4527 eCSR_ENCRYPT_TYPE_AES;
4528 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4529 eCSR_ENCRYPT_TYPE_AES;
4530 }
4531 else
4532 {
4533 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4534 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4535 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4536 pScanResult->mcEncryptionType;
4537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4539 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4540 {
4541 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4542 {
4543 eRoamState = eCsrStartIbssSameIbss;
4544 break;
4545 }
4546 }
4547 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4548 {
4549 //trying to connect to the one already connected
4550 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4551 eRoamState = eCsrReassocToSelfNoCapChange;
4552 break;
4553 }
4554 // Attempt to Join this Bss...
4555 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4556 break;
4557 }
4558
4559 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4561 {
4562 //Need to indicate association_completion if association_start has been done
4563 if(pSession->bRefAssocStartCnt > 0)
4564 {
4565 pSession->bRefAssocStartCnt--;
4566 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004567 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4569 eCSR_ROAM_ASSOCIATION_COMPLETION,
4570 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4571 }
4572 }
4573
4574 return( eRoamState );
4575}
4576
Jeff Johnson295189b2012-06-20 16:38:30 -07004577static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4578{
4579 eHalStatus status = eHAL_STATUS_SUCCESS;
4580 eCsrJoinState RoamState;
4581 tANI_U32 sessionId = pCommand->sessionId;
4582
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 //***if( hddIsRadioStateOn( pAdapter ) )
4584 {
4585 // Attept to join a Bss...
4586 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004587
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004589 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 {
4591 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 // and if connected in Infrastructure mode...
4593 if ( csrIsConnStateInfra(pMac, sessionId) )
4594 {
4595 //... then we need to issue a disassociation
4596 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4597 if(!HAL_STATUS_SUCCESS(status))
4598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004599 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 //roam command is completed by caller in the failed case
4601 fComplete = eANI_BOOLEAN_TRUE;
4602 }
4603 }
4604 else if( csrIsConnStateIbss(pMac, sessionId) )
4605 {
4606 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4607 if(!HAL_STATUS_SUCCESS(status))
4608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004609 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 //roam command is completed by caller in the failed case
4611 fComplete = eANI_BOOLEAN_TRUE;
4612 }
4613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4615 {
4616 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4617 if(!HAL_STATUS_SUCCESS(status))
4618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004619 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 //roam command is completed by caller in the failed case
4621 fComplete = eANI_BOOLEAN_TRUE;
4622 }
4623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 else
4625 {
4626 fComplete = eANI_BOOLEAN_TRUE;
4627 }
4628 if(fComplete)
4629 {
4630 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004631 if(eCsrStopRoamingDueToConcurrency == RoamState)
4632 {
4633 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4634 }
4635 else
4636 {
4637 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 }
4640 }
4641 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4642 {
4643 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4644 }
4645 else if ( eCsrStartIbssSameIbss == RoamState )
4646 {
4647 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4648 }
4649 }//hddIsRadioStateOn
4650
4651 return status;
4652}
Jeff Johnson295189b2012-06-20 16:38:30 -07004653eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4654{
4655 tANI_U32 sessionId;
4656 tCsrRoamSession *pSession;
4657 tCsrScanResult *pScanResult = NULL;
4658 tSirBssDescription *pBssDesc = NULL;
4659 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 sessionId = pCommand->sessionId;
4661 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004662
4663 if(!pSession)
4664 {
4665 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4666 return eHAL_STATUS_FAILURE;
4667 }
4668
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4670 {
4671 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004672 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4674 return eHAL_STATUS_FAILURE;
4675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 if (pCommand->u.roamCmd.pRoamBssEntry)
4677 {
4678 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4679 pBssDesc = &pScanResult->Result.BssDescriptor;
4680 }
4681 else
4682 {
4683 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004684 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4686 return eHAL_STATUS_FAILURE;
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4689 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4690 return status;
4691}
4692
Jeff Johnson295189b2012-06-20 16:38:30 -07004693eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4694{
4695 eHalStatus status = eHAL_STATUS_SUCCESS;
4696 tCsrRoamInfo roamInfo;
4697 tANI_U32 sessionId = pCommand->sessionId;
4698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004699
4700 if(!pSession)
4701 {
4702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4703 return eHAL_STATUS_FAILURE;
4704 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304705 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
4706 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 switch ( pCommand->u.roamCmd.roamReason )
4708 {
4709 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004711 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 case eCsrSmeIssuedDisassocForHandoff:
4714 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4715#if 0 // TODO : Confirm this change
4716 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4717#else
4718 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4719#endif
4720
4721 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004724 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004728 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 case eCsrHddIssuedReassocToSameAP:
4731 case eCsrSmeIssuedReassocToSameAP:
4732 {
4733 tDot11fBeaconIEs *pIes = NULL;
4734
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 if( pSession->pConnectBssDesc )
4736 {
4737 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4738 if(!HAL_STATUS_SUCCESS(status) )
4739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004740 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 }
4742 else
4743 {
4744 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4745 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4746 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4748 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4749 pSession->bRefAssocStartCnt++;
4750 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4751 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4752
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004753 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004754 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4755 &pCommand->u.roamCmd.roamProfile );
4756 if(!HAL_STATUS_SUCCESS(status))
4757 {
4758 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004759 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004760 }
4761
Kiet Lam64c1b492013-07-12 13:56:44 +05304762 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 pIes = NULL;
4764 }
4765 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304766 else
4767 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 break;
4769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004771 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4773 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004776 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4778 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004779
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 case eCsrStopBss:
4781 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4782 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4783 break;
4784
4785 case eCsrForcedDisassocSta:
4786 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4787 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4788 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4789 pCommand->u.roamCmd.reason);
4790 break;
4791
4792 case eCsrForcedDeauthSta:
4793 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4794 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4795 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4796 pCommand->u.roamCmd.reason);
4797 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004798
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004799 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004800 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004801 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4802 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004803 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004804
4805 default:
4806 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4807
4808 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4809 {
4810 //Remember the roaming profile
4811 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304812 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4813 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304815 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4817 }
4818 }
4819
4820 //At this point, original uapsd_mask is saved in pCurRoamProfile
4821 //uapsd_mask in the pCommand may change from this point on.
4822
4823 // Attempt to roam with the new scan results (if we need to..)
4824 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004825 if(!HAL_STATUS_SUCCESS(status))
4826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004827 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 break;
4830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 return (status);
4832}
4833
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004834void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4835{
4836 pCommand->u.roamCmd.pLastRoamBss = NULL;
4837 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4838 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304839 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004840}
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4843{
4844 if(pCommand->u.roamCmd.fReleaseBssList)
4845 {
4846 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4847 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4848 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4849 }
4850 if(pCommand->u.roamCmd.fReleaseProfile)
4851 {
4852 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4853 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4854 }
4855 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4856 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304857 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004858}
4859
Jeff Johnson295189b2012-06-20 16:38:30 -07004860void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4861{
Kiet Lam64c1b492013-07-12 13:56:44 +05304862 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004863}
Jeff Johnson295189b2012-06-20 16:38:30 -07004864void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4865{
4866 tListElem *pEntry;
4867 tSmeCmd *pCommand;
4868 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004869 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4871 if ( pEntry )
4872 {
4873 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 // If the head of the queue is Active and it is a ROAM command, remove
4875 // and put this on the Free queue.
4876 if ( eSmeCommandRoam == pCommand->command )
4877 {
4878 //we need to process the result first before removing it from active list because state changes
4879 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4880 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4881 if( fReleaseCommand )
4882 {
4883 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4884 {
4885 csrReleaseCommandRoam( pMac, pCommand );
4886 }
4887 else
4888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004889 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004890 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 }
4892 }
4893 else
4894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004895 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004896 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 }
4898 }
4899 else
4900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004901 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 }
4903 }
4904 else
4905 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004906 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 if( fReleaseCommand )
4909 {
4910 smeProcessPendingQueue( pMac );
4911 }
4912}
4913
Jeff Johnson295189b2012-06-20 16:38:30 -07004914void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4915{
4916 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004917 if(!pSession)
4918 {
4919 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4920 return;
4921 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304922 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4923 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 pSession->NumPmkidCandidate = 0;
4925}
Jeff Johnson295189b2012-06-20 16:38:30 -07004926#ifdef FEATURE_WLAN_WAPI
4927void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4928{
4929 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004930 if(!pSession)
4931 {
4932 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4933 return;
4934 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304935 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4936 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 pSession->NumBkidCandidate = 0;
4938}
4939#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004940extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4941
Jeff Johnson295189b2012-06-20 16:38:30 -07004942static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4943 tSirBssDescription *pSirBssDesc,
4944 tDot11fBeaconIEs *pIes)
4945{
4946 eHalStatus status = eHAL_STATUS_SUCCESS;
4947 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4948 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004949
4950 if(!pSession)
4951 {
4952 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4953 return eHAL_STATUS_FAILURE;
4954 }
4955
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 if((eCSR_AUTH_TYPE_WPA == authType) ||
4957 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4958 (eCSR_AUTH_TYPE_RSN == authType) ||
4959 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4960#if defined WLAN_FEATURE_VOWIFI_11R
4961 ||
4962 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4963 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4964#endif /* FEATURE_WLAN_WAPI */
4965#ifdef FEATURE_WLAN_WAPI
4966 ||
4967 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4968 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4969#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004970#ifdef WLAN_FEATURE_11W
4971 ||
Abhishek Singhae408032014-09-25 17:22:04 +05304972 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4973 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07004974#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 )
4976 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004979 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 }
4981 if( pIesLocal )
4982 {
4983 tANI_U32 nIeLen;
4984 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 if((eCSR_AUTH_TYPE_RSN == authType) ||
4986#if defined WLAN_FEATURE_VOWIFI_11R
4987 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4988 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4989#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004990#if defined WLAN_FEATURE_11W
4991 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05304992 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07004993#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4995 {
4996 if(pIesLocal->RSN.present)
4997 {
4998 //Calculate the actual length
4999 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5000 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5001 + 2 //akm_suite_count
5002 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5003 + 2; //reserved
5004 if( pIesLocal->RSN.pmkid_count )
5005 {
5006 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5007 }
5008 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305009 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5010 if (NULL == pSession->pWpaRsnRspIE)
5011 status = eHAL_STATUS_FAILURE;
5012 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305014 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5016 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5017 //copy upto akm_suites
5018 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305019 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5020 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005021 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305022 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5023 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005024 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305025 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5026 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005027 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 if( pIesLocal->RSN.pwise_cipher_suite_count )
5029 {
5030 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305031 vos_mem_copy(pIeBuf,
5032 pIesLocal->RSN.pwise_cipher_suites,
5033 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5035 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305036 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 pIeBuf += 2;
5038 if( pIesLocal->RSN.akm_suite_count )
5039 {
5040 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305041 vos_mem_copy(pIeBuf,
5042 pIesLocal->RSN.akm_suites,
5043 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5045 }
5046 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305047 vos_mem_copy(pIeBuf,
5048 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5049 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5051 }
5052 }
5053 }
5054 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5055 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5056 {
5057 if(pIesLocal->WPA.present)
5058 {
5059 //Calculate the actual length
5060 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5061 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5062 + 2 //auth_suite_count
5063 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5064 // The WPA capabilities follows the Auth Suite (two octects)--
5065 // this field is optional, and we always "send" zero, so just
5066 // remove it. This is consistent with our assumptions in the
5067 // frames compiler; c.f. bug 15234:
5068 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305069
5070 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5071 if ( NULL == pSession->pWpaRsnRspIE )
5072 status = eHAL_STATUS_FAILURE;
5073 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 {
5075 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5076 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5077 pIeBuf = pSession->pWpaRsnRspIE + 2;
5078 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305079 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305081 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5082 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305084 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5085 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5087 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5088 }
5089 }
5090 }
5091#ifdef FEATURE_WLAN_WAPI
5092 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5093 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5094 {
5095 if(pIesLocal->WAPI.present)
5096 {
5097 //Calculate the actual length
5098 nIeLen = 4 //version + akm_suite_count
5099 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5100 + 2 //pwise_cipher_suite_count
5101 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5102 + 6; //gp_cipher_suite + preauth + reserved
5103 if( pIesLocal->WAPI.bkid_count )
5104 {
5105 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5106 }
5107
5108 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305109 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5110 if ( NULL == pSession->pWapiRspIE )
5111 status = eHAL_STATUS_FAILURE;
5112 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 {
5114 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5115 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5116 pIeBuf = pSession->pWapiRspIE + 2;
5117 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305118 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 pIeBuf += 4;
5120 if( pIesLocal->WAPI.akm_suite_count )
5121 {
5122 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305123 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5124 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305126 }
5127 vos_mem_copy(pIeBuf,
5128 &pIesLocal->WAPI.unicast_cipher_suite_count,
5129 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5132 {
5133 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305134 vos_mem_copy( pIeBuf,
5135 pIesLocal->WAPI.unicast_cipher_suites,
5136 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5138 }
lukez3c809222013-05-03 10:23:02 -07005139 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305140 vos_mem_copy(pIeBuf,
5141 pIesLocal->WAPI.multicast_cipher_suite,
5142 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005143 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305144 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305145 vos_mem_copy(pIeBuf,
5146 pIesLocal->WAPI.multicast_cipher_suite + 4,
5147 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005148 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305149 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305151 //bkid_count
5152 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5153 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305155 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5156 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5158 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305159 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 }
5162 }
5163#endif /* FEATURE_WLAN_WAPI */
5164 if( !pIes )
5165 {
5166 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305167 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 }
5169 }
5170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 return (status);
5172}
5173
Jeff Johnson295189b2012-06-20 16:38:30 -07005174static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5175{
5176 v_U8_t bACWeights[WLANTL_MAX_AC];
5177 v_U8_t paramBk, paramBe, paramVi, paramVo;
5178 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5180 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5181 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5182 //This doesn't address the case where the lower AC needs a real higher weight
5183 if( pIEs->WMMParams.present )
5184 {
5185 //no change to the lowest ones
5186 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5187 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5188 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5189 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5190 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5191 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5192 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5193 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5194 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5195 {
5196 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5197 fWeightChange = VOS_TRUE;
5198 }
5199 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5200 {
5201 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5202 fWeightChange = VOS_TRUE;
5203 }
5204 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5205 {
5206 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5207 fWeightChange = VOS_TRUE;
5208 }
5209 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5210 {
5211 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5212 fWeightChange = VOS_TRUE;
5213 }
5214 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5215 {
5216 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5217 fWeightChange = VOS_TRUE;
5218 }
5219 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5220 {
5221 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5222 fWeightChange = VOS_TRUE;
5223 }
5224 if(fWeightChange)
5225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005226 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 bACWeights[2], bACWeights[3]);
5228 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5229 }
5230 }
5231}
Jeff Johnson295189b2012-06-20 16:38:30 -07005232#ifdef WLAN_FEATURE_VOWIFI_11R
5233//Returns whether the current association is a 11r assoc or not
5234tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5235{
5236#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5237 return csrNeighborRoamIs11rAssoc(pMac);
5238#else
5239 return eANI_BOOLEAN_FALSE;
5240#endif
5241}
5242#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005243#ifdef FEATURE_WLAN_ESE
5244//Returns whether the current association is a ESE assoc or not
5245tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005246{
5247#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005248 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005249#else
5250 return eANI_BOOLEAN_FALSE;
5251#endif
5252}
5253#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005254#ifdef FEATURE_WLAN_LFR
5255//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305256tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005257{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305258 tCsrRoamSession *pSession = NULL;
5259
5260 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5261 {
5262 pSession = CSR_GET_SESSION( pMac, sessionId );
5263 if (NULL != pSession->pCurRoamProfile)
5264 {
5265 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5266 {
5267 return eANI_BOOLEAN_FALSE;
5268 }
5269 }
5270 }
5271
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005272#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5273 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5274 {
5275 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5276 }
5277 else
5278#endif
5279 {
5280 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005281 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005282 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005283}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005284
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005285#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005286/* ---------------------------------------------------------------------------
5287
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005288 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005289
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005290 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005291
5292 \param pMac - The handle returned by macOpen.
5293
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005294 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005295
5296---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005297tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005298{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005299 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005300}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005301#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005302
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005303#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5304//Returns whether "FW based BG scan" is currently enabled...or not
5305tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5306{
5307 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5308}
5309#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005310#endif
5311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005312#if defined(FEATURE_WLAN_ESE)
5313tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005314{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005315 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005316}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005317#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005318
Jeff Johnson295189b2012-06-20 16:38:30 -07005319//Return true means the command can be release, else not
5320static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5321 eCsrRoamCompleteResult Result, void *Context )
5322{
5323 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5324 tSirBssDescription *pSirBssDesc = NULL;
5325 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5326 tCsrScanResult *pScanResult = NULL;
5327 tCsrRoamInfo roamInfo;
5328 sme_QosAssocInfo assocInfo;
5329 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5330 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5331 tDot11fBeaconIEs *pIes = NULL;
5332 tANI_U32 sessionId = pCommand->sessionId;
5333 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5334 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5335 eRoamCmdStatus roamStatus;
5336 eCsrRoamResult roamResult;
5337 eHalStatus status;
5338 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005340
Jeff Johnson32d95a32012-09-10 13:15:23 -07005341 if(!pSession)
5342 {
5343 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5344 return eANI_BOOLEAN_FALSE;
5345 }
5346
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005347 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 switch( Result )
5349 {
5350 case eCsrJoinSuccess:
5351 // reset the IDLE timer
5352 // !!
5353 // !! fall through to the next CASE statement here is intentional !!
5354 // !!
5355 case eCsrReassocSuccess:
5356 if(eCsrReassocSuccess == Result)
5357 {
5358 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5359 }
5360 else
5361 {
5362 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5363 }
5364 // Success Join Response from LIM. Tell NDIS we are connected and save the
5365 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005366 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305367 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 //always free the memory here
5369 if(pSession->pWpaRsnRspIE)
5370 {
5371 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305372 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 pSession->pWpaRsnRspIE = NULL;
5374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005375#ifdef FEATURE_WLAN_WAPI
5376 if(pSession->pWapiRspIE)
5377 {
5378 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305379 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 pSession->pWapiRspIE = NULL;
5381 }
5382#endif /* FEATURE_WLAN_WAPI */
5383#ifdef FEATURE_WLAN_BTAMP_UT_RF
5384 //Reset counter so no join retry is needed.
5385 pSession->maxRetryCount = 0;
5386 csrRoamStopJoinRetryTimer(pMac, sessionId);
5387#endif
5388 /* This creates problem since we have not saved the connected profile.
5389 So moving this after saving the profile
5390 */
5391 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305392
5393 /* Reset remainInPowerActiveTillDHCP as it might have been set
5394 * by last failed secured connection.
5395 * It should be set only for secured connection.
5396 */
5397 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5399 {
5400 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5401 }
5402 else
5403 {
5404 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 //Use the last connected bssdesc for reassoc-ing to the same AP.
5407 //NOTE: What to do when reassoc to a different AP???
5408 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5409 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5410 {
5411 pSirBssDesc = pSession->pConnectBssDesc;
5412 if(pSirBssDesc)
5413 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305414 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5415 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 }
5417 }
5418 else
5419 {
5420
5421 if(pCommand->u.roamCmd.pRoamBssEntry)
5422 {
5423 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5424 if(pScanResult != NULL)
5425 {
5426 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5427 //this can be NULL
5428 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305429 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5430 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 }
5432 }
5433 }
5434 if( pSirBssDesc )
5435 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5438 //Save WPA/RSN IE
5439 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005440#ifdef FEATURE_WLAN_ESE
5441 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005442#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305443#ifdef WLAN_FEATURE_VOWIFI_11R
5444 if (pSirBssDesc->mdiePresent)
5445 {
5446 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5447#ifdef FEATURE_WLAN_ESE
5448 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5449 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5450#endif
5451 )
5452 {
5453 // is11Rconnection;
5454 roamInfo.is11rAssoc = VOS_TRUE;
5455 }
5456 else
5457 {
5458 // is11Rconnection;
5459 roamInfo.is11rAssoc = VOS_FALSE;
5460 }
5461 }
5462#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5464 // substate change.
5465 // Moving even save profile above so that below mentioned conditon is also met.
5466 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5467 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5469 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5470 // will be dropped for the security context may not be set properly.
5471 //
5472 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5473 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5474 //
5475 // this reordering was done on titan_prod_usb branch and is being replicated here.
5476 //
5477
5478 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5479 !pProfile->bWPSAssociation)
5480 {
5481 // Issue the set Context request to LIM to establish the Unicast STA context
5482 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5483 pProfile->negotiatedUCEncryptionType,
5484 pSirBssDesc, &(pSirBssDesc->bssId),
5485 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005487 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5489 }
5490 // Issue the set Context request to LIM to establish the Broadcast STA context
5491 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5492 pSirBssDesc, &BroadcastMac,
5493 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5494 }
5495 else
5496 {
5497 //Need to wait for supplicant authtication
5498 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 //Set the subestate to WaitForKey in case authentiation is needed
5500 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5501
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 if(pProfile->bWPSAssociation)
5503 {
5504 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5505 }
5506 else
5507 {
5508 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5509 }
5510
5511 //Save sessionId in case of timeout
5512 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5513 //This time should be long enough for the rest of the process plus setting key
5514 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5515 {
5516 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005517 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5519 }
5520 }
5521
5522 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5523 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 if(Context)
5525 {
5526 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5527 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5529 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5530#ifdef WLAN_FEATURE_VOWIFI_11R
5531 len += pJoinRsp->parsedRicRspLen;
5532#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005533#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 len += pJoinRsp->tspecIeLen;
5535#endif
5536 if(len)
5537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305538 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5539 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305541 vos_mem_copy(pSession->connectedInfo.pbFrames,
5542 pJoinRsp->frames, len);
5543 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5544 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5545 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005546#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305547 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005549#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305550 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005551#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305552 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5553 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5554 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5555 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 }
5557 }
5558 if(pCommand->u.roamCmd.fReassoc)
5559 {
5560 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5561 }
5562 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5563 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5564 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5565 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305566 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 }
5568 else
5569 {
5570 if(pCommand->u.roamCmd.fReassoc)
5571 {
5572 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5573 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5574 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5575 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5576 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5577 }
5578 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305579 /* Update the staId from the previous connected profile info
5580 as the reassociation is triggred at SME/HDD */
5581 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5582 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5583 {
5584 roamInfo.staId = pSession->connectedInfo.staId;
5585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005586#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5587 // Indicate SME-QOS with reassoc success event, only after
5588 // copying the frames
5589 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5590#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 roamInfo.pBssDesc = pSirBssDesc;
5592 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5593 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5594#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5595 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5596#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5597 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5599 //It may be better to let QoS do this????
5600 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005602 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5604 pmcStartUapsd( pMac, NULL, NULL );
5605 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305606 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5608 if( pSession->bRefAssocStartCnt > 0 )
5609 {
5610 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005611 //Remove this code once SLM_Sessionization is supported
5612 //BMPS_WORKAROUND_NOT_NEEDED
5613 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005614 {
5615 pMac->roam.configParam.doBMPSWorkaround = 1;
5616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5618 }
5619
5620 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 // reset the PMKID candidate list
5622 csrResetPMKIDCandidateList( pMac, sessionId );
5623 //Update TL's AC weight base on the current EDCA parameters
5624 //These parameters may change in the course of the connection, that sictuation
5625 //is not taken care here. This change is mainly to address a WIFI WMM test where
5626 //BE has a equal or higher TX priority than VI.
5627 //We only do this for infra link
5628 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5629 {
5630 csrCheckAndUpdateACWeight(pMac, pIes);
5631 }
5632#ifdef FEATURE_WLAN_WAPI
5633 // reset the BKID candidate list
5634 csrResetBKIDCandidateList( pMac, sessionId );
5635#endif /* FEATURE_WLAN_WAPI */
5636 }
5637 else
5638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005639 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 csrScanCancelIdleScan(pMac);
5642 //Not to signal link up because keys are yet to be set.
5643 //The linkup function will overwrite the sub-state that we need to keep at this point.
5644 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5645 {
5646 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5649 //enough to let security and DHCP handshake succeed before entry into BMPS
5650 if (pmcShouldBmpsTimerRun(pMac))
5651 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305652 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5653 * until keys are set before going into BMPS.
5654 */
5655 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5656 {
5657 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5658 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5659 "to make sure we wait until keys are set before"
5660 " going to BMPS"));
5661 }
5662
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5664 != eHAL_STATUS_SUCCESS)
5665 {
5666 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5667 }
5668 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 break;
5671
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 case eCsrStartBssSuccess:
5673 // on the StartBss Response, LIM is returning the Bss Description that we
5674 // are beaconing. Add this Bss Description to our scan results and
5675 // chain the Profile to this Bss Description. On a Start BSS, there was no
5676 // detected Bss description (no partner) so we issued the Start Bss to
5677 // start the Ibss without any Bss description. Lim was kind enough to return
5678 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005679 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305682 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 if( CSR_IS_IBSS( pProfile ) )
5684 {
5685 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 else if (CSR_IS_INFRA_AP(pProfile))
5688 {
5689 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 else
5692 {
5693 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5694 }
5695 if( !CSR_IS_WDS_STA( pProfile ) )
5696 {
5697 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5700 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305701 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 roamInfo.pBssDesc = pSirBssDesc;
5703 //We need to associate_complete it first, becasue Associate_start already indicated.
5704 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5705 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5706 break;
5707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005710 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 }
5712 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5713 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5714 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5715 if(pSirBssDesc)
5716 {
5717 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305718 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5719 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 }
5721 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305722 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005723#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5724 {
5725 vos_log_ibss_pkt_type *pIbssLog;
5726 tANI_U32 bi;
5727
5728 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5729 if(pIbssLog)
5730 {
5731 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5732 {
5733 //We start the IBSS (didn't find any matched IBSS out there)
5734 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5735 }
5736 else
5737 {
5738 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5739 }
5740 if(pSirBssDesc)
5741 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305742 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5744 }
5745 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5746 {
5747 //***U8 is not enough for beacon interval
5748 pIbssLog->beaconInterval = (v_U8_t)bi;
5749 }
5750 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5751 }
5752 }
5753#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5754 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5755 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5757 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5759 csrRoamIssueSetContextReq( pMac, sessionId,
5760 pProfile->negotiatedMCEncryptionType,
5761 pSirBssDesc, &BroadcastMac,
5762 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5763 }
5764 }
5765 else
5766 {
5767 //Keep the state to eCSR_ROAMING_STATE_JOINING
5768 //Need to send join_req.
5769 if(pCommand->u.roamCmd.pRoamBssEntry)
5770 {
5771 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5772 {
5773 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5774 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5775 // Set the roaming substate to 'join attempt'...
5776 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005777 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 }
5779 }
5780 else
5781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005782 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 VOS_ASSERT( 0 );
5784 }
5785 }
5786 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5787 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5788 //trigger the connection start indication in Vista
5789 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5790 {
5791 roamStatus = eCSR_ROAM_IBSS_IND;
5792 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5793 if( CSR_IS_WDS( pProfile ) )
5794 {
5795 roamStatus = eCSR_ROAM_WDS_IND;
5796 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 if( CSR_IS_INFRA_AP( pProfile ) )
5799 {
5800 roamStatus = eCSR_ROAM_INFRA_IND;
5801 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005803
5804 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5805 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5806 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305807 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5809 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005810 //We start the IBSS (didn't find any matched IBSS out there)
5811 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305813 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5814 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005815 //Remove this code once SLM_Sessionization is supported
5816 //BMPS_WORKAROUND_NOT_NEEDED
5817 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005818 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005819 {
5820 pMac->roam.configParam.doBMPSWorkaround = 1;
5821 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005822
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5824 }
5825
5826 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005827
5828 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 {
5830 //need to send stop BSS because we fail to send join_req
5831 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5832 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5833 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 case eCsrStartBssFailure:
5837#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5838 {
5839 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5841 if(pIbssLog)
5842 {
5843 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5844 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5845 }
5846 }
5847#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 roamStatus = eCSR_ROAM_IBSS_IND;
5849 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5850 if( CSR_IS_WDS( pProfile ) )
5851 {
5852 roamStatus = eCSR_ROAM_WDS_IND;
5853 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 if( CSR_IS_INFRA_AP( pProfile ) )
5856 {
5857 roamStatus = eCSR_ROAM_INFRA_IND;
5858 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 if(Context)
5861 {
5862 pSirBssDesc = (tSirBssDescription *)Context;
5863 }
5864 else
5865 {
5866 pSirBssDesc = NULL;
5867 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305868 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 roamInfo.pBssDesc = pSirBssDesc;
5870 //We need to associate_complete it first, becasue Associate_start already indicated.
5871 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5872 csrSetDefaultDot11Mode( pMac );
5873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 case eCsrSilentlyStopRoaming:
5875 // We are here because we try to start the same IBSS
5876 //No message to PE
5877 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005878 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5880 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305881 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5883 if( roamInfo.pBssDesc )
5884 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305885 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5886 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 }
5888 //Since there is no change in the current state, simply pass back no result otherwise
5889 //HDD may be mistakenly mark to disconnected state.
5890 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5891 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 case eCsrSilentlyStopRoamingSaveState:
5894 //We are here because we try to connect to the same AP
5895 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005896 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305897 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005898
5899 //to aviod resetting the substate to NONE
5900 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5901 //No need to change substate to wai_for_key because there is no state change
5902 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5903 if( roamInfo.pBssDesc )
5904 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305905 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5906 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5909 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5910 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5911 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5912 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5913 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5914 roamInfo.staId = pSession->connectedInfo.staId;
5915 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 pSession->bRefAssocStartCnt--;
5918 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5919 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5920 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5921 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 case eCsrReassocFailure:
5923#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5924 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5925#endif
5926 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005927 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 csrFreeConnectBssDesc(pMac, sessionId);
5929 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5930 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305931 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5933 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5934 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5935 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5936 eCSR_ROAM_WDS_IND,
5937 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5938 //Need to issue stop_bss
5939 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 case eCsrJoinFailure:
5941 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005942 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 default:
5944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005945 smsLog(pMac, LOGW, FL("receives no association indication"));
5946 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005947 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5949 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5950 {
5951 //do not free for the other profiles as we need to send down stop BSS later
5952 csrFreeConnectBssDesc(pMac, sessionId);
5953 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5954 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5955 csrSetDefaultDot11Mode( pMac );
5956 }
5957
5958 switch( pCommand->u.roamCmd.roamReason )
5959 {
5960 // If this transition is because of an 802.11 OID, then we transition
5961 // back to INIT state so we sit waiting for more OIDs to be issued and
5962 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005963 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 case eCsrSmeIssuedAssocToSimilarAP:
5965 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005966 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305968 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5970 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5971 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305972 vos_mem_copy(&roamInfo.bssid,
5973 &pSession->joinFailStatusCode.bssId,
5974 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005975
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 /* Defeaturize this later if needed */
5977#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5978 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5979 if (csrRoamIsHandoffInProgress(pMac))
5980 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 /* Should indicate neighbor roam algorithm about the connect failure here */
5982 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 if(pSession->bRefAssocStartCnt > 0)
5986 {
5987 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005988 if(eCsrJoinFailureDueToConcurrency == Result)
5989 {
5990 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5991 eCSR_ROAM_ASSOCIATION_COMPLETION,
5992 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5993 }
5994 else
5995 {
5996 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 eCSR_ROAM_ASSOCIATION_COMPLETION,
5998 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006001 else
6002 {
6003 /* bRefAssocStartCnt is not incremented when
6004 * eRoamState == eCsrStopRoamingDueToConcurrency
6005 * in csrRoamJoinNextBss API. so handle this in
6006 * else case by sending assoc failure
6007 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006008 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006009 pCommand->u.scanCmd.roamId,
6010 eCSR_ROAM_ASSOCIATION_FAILURE,
6011 eCSR_ROAM_RESULT_FAILURE);
6012 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006013 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006014#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306015 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6017#endif
6018 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6019 csrScanStartIdleScan(pMac);
6020#ifdef FEATURE_WLAN_BTAMP_UT_RF
6021 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6022 //BT activity and not able to recevie WLAN traffic. Retry the join
6023 if( CSR_IS_WDS_STA(pProfile) )
6024 {
6025 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6026 }
6027#endif
6028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 case eCsrHddIssuedReassocToSameAP:
6030 case eCsrSmeIssuedReassocToSameAP:
6031 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6032
6033 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6034#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6035 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6036#endif
6037 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6038 csrScanStartIdleScan(pMac);
6039 break;
6040 case eCsrForcedDisassoc:
6041 case eCsrForcedDeauth:
6042 case eCsrSmeIssuedIbssJoinFailure:
6043 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6044
6045 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6046 {
6047 // Notify HDD that IBSS join failed
6048 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6049 }
6050 else
6051 {
6052 csrRoamCallCallback(pMac, sessionId, NULL,
6053 pCommand->u.roamCmd.roamId,
6054 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6055 }
6056#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6057 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6058#endif
6059 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006060 /*
6061 *DelSta not done FW still in conneced state so dont
6062 *issue IMPS req
6063 */
6064 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6065 {
6066 smsLog(pMac, LOGW, FL("FW still in connected state "));
6067 break;
6068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 csrScanStartIdleScan(pMac);
6070 break;
6071 case eCsrForcedIbssLeave:
6072 csrRoamCallCallback(pMac, sessionId, NULL,
6073 pCommand->u.roamCmd.roamId,
6074 eCSR_ROAM_IBSS_LEAVE,
6075 eCSR_ROAM_RESULT_IBSS_STOP);
6076 break;
6077 case eCsrForcedDisassocMICFailure:
6078 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6079
6080 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6081#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6082 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6083#endif
6084 csrScanStartIdleScan(pMac);
6085 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 case eCsrStopBss:
6087 csrRoamCallCallback(pMac, sessionId, NULL,
6088 pCommand->u.roamCmd.roamId,
6089 eCSR_ROAM_INFRA_IND,
6090 eCSR_ROAM_RESULT_INFRA_STOPPED);
6091 break;
6092 case eCsrForcedDisassocSta:
6093 case eCsrForcedDeauthSta:
6094 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6095 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6096 {
6097 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098
6099 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6100 {
6101 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306102 vos_mem_copy(roamInfo.peerMac,
6103 pCommand->u.roamCmd.peerMac,
6104 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6106 roamInfo.statusCode = eSIR_SME_SUCCESS;
6107 status = csrRoamCallCallback(pMac, sessionId,
6108 &roamInfo, pCommand->u.roamCmd.roamId,
6109 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6110 }
6111 }
6112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 case eCsrLostLink1:
6114 // if lost link roam1 failed, then issue lost link Scan2 ...
6115 csrScanRequestLostLink2(pMac, sessionId);
6116 break;
6117 case eCsrLostLink2:
6118 // if lost link roam2 failed, then issue lost link scan3 ...
6119 csrScanRequestLostLink3(pMac, sessionId);
6120 break;
6121 case eCsrLostLink3:
6122 default:
6123 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6124
6125 //We are done with one round of lostlink roaming here
6126 csrScanHandleFailedLostlink3(pMac, sessionId);
6127 break;
6128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 break;
6130 }
6131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 return ( fReleaseCommand );
6133}
6134
Jeff Johnson295189b2012-06-20 16:38:30 -07006135eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6136{
6137 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 return (status);
6139}
6140
Jeff Johnson295189b2012-06-20 16:38:30 -07006141eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6142{
6143 eHalStatus status = eHAL_STATUS_SUCCESS;
6144 tANI_U32 size = 0;
6145
6146 do
6147 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306148 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6150 {
6151 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306152 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6153 if ( NULL == pDstProfile->BSSIDs.bssid )
6154 status = eHAL_STATUS_FAILURE;
6155 else
6156 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 if(!HAL_STATUS_SUCCESS(status))
6158 {
6159 break;
6160 }
6161 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306162 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6163 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 }
6165 if(pSrcProfile->SSIDs.numOfSSIDs)
6166 {
6167 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306168 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6169 if ( NULL == pDstProfile->SSIDs.SSIDList )
6170 status = eHAL_STATUS_FAILURE;
6171 else
6172 status = eHAL_STATUS_SUCCESS;
6173 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 {
6175 break;
6176 }
6177 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306178 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6179 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 }
6181 if(pSrcProfile->nWPAReqIELength)
6182 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306183 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6184 if ( NULL == pDstProfile->pWPAReqIE )
6185 status = eHAL_STATUS_FAILURE;
6186 else
6187 status = eHAL_STATUS_SUCCESS;
6188
6189 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 {
6191 break;
6192 }
6193 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306194 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6195 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 }
6197 if(pSrcProfile->nRSNReqIELength)
6198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306199 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6200 if ( NULL == pDstProfile->pRSNReqIE )
6201 status = eHAL_STATUS_FAILURE;
6202 else
6203 status = eHAL_STATUS_SUCCESS;
6204
6205 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 {
6207 break;
6208 }
6209 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306210 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6211 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 }
6213#ifdef FEATURE_WLAN_WAPI
6214 if(pSrcProfile->nWAPIReqIELength)
6215 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306216 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6217 if ( NULL == pDstProfile->pWAPIReqIE )
6218 status = eHAL_STATUS_FAILURE;
6219 else
6220 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 if(!HAL_STATUS_SUCCESS(status))
6222 {
6223 break;
6224 }
6225 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306226 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6227 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
6229#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 if(pSrcProfile->nAddIEScanLength)
6231 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306232 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6233 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306235 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306236 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306237 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6238 }
6239 else
6240 {
6241 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6242 FL(" AddIEScanLength is not valid %u"),
6243 pSrcProfile->nAddIEScanLength);
6244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 if(pSrcProfile->nAddIEAssocLength)
6247 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306248 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6249 if ( NULL == pDstProfile->pAddIEAssoc )
6250 status = eHAL_STATUS_FAILURE;
6251 else
6252 status = eHAL_STATUS_SUCCESS;
6253
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 if(!HAL_STATUS_SUCCESS(status))
6255 {
6256 break;
6257 }
6258 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306259 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6260 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 if(pSrcProfile->ChannelInfo.ChannelList)
6263 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306264 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6265 pSrcProfile->ChannelInfo.numOfChannels);
6266 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6267 status = eHAL_STATUS_FAILURE;
6268 else
6269 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 if(!HAL_STATUS_SUCCESS(status))
6271 {
6272 break;
6273 }
6274 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306275 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6276 pSrcProfile->ChannelInfo.ChannelList,
6277 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 pDstProfile->AuthType = pSrcProfile->AuthType;
6280 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6281 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6282 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6283 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6284 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006285#ifdef WLAN_FEATURE_11W
6286 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6287 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6288 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 pDstProfile->BSSType = pSrcProfile->BSSType;
6291 pDstProfile->phyMode = pSrcProfile->phyMode;
6292 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6293
6294#ifdef FEATURE_WLAN_WAPI
6295 if(csrIsProfileWapi(pSrcProfile))
6296 {
6297 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6298 {
6299 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6300 }
6301 }
6302#endif /* FEATURE_WLAN_WAPI */
6303 pDstProfile->CBMode = pSrcProfile->CBMode;
6304 /*Save the WPS info*/
6305 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006306 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 pDstProfile->privacy = pSrcProfile->privacy;
6310 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6311 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6312 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6313 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6314 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6315 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6316 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6317 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6318 pDstProfile->wps_state = pSrcProfile->wps_state;
6319 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306320 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6321 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006322#ifdef WLAN_FEATURE_VOWIFI_11R
6323 if (pSrcProfile->MDID.mdiePresent)
6324 {
6325 pDstProfile->MDID.mdiePresent = 1;
6326 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6327 }
6328#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 }while(0);
6330
6331 if(!HAL_STATUS_SUCCESS(status))
6332 {
6333 csrReleaseProfile(pMac, pDstProfile);
6334 pDstProfile = NULL;
6335 }
6336
6337 return (status);
6338}
Jeff Johnson295189b2012-06-20 16:38:30 -07006339eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6340{
6341 eHalStatus status = eHAL_STATUS_SUCCESS;
6342 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6343 do
6344 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306345 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 if(pSrcProfile->bssid)
6347 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306348 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6349 if ( NULL == pDstProfile->BSSIDs.bssid )
6350 status = eHAL_STATUS_FAILURE;
6351 else
6352 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 if(!HAL_STATUS_SUCCESS(status))
6354 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306355 smsLog( pMac, LOGE,
6356 FL("failed to allocate memory for BSSID"
6357 "%02x:%02x:%02x:%02x:%02x:%02x"),
6358 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6359 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 break;
6361 }
6362 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306363 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6364 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 }
6366 if(pSrcProfile->SSID.ssId)
6367 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306368 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6369 if ( NULL == pDstProfile->SSIDs.SSIDList )
6370 status = eHAL_STATUS_FAILURE;
6371 else
6372 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 if(!HAL_STATUS_SUCCESS(status))
6374 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306375 smsLog( pMac, LOGE,
6376 FL("failed to allocate memory for SSIDList"
6377 "%02x:%02x:%02x:%02x:%02x:%02x"),
6378 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6379 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 break;
6381 }
6382 pDstProfile->SSIDs.numOfSSIDs = 1;
6383 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6384 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306385 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6386 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006388 if(pSrcProfile->nAddIEAssocLength)
6389 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306390 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6391 if ( NULL == pDstProfile->pAddIEAssoc)
6392 status = eHAL_STATUS_FAILURE;
6393 else
6394 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006395 if(!HAL_STATUS_SUCCESS(status))
6396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006397 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006398 break;
6399 }
6400 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306401 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6402 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006403 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306404 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6405 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6406 status = eHAL_STATUS_FAILURE;
6407 else
6408 status = eHAL_STATUS_SUCCESS;
6409
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 if(!HAL_STATUS_SUCCESS(status))
6411 {
6412 break;
6413 }
6414 pDstProfile->ChannelInfo.numOfChannels = 1;
6415 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 pDstProfile->AuthType.numEntries = 1;
6417 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6418 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6419 pDstProfile->EncryptionType.numEntries = 1;
6420 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6421 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6422 pDstProfile->mcEncryptionType.numEntries = 1;
6423 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6424 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6425 pDstProfile->BSSType = pSrcProfile->BSSType;
6426 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306427 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6428 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306429#ifdef WLAN_FEATURE_11W
6430 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6431 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6432 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6433#endif
6434
Jeff Johnson295189b2012-06-20 16:38:30 -07006435#ifdef WLAN_FEATURE_VOWIFI_11R
6436 if (pSrcProfile->MDID.mdiePresent)
6437 {
6438 pDstProfile->MDID.mdiePresent = 1;
6439 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6440 }
6441#endif
6442
6443 }while(0);
6444
6445 if(!HAL_STATUS_SUCCESS(status))
6446 {
6447 csrReleaseProfile(pMac, pDstProfile);
6448 pDstProfile = NULL;
6449 }
6450
6451 return (status);
6452}
6453
Jeff Johnson295189b2012-06-20 16:38:30 -07006454eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6455 tScanResultHandle hBSSList,
6456 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6457 tANI_BOOLEAN fClearScan)
6458{
6459 eHalStatus status = eHAL_STATUS_SUCCESS;
6460 tSmeCmd *pCommand;
6461
6462 pCommand = csrGetCommandBuffer(pMac);
6463 if(NULL == pCommand)
6464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006465 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 status = eHAL_STATUS_RESOURCES;
6467 }
6468 else
6469 {
6470 if( fClearScan )
6471 {
6472 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306473 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 }
6475 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6476 if(NULL == pProfile)
6477 {
6478 //We can roam now
6479 //Since pProfile is NULL, we need to build our own profile, set everything to default
6480 //We can only support open and no encryption
6481 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6482 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6483 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6484 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6485 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6486 }
6487 else
6488 {
6489 //make a copy of the profile
6490 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6491 if(HAL_STATUS_SUCCESS(status))
6492 {
6493 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6494 }
6495 }
6496 pCommand->command = eSmeCommandRoam;
6497 pCommand->sessionId = (tANI_U8)sessionId;
6498 pCommand->u.roamCmd.hBSSList = hBSSList;
6499 pCommand->u.roamCmd.roamId = roamId;
6500 pCommand->u.roamCmd.roamReason = reason;
6501 //We need to free the BssList when the command is done
6502 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6503 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6505 FL("CSR PERSONA=%d"),
6506 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6508 if( !HAL_STATUS_SUCCESS( status ) )
6509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006510 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 csrReleaseCommandRoam( pMac, pCommand );
6512 }
6513 }
6514
6515 return (status);
6516}
Jeff Johnson295189b2012-06-20 16:38:30 -07006517eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6518 tCsrRoamModifyProfileFields *pMmodProfileFields,
6519 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6520{
6521 eHalStatus status = eHAL_STATUS_SUCCESS;
6522 tSmeCmd *pCommand;
6523
6524 pCommand = csrGetCommandBuffer(pMac);
6525 if(NULL == pCommand)
6526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006527 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 status = eHAL_STATUS_RESOURCES;
6529 }
6530 else
6531 {
6532 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306533 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 if(pProfile)
6535 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 //This is likely trying to reassoc to different profile
6537 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6538 //make a copy of the profile
6539 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6540 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 }
6542 else
6543 {
6544 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6545 //how to update WPA/WPA2 info in roamProfile??
6546 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 if(HAL_STATUS_SUCCESS(status))
6549 {
6550 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6551 }
6552 pCommand->command = eSmeCommandRoam;
6553 pCommand->sessionId = (tANI_U8)sessionId;
6554 pCommand->u.roamCmd.roamId = roamId;
6555 pCommand->u.roamCmd.roamReason = reason;
6556 //We need to free the BssList when the command is done
6557 //For reassoc there is no BSS list, so the boolean set to false
6558 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6559 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6560 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6562 if( !HAL_STATUS_SUCCESS( status ) )
6563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006564 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6566 csrReleaseCommandRoam( pMac, pCommand );
6567 }
6568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 return (status);
6570}
6571
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006572eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6573 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306574// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006575{
6576 eHalStatus status = eHAL_STATUS_SUCCESS;
6577 tSmeCmd *pCommand;
6578
6579 pCommand = csrGetCommandBuffer(pMac);
6580 if(NULL == pCommand)
6581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006582 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006583 status = eHAL_STATUS_RESOURCES;
6584 }
6585 else
6586 {
6587 if(pBssDescription)
6588 {
6589 //copy over the parameters we need later
6590 pCommand->command = eSmeCommandRoam;
6591 pCommand->sessionId = (tANI_U8)sessionId;
6592 pCommand->u.roamCmd.roamReason = reason;
6593 //this is the important parameter
6594 //in this case we are using this field for the "next" BSS
6595 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6596 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6597 if( !HAL_STATUS_SUCCESS( status ) )
6598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006599 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006600 csrReleaseCommandPreauth( pMac, pCommand );
6601 }
6602 }
6603 else
6604 {
6605 //Return failure
6606 status = eHAL_STATUS_RESOURCES;
6607 }
6608 }
6609 return (status);
6610}
6611
6612eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6613{
6614 tListElem *pEntry;
6615 tSmeCmd *pCommand;
6616 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6617 if ( pEntry )
6618 {
6619 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6620 if ( (eSmeCommandRoam == pCommand->command) &&
6621 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6622 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006623 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006624 pCommand->command, pCommand->u.roamCmd.roamReason);
6625 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6626 csrReleaseCommandPreauth( pMac, pCommand );
6627 }
6628 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006629 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006630 pCommand->command, pCommand->u.roamCmd.roamReason);
6631 }
6632 }
6633 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006634 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006635 }
6636 smeProcessPendingQueue( pMac );
6637 return eHAL_STATUS_SUCCESS;
6638}
6639
Jeff Johnson295189b2012-06-20 16:38:30 -07006640eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6641 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6642{
6643 eHalStatus status = eHAL_STATUS_FAILURE;
6644 tScanResultHandle hBSSList;
6645 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6647 if(HAL_STATUS_SUCCESS(status))
6648 {
6649 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6650 if(pRoamId)
6651 {
6652 *pRoamId = roamId;
6653 }
6654 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6655 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6656 if(!HAL_STATUS_SUCCESS(status))
6657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006658 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 csrScanResultPurge(pMac, hBSSList);
6660 }
6661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 return (status);
6663}
6664
Jeff Johnson295189b2012-06-20 16:38:30 -07006665eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6666 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6667{
6668 eHalStatus status = eHAL_STATUS_SUCCESS;
6669 tScanResultHandle hBSSList;
6670 tCsrScanResultFilter *pScanFilter;
6671 tANI_U32 roamId = 0;
6672 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6673 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 if (NULL == pProfile)
6675 {
6676 smsLog(pMac, LOGP, FL("No profile specified"));
6677 return eHAL_STATUS_FAILURE;
6678 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306679 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6680 "encryType = %d"),
6681 lim_BssTypetoString(pProfile->BSSType),
6682 pProfile->BSSType,
6683 pProfile->AuthType.authType[0],
6684 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 if( CSR_IS_WDS( pProfile ) &&
6686 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006688 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006689 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 return status;
6691 }
6692 csrRoamCancelRoaming(pMac, sessionId);
6693 csrScanRemoveFreshScanCommand(pMac, sessionId);
6694 csrScanCancelIdleScan(pMac);
6695 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306696 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306697
6698 if (!vos_concurrent_open_sessions_running() &&
6699 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306701 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 csrScanDisable(pMac);
6703 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306704
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6706 //Check whether ssid changes
6707 if(csrIsConnStateConnected(pMac, sessionId))
6708 {
6709 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6710 {
6711 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6712 }
6713 }
6714#ifdef FEATURE_WLAN_BTAMP_UT_RF
6715 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6716#endif
6717 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006719 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6721 if(pRoamId)
6722 {
6723 roamId = *pRoamId;
6724 }
6725 if(!HAL_STATUS_SUCCESS(status))
6726 {
6727 fCallCallback = eANI_BOOLEAN_TRUE;
6728 }
6729 }
6730 else
6731 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306732 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6733 if ( NULL == pScanFilter )
6734 status = eHAL_STATUS_FAILURE;
6735 else
6736 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 if(HAL_STATUS_SUCCESS(status))
6738 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306739 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 //Try to connect to any BSS
6741 if(NULL == pProfile)
6742 {
6743 //No encryption
6744 pScanFilter->EncryptionType.numEntries = 1;
6745 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6746 }//we don't have a profile
6747 else
6748 {
6749 //Here is the profile we need to connect to
6750 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6751 }//We have a profile
6752 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6753 if(pRoamId)
6754 {
6755 *pRoamId = roamId;
6756 }
6757
6758 if(HAL_STATUS_SUCCESS(status))
6759 {
6760 /*Save the WPS info*/
6761 if(NULL != pProfile)
6762 {
6763 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006764 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 }
6766 else
6767 {
6768 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006769 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 do
6772 {
6773 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 )
6776 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006777 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6779 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6780 if(!HAL_STATUS_SUCCESS(status))
6781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006782 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 fCallCallback = eANI_BOOLEAN_TRUE;
6784 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006785 else
6786 {
6787 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 break;
6790 }
6791 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006792 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 if(HAL_STATUS_SUCCESS(status))
6794 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006795 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6796 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6797 if(!HAL_STATUS_SUCCESS(status))
6798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006799 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 csrScanResultPurge(pMac, hBSSList);
6801 fCallCallback = eANI_BOOLEAN_TRUE;
6802 }
6803 }//Have scan result
6804 else if(NULL != pProfile)
6805 {
6806 //Check whether it is for start ibss
6807 if(CSR_IS_START_IBSS(pProfile))
6808 {
6809 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6810 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6811 if(!HAL_STATUS_SUCCESS(status))
6812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006813 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 fCallCallback = eANI_BOOLEAN_TRUE;
6815 }
6816 }
6817 else
6818 {
6819 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006820 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 if(!HAL_STATUS_SUCCESS(status))
6822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006823 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 fCallCallback = eANI_BOOLEAN_TRUE;
6825 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006826 else
6827 {
6828 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 }
6831 }
6832 else
6833 {
6834 fCallCallback = eANI_BOOLEAN_TRUE;
6835 }
6836 } while (0);
6837 if(NULL != pProfile)
6838 {
6839 //we need to free memory for filter if profile exists
6840 csrFreeScanFilter(pMac, pScanFilter);
6841 }
6842 }//Got the scan filter from profile
6843
Kiet Lam64c1b492013-07-12 13:56:44 +05306844 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 }//allocated memory for pScanFilter
6846 }//No Bsslist coming in
6847 //tell the caller if we fail to trigger a join request
6848 if( fCallCallback )
6849 {
6850 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6851 }
6852
6853 return (status);
6854}
Jeff Johnson295189b2012-06-20 16:38:30 -07006855eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6856 tCsrRoamModifyProfileFields modProfileFields,
6857 tANI_U32 *pRoamId)
6858{
6859 eHalStatus status = eHAL_STATUS_SUCCESS;
6860 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6861 tANI_U32 roamId = 0;
6862 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 if (NULL == pProfile)
6864 {
6865 smsLog(pMac, LOGP, FL("No profile specified"));
6866 return eHAL_STATUS_FAILURE;
6867 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306868 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6869 "encryType = %d"),
6870 lim_BssTypetoString(pProfile->BSSType),
6871 pProfile->BSSType,
6872 pProfile->AuthType.authType[0],
6873 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 csrRoamCancelRoaming(pMac, sessionId);
6875 csrScanRemoveFreshScanCommand(pMac, sessionId);
6876 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306877 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 if(csrIsConnStateConnected(pMac, sessionId))
6880 {
6881 if(pProfile)
6882 {
6883 if(pProfile->SSIDs.numOfSSIDs &&
6884 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6885 {
6886 fCallCallback = eANI_BOOLEAN_FALSE;
6887 }
6888 else
6889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006890 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 }
6892 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306893 else if (!vos_mem_compare(&modProfileFields,
6894 &pSession->connectedProfile.modifyProfileFields,
6895 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 {
6897 fCallCallback = eANI_BOOLEAN_FALSE;
6898 }
6899 else
6900 {
6901 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006902 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 }
6904 }
6905 else
6906 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006907 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 if(!fCallCallback)
6910 {
6911 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6912 if(pRoamId)
6913 {
6914 *pRoamId = roamId;
6915 }
6916
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6918 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 }
6920 else
6921 {
6922 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6923 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 return status;
6926}
Jeff Johnson295189b2012-06-20 16:38:30 -07006927eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6928{
6929 eHalStatus status = eHAL_STATUS_FAILURE;
6930 tScanResultHandle hBSSList = NULL;
6931 tCsrScanResultFilter *pScanFilter = NULL;
6932 tANI_U32 roamId;
6933 tCsrRoamProfile *pProfile = NULL;
6934 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006935
6936 if(!pSession)
6937 {
6938 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6939 return eHAL_STATUS_FAILURE;
6940 }
6941
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 do
6943 {
6944 if(pSession->pCurRoamProfile)
6945 {
6946 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306947 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306949 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6950 if ( NULL == pProfile )
6951 status = eHAL_STATUS_FAILURE;
6952 else
6953 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 if(!HAL_STATUS_SUCCESS(status))
6955 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306956 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306958 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306960 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6961 if ( NULL == pScanFilter )
6962 status = eHAL_STATUS_FAILURE;
6963 else
6964 status = eHAL_STATUS_SUCCESS;
6965
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 if(!HAL_STATUS_SUCCESS(status))
6967 {
6968 break;
6969 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306970 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6972 if(!HAL_STATUS_SUCCESS(status))
6973 {
6974 break;
6975 }
6976 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6977 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6978 if(HAL_STATUS_SUCCESS(status))
6979 {
6980 //we want to put the last connected BSS to the very beginning, if possible
6981 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6982 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6983 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6984 if(!HAL_STATUS_SUCCESS(status))
6985 {
6986 csrScanResultPurge(pMac, hBSSList);
6987 break;
6988 }
6989 }
6990 else
6991 {
6992 //Do a scan on this profile
6993 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006994 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 if(!HAL_STATUS_SUCCESS(status))
6996 {
6997 break;
6998 }
6999 }
7000 }//We have a profile
7001 else
7002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007003 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 break;
7005 }
7006 }while(0);
7007 if(pScanFilter)
7008 {
7009 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307010 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 }
7012 if(NULL != pProfile)
7013 {
7014 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307015 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 return (status);
7018}
Jeff Johnson295189b2012-06-20 16:38:30 -07007019eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7020{
7021 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 if(csrIsConnStateConnected(pMac, sessionId))
7023 {
7024 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7025 if(HAL_STATUS_SUCCESS(status))
7026 {
7027 status = csrRoamJoinLastProfile(pMac, sessionId);
7028 }
7029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 return (status);
7031}
7032
Jeff Johnson295189b2012-06-20 16:38:30 -07007033eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7034{
7035 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007036 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 csrRoamCancelRoaming(pMac, sessionId);
7038 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7039 if(csrIsConnStateDisconnected(pMac, sessionId))
7040 {
7041 status = csrRoamJoinLastProfile(pMac, sessionId);
7042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 return (status);
7044}
7045
Jeff Johnson295189b2012-06-20 16:38:30 -07007046eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7047{
7048 eHalStatus status = eHAL_STATUS_SUCCESS;
7049 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7050 eCsrRoamSubState NewSubstate;
7051 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307052
7053 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7054 {
7055 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7056 " eCSR_ROAM_SUBSTATE_NONE"));
7057 csrRoamStopWaitForKeyTimer( pMac );
7058 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 // change state to 'Roaming'...
7061 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7062
7063 if ( csrIsConnStateIbss( pMac, sessionId ) )
7064 {
7065 // If we are in an IBSS, then stop the IBSS...
7066 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7067 fComplete = (!HAL_STATUS_SUCCESS(status));
7068 }
7069 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7070 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007071 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 -07007072 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7073 //Restore AC weight in case we change it
7074 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7075 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7076 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7077 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7078 {
7079 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7080 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307081 else
7082 {
7083 // If we are in neighbor preauth done state then on receiving
7084 // disassoc or deauth we dont roam instead we just disassoc
7085 // from current ap and then go to disconnected state
7086 // This happens for ESE and 11r FT connections ONLY.
7087#ifdef WLAN_FEATURE_VOWIFI_11R
7088 if (csrRoamIs11rAssoc(pMac) &&
7089 (csrNeighborRoamStatePreauthDone(pMac)))
7090 {
7091 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7092 }
7093#endif
7094#ifdef FEATURE_WLAN_ESE
7095 if (csrRoamIsESEAssoc(pMac) &&
7096 (csrNeighborRoamStatePreauthDone(pMac)))
7097 {
7098 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7099 }
7100#endif
7101#ifdef FEATURE_WLAN_LFR
7102 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7103 (csrNeighborRoamStatePreauthDone(pMac)))
7104 {
7105 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7106 }
7107#endif
7108 }
7109
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 if( fDisassoc )
7111 {
7112 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307113#ifdef DEBUG_ROAM_DELAY
7114 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7115#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 }
7117 else
7118 {
7119 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7120 }
7121 fComplete = (!HAL_STATUS_SUCCESS(status));
7122 }
7123 else if ( csrIsConnStateWds( pMac, sessionId ) )
7124 {
7125 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7126 {
7127 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7128 fComplete = (!HAL_STATUS_SUCCESS(status));
7129 }
7130 //This has to be WDS station
7131 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7132 {
7133
7134 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7135 if( fDisassoc )
7136 {
7137 status = csrRoamIssueDisassociate( pMac, sessionId,
7138 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7139 fComplete = (!HAL_STATUS_SUCCESS(status));
7140 }
7141 }
7142 } else {
7143 // we got a dis-assoc request while not connected to any peer
7144 // just complete the command
7145 fComplete = eANI_BOOLEAN_TRUE;
7146 status = eHAL_STATUS_FAILURE;
7147 }
7148 if(fComplete)
7149 {
7150 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7151 }
7152
7153 if(HAL_STATUS_SUCCESS(status))
7154 {
7155 if ( csrIsConnStateInfra( pMac, sessionId ) )
7156 {
7157 //Set the state to disconnect here
7158 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307159#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7160 //we don't need to run this timer any more
7161 if (VOS_TIMER_STATE_RUNNING ==
7162 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7163 {
7164 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7165 if (status != eHAL_STATUS_SUCCESS)
7166 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7167 }
7168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 }
7170 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007171 else
7172 {
7173 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 return (status);
7176}
7177
Jeff Johnson295189b2012-06-20 16:38:30 -07007178/* This is been removed from latest code base */
7179/*
7180static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7181{
7182 eHalStatus status;
7183 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7185 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 return ( status );
7187}
7188*/
7189
Jeff Johnson295189b2012-06-20 16:38:30 -07007190eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7191{
7192 eHalStatus status = eHAL_STATUS_SUCCESS;
7193 tSmeCmd *pCommand;
7194 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 do
7196 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 pCommand = csrGetCommandBuffer( pMac );
7198 if ( !pCommand )
7199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007200 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 status = eHAL_STATUS_RESOURCES;
7202 break;
7203 }
7204 //Change the substate in case it is wait-for-key
7205 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7206 {
7207 csrRoamStopWaitForKeyTimer( pMac );
7208 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7209 }
7210 pCommand->command = eSmeCommandRoam;
7211 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307212 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7213 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 switch ( reason )
7215 {
7216 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7217 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7218 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 case eCSR_DISCONNECT_REASON_DEAUTH:
7220 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 case eCSR_DISCONNECT_REASON_HANDOFF:
7223 fHighPriority = eANI_BOOLEAN_TRUE;
7224 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7225 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7227 case eCSR_DISCONNECT_REASON_DISASSOC:
7228 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7229 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7231 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7232 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7234 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7235 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 default:
7237 break;
7238 }
7239 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7240 if( !HAL_STATUS_SUCCESS( status ) )
7241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007242 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 csrReleaseCommandRoam( pMac, pCommand );
7244 }
7245 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 return( status );
7247}
7248
Jeff Johnson295189b2012-06-20 16:38:30 -07007249eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7250{
7251 eHalStatus status = eHAL_STATUS_SUCCESS;
7252 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 pCommand = csrGetCommandBuffer( pMac );
7254 if ( NULL != pCommand )
7255 {
7256 //Change the substate in case it is wait-for-key
7257 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7258 {
7259 csrRoamStopWaitForKeyTimer( pMac );
7260 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7261 }
7262 pCommand->command = eSmeCommandRoam;
7263 pCommand->sessionId = (tANI_U8)sessionId;
7264 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7265 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7266 if( !HAL_STATUS_SUCCESS( status ) )
7267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007268 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 csrReleaseCommandRoam( pMac, pCommand );
7270 }
7271 }
7272 else
7273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007274 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 status = eHAL_STATUS_RESOURCES;
7276 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 return ( status );
7278}
7279
Jeff Johnson295189b2012-06-20 16:38:30 -07007280eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7281{
7282 eHalStatus status = eHAL_STATUS_SUCCESS;
7283 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007284
7285 if(!pSession)
7286 {
7287 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7288 return eHAL_STATUS_FAILURE;
7289 }
7290
Jeff Johnson295189b2012-06-20 16:38:30 -07007291#ifdef FEATURE_WLAN_BTAMP_UT_RF
7292 //Stop te retry
7293 pSession->maxRetryCount = 0;
7294 csrRoamStopJoinRetryTimer(pMac, sessionId);
7295#endif
7296 //Not to call cancel roaming here
7297 //Only issue disconnect when necessary
7298 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7299 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7300 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7301
7302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007303 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7305 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307306 else
7307 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307308 csrScanAbortScanForSSID(pMac, sessionId);
7309 status = eHAL_STATUS_CMD_NOT_QUEUED;
7310 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7311 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 return (status);
7314}
7315
Jeff Johnson295189b2012-06-20 16:38:30 -07007316eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7317{
7318 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007319
7320 if(!pSession)
7321 {
7322 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7323 return eHAL_STATUS_FAILURE;
7324 }
7325
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7328
7329 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7330}
7331
Jeff Johnson295189b2012-06-20 16:38:30 -07007332eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7333 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7334{
7335 eHalStatus status = eHAL_STATUS_SUCCESS;
7336 tDot11fBeaconIEs *pIesTemp = pIes;
7337 tANI_U8 index;
7338 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7339 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007340
7341 if(!pSession)
7342 {
7343 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7344 return eHAL_STATUS_FAILURE;
7345 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007346 if(pConnectProfile->pAddIEAssoc)
7347 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307348 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007349 pConnectProfile->pAddIEAssoc = NULL;
7350 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307351 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7353 pConnectProfile->AuthInfo = pProfile->AuthType;
7354 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7355 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7356 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7357 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7358 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7359 pConnectProfile->BSSType = pProfile->BSSType;
7360 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7361 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007362 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307363 if (!pConnectProfile->beaconInterval)
7364 {
7365 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7366 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307367 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007368 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7369 if(pProfile->nAddIEAssocLength)
7370 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307371 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7372 if ( NULL == pConnectProfile->pAddIEAssoc )
7373 status = eHAL_STATUS_FAILURE;
7374 else
7375 status = eHAL_STATUS_SUCCESS;
7376 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007377 {
7378 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7379 return eHAL_STATUS_FAILURE;
7380 }
7381 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307382 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7383 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007384 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307385
7386#ifdef WLAN_FEATURE_11W
7387 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7388 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7389 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7390#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007391
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 //Save bssid
7393 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7394#ifdef WLAN_FEATURE_VOWIFI_11R
7395 if (pSirBssDesc->mdiePresent)
7396 {
7397 pConnectProfile->MDID.mdiePresent = 1;
7398 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7399 }
7400#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007401 if( NULL == pIesTemp )
7402 {
7403 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7404 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007405#ifdef FEATURE_WLAN_ESE
7406 if ((csrIsProfileESE(pProfile) ||
7407 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307408 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7409 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7410 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7411 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7412#ifdef WLAN_FEATURE_11W
7413 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307414 || (pProfile->negotiatedAuthType ==
7415 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307416#endif
7417 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007418 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007420 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 }
7422#endif
7423 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 if(HAL_STATUS_SUCCESS(status))
7425 {
7426 if(pIesTemp->SSID.present)
7427 {
7428 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307429 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7430 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 }
7432
7433 //Save the bss desc
7434 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307435
7436 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307438 //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 -07007439 pConnectProfile->qap = TRUE;
7440 }
7441 else
7442 {
7443 pConnectProfile->qap = FALSE;
7444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 if ( NULL == pIes )
7446 {
7447 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307448 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 }
7450 }
7451 //Save Qos connection
7452 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7453
7454 if(!HAL_STATUS_SUCCESS(status))
7455 {
7456 csrFreeConnectBssDesc(pMac, sessionId);
7457 }
7458 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7459 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307460 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7461 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7462 pConnectProfile->SSID.ssId,
7463 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 {
7465 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7466 break;
7467 }
7468 pConnectProfile->handoffPermitted = FALSE;
7469 }
7470
7471 return (status);
7472}
7473
Jeff Johnson295189b2012-06-20 16:38:30 -07007474static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7475{
7476 tListElem *pEntry = NULL;
7477 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 //The head of the active list is the request we sent
7479 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7480 if(pEntry)
7481 {
7482 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7485 {
7486 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7487 {
7488#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7489 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7490#endif
7491 }
7492 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7493 }
7494 else
7495 {
7496 tANI_U32 roamId = 0;
7497 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007498 if(!pSession)
7499 {
7500 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7501 return;
7502 }
7503
Jeff Johnson295189b2012-06-20 16:38:30 -07007504
7505 //The head of the active list is the request we sent
7506 //Try to get back the same profile and roam again
7507 if(pCommand)
7508 {
7509 roamId = pCommand->u.roamCmd.roamId;
7510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7512 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007513 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007514#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7515 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7516 if (csrRoamIsHandoffInProgress(pMac))
7517 {
7518 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7519 /* Should indicate neighbor roam algorithm about the connect failure here */
7520 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7521 }
7522#endif
7523 if (pCommand)
7524 {
7525 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7526 {
7527 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7528 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7529 csrRoamReissueRoamCommand(pMac);
7530 }
7531 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7532 {
7533 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7534 }
7535 else
7536 {
7537 csrRoam(pMac, pCommand);
7538 }
7539 }
7540 else
7541 {
7542 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7543 }
7544 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7545}
7546
Jeff Johnson295189b2012-06-20 16:38:30 -07007547eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7548 tDot11fBeaconIEs *pIes,
7549 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7550{
7551 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007552 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7553 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007554
7555 // Set the roaming substate to 'join attempt'...
7556 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007558 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 return (status);
7560}
7561
Jeff Johnson295189b2012-06-20 16:38:30 -07007562static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7563 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7564{
7565 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 // Set the roaming substate to 'join attempt'...
7567 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7568
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307569 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7570 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307571#ifdef DEBUG_ROAM_DELAY
7572 //HACK usign buff len as Auth type
7573 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7574 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007577 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007578}
7579
Jeff Johnson295189b2012-06-20 16:38:30 -07007580void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7581{
7582 tListElem *pEntry;
7583 tSmeCmd *pCommand;
7584 tCsrRoamInfo roamInfo;
7585 tANI_U32 sessionId;
7586 tCsrRoamSession *pSession;
7587
7588 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7589 if(pEntry)
7590 {
7591 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7592 if ( eSmeCommandRoam == pCommand->command )
7593 {
7594 sessionId = pCommand->sessionId;
7595 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007596
7597 if(!pSession)
7598 {
7599 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7600 return;
7601 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307602 /* While switching between two AP, csr will reissue roam command again
7603 to the nextbss if it was interrupted by the dissconnect req for the
7604 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7605 so reset the bRefAssocStartCnt.
7606 */
7607 if(pSession->bRefAssocStartCnt > 0)
7608 {
7609 pSession->bRefAssocStartCnt--;
7610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007611 if( pCommand->u.roamCmd.fStopWds )
7612 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307613 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7615 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7616 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7619 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7620 eCSR_ROAM_WDS_IND,
7621 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7623 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7624 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7625 eCSR_ROAM_INFRA_IND,
7626 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7627 }
7628
Jeff Johnson295189b2012-06-20 16:38:30 -07007629
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7631 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007632 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7634 }
7635 }
7636 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007638 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007639 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7640 }
7641 }
7642 else
7643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007644 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 }
7646 }
7647 else
7648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007649 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 }
7651}
7652
Jeff Johnson295189b2012-06-20 16:38:30 -07007653tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7654{
7655 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7656 tListElem *pEntry;
7657 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 //alwasy lock active list before locking pending list
7659 csrLLLock( &pMac->sme.smeCmdActiveList );
7660 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7661 if(pEntry)
7662 {
7663 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7664 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7665 {
7666 fRet = eANI_BOOLEAN_TRUE;
7667 }
7668 }
7669 if(eANI_BOOLEAN_FALSE == fRet)
7670 {
7671 csrLLLock(&pMac->sme.smeCmdPendingList);
7672 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7673 while(pEntry)
7674 {
7675 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7676 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7677 {
7678 fRet = eANI_BOOLEAN_TRUE;
7679 break;
7680 }
7681 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7682 }
7683 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7684 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307685 if (eANI_BOOLEAN_FALSE == fRet)
7686 {
7687 csrLLLock(&pMac->roam.roamCmdPendingList);
7688 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7689 while (pEntry)
7690 {
7691 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7692 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7693 {
7694 fRet = eANI_BOOLEAN_TRUE;
7695 break;
7696 }
7697 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7698 }
7699 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 return (fRet);
7703}
7704
Jeff Johnson295189b2012-06-20 16:38:30 -07007705tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7706{
7707 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7708 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7710 {
7711 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7712 {
7713 break;
7714 }
7715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 return ( fRet );
7717}
7718
Jeff Johnson295189b2012-06-20 16:38:30 -07007719tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7720{
7721 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 //alwasy lock active list before locking pending list
7723 csrLLLock( &pMac->sme.smeCmdActiveList );
7724 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7725 if(eANI_BOOLEAN_FALSE == fRet)
7726 {
7727 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7728 }
7729 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 return (fRet);
7731}
7732
Jeff Johnson295189b2012-06-20 16:38:30 -07007733tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7734{
7735 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7736 tListElem *pEntry;
7737 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 //alwasy lock active list before locking pending list
7739 csrLLLock( &pMac->sme.smeCmdActiveList );
7740 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7741 if( pEntry )
7742 {
7743 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7744 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7745 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7746 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7747 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7748 {
7749 fRet = eANI_BOOLEAN_TRUE;
7750 }
7751 }
7752 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007753 return (fRet);
7754}
Jeff Johnson295189b2012-06-20 16:38:30 -07007755eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7756{
7757 eHalStatus status = eHAL_STATUS_SUCCESS;
7758 tSmeCmd *pCommand = NULL;
7759 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7760 tANI_BOOLEAN fRemoveCmd = FALSE;
7761 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 // Delete the old assoc command. All is setup for reassoc to be serialized
7763 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7764 if ( pEntry )
7765 {
7766 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7767 if ( !pCommand )
7768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007769 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 return eHAL_STATUS_RESOURCES;
7771 }
7772 if ( eSmeCommandRoam == pCommand->command )
7773 {
7774 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7775 {
7776 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7777 }
7778 else
7779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007780 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 }
7782 if (fRemoveCmd == FALSE)
7783 {
7784 // Implies we did not get the serialized assoc command we
7785 // were expecting
7786 pCommand = NULL;
7787 }
7788 }
7789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 if(NULL == pCommand)
7791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007792 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007793 return eHAL_STATUS_RESOURCES;
7794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 do
7796 {
7797 //Change the substate in case it is wait-for-key
7798 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7799 {
7800 csrRoamStopWaitForKeyTimer( pMac );
7801 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7802 }
7803 pCommand->command = eSmeCommandRoam;
7804 pCommand->sessionId = (tANI_U8)sessionId;
7805 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7807 if( !HAL_STATUS_SUCCESS( status ) )
7808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007809 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 csrReleaseCommandRoam( pMac, pCommand );
7811 }
7812 } while( 0 );
7813
Jeff Johnson295189b2012-06-20 16:38:30 -07007814 return( status );
7815}
7816static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7817{
7818 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7819 tCsrScanResult *pScanResult = NULL;
7820 tSirBssDescription *pBssDesc = NULL;
7821 tSmeCmd *pCommand = NULL;
7822 tANI_U32 sessionId;
7823 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 if(NULL == pEntry)
7825 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307826 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 return;
7828 }
7829 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7830 sessionId = pCommand->sessionId;
7831 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007832
7833 if(!pSession)
7834 {
7835 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7836 return;
7837 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307838 smsLog(pMac, LOG1, FL("CFG return value is %d "
7839 " current state is : %d substate is : %d "),
7840 result, pMac->roam.curState[sessionId],
7841 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7843 {
7844 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007845 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7847 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007848 /* If the roaming has stopped, not to continue the roaming command*/
7849 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7850 {
7851 //No need to complete roaming here as it already completes
7852 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7853 pCommand->u.roamCmd.roamReason);
7854 csrSetAbortRoamingCommand( pMac, pCommand );
7855 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 else
7858 {
7859 if ( CCM_IS_RESULT_SUCCESS(result) )
7860 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307861 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 // Successfully set the configuration parameters for the new Bss. Attempt to
7863 // join the roaming Bss.
7864 if(pCommand->u.roamCmd.pRoamBssEntry)
7865 {
7866 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7867 pBssDesc = &pScanResult->Result.BssDescriptor;
7868 }
7869 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7870 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 )
7873 {
7874 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7875 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7876 pBssDesc, pCommand->u.roamCmd.roamId )))
7877 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307878 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 //We need to complete the command
7880 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7881 }
7882 }
7883 else
7884 {
7885 if (!pCommand->u.roamCmd.pRoamBssEntry)
7886 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307887 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 //We need to complete the command
7889 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7890 return;
7891 }
7892 // If we are roaming TO an Infrastructure BSS...
7893 VOS_ASSERT(pScanResult != NULL);
7894 if ( csrIsInfraBssDesc( pBssDesc ) )
7895 {
7896 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307897 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007898 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7899 {
7900 // ..and currently in an Infrastructure connection....
7901 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7902 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307903 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 // ...and the SSIDs are equal, then we Reassoc.
7905 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7906 pIesLocal ) )
7907 // ..and currently in an infrastructure connection
7908 {
7909 // then issue a Reassoc.
7910 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7911 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7912 &pCommand->u.roamCmd.roamProfile );
7913 }
7914 else
7915 {
7916
7917 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7918 // previously associated AP.
7919 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7920 pIesLocal,
7921 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7922 {
7923 //try something else
7924 csrRoam( pMac, pCommand );
7925 }
7926 }
7927 }
7928 else
7929 {
7930 eHalStatus status = eHAL_STATUS_SUCCESS;
7931
7932 /* We need to come with other way to figure out that this is because of HO in BMP
7933 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007934 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 * use join request */
7936#ifdef WLAN_FEATURE_VOWIFI_11R
7937 if (csrRoamIsHandoffInProgress(pMac) &&
7938 csrRoamIs11rAssoc(pMac))
7939 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307940 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7942 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7943 }
7944 else
7945#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007946#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007948 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307950 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 // Now serialize the reassoc command.
7952 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7953 }
7954 else
7955#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007956#ifdef FEATURE_WLAN_LFR
7957 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307958 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007959 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307960 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007961 // Now serialize the reassoc command.
7962 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7963 }
7964 else
7965#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 // else we are not connected and attempting to Join. Issue the
7967 // Join request.
7968 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307969 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7971 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7972 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7973 }
7974 if(!HAL_STATUS_SUCCESS(status))
7975 {
7976 //try something else
7977 csrRoam( pMac, pCommand );
7978 }
7979 }
7980 if( !pScanResult->Result.pvIes )
7981 {
7982 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307983 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 }
7985 }
7986 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7987 else
7988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007989 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 }
7991 }//else
7992 }//if ( WNI_CFG_SUCCESS == result )
7993 else
7994 {
7995 // In the event the configuration failed, for infra let the roam processor
7996 //attempt to join something else...
7997 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7998 {
7999 csrRoam(pMac, pCommand);
8000 }
8001 else
8002 {
8003 //We need to complete the command
8004 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8005 {
8006 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8007 }
8008 else
8009 {
8010 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8011 }
8012 }
8013 }
8014 }//we have active entry
8015}
8016
Jeff Johnson295189b2012-06-20 16:38:30 -07008017static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8018{
8019 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008020 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008023 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8025 // join the new one...
8026 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8028 }
8029 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008030 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 /***profHandleLostLinkAfterReset(pAdapter);
8032 // In the event the authenticate fails, let the roam processor attempt to join something else...
8033 roamRoam( pAdapter );***/
8034 }
8035}
8036
Jeff Johnson295189b2012-06-20 16:38:30 -07008037static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8038{
8039 eCsrRoamCompleteResult result;
8040 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8041 tCsrRoamInfo roamInfo;
8042 tANI_U32 roamId = 0;
8043
8044 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
8045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008046 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 /* Defeaturize this part later if needed */
8049#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8050 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8051 * we need the response contents while processing the result in csrRoamProcessResults() */
8052 if (csrRoamIsHandoffInProgress(pMac))
8053 {
8054 /* Need to dig more on indicating events to SME QoS module */
8055 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8056 csrRoamComplete( pMac, result, pSmeJoinRsp);
8057 }
8058 else
8059#endif
8060 {
8061 csrRoamComplete( pMac, result, NULL );
8062 }
8063 }
8064 /* Should we handle this similar to handling the join failure? Is it ok
8065 * to call csrRoamComplete() with state as CsrJoinFailure */
8066 else
8067 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008068 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 result = eCsrReassocFailure;
8070#ifdef WLAN_FEATURE_VOWIFI_11R
8071 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308072 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8073 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 {
8075 // Inform HDD to turn off FT flag in HDD
8076 if (pNeighborRoamInfo)
8077 {
8078 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8079 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8080 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008081 /*
8082 * Since the above callback sends a disconnect
8083 * to HDD, we should clean-up our state
8084 * machine as well to be in sync with the upper
8085 * layers. There is no need to send a disassoc
8086 * since: 1) we will never reassoc to the current
8087 * AP in LFR, and 2) there is no need to issue a
8088 * disassoc to the AP with which we were trying
8089 * to reassoc.
8090 */
8091 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8092 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 }
8094 }
8095#endif
8096 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8097 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8098 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8099 //The disassoc rsp message will remove the command from active list
8100 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8101 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8102 {
8103 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8104 }
8105 }
8106}
8107
Jeff Johnson295189b2012-06-20 16:38:30 -07008108static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8109{
Jeff Johnson295189b2012-06-20 16:38:30 -07008110#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8111 {
8112 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8114 if(pIbssLog)
8115 {
8116 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8117 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8118 {
8119 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8120 }
8121 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8122 }
8123 }
8124#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8126 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8127 {
8128 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8129 }
8130 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8131 {
8132 csrRoamReissueRoamCommand(pMac);
8133 }
8134}
8135
Jeff Johnson295189b2012-06-20 16:38:30 -07008136void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8137{
8138 tSirResultCodes statusCode;
8139#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8140 tScanResultHandle hBSSList;
8141 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8142 eHalStatus status;
8143 tCsrRoamInfo roamInfo;
8144 tCsrScanResultFilter *pScanFilter = NULL;
8145 tANI_U32 roamId = 0;
8146 tCsrRoamProfile *pCurRoamProfile = NULL;
8147 tListElem *pEntry = NULL;
8148 tSmeCmd *pCommand = NULL;
8149#endif
8150 tANI_U32 sessionId;
8151 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008152
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 tSirSmeDisassocRsp SmeDisassocRsp;
8154
8155 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8156 sessionId = SmeDisassocRsp.sessionId;
8157 statusCode = SmeDisassocRsp.statusCode;
8158
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008159 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008160
8161 if ( csrIsConnStateInfra( pMac, sessionId ) )
8162 {
8163 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008166
8167 if(!pSession)
8168 {
8169 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8170 return;
8171 }
8172
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8174 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308175 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8177 }
8178 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8179 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8180 {
8181 if ( eSIR_SME_SUCCESS == statusCode )
8182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008183 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8185 }
8186 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8189 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308190 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8191 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008192#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008193 /*
8194 * First ensure if the roam profile is in the scan cache.
8195 * If not, post a reassoc failure and disconnect.
8196 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308197 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8198 if ( NULL == pScanFilter )
8199 status = eHAL_STATUS_FAILURE;
8200 else
8201 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008202 if(HAL_STATUS_SUCCESS(status))
8203 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308204 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008205 status = csrRoamPrepareFilterFromProfile(pMac,
8206 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8207 if(!HAL_STATUS_SUCCESS(status))
8208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008209 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008210 __func__, status);
8211 goto POST_ROAM_FAILURE;
8212 }
8213 else
8214 {
8215 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8216 if (!HAL_STATUS_SUCCESS(status))
8217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008218 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008219 __func__, status);
8220 goto POST_ROAM_FAILURE;
8221 }
8222 }
8223 }
8224 else
8225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008226 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008227 __func__, status);
8228 goto POST_ROAM_FAILURE;
8229 }
8230
8231 /*
8232 * After ensuring that the roam profile is in the scan result list,
8233 * dequeue the command from the active list.
8234 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8236 if ( pEntry )
8237 {
8238 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008239 /* If the head of the queue is Active and it is a ROAM command, remove
8240 * and put this on the Free queue.
8241 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 if ( eSmeCommandRoam == pCommand->command )
8243 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008244
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008245 /*
8246 * we need to process the result first before removing it from active list
8247 * because state changes still happening insides roamQProcessRoamResults so
8248 * no other roam command should be issued.
8249 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8251 if(pCommand->u.roamCmd.fReleaseProfile)
8252 {
8253 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8254 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 else
8259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008260 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008261 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 }
8263 }
8264 else
8265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008266 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 }
8268 }
8269 else
8270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008271 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008273
8274 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8276
Kiet Lam64c1b492013-07-12 13:56:44 +05308277 vos_mem_copy(roamInfo.bssid,
8278 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8279 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008280
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008281 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8282 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008283
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008284 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308285 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8286 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308288 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008289 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8290 //make sure to put it at the head of the cmd queue
8291 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8292 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8293 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8294
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 if(!HAL_STATUS_SUCCESS(status))
8296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008297 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008298 __func__, status);
8299 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 }
8301
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008302 /* Notify sub-modules like QoS etc. that handoff happening */
8303 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008304 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308305 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308307 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008308 return;
8309 }
8310
8311POST_ROAM_FAILURE:
8312 if (pScanFilter)
8313 {
8314 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308315 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008316 }
8317 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308318 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008319
8320 /* Inform the upper layers that the reassoc failed */
8321 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8322 csrRoamCallCallback(pMac, sessionId,
8323 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8324
8325 /*
8326 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8327 * Upon success, we would re-enter this routine after receiving the disassoc
8328 * response and will fall into the reassoc fail sub-state. And, eventually
8329 * call csrRoamComplete which would remove the roam command from SME active
8330 * queue.
8331 */
8332 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8333 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8334 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008335 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008336 __func__, status);
8337 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008339#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008340
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8342 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8343 {
8344 // Disassoc due to Reassoc failure falls into this codepath....
8345 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8346 }
8347 else
8348 {
8349 if ( eSIR_SME_SUCCESS == statusCode )
8350 {
8351 // Successfully disassociated from the 'old' Bss...
8352 //
8353 // We get Disassociate response in three conditions.
8354 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8355 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8356 // Infrastructure network.
8357 // - Third is where we are doing an Infra to Infra roam between networks with different
8358 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8359
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008360 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 }
8362 else
8363 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008364 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 }
8366 //We are not done yet. Get the data and continue roaming
8367 csrRoamReissueRoamCommand(pMac);
8368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008369}
8370
Jeff Johnson295189b2012-06-20 16:38:30 -07008371static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8372{
8373 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008375 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008377 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8379 {
8380 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8381 }
8382 else
8383 {
8384 if ( eSIR_SME_SUCCESS == statusCode )
8385 {
8386 // Successfully deauth from the 'old' Bss...
8387 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008388 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 }
8390 else
8391 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008392 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 }
8394 //We are not done yet. Get the data and continue roaming
8395 csrRoamReissueRoamCommand(pMac);
8396 }
8397}
8398
Jeff Johnson295189b2012-06-20 16:38:30 -07008399static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8400{
8401 eCsrRoamCompleteResult result;
8402
8403 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008405 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 result = eCsrStartBssSuccess;
8407 }
8408 else
8409 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008410 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 //Let csrRoamComplete decide what to do
8412 result = eCsrStartBssFailure;
8413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008415}
8416
Jeff Johnson295189b2012-06-20 16:38:30 -07008417/*
8418 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8419 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8420 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8421 For the messages where sender allocates memory for specific structures, then it can be
8422 cast accordingly.
8423*/
8424void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8425{
8426 tSirSmeRsp *pSmeRsp;
8427 tSmeIbssPeerInd *pIbssPeerInd;
8428 tCsrRoamInfo roamInfo;
8429 // TODO Session Id need to be acquired in this function
8430 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308432 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8433 pSmeRsp->messageType, pSmeRsp->messageType,
8434 macTraceGetcsrRoamSubState(
8435 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 pSmeRsp->messageType = (pSmeRsp->messageType);
8437 pSmeRsp->length = (pSmeRsp->length);
8438 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 switch (pSmeRsp->messageType)
8440 {
8441
8442 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8443 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8444 {
8445 //We sent a JOIN_REQ
8446 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8447 }
8448 break;
8449
8450 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8451 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8452 {
8453 //We sent a AUTH_REQ
8454 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8455 }
8456 break;
8457
8458 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8459 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8460 {
8461 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8462 }
8463 break;
8464
8465 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8466 {
8467 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8468 }
8469 break;
8470
8471 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8472 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8473 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8474 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8475 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8476 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8477//HO
8478 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8479 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308480 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8481 macTraceGetcsrRoamSubState(
8482 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308484#ifdef DEBUG_ROAM_DELAY
8485 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8486#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 }
8488 break;
8489
8490 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8491 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8492 {
8493 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8494 }
8495 break;
8496
8497 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8498 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8499 {
8500 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8501 }
8502 break;
8503
8504 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8505 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8506 {
8507 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8511 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8512 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008513 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308514 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8515 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8517 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308518 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8519 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8521 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8522 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8523 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308525 smsLog(pMac, LOG1,
8526 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8527 pSmeRsp->messageType, pSmeRsp->messageType,
8528 macTraceGetcsrRoamSubState(
8529 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008530
8531 //If we are connected, check the link status change
8532 if(!csrIsConnStateDisconnected(pMac, sessionId))
8533 {
8534 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8535 }
8536 break;
8537 }
8538}
8539
Jeff Johnson295189b2012-06-20 16:38:30 -07008540void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8541{
8542 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 switch (pSirMsg->messageType)
8544 {
8545 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008546 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 csrRoamStatsRspProcessor( pMac, pSirMsg );
8548 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8550 {
8551 tCsrRoamSession *pSession;
8552 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8553 tCsrRoamInfo roamInfo;
8554 tCsrRoamInfo *pRoamInfo = NULL;
8555 tANI_U32 sessionId;
8556 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008557 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308558 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8561 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8562 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008563
8564 if(!pSession)
8565 {
8566 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8567 return;
8568 }
8569
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8571 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8573 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8574 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8576 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308577 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8578 sizeof(tSirMacAddr));
8579 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8580 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008581 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308582#ifdef WLAN_FEATURE_AP_HT40_24G
8583 pRoamInfo->HT40MHzIntoEnabledSta =
8584 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8585 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8586 pRoamInfo->HT40MHzIntoEnabledSta);
8587#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8589 {
8590 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8591 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8592 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8593 }
8594 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8595 {
8596 vos_sleep( 100 );
8597 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8598 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8599 }
8600
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 }
8602 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 default:
8604 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8605 break;
8606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008607}
8608
Jeff Johnson295189b2012-06-20 16:38:30 -07008609eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8610 tSirBssDescription *pBssDescription,
8611 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8612 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8613 tANI_U8 keyId, tANI_U16 keyLength,
8614 tANI_U8 *pKey, tANI_U8 paeRole )
8615{
8616 eHalStatus status = eHAL_STATUS_SUCCESS;
8617 tAniEdType edType;
8618
8619 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8620 {
8621 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8622 }
8623
8624 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8625
8626 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8627 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8628 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8629 addKey )
8630 {
8631 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 setKey.encType = EncryptType;
8633 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308634 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008635 setKey.paeRole = paeRole; //0 for supplicant
8636 setKey.keyId = keyId; // Kye index
8637 setKey.keyLength = keyLength;
8638 if( keyLength )
8639 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308640 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008641 }
8642 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 return (status);
8645}
8646
Jeff Johnson295189b2012-06-20 16:38:30 -07008647static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8648 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8649{
8650 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8651 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008652#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008654#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008655
8656 do
8657 {
8658 pCommand = csrGetCommandBuffer(pMac);
8659 if(NULL == pCommand)
8660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008661 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 status = eHAL_STATUS_RESOURCES;
8663 break;
8664 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308665 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 pCommand->command = eSmeCommandSetKey;
8667 pCommand->sessionId = (tANI_U8)sessionId;
8668 // validate the key length, Adjust if too long...
8669 // for static WEP the keys are not set thru' SetContextReq
8670 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8671 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8672 {
8673 //KeyLength maybe 0 for static WEP
8674 if( pSetKey->keyLength )
8675 {
8676 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008678 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 break;
8680 }
8681
8682 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308683 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8684 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 }
8686 }
8687 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8688 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8689 {
8690 //KeyLength maybe 0 for static WEP
8691 if( pSetKey->keyLength )
8692 {
8693 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008695 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 break;
8697 }
8698
8699 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308700 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8701 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 }
8703 }
8704 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8705 {
8706 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8707 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008708 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 break;
8710 }
8711 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308712 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8713 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 }
8715 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8716 {
8717 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008719 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 break;
8721 }
8722 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308723 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8724 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 }
8726#ifdef FEATURE_WLAN_WAPI
8727 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8728 {
8729 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008731 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 break;
8733 }
8734 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308735 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8736 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 }
8738#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008739#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8741 {
8742 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008744 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 break;
8746 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008747 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308748 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008749 pSession->eseCckmInfo.reassoc_req_num=1;
8750 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 status = eHAL_STATUS_SUCCESS;
8752 break;
8753 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008754#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008755
Jeff Johnson295189b2012-06-20 16:38:30 -07008756#ifdef WLAN_FEATURE_11W
8757 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008758 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008760 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008762 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008763 break;
8764 }
8765 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308766 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 }
8768#endif
8769 status = eHAL_STATUS_SUCCESS;
8770 pCommand->u.setKeyCmd.roamId = roamId;
8771 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8772 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308773 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8774 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008775 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8776 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308777 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 //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
8779
8780 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8781 if( !HAL_STATUS_SUCCESS( status ) )
8782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008783 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 }
8785 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008787 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008788 if ( ( NULL != pCommand ) &&
8789 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008790#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008792#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008793 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008794 {
8795 csrReleaseCommandSetKey( pMac, pCommand );
8796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 return( status );
8798}
8799
Jeff Johnson295189b2012-06-20 16:38:30 -07008800eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8801 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8802{
8803 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8804 tSmeCmd *pCommand = NULL;
8805 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 do
8807 {
8808 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008810 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 status = eHAL_STATUS_CSR_WRONG_STATE;
8812 break;
8813 }
8814 pCommand = csrGetCommandBuffer(pMac);
8815 if(NULL == pCommand)
8816 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008817 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 status = eHAL_STATUS_RESOURCES;
8819 break;
8820 }
8821 pCommand->command = eSmeCommandRemoveKey;
8822 pCommand->sessionId = (tANI_U8)sessionId;
8823 pCommand->u.removeKeyCmd.roamId = roamId;
8824 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308825 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8826 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8828 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8829 {
8830 //in this case, put it to the end of the Q incase there is a set key pending.
8831 fImediate = eANI_BOOLEAN_FALSE;
8832 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008833 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008835 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8837 if( !HAL_STATUS_SUCCESS( status ) )
8838 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008839 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 break;
8841 }
8842 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008843 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8844 {
8845 csrReleaseCommandRemoveKey( pMac, pCommand );
8846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 return (status );
8848}
8849
Jeff Johnson295189b2012-06-20 16:38:30 -07008850eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8851{
8852 eHalStatus status;
8853 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8854 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8855 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8856 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8858 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8859 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308860 if(!pSession)
8861 {
8862 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8863 return eHAL_STATUS_FAILURE;
8864 }
lukez3c809222013-05-03 10:23:02 -07008865 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308867 vos_mem_set(&setKeyEvent,
8868 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8870 {
8871 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8872 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8873 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8874 }
8875 else
8876 {
8877 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8878 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8879 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8880 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308881 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008882 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 {
8884 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 //It has to be static WEP here
8886 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8887 {
8888 setKeyEvent.keyId = (v_U8_t)defKeyId;
8889 }
8890 }
8891 else
8892 {
8893 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8894 }
8895 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8896 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8897 }
8898#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 if( csrIsSetKeyAllowed(pMac, sessionId) )
8900 {
8901 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8902 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8903 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8904 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8905 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8906 pCommand->u.setKeyCmd.keyRsc);
8907 }
8908 else
8909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008910 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 //Set this status so the error handling take care of the case.
8912 status = eHAL_STATUS_CSR_WRONG_STATE;
8913 }
8914 if( !HAL_STATUS_SUCCESS(status) )
8915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008916 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008918#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008919 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 {
8921 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8922 {
8923 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8924 }
8925 else
8926 {
8927 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8928 }
8929 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8930 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8931 }
8932#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 return ( status );
8935}
8936
Jeff Johnson295189b2012-06-20 16:38:30 -07008937eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8938{
8939 eHalStatus status;
8940 tpSirSmeRemoveKeyReq pMsg = NULL;
8941 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8942 tANI_U8 *p;
8943 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008944#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8945 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8946 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308947 if(!pSession)
8948 {
8949 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8950 return eHAL_STATUS_FAILURE;
8951 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308952 vos_mem_set(&removeKeyEvent,
8953 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8955 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8956 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308957 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008958 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8959 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8960 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8961#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 if( csrIsSetKeyAllowed(pMac, sessionId) )
8963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308964 pMsg = vos_mem_malloc(wMsgLen);
8965 if ( NULL == pMsg )
8966 status = eHAL_STATUS_FAILURE;
8967 else
8968 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008969 }
8970 else
8971 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008972 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 //Set the error status so error handling kicks in below
8974 status = eHAL_STATUS_CSR_WRONG_STATE;
8975 }
8976 if( HAL_STATUS_SUCCESS( status ) )
8977 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308978 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008979 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8980 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 pMsg->sessionId = (tANI_U8)sessionId;
8982 pMsg->transactionId = 0;
8983 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8984 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8985 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308986 vos_mem_copy(p,
8987 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8988 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 p += sizeof(tSirMacAddr);
8990 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308991 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 p += sizeof(tSirMacAddr);
8993 // edType
8994 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8995 p++;
8996 // weptype
8997 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8998 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8999 {
9000 *p = (tANI_U8)eSIR_WEP_STATIC;
9001 }
9002 else
9003 {
9004 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9005 }
9006 p++;
9007 //keyid
9008 *p = pCommand->u.removeKeyCmd.keyId;
9009 p++;
9010 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 status = palSendMBMessage(pMac->hHdd, pMsg);
9012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 if( !HAL_STATUS_SUCCESS( status ) )
9014 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009015 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009016#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9017 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009018 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9020#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009021 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009023 return ( status );
9024}
9025
Jeff Johnson295189b2012-06-20 16:38:30 -07009026eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9027{
9028 eHalStatus status;
9029
9030 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9031 {
9032 status = eHAL_STATUS_CSR_WRONG_STATE;
9033 }
9034 else
9035 {
9036 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009038 return ( status );
9039}
9040
Jeff Johnson295189b2012-06-20 16:38:30 -07009041/*
9042 Prepare a filter base on a profile for parsing the scan results.
9043 Upon successful return, caller MUST call csrFreeScanFilter on
9044 pScanFilter when it is done with the filter.
9045*/
9046eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9047 tCsrScanResultFilter *pScanFilter)
9048{
9049 eHalStatus status = eHAL_STATUS_SUCCESS;
9050 tANI_U32 size = 0;
9051 tANI_U8 index = 0;
9052
9053 do
9054 {
9055 if(pProfile->BSSIDs.numOfBSSIDs)
9056 {
9057 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309058 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9059 if ( NULL == pScanFilter->BSSIDs.bssid )
9060 status = eHAL_STATUS_FAILURE;
9061 else
9062 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 if(!HAL_STATUS_SUCCESS(status))
9064 {
9065 break;
9066 }
9067 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309068 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 }
9070 if(pProfile->SSIDs.numOfSSIDs)
9071 {
9072 if( !CSR_IS_WDS_STA( pProfile ) )
9073 {
9074 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9075 }
9076 else
9077 {
9078 //For WDS station
9079 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9080 pScanFilter->SSIDs.numOfSSIDs = 1;
9081 }
9082 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309083 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9084 if ( NULL == pScanFilter->SSIDs.SSIDList )
9085 status = eHAL_STATUS_FAILURE;
9086 else
9087 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009088 if(!HAL_STATUS_SUCCESS(status))
9089 {
9090 break;
9091 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309092 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9093 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 }
9095 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9096 {
9097 pScanFilter->ChannelInfo.numOfChannels = 0;
9098 pScanFilter->ChannelInfo.ChannelList = NULL;
9099 }
9100 else if(pProfile->ChannelInfo.numOfChannels)
9101 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309102 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9103 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9104 pProfile->ChannelInfo.numOfChannels);
9105 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9106 status = eHAL_STATUS_FAILURE;
9107 else
9108 status = eHAL_STATUS_SUCCESS;
9109
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 pScanFilter->ChannelInfo.numOfChannels = 0;
9111 if(HAL_STATUS_SUCCESS(status))
9112 {
9113 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9114 {
9115 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9116 {
9117 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9118 = pProfile->ChannelInfo.ChannelList[index];
9119 pScanFilter->ChannelInfo.numOfChannels++;
9120 }
9121 else
9122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009123 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 }
9126 }
9127 else
9128 {
9129 break;
9130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 }
9132 else
9133 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309134 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 status = eHAL_STATUS_FAILURE;
9136 break;
9137 }
9138 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9139 pScanFilter->authType = pProfile->AuthType;
9140 pScanFilter->EncryptionType = pProfile->EncryptionType;
9141 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9142 pScanFilter->BSSType = pProfile->BSSType;
9143 pScanFilter->phyMode = pProfile->phyMode;
9144#ifdef FEATURE_WLAN_WAPI
9145 //check if user asked for WAPI with 11n or auto mode, in that case modify
9146 //the phymode to 11g
9147 if(csrIsProfileWapi(pProfile))
9148 {
9149 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9150 {
9151 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9152 }
9153 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9154 {
9155 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9156 }
9157 if(!pScanFilter->phyMode)
9158 {
9159 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9160 }
9161 }
9162#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 /*Save the WPS info*/
9164 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009165 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 if( pProfile->countryCode[0] )
9167 {
9168 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309169 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9170 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 }
9172#ifdef WLAN_FEATURE_VOWIFI_11R
9173 if (pProfile->MDID.mdiePresent)
9174 {
9175 pScanFilter->MDID.mdiePresent = 1;
9176 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9177 }
9178#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309179
9180#ifdef WLAN_FEATURE_11W
9181 // Management Frame Protection
9182 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9183 pScanFilter->MFPRequired = pProfile->MFPRequired;
9184 pScanFilter->MFPCapable = pProfile->MFPCapable;
9185#endif
9186
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 }while(0);
9188
9189 if(!HAL_STATUS_SUCCESS(status))
9190 {
9191 csrFreeScanFilter(pMac, pScanFilter);
9192 }
9193
9194 return(status);
9195}
9196
Jeff Johnson295189b2012-06-20 16:38:30 -07009197tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9198 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9199{
9200 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9201 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 do
9203 {
9204 // Validate the type is ok...
9205 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9206 pCommand = csrGetCommandBuffer( pMac );
9207 if ( !pCommand )
9208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009209 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 break;
9211 }
9212 //Change the substate in case it is waiting for key
9213 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9214 {
9215 csrRoamStopWaitForKeyTimer( pMac );
9216 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9217 }
9218 pCommand->command = eSmeCommandWmStatusChange;
9219 pCommand->sessionId = (tANI_U8)sessionId;
9220 pCommand->u.wmStatusChangeCmd.Type = Type;
9221 if ( eCsrDisassociated == Type )
9222 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309223 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9224 pSmeRsp,
9225 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
9227 else
9228 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309229 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9230 pSmeRsp,
9231 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 }
9233 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9234 {
9235 fCommandQueued = eANI_BOOLEAN_TRUE;
9236 }
9237 else
9238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009239 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 csrReleaseCommandWmStatusChange( pMac, pCommand );
9241 }
9242
Jeff Johnson295189b2012-06-20 16:38:30 -07009243 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9244 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 return( fCommandQueued );
9247}
9248
Jeff Johnson295189b2012-06-20 16:38:30 -07009249static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9250{
9251 v_S7_t rssi = 0;
9252 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9253 if(pGetRssiReq)
9254 {
9255 if(NULL != pGetRssiReq->pVosContext)
9256 {
9257 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9258 }
9259 else
9260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009261 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 return;
9263 }
9264
9265 if(NULL != pGetRssiReq->rssiCallback)
9266 {
9267 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9268 }
9269 else
9270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009271 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 return;
9273 }
9274 }
9275 else
9276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009277 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 }
9279 return;
9280}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309281
9282static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9283{
9284 tANI_S8 snr = 0;
9285 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9286
9287 if (pGetSnrReq)
9288 {
9289 if (VOS_STATUS_SUCCESS !=
9290 WDA_GetSnr(pGetSnrReq->staId, &snr))
9291 {
9292 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9293 return;
9294 }
9295
9296 if (pGetSnrReq->snrCallback)
9297 {
9298 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9299 pGetSnrReq->pDevContext);
9300 }
9301 else
9302 {
9303 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9304 return;
9305 }
9306 }
9307 else
9308 {
9309 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9310 }
9311 return;
9312}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009313#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009314void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9315{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009316 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9317
Jeff Johnson36d483b2013-04-08 11:08:53 -07009318 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009319 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009320 /* Get roam Rssi request is backed up and passed back to the response,
9321 Extract the request message to fetch callback */
9322 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9323 v_S7_t rssi = pRoamRssiRsp->rssi;
9324
9325 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009326 {
9327 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9328 reqBkp->rssiCallback = NULL;
9329 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009330 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009331 }
9332 else
9333 {
9334 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9335 if (NULL != reqBkp)
9336 {
9337 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009338 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009339 }
9340 }
9341 }
9342 else
9343 {
9344 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9345 }
9346 return;
9347}
9348#endif
9349
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009350
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009351#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009352void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9353{
9354 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9355
9356 if (NULL != pTsmStatsRsp)
9357 {
9358 /* Get roam Rssi request is backed up and passed back to the response,
9359 Extract the request message to fetch callback */
9360 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9361
9362 if (NULL != reqBkp)
9363 {
9364 if (NULL != reqBkp->tsmStatsCallback)
9365 {
9366 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9367 pTsmStatsRsp->staId, reqBkp->pDevContext);
9368 reqBkp->tsmStatsCallback = NULL;
9369 }
9370 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009371 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009372 }
9373 else
9374 {
9375 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9376 if (NULL != reqBkp)
9377 {
9378 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009379 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009380 }
9381 }
9382 }
9383 else
9384 {
9385 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9386 }
9387 return;
9388}
9389
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009390void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009391{
9392 tANI_U32 roamTS2 = 0;
9393 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009394 tpPESession pSessionEntry = NULL;
9395 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009396
9397 if (NULL == pSession)
9398 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009399 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009400 return;
9401 }
9402
9403 roamTS2 = vos_timer_get_system_time();
9404 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009405 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9406 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009407 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009408
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009409 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9410 if (NULL == pSessionEntry)
9411 {
9412 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9413 return;
9414 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009415 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009416 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009417 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009418}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009419#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009420
Jeff Johnsone7245742012-09-05 17:12:55 -07009421static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9422{
9423 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9424 if(pTlRssiInd)
9425 {
9426 if(NULL != pTlRssiInd->tlCallback)
9427 {
9428 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009429 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009430 }
9431 else
9432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009433 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009434 }
9435 }
9436 else
9437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009438 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009439 }
9440 return;
9441}
Jeff Johnson295189b2012-06-20 16:38:30 -07009442
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309443eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9444{
9445 tpSirResetAPCapsChange pMsg;
9446 tANI_U16 len;
9447 eHalStatus status = eHAL_STATUS_SUCCESS;
9448
9449 /* Create the message and send to lim */
9450 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309451 pMsg = vos_mem_malloc(len);
9452 if ( NULL == pMsg )
9453 status = eHAL_STATUS_FAILURE;
9454 else
9455 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309456 if (HAL_STATUS_SUCCESS(status))
9457 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309458 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309459 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9460 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309461 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009462 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9463 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309464 status = palSendMBMessage(pMac->hHdd, pMsg);
9465 }
9466 else
9467 {
9468 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9469 }
9470 return status;
9471}
9472
Jeff Johnson295189b2012-06-20 16:38:30 -07009473void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9474{
9475 tSirSmeAssocInd *pAssocInd;
9476 tSirSmeDisassocInd *pDisassocInd;
9477 tSirSmeDeauthInd *pDeauthInd;
9478 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9479 tSirSmeNewBssInfo *pNewBss;
9480 tSmeIbssPeerInd *pIbssPeerInd;
9481 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9482 tSirSmeApNewCaps *pApNewCaps;
9483 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9484 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9485 tCsrRoamInfo *pRoamInfo = NULL;
9486 tCsrRoamInfo roamInfo;
9487 eHalStatus status;
9488 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9489 tCsrRoamSession *pSession = NULL;
9490 tpSirSmeSwitchChannelInd pSwitchChnInd;
9491 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309492 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009493
9494
9495 if (NULL == pSirMsg)
9496 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9497 return;
9498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 switch( pSirMsg->messageType )
9500 {
9501 case eWNI_SME_ASSOC_IND:
9502 {
9503 tCsrRoamSession *pSession;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05309504 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9506 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9507 if( HAL_STATUS_SUCCESS( status ) )
9508 {
9509 pSession = CSR_GET_SESSION(pMac, sessionId);
9510
Jeff Johnson32d95a32012-09-10 13:15:23 -07009511 if(!pSession)
9512 {
9513 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9514 return;
9515 }
9516
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 pRoamInfo = &roamInfo;
9518
9519 // Required for indicating the frames to upper layer
9520 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9521 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9522
9523 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9524 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9525 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9526 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9527
9528 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9529 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9530 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9531
9532 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9533 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309534 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9535 sizeof(tSirMacAddr));
9536 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9537 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309539#ifdef WLAN_FEATURE_AP_HT40_24G
9540 pRoamInfo->HT40MHzIntoEnabledSta =
9541 pAssocInd->HT40MHzIntoEnabledSta;
9542 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9543 pRoamInfo->HT40MHzIntoEnabledSta);
9544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9548 {
9549 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9550 {
9551 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9552 pSession->pConnectBssDesc,
9553 &(pRoamInfo->peerMac),
9554 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9555 pRoamInfo->fAuthRequired = FALSE;
9556 }
9557 else
9558 {
9559 pRoamInfo->fAuthRequired = TRUE;
9560 }
9561 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9562 if (!HAL_STATUS_SUCCESS(status))
9563 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 /* Send Association completion message to PE */
9566 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9567
9568 /* send a message to CSR itself just to avoid the EAPOL frames going
9569 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9571 {
9572 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9575 {
9576 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9577 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9578 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 }
9581 }
9582 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309585 // Check if AP dis-associated us because of MIC failure. If so,
9586 // then we need to take action immediately and not wait till the
9587 // the WmStatusChange requests is pushed and processed
9588 tSmeCmd *pCommand;
9589
9590 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9591 status = csrRoamGetSessionIdFromBSSID( pMac,
9592 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9593 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009594 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309595 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9596 " for session %d "), sessionId);
9597 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9598 MAC_ADDRESS_STR " "
9599 " reason = %d status = %d "),
9600 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9601 pDisassocInd->reasonCode,
9602 pDisassocInd->statusCode);
9603 // If we are in neighbor preauth done state then on receiving
9604 // disassoc or deauth we dont roam instead we just disassoc
9605 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009606 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309607#ifdef WLAN_FEATURE_VOWIFI_11R
9608 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9609 {
9610 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009612#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009613#ifdef FEATURE_WLAN_ESE
9614 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309615 {
9616 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009618#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009619#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309620 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9621 {
9622 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9623 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009624#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309625 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009626
Agarwal Ashish4f616132013-12-30 23:32:50 +05309627 if (!pSession)
9628 {
9629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9630 return;
9631 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009632
Agarwal Ashish4f616132013-12-30 23:32:50 +05309633 if ( csrIsConnStateInfra( pMac, sessionId ) )
9634 {
9635 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009637#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309638 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009639#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309640 csrRoamLinkDown(pMac, sessionId);
9641 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9642 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9643 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309644 pRoamInfo = &roamInfo;
9645 pRoamInfo->statusCode = pDisassocInd->statusCode;
9646 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9647 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009648
Agarwal Ashish4f616132013-12-30 23:32:50 +05309649 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9650 sizeof(tSirMacAddr));
9651 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9652 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009653
Agarwal Ashish4f616132013-12-30 23:32:50 +05309654 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9655 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009656
Agarwal Ashish4f616132013-12-30 23:32:50 +05309657 /*
9658 * STA/P2P client got disassociated so remove any pending deauth
9659 * commands in sme pending list
9660 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309661 pCommand = csrGetCommandBuffer(pMac);
9662 if (NULL == pCommand)
9663 {
9664 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9665 status = eHAL_STATUS_RESOURCES;
9666 return;
9667 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309668 pCommand->command = eSmeCommandRoam;
9669 pCommand->sessionId = (tANI_U8)sessionId;
9670 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9671 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9672 pDisassocInd->peerMacAddr,
9673 sizeof(tSirMacAddr));
9674 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9675 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009676
Agarwal Ashish4f616132013-12-30 23:32:50 +05309677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309679 else
9680 {
9681 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9682 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9683 }
Kiet Lam82004c62013-11-11 13:24:28 +05309684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009687 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9689 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9690 if( HAL_STATUS_SUCCESS( status ) )
9691 {
9692 // If we are in neighbor preauth done state then on receiving
9693 // disassoc or deauth we dont roam instead we just disassoc
9694 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009695 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009696#ifdef WLAN_FEATURE_VOWIFI_11R
9697 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9698 {
9699 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9700 }
9701#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009702#ifdef FEATURE_WLAN_ESE
9703 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 {
9705 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9706 }
9707#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009708#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309709 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009710 {
9711 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9712 }
9713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 pSession = CSR_GET_SESSION( pMac, sessionId );
9715
Jeff Johnson32d95a32012-09-10 13:15:23 -07009716 if(!pSession)
9717 {
9718 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9719 return;
9720 }
9721
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 if ( csrIsConnStateInfra( pMac, sessionId ) )
9723 {
9724 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009726#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9727 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9728#endif
9729 csrRoamLinkDown(pMac, sessionId);
9730 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9732 {
9733
9734 pRoamInfo = &roamInfo;
9735
9736 pRoamInfo->statusCode = pDeauthInd->statusCode;
9737 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9738
9739 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9740
Kiet Lam64c1b492013-07-12 13:56:44 +05309741 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9742 sizeof(tSirMacAddr));
9743 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9744 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009745
9746 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 }
9749 break;
9750
9751 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 -08009752 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009753 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9754 //Update with the new channel id.
9755 //The channel id is hidden in the statusCode.
9756 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9757 if( HAL_STATUS_SUCCESS( status ) )
9758 {
9759 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009760 if(!pSession)
9761 {
9762 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9763 return;
9764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9766 if(pSession->pConnectBssDesc)
9767 {
9768 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9769 }
9770 }
9771 break;
9772
9773 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009774 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 {
9776 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9777 sessionId = pDeauthRsp->sessionId;
9778 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9779 {
9780 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9782 {
9783 pRoamInfo = &roamInfo;
9784 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309785 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9786 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9788 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9789 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9790 }
9791 }
9792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 break;
9794
9795 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009796 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009797 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 {
9799 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9800 sessionId = pDisassocRsp->sessionId;
9801 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9802 {
9803 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9805 {
9806 pRoamInfo = &roamInfo;
9807 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309808 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9809 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9811 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9812 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9813 }
9814 }
9815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009817 case eWNI_SME_MIC_FAILURE_IND:
9818 {
9819 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9820 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9821 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009822
9823 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9824 if( HAL_STATUS_SUCCESS( status ) )
9825 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309826 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009827 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9828 pRoamInfo = &roamInfo;
9829 if(pMicInd->info.multicast)
9830 {
9831 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9832 }
9833 else
9834 {
9835 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9836 }
9837 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9838 }
9839
Jeff Johnson295189b2012-06-20 16:38:30 -07009840#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9841 {
lukez3c809222013-05-03 10:23:02 -07009842 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009844 if(!pSession)
9845 {
9846 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9847 return;
9848 }
lukez3c809222013-05-03 10:23:02 -07009849
Kiet Lam64c1b492013-07-12 13:56:44 +05309850 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9852 secEvent.encryptionModeMulticast =
9853 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9854 secEvent.encryptionModeUnicast =
9855 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9856 secEvent.authMode =
9857 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309858 vos_mem_copy(secEvent.bssid,
9859 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9861 }
9862#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 }
9864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9866 {
9867 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9868 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009869 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009870
9871 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9872 if( HAL_STATUS_SUCCESS( status ) )
9873 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309874 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009875 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9876 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9877 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9878 }
9879 }
9880 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9883 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9884 switch( pStatusChangeMsg->statusChangeCode )
9885 {
9886 case eSIR_SME_IBSS_ACTIVE:
9887 sessionId = csrFindIbssSession( pMac );
9888 if( CSR_SESSION_ID_INVALID != sessionId )
9889 {
9890 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009891 if(!pSession)
9892 {
9893 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9894 return;
9895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9897 if(pSession->pConnectBssDesc)
9898 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309899 vos_mem_copy(&roamInfo.bssid,
9900 pSession->pConnectBssDesc->bssId,
9901 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9903 pRoamInfo = &roamInfo;
9904 }
9905 else
9906 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009907 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 }
9909 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9910 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9911 }
9912 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 case eSIR_SME_IBSS_INACTIVE:
9914 sessionId = csrFindIbssSession( pMac );
9915 if( CSR_SESSION_ID_INVALID != sessionId )
9916 {
9917 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009918 if(!pSession)
9919 {
9920 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9921 return;
9922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9924 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9925 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9926 }
9927 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9929 sessionId = csrFindIbssSession( pMac );
9930 if( CSR_SESSION_ID_INVALID != sessionId )
9931 {
9932 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009933 if(!pSession)
9934 {
9935 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9936 return;
9937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 // update the connection state information
9939 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009940#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9941 {
9942 vos_log_ibss_pkt_type *pIbssLog;
9943 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9945 if(pIbssLog)
9946 {
9947 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9948 if(pNewBss)
9949 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309950 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 if(pNewBss->ssId.length)
9952 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309953 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9954 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 }
9956 pIbssLog->operatingChannel = pNewBss->channelNumber;
9957 }
9958 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9959 {
9960 //***U8 is not enough for beacon interval
9961 pIbssLog->beaconInterval = (v_U8_t)bi;
9962 }
9963 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9964 }
9965 }
9966#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009968
9969 if ((eCSR_ENCRYPT_TYPE_NONE ==
9970 pSession->connectedProfile.EncryptionType ))
9971 {
9972 csrRoamIssueSetContextReq( pMac, sessionId,
9973 pSession->connectedProfile.EncryptionType,
9974 pSession->pConnectBssDesc,
9975 &Broadcastaddr,
9976 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9979 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309980 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9981 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 pRoamInfo = &roamInfo;
9983 //This BSSID is th ereal BSSID, let's save it
9984 if(pSession->pConnectBssDesc)
9985 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309986 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9987 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009990 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 // detection by LIM that the capabilities of the associated AP have changed.
9993 case eSIR_SME_AP_CAPS_CHANGED:
9994 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009995 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9997 if( HAL_STATUS_SUCCESS( status ) )
9998 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009999 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10000 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010001 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010002 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10003 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10004 )
10005 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010006 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10007 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010008 }
10009 else
10010 {
10011 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010012 FL("Skipping csrScanForCapabilityChange as "
10013 "CSR is in state %s and sub-state %s"),
10014 macTraceGetcsrRoamState(
10015 pMac->roam.curState[sessionId]),
10016 macTraceGetcsrRoamSubState(
10017 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010018 /* We ignore the caps change event if CSR is not in full connected state.
10019 * Send one event to PE to reset limSentCapsChangeNtf
10020 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10021 * otherwise lim cannot send any CAPS change events to SME */
10022 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 }
10025 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010026
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 default:
10028 roamStatus = eCSR_ROAM_FAILED;
10029 result = eCSR_ROAM_RESULT_NONE;
10030 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 } // end switch on statusChangeCode
10032 if(eCSR_ROAM_RESULT_NONE != result)
10033 {
10034 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10035 }
10036 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 case eWNI_SME_IBSS_NEW_PEER_IND:
10038 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010039#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10040 {
10041 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10043 if(pIbssLog)
10044 {
10045 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010046 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10048 }
10049 }
10050#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 sessionId = csrFindIbssSession( pMac );
10052 if( CSR_SESSION_ID_INVALID != sessionId )
10053 {
10054 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010055
10056 if(!pSession)
10057 {
10058 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10059 return;
10060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10062 if(pSession->pConnectBssDesc)
10063 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010064 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10065 sizeof(tCsrBssid));
10066 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10067 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10069 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010070 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10071 - sizeof(tSmeIbssPeerInd)));
10072 if ( NULL == roamInfo.pbFrames )
10073 status = eHAL_STATUS_FAILURE;
10074 else
10075 status = eHAL_STATUS_SUCCESS;
10076 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 {
10078 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010079 vos_mem_copy(roamInfo.pbFrames,
10080 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10081 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 }
10083 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10084 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10085 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010086 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10087 if ( NULL == roamInfo.pBssDesc )
10088 status = eHAL_STATUS_FAILURE;
10089 else
10090 status = eHAL_STATUS_SUCCESS;
10091 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010093 vos_mem_copy(roamInfo.pBssDesc,
10094 pSession->pConnectBssDesc,
10095 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 }
10097 if(HAL_STATUS_SUCCESS(status))
10098 {
10099 pRoamInfo = &roamInfo;
10100 }
10101 else
10102 {
10103 if(roamInfo.pbFrames)
10104 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010105 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 }
10107 if(roamInfo.pBssDesc)
10108 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010109 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 }
10111 }
10112 }
10113 else
10114 {
10115 pRoamInfo = &roamInfo;
10116 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010117 if ((eCSR_ENCRYPT_TYPE_NONE ==
10118 pSession->connectedProfile.EncryptionType ))
10119 {
10120 csrRoamIssueSetContextReq( pMac, sessionId,
10121 pSession->connectedProfile.EncryptionType,
10122 pSession->pConnectBssDesc,
10123 &(pIbssPeerInd->peerAddr),
10124 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 }
10127 else
10128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010129 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 }
10131 //send up the sec type for the new peer
10132 if (pRoamInfo)
10133 {
10134 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10135 }
10136 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10137 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10138 if(pRoamInfo)
10139 {
10140 if(roamInfo.pbFrames)
10141 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010142 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010143 }
10144 if(roamInfo.pBssDesc)
10145 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010146 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 }
10148 }
10149 }
10150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10152 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10153 sessionId = csrFindIbssSession( pMac );
10154 if( CSR_SESSION_ID_INVALID != sessionId )
10155 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010156#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10157 {
10158 vos_log_ibss_pkt_type *pIbssLog;
10159
10160 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10161 if(pIbssLog)
10162 {
10163 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10164 if(pIbssPeerInd)
10165 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010166 vos_mem_copy(pIbssLog->peerMacAddr,
10167 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010168 }
10169 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10170 }
10171 }
10172#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010173 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10175 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10176 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010177 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10178 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10180 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10181 }
10182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 case eWNI_SME_SETCONTEXT_RSP:
10184 {
10185 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10186 tListElem *pEntry;
10187 tSmeCmd *pCommand;
10188
10189 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10190 if ( pEntry )
10191 {
10192 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10193 if ( eSmeCommandSetKey == pCommand->command )
10194 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010195 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010197
10198 if(!pSession)
10199 {
10200 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10201 return;
10202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010203
10204#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10205 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10206 {
10207 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010208 vos_mem_set(&setKeyEvent,
10209 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 if( pRsp->peerMacAddr[0] & 0x01 )
10211 {
10212 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10213 }
10214 else
10215 {
10216 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10217 }
10218 setKeyEvent.encryptionModeMulticast =
10219 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10220 setKeyEvent.encryptionModeUnicast =
10221 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010222 vos_mem_copy(setKeyEvent.bssid,
10223 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 setKeyEvent.authMode =
10225 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010226 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010227 {
10228 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10229 }
10230 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10231 }
10232#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10233 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10234 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010235 csrRoamStopWaitForKeyTimer( pMac );
10236
Jeff Johnson295189b2012-06-20 16:38:30 -070010237 //We are done with authentication, whethere succeed or not
10238 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 //We do it here because this linkup function is not called after association
10240 //when a key needs to be set.
10241 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10242 {
10243 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10244 }
10245 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010246 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010248 vos_mem_copy(&roamInfo.peerMac,
10249 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010250 //Make sure we install the GTK before indicating to HDD as authenticated
10251 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010252 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10253 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010254 {
Yathish9f22e662012-12-10 14:21:35 -080010255#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10256 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10257 {
10258 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010259 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010260 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10261 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10262 pMsg->seesionId = sessionId;
10263 status = palSendMBMessage(pMac->hHdd, pMsg );
10264 }
10265#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010266 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +053010267 smsLog(pMac, LOG1, FL("Current channel is %d,"
10268 "OBSS cap is %d, Persona is %d"),
10269 pSession->connectedProfile.operationChannel,
10270 IS_HT40_OBSS_SCAN_FEATURE_ENABLE,
10271 pSession->pCurRoamProfile->csrPersona);
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010272 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010273 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
10274 && (VOS_P2P_GO_MODE !=
10275 pSession->pCurRoamProfile->csrPersona
10276 && VOS_STA_SAP_MODE !=
10277 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010278 {
10279 tpSirSmeHT40OBSSScanInd pMsg;
10280 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10281 pMsg->messageType =
10282 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10283 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010284 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10285 vos_mem_copy(pMsg->peerMacAddr,
10286 pSession->connectedProfile.bssid,
10287 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010288 status = palSendMBMessage(pMac->hHdd,
10289 pMsg );
10290 }
10291 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010292 }
10293 else
10294 {
10295 result = eCSR_ROAM_RESULT_NONE;
10296 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010297 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 }
10299 else
10300 {
10301 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010302 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10303 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10304 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 }
10306 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10307 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10309 // can go ahead and initiate the TSPEC if any are pending
10310 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010311#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 //Send Adjacent AP repot to new AP.
10313 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10314 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010315 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010316 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010317#ifdef FEATURE_WLAN_ESE_UPLOAD
10318 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010319#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010320 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010321#endif
10322 pSession->isPrevApInfoValid = FALSE;
10323 }
10324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10326 {
10327 csrReleaseCommandSetKey( pMac, pCommand );
10328 }
10329 }
10330 else
10331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010332 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 }
10334 }
10335 else
10336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010337 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 smeProcessPendingQueue( pMac );
10340 }
10341 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010342 case eWNI_SME_REMOVEKEY_RSP:
10343 {
10344 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10345 tListElem *pEntry;
10346 tSmeCmd *pCommand;
10347
10348 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10349 if ( pEntry )
10350 {
10351 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10352 if ( eSmeCommandRemoveKey == pCommand->command )
10353 {
10354 sessionId = pCommand->sessionId;
10355 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010356
10357 if(!pSession)
10358 {
10359 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10360 return;
10361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010362#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10363 {
10364 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010365 vos_mem_set(&removeKeyEvent,
10366 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10368 removeKeyEvent.encryptionModeMulticast =
10369 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10370 removeKeyEvent.encryptionModeUnicast =
10371 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010372 vos_mem_copy( removeKeyEvent.bssid,
10373 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 removeKeyEvent.authMode =
10375 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010376 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 {
10378 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10379 }
10380 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10381 }
10382#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010383 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010385 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10386 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 result = eCSR_ROAM_RESULT_NONE;
10388 pRoamInfo = &roamInfo;
10389 }
10390 else
10391 {
10392 result = eCSR_ROAM_RESULT_FAILURE;
10393 }
10394 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10395 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10396 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10397 {
10398 csrReleaseCommandRemoveKey( pMac, pCommand );
10399 }
10400 }
10401 else
10402 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010403 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 }
10405 }
10406 else
10407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010408 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 smeProcessPendingQueue( pMac );
10411 }
10412 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010414 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 csrRoamStatsRspProcessor( pMac, pSirMsg );
10416 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010417#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010418 case eWNI_SME_GET_ROAM_RSSI_RSP:
10419 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10420 csrRoamRssiRspProcessor( pMac, pSirMsg );
10421 break;
10422#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010423#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010424 case eWNI_SME_GET_TSM_STATS_RSP:
10425 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10426 csrTsmStatsRspProcessor( pMac, pSirMsg );
10427 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010428#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010430 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010431 csrUpdateRssi( pMac, pSirMsg );
10432 break;
10433
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010434 case eWNI_SME_GET_SNR_REQ:
10435 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10436 csrUpdateSnr(pMac, pSirMsg);
10437 break;
10438
Jeff Johnson295189b2012-06-20 16:38:30 -070010439#ifdef WLAN_FEATURE_VOWIFI_11R
10440 case eWNI_SME_FT_PRE_AUTH_RSP:
10441 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10442 break;
10443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010444 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10445 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010446 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 -070010447 sessionId = pSmeMaxAssocInd->sessionId;
10448 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010449 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10450 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10452 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10453 break;
10454
10455 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010456 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 btampEstablishLogLinkHdlr( pSirMsg );
10458 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010459 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010460 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010461 csrRoamRssiIndHdlr( pMac, pSirMsg );
10462 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010463#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10464 case eWNI_SME_CANDIDATE_FOUND_IND:
10465 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10466 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10467 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010468 case eWNI_SME_HANDOFF_REQ:
10469 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10470 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10471 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010472#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010473
10474 default:
10475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010477}
10478
Jeff Johnson295189b2012-06-20 16:38:30 -070010479void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10480 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10481{
10482 if(pSession)
10483 {
10484 if(pSession->bRefAssocStartCnt)
10485 {
10486 pSession->bRefAssocStartCnt--;
10487 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10488 //Need to call association_completion because there is an assoc_start pending.
10489 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10490 eCSR_ROAM_ASSOCIATION_COMPLETION,
10491 eCSR_ROAM_RESULT_FAILURE);
10492 }
10493 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10494 }
10495 else
10496 {
10497 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10498 }
10499}
10500
10501
10502eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10503{
10504 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010505 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10506 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10507 {
10508 status = csrScanRequestLostLink1( pMac, sessionId );
10509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 return(status);
10511}
10512
Jeff Johnson295189b2012-06-20 16:38:30 -070010513//return a boolean to indicate whether roaming completed or continue.
10514tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10515 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10516{
10517 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10518 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10519 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10520 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010521 if(!pSession)
10522 {
10523 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10524 return eANI_BOOLEAN_FALSE;
10525 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 //Check whether time is up
10527 if(pSession->fCancelRoaming || fForce ||
10528 ((curTime - pSession->roamingStartTime) > roamTime) ||
10529 eCsrReassocRoaming == pSession->roamingReason ||
10530 eCsrDynamicRoaming == pSession->roamingReason)
10531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010532 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010533 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10534 {
10535 //roaming is cancelled, tell HDD to indicate disconnect
10536 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10537 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10538 //to be eSIR_BEACON_MISSED
10539 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10540 {
10541 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10542 }
10543 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10544 {
10545 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10546 }
10547 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10548 {
10549 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10550 }
10551 else
10552 {
10553 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10554 }
10555 }
10556 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10557 pSession->roamingReason = eCsrNotRoaming;
10558 }
10559 else
10560 {
10561 pSession->roamResult = roamResult;
10562 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10563 {
10564 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10565 pSession->roamingReason = eCsrNotRoaming;
10566 }
10567 else
10568 {
10569 fCompleted = eANI_BOOLEAN_FALSE;
10570 }
10571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 return(fCompleted);
10573}
10574
Jeff Johnson295189b2012-06-20 16:38:30 -070010575void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10576{
10577 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010578
10579 if(!pSession)
10580 {
10581 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10582 return;
10583 }
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 if(CSR_IS_ROAMING(pSession))
10586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010587 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10589 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10590 {
10591 //No need to do anything in here because the handler takes care of it
10592 }
10593 else
10594 {
10595 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10596 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10597 //Roaming is stopped after here
10598 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10599 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010600 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 csrRoamStopRoamingTimer(pMac, sessionId);
10602 }
10603 }
10604}
10605
Jeff Johnson295189b2012-06-20 16:38:30 -070010606void csrRoamRoamingTimerHandler(void *pv)
10607{
10608 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10609 tpAniSirGlobal pMac = pInfo->pMac;
10610 tANI_U32 sessionId = pInfo->sessionId;
10611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010612
10613 if(!pSession)
10614 {
10615 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10616 return;
10617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010618
10619 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10620 {
10621 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10622 {
10623 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10624 pSession->roamingReason = eCsrNotRoaming;
10625 }
10626 }
10627}
10628
Jeff Johnson295189b2012-06-20 16:38:30 -070010629eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10630{
10631 eHalStatus status;
10632 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010633
10634 if(!pSession)
10635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010636 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010637 return eHAL_STATUS_FAILURE;
10638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010639
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010640 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010642 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010643
10644 return (status);
10645}
10646
Jeff Johnson295189b2012-06-20 16:38:30 -070010647eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10648{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010649 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010650}
10651
Jeff Johnson295189b2012-06-20 16:38:30 -070010652void csrRoamWaitForKeyTimeOutHandler(void *pv)
10653{
10654 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10655 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010656 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010657 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010658
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010659 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10660 macTraceGetNeighbourRoamState(
10661 pMac->roam.neighborRoamInfo.neighborRoamState),
10662 macTraceGetcsrRoamSubState(
10663 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010664
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10666 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010667#ifdef FEATURE_WLAN_LFR
10668 if (csrNeighborRoamIsHandoffInProgress(pMac))
10669 {
10670 /*
10671 * Enable heartbeat timer when hand-off is in progress
10672 * and Key Wait timer expired.
10673 */
10674 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010675 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010676 pMac->roam.configParam.HeartbeatThresh24);
10677 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10678 pMac->roam.configParam.HeartbeatThresh24,
10679 NULL, eANI_BOOLEAN_FALSE);
10680 }
10681#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010682 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010683
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010685 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10686 {
10687 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10688 pInfo->sessionId);
10689 }
10690
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010691 if (pSession)
10692 {
10693 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10694 {
10695 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10696 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010697 if( (pSession->connectedProfile.AuthType ==
10698 eCSR_AUTH_TYPE_SHARED_KEY) &&
10699 ( (pSession->connectedProfile.EncryptionType ==
10700 eCSR_ENCRYPT_TYPE_WEP40) ||
10701 (pSession->connectedProfile.EncryptionType ==
10702 eCSR_ENCRYPT_TYPE_WEP104) ))
10703 {
10704 status = sme_AcquireGlobalLock( &pMac->sme );
10705 if ( HAL_STATUS_SUCCESS( status ) )
10706 {
10707 csrRoamDisconnect( pMac, pInfo->sessionId,
10708 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10709 sme_ReleaseGlobalLock( &pMac->sme );
10710 }
10711 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010712 }
10713 else
10714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010715 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010716 __func__);
10717 }
10718 }
10719 else
10720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010721 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 }
10724
10725}
10726
Jeff Johnson295189b2012-06-20 16:38:30 -070010727eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10728{
10729 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010730#ifdef FEATURE_WLAN_LFR
10731 if (csrNeighborRoamIsHandoffInProgress(pMac))
10732 {
10733 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010734 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10735 macTraceGetNeighbourRoamState(
10736 pMac->roam.neighborRoamInfo.neighborRoamState),
10737 macTraceGetcsrRoamSubState(
10738 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10739 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010740 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10741 }
10742#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010743 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010744 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010745
10746 return (status);
10747}
10748
Jeff Johnson295189b2012-06-20 16:38:30 -070010749eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10750{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010751 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10752 macTraceGetNeighbourRoamState(
10753 pMac->roam.neighborRoamInfo.neighborRoamState),
10754 macTraceGetcsrRoamSubState(
10755 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010756#ifdef FEATURE_WLAN_LFR
10757 if (csrNeighborRoamIsHandoffInProgress(pMac))
10758 {
10759 /*
10760 * Enable heartbeat timer when hand-off is in progress
10761 * and Key Wait timer got stopped for some reason
10762 */
10763 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010764 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010765 pMac->roam.configParam.HeartbeatThresh24);
10766 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10767 pMac->roam.configParam.HeartbeatThresh24,
10768 NULL, eANI_BOOLEAN_FALSE);
10769 }
10770#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010771 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010772}
10773
Jeff Johnson295189b2012-06-20 16:38:30 -070010774void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10775 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10776{
10777 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10778 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010779 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10780 /* To silence the KW tool Null chaeck is added */
10781 if(!pSession)
10782 {
10783 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10784 return;
10785 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010786
10787 if(pCommand)
10788 {
10789 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010790 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010792 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10793 {
10794 //if success, force roaming completion
10795 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10796 }
10797 else
10798 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010799 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010800 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10802 }
10803}
10804
Jeff Johnson295189b2012-06-20 16:38:30 -070010805eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10806{
10807 eHalStatus status = eHAL_STATUS_SUCCESS;
10808 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10809 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10810 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10811 tCsrRoamInfo *pRoamInfo = NULL;
10812 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010813 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010815 /* To silence the KW tool Null chaeck is added */
10816 if(!pSession)
10817 {
10818 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10819 return eHAL_STATUS_FAILURE;
10820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010822 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10824 if ( eWNI_SME_DISASSOC_IND == type )
10825 {
10826 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10827 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10828 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010829 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 }
10831 else if ( eWNI_SME_DEAUTH_IND == type )
10832 {
10833 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10834 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10835 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010836 /* Convert into proper reason code */
Deepthi Gowridf91a662014-12-17 17:14:35 +053010837 if ((pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ||
10838 (pDeauthIndMsg->reasonCode ==
10839 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON))
10840 pSession->joinFailStatusCode.reasonCode = 0;
10841 else
10842 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
10843
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010844 /* cfg layer expects 0 as reason code if
10845 the driver dosent know the reason code
10846 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 }
10848 else
10849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010850 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010852 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 }
10854
10855 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 {
10858 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10859 }
10860
10861 if ( eWNI_SME_DISASSOC_IND == type )
10862 {
10863 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10864 }
10865 else if ( eWNI_SME_DEAUTH_IND == type )
10866 {
10867 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010869 if(!HAL_STATUS_SUCCESS(status))
10870 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010871 //If fail to send confirmation to PE, not to trigger roaming
10872 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010873 }
10874
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010875 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010876 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10878 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 if( eWNI_SME_DISASSOC_IND == type)
10880 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010881 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010882 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10883 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010884 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010886 else if( eWNI_SME_DEAUTH_IND == type )
10887 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010888 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010889 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10890 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010891 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10892 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010893 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010894
10895 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10896 that we are roaming. But if we cannot possibly roam, or if we are unable to
10897 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 if(fToRoam)
10899 {
10900 //Only remove the connected BSS in infrastructure mode
10901 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10902 //Not to do anying for lostlink with WDS
10903 if( pMac->roam.configParam.nRoamingTime )
10904 {
10905 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10906 ( eWNI_SME_DEAUTH_IND == type ) ?
10907 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10908 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010909 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 //For IBSS, we need to give some more info to HDD
10911 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10912 {
10913 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10914 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10915 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10916 }
10917 else
10918 {
10919 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10920 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010921 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10923 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10924 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10925 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10926 }
10927 else
10928 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010929 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 fToRoam = eANI_BOOLEAN_FALSE;
10931 }
10932 }
10933 else
10934 {
10935 //We are told not to roam, indicate lostlink
10936 fToRoam = eANI_BOOLEAN_FALSE;
10937 }
10938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 if(!fToRoam)
10940 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010941 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010942 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010943 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010944 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10945 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10946 * csrRoamCheckForLinkStatusChange API.
10947 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010948 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10949 }
10950
10951 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010952 Still enable idle scan for polling in case concurrent sessions are running */
10953 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10954 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010955 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010956 }
10957 }
10958
10959 return (status);
10960}
10961
Jeff Johnson295189b2012-06-20 16:38:30 -070010962eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10963{
10964 eHalStatus status = eHAL_STATUS_SUCCESS;
10965 tListElem *pEntry = NULL;
10966 tSmeCmd *pCommand = NULL;
10967 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010968
10969 if(!pSession)
10970 {
10971 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10972 return eHAL_STATUS_FAILURE;
10973 }
10974
Jeff Johnson295189b2012-06-20 16:38:30 -070010975 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 //Only remove the connected BSS in infrastructure mode
10977 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10978 if(pMac->roam.configParam.nRoamingTime)
10979 {
10980 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10981 {
10982 //before starting the lost link logic release the roam command for handoff
10983 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10984 if(pEntry)
10985 {
10986 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10987 }
10988 if(pCommand)
10989 {
10990 if (( eSmeCommandRoam == pCommand->command ) &&
10991 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10992 {
10993 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10994 {
10995 csrReleaseCommandRoam( pMac, pCommand );
10996 }
10997 }
10998 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010999 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 }
11001 }
11002 else
11003 {
11004 //We are told not to roam, indicate lostlink
11005 status = eHAL_STATUS_FAILURE;
11006 }
11007
11008 return (status);
11009}
Jeff Johnson295189b2012-06-20 16:38:30 -070011010void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11011{
11012 tListElem *pEntry;
11013 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11015 if ( pEntry )
11016 {
11017 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11018 if ( eSmeCommandWmStatusChange == pCommand->command )
11019 {
11020 // Nothing to process in a Lost Link completion.... It just kicks off a
11021 // roaming sequence.
11022 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11023 {
11024 csrReleaseCommandWmStatusChange( pMac, pCommand );
11025 }
11026 else
11027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011028 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 }
11030
11031 }
11032 else
11033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011034 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 }
11036 }
11037 else
11038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011039 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 smeProcessPendingQueue( pMac );
11042}
11043
Jeff Johnson295189b2012-06-20 16:38:30 -070011044void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11045{
11046 eHalStatus status = eHAL_STATUS_FAILURE;
11047 tSirSmeRsp *pSirSmeMsg;
11048 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011049
11050 if(!pSession)
11051 {
11052 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11053 return;
11054 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011055 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11056 pCommand->sessionId,
11057 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 switch ( pCommand->u.wmStatusChangeCmd.Type )
11059 {
11060 case eCsrDisassociated:
11061 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11062 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11063 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011064 case eCsrDeauthenticated:
11065 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11066 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11067 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011069 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011070 break;
11071 }
11072 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11073 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11074 {
11075 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11076 {
11077 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011078 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011079 }
11080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11082 // command here since there is nothing else to do.
11083 csrRoamWmStatusChangeComplete( pMac );
11084}
11085
Jeff Johnson295189b2012-06-20 16:38:30 -070011086//This function returns band and mode information.
11087//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11088//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011089static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11090 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011091{
Jeff Johnson295189b2012-06-20 16:38:30 -070011092 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11093 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11094 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011096
Jeff Johnson295189b2012-06-20 16:38:30 -070011097 //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 -070011098 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11099 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11100 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11101 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011102 {
11103 switch( pMac->roam.configParam.uCfgDot11Mode )
11104 {
11105 case eCSR_CFG_DOT11_MODE_11A:
11106 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11107 eBand = eCSR_BAND_5G;
11108 break;
11109 case eCSR_CFG_DOT11_MODE_11B:
11110 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11111 eBand = eCSR_BAND_24;
11112 break;
11113 case eCSR_CFG_DOT11_MODE_11G:
11114 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11115 eBand = eCSR_BAND_24;
11116 break;
11117 case eCSR_CFG_DOT11_MODE_11N:
11118 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011119 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11120 break;
11121#ifdef WLAN_FEATURE_11AC
11122 case eCSR_CFG_DOT11_MODE_11AC:
11123 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11124 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011125 /* If the operating channel is in 2.4 GHz band, check for
11126 * INI item to disable VHT operation in 2.4 GHz band
11127 */
11128 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11129 !pMac->roam.configParam.enableVhtFor24GHz)
11130 {
11131 /* Disable 11AC operation */
11132 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11133 }
11134 else
11135 {
11136 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11137 }
11138 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011139 }
11140 else
11141 {
11142 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11143 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11144 }
11145 break;
11146 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11147 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11148 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011149 /* If the operating channel is in 2.4 GHz band, check for
11150 * INI item to disable VHT operation in 2.4 GHz band
11151 */
11152 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11153 !pMac->roam.configParam.enableVhtFor24GHz)
11154 {
11155 /* Disable 11AC operation */
11156 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11157 }
11158 else
11159 {
11160 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11161 }
11162 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011163 }
11164 else
11165 {
11166 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11167 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11168 }
11169 break;
11170#endif
11171 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011172#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011173 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11174 {
11175 /* If the operating channel is in 2.4 GHz band, check for
11176 * INI item to disable VHT operation in 2.4 GHz band
11177 */
11178 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11179 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011180 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011181 /* Disable 11AC operation */
11182 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011183 }
11184 else
11185 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011186 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11187 }
11188 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11189 }
11190 else
11191 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011192 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11193 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011194 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011195#else
11196 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11197 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11198#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 default:
11201 // Global dot11 Mode setting is 11a/b/g.
11202 // use the channel number to determine the Mode setting.
11203 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11204 {
11205 eBand = pMac->roam.configParam.eBand;
11206 if(eCSR_BAND_24 == eBand)
11207 {
11208 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11209 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11210 }
11211 else
11212 {
11213 //prefer 5GHz
11214 eBand = eCSR_BAND_5G;
11215 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11216 }
11217 }
11218 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11219 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011220 // WiFi tests require IBSS networks to start in 11b mode
11221 // without any change to the default parameter settings
11222 // on the adapter. We use ACU to start an IBSS through
11223 // creation of a startIBSS profile. This startIBSS profile
11224 // has Auto MACProtocol and the adapter property setting
11225 // for dot11Mode is also AUTO. So in this case, let's
11226 // start the IBSS network in 11b mode instead of 11g mode.
11227 // So this is for Auto=profile->MacProtocol && Auto=Global.
11228 // dot11Mode && profile->channel is < 14, then start the IBSS
11229 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011231 // Note: we used to have this start as an 11g IBSS for best
11232 // performance... now to specify that the user will have to
11233 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11235 eBand = eCSR_BAND_24;
11236 }
11237 else
11238 {
11239 // else, it's a 5.0GHz channel. Set mode to 11a.
11240 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11241 eBand = eCSR_BAND_5G;
11242 }
11243 break;
11244 }//switch
11245 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11246 else
11247 {
11248 //dot11 mode is set, lets pick the band
11249 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11250 {
11251 // channel is Auto also.
11252 eBand = pMac->roam.configParam.eBand;
11253 if(eCSR_BAND_ALL == eBand)
11254 {
11255 //prefer 5GHz
11256 eBand = eCSR_BAND_5G;
11257 }
11258 }
11259 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11260 {
11261 eBand = eCSR_BAND_24;
11262 }
11263 else
11264 {
11265 eBand = eCSR_BAND_5G;
11266 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011268 if(pBand)
11269 {
11270 *pBand = eBand;
11271 }
11272
11273 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011274 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11276 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011277
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011278 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11279 if( (!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) || ((pProfile->privacy == 1) && (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)) ) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011280 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011281#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011282 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011283#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011284 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11285 {
11286 //We cannot do 11n here
11287 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11288 {
11289 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11290 }
11291 else
11292 {
11293 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11294 }
11295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 return( cfgDot11Mode );
11297}
11298
Jeff Johnson295189b2012-06-20 16:38:30 -070011299eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11300{
11301 eHalStatus status;
11302 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011303
11304 if(!pSession)
11305 {
11306 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11307 return eHAL_STATUS_FAILURE;
11308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011309
11310#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11311 {
11312 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11314 if(pIbssLog)
11315 {
11316 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11317 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11318 }
11319 }
11320#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011321 // Set the roaming substate to 'stop Bss request'...
11322 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11323
11324 // attempt to stop the Bss (reason code is ignored...)
11325 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011326 if(!HAL_STATUS_SUCCESS(status))
11327 {
11328 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11329 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 return (status);
11331}
11332
Jeff Johnson295189b2012-06-20 16:38:30 -070011333//pNumChan is a caller allocated space with the sizeof pChannels
11334eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11335{
11336
11337 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11338 (tANI_U8 *)pChannels,
11339 pNumChan));
11340}
11341
Kiran4a17ebe2013-01-31 10:43:43 -080011342tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11343{
11344 tANI_U32 cfgLength = 0;
11345 tANI_U16 cfgId = 0;
11346 tPowerdBm maxTxPwr = 0;
11347 tANI_U8 *pCountryInfo = NULL;
11348 eHalStatus status;
11349 tANI_U8 count = 0;
11350 tANI_U8 firstChannel;
11351 tANI_U8 maxChannels;
11352
11353 if (CSR_IS_CHANNEL_5GHZ(channel))
11354 {
11355 cfgId = WNI_CFG_MAX_TX_POWER_5;
11356 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11357 }
11358 else if (CSR_IS_CHANNEL_24GHZ(channel))
11359 {
11360 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11361 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11362 }
11363 else
11364 return maxTxPwr;
11365
Kiet Lam64c1b492013-07-12 13:56:44 +053011366 pCountryInfo = vos_mem_malloc(cfgLength);
11367 if ( NULL == pCountryInfo )
11368 status = eHAL_STATUS_FAILURE;
11369 else
11370 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011371 if (status != eHAL_STATUS_SUCCESS)
11372 {
11373 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011374 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011375 __FUNCTION__, status);
11376 goto error;
11377 }
11378 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11379 if (status != eHAL_STATUS_SUCCESS)
11380 {
11381 goto error;
11382 }
11383 /* Identify the channel and maxtxpower */
11384 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11385 {
11386 firstChannel = pCountryInfo[count++];
11387 maxChannels = pCountryInfo[count++];
11388 maxTxPwr = pCountryInfo[count++];
11389
11390 if ((channel >= firstChannel) &&
11391 (channel < (firstChannel + maxChannels)))
11392 {
11393 break;
11394 }
11395 }
11396
11397error:
11398 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011399 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011400
11401 return maxTxPwr;
11402}
11403
11404
Jeff Johnson295189b2012-06-20 16:38:30 -070011405tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11406{
11407 tANI_BOOLEAN fValid = FALSE;
11408 tANI_U32 idxValidChannels;
11409 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11410
11411 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11412 {
11413 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11414 {
11415 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11416 {
11417 fValid = TRUE;
11418 break;
11419 }
11420 }
11421 }
11422 pMac->roam.numValidChannels = len;
11423 return fValid;
11424}
11425
Jeff Johnson295189b2012-06-20 16:38:30 -070011426tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11427{
11428 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11429 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11431 {
11432 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11433 {
11434 fValid = eANI_BOOLEAN_TRUE;
11435 break;
11436 }
11437 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 return (fValid);
11439}
11440
Jeff Johnson295189b2012-06-20 16:38:30 -070011441//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011442 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011443{
Jeff Johnsone7245742012-09-05 17:12:55 -070011444 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 tANI_U8 centerChn;
11446 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011447
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11449 {
11450 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11451 }
11452 else
11453 {
11454 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11455 }
11456 //Figure what the other side's CB mode
11457 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11458 {
11459 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11460 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011461 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11462 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11463 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11464 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011465 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11466 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011467 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011468 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011469
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011470 {
11471 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11472 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11473 }
11474
11475 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011477 /* This is called during INFRA STA/CLIENT and should use the merged value of
11478 * supported channel width and recommended tx width as per standard
11479 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011480 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011481 pIes->HTCaps.supportedChannelWidthSet,
11482 pIes->HTInfo.recommendedTxWidthSet,
11483 pIes->HTInfo.secondaryChannelOffset);
11484
11485 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11486 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011488 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11489 switch (eRet) {
11490 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11491 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11492 break;
11493 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11494 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11495 break;
11496 case PHY_SINGLE_CHANNEL_CENTERED:
11497 default:
11498 centerChn = primaryChn;
11499 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011500 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011501 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011503 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011504 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011505 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053011506 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
11507 {
11508 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
11509 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 }
11512 }
11513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 return eRet;
11515}
Jeff Johnson295189b2012-06-20 16:38:30 -070011516tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11517{
11518 tANI_BOOLEAN fFound = FALSE;
11519 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11521 {
11522 if( pCipherList->encryptionType[idx] == encryptionType )
11523 {
11524 fFound = TRUE;
11525 break;
11526 }
11527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 return fFound;
11529}
Jeff Johnson295189b2012-06-20 16:38:30 -070011530tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11531{
11532 tANI_BOOLEAN fFound = FALSE;
11533 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11535 {
11536 if( pAuthList->authType[idx] == authType )
11537 {
11538 fFound = TRUE;
11539 break;
11540 }
11541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 return fFound;
11543}
Jeff Johnson295189b2012-06-20 16:38:30 -070011544tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11545{
11546 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11547 tCsrScanResultFilter *pScanFilter = NULL;
11548 eHalStatus status = eHAL_STATUS_SUCCESS;
11549
11550 if(pProfile1 && pProfile2)
11551 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011552 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11553 if ( NULL == pScanFilter )
11554 status = eHAL_STATUS_FAILURE;
11555 else
11556 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 if(HAL_STATUS_SUCCESS(status))
11558 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011559 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11561 if(HAL_STATUS_SUCCESS(status))
11562 {
11563 fCheck = eANI_BOOLEAN_FALSE;
11564 do
11565 {
11566 tANI_U32 i;
11567 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11568 {
11569 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11570 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11571 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11572 if ( fCheck ) break;
11573 }
11574 if(!fCheck)
11575 {
11576 break;
11577 }
11578 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11579 || pProfile2->BSSType != pProfile1->BSSType
11580 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11581 )
11582 {
11583 fCheck = eANI_BOOLEAN_FALSE;
11584 break;
11585 }
11586#ifdef WLAN_FEATURE_VOWIFI_11R
11587 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11588 {
11589 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11590 {
11591 fCheck = eANI_BOOLEAN_FALSE;
11592 break;
11593 }
11594 }
11595#endif
11596 //Match found
11597 fCheck = eANI_BOOLEAN_TRUE;
11598 }while(0);
11599 csrFreeScanFilter(pMac, pScanFilter);
11600 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011601 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 }
11603 }
11604
11605 return (fCheck);
11606}
11607
Jeff Johnson295189b2012-06-20 16:38:30 -070011608tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11609{
11610 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11611 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 do
11613 {
11614 //Only check for static WEP
11615 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11616 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11617 {
11618 fCheck = eANI_BOOLEAN_TRUE;
11619 break;
11620 }
11621 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11622 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11623 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11624 {
11625 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011626 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11627 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 {
11629 break;
11630 }
11631 }
11632 if( i == CSR_MAX_NUM_KEY)
11633 {
11634 fCheck = eANI_BOOLEAN_TRUE;
11635 }
11636 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 return (fCheck);
11638}
11639
Jeff Johnson295189b2012-06-20 16:38:30 -070011640//IBSS
11641
Jeff Johnson295189b2012-06-20 16:38:30 -070011642tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11643{
11644 tANI_U8 channel = 0;
11645 tANI_U32 idx;
11646 tANI_U32 idxValidChannels;
11647 tANI_BOOLEAN fFound = FALSE;
11648 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11649
11650 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11651 {
11652 channel = pMac->roam.configParam.AdHocChannel5G;
11653 if(!csrRoamIsChannelValid(pMac, channel))
11654 {
11655 channel = 0;
11656 }
11657 }
11658 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11659 {
11660 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11661 {
11662 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11663 {
11664 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11665 {
11666 fFound = TRUE;
11667 channel = csrStartIbssChannels50[ idx ];
11668 }
11669 }
11670 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11672 if (!fFound)
11673 {
11674 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11675 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011676 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011678 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 break;
11680 }
11681 }
11682 }
11683 }//if
11684
11685 return( channel );
11686}
11687
Jeff Johnson295189b2012-06-20 16:38:30 -070011688tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11689{
11690 tANI_U8 channel = 1;
11691 tANI_U32 idx;
11692 tANI_U32 idxValidChannels;
11693 tANI_BOOLEAN fFound = FALSE;
11694 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11695
11696 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11697 {
11698 channel = pMac->roam.configParam.AdHocChannel24;
11699 if(!csrRoamIsChannelValid(pMac, channel))
11700 {
11701 channel = 0;
11702 }
11703 }
11704
11705 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11706 {
11707 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11708 {
11709 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11710 {
11711 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11712 {
11713 fFound = TRUE;
11714 channel = csrStartIbssChannels24[ idx ];
11715 }
11716 }
11717 }
11718 }
11719
11720 return( channel );
11721}
11722
Jeff Johnson295189b2012-06-20 16:38:30 -070011723static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11724 tCsrRoamStartBssParams *pParam )
11725{
11726 eCsrCfgDot11Mode cfgDot11Mode;
11727 eCsrBand eBand;
11728 tANI_U8 channel = 0;
11729 tSirNwType nwType;
11730 tANI_U8 operationChannel = 0;
11731
11732 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11733 {
11734 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11735 }
11736
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011738
Jeff Johnson295189b2012-06-20 16:38:30 -070011739 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11740 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11741 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11742 )
11743 {
11744 /* This should never happen */
11745 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011746 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 pProfile->csrPersona);
11748 VOS_ASSERT(0);
11749 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 switch( cfgDot11Mode )
11751 {
11752 case eCSR_CFG_DOT11_MODE_11G:
11753 nwType = eSIR_11G_NW_TYPE;
11754 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011755 case eCSR_CFG_DOT11_MODE_11B:
11756 nwType = eSIR_11B_NW_TYPE;
11757 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 case eCSR_CFG_DOT11_MODE_11A:
11759 nwType = eSIR_11A_NW_TYPE;
11760 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011761 default:
11762 case eCSR_CFG_DOT11_MODE_11N:
11763 case eCSR_CFG_DOT11_MODE_TAURUS:
11764 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11765 if(eCSR_BAND_24 == eBand)
11766 {
11767 nwType = eSIR_11G_NW_TYPE;
11768 }
11769 else
11770 {
11771 nwType = eSIR_11A_NW_TYPE;
11772 }
11773 break;
11774 }
11775
11776 pParam->extendedRateSet.numRates = 0;
11777
11778 switch ( nwType )
11779 {
11780 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011781 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 case eSIR_11A_NW_TYPE:
11783
11784 pParam->operationalRateSet.numRates = 8;
11785
11786 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11787 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11788 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11789 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11790 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11791 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11792 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11793 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11794
11795 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11796 {
11797 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11798 if( 0 == channel &&
11799 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11800 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11801 )
11802 {
11803 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11804 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11805 nwType = eSIR_11B_NW_TYPE;
11806 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11807 pParam->operationalRateSet.numRates = 4;
11808 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11809 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11810 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11811 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11812 }
11813 }
11814 else
11815 {
11816 channel = operationChannel;
11817 }
11818 break;
11819
11820 case eSIR_11B_NW_TYPE:
11821 pParam->operationalRateSet.numRates = 4;
11822 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11823 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11824 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11825 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11827 {
11828 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11829 }
11830 else
11831 {
11832 channel = operationChannel;
11833 }
11834
11835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 /* For P2P Client and P2P GO, disable 11b rates */
11838 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11839 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11840 )
11841 {
11842 pParam->operationalRateSet.numRates = 8;
11843
11844 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11845 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11846 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11847 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11848 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11849 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11850 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11851 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11852 }
11853 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 {
11855 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11857 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11858 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11859 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11860
11861 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11863 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11864 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11865 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11866 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11867 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11868 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11869 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11870 }
11871
11872 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11873 {
11874 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11875 }
11876 else
11877 {
11878 channel = operationChannel;
11879 }
11880
11881 break;
11882 }
11883 pParam->operationChn = channel;
11884 pParam->sirNwType = nwType;
11885}
11886
Jeff Johnson295189b2012-06-20 16:38:30 -070011887static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11888 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11889{
11890
11891 if( pParam )
11892 {
11893 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011894 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011895 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011896 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011897
11898 if( pIes )
11899 {
11900 if(pIes->SuppRates.present)
11901 {
11902 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11903 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11904 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011905 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 -070011906 pIes->SuppRates.num_rates);
11907 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11908 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011909 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11910 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011912 if (pIes->ExtSuppRates.present)
11913 {
11914 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011915 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011916 {
11917 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11918 SIR_MAC_RATESET_EID_MAX, resetting to \
11919 SIR_MAC_RATESET_EID_MAX"),
11920 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011921 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011922 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011923 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011924 pIes->ExtSuppRates.rates,
11925 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 if( pIes->SSID.present )
11928 {
11929 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011930 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11931 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 }
11933 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 }
11935 else
11936 {
11937 pParam->ssId.length = 0;
11938 pParam->operationalRateSet.numRates = 0;
11939 }
11940 }
11941}
11942
Jeff Johnson295189b2012-06-20 16:38:30 -070011943static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11944{
11945 tANI_U8 MaxRate = 0;
11946 tANI_U32 i;
11947 tANI_U8 *pRate;
11948
11949 pRate = pSirRateSet->rate;
11950 for ( i = 0; i < pSirRateSet->numRates; i++ )
11951 {
11952 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11953 }
11954
11955 // Save the max rate in the connected state information...
11956
11957 // modify LastRates variable as well
11958
11959 return;
11960}
11961
Jeff Johnson295189b2012-06-20 16:38:30 -070011962eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11963 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11964{
11965 eHalStatus status = eHAL_STATUS_SUCCESS;
11966 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011967 // Set the roaming substate to 'Start BSS attempt'...
11968 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011969#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11970 //Need to figure out whether we need to log WDS???
11971 if( CSR_IS_IBSS( pProfile ) )
11972 {
11973 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11975 if(pIbssLog)
11976 {
11977 if(pBssDesc)
11978 {
11979 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011980 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 }
11982 else
11983 {
11984 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11985 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011986 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 if(pProfile->ChannelInfo.numOfChannels == 0)
11988 {
11989 pIbssLog->channelSetting = AUTO_PICK;
11990 }
11991 else
11992 {
11993 pIbssLog->channelSetting = SPECIFIED;
11994 }
11995 pIbssLog->operatingChannel = pParam->operationChn;
11996 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11997 }
11998 }
11999#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12000 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012001 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12002 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012003
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 pParam->privacy = pProfile->privacy;
12005 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12006 pParam->authType = pProfile->csr80211AuthType;
12007 pParam->beaconInterval = pProfile->beaconInterval;
12008 pParam->dtimPeriod = pProfile->dtimPeriod;
12009 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12010 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12011 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12012 {
12013 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12014 {
12015 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12016 }
12017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 pParam->protEnabled = pProfile->protEnabled;
12019 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12020 pParam->ht_protection = pProfile->cfg_protection;
12021 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012022
Jeff Johnson295189b2012-06-20 16:38:30 -070012023 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12024 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012026
12027#ifdef WLAN_FEATURE_11W
12028 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12029 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12030#endif
12031
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 // When starting an IBSS, start on the channel from the Profile.
12033 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 return (status);
12035}
12036
Jeff Johnson295189b2012-06-20 16:38:30 -070012037static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012038 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012039{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012040 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012041 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012043
12044 if(!pSession)
12045 {
12046 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12047 return;
12048 }
12049
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 if( pBssDesc )
12051 {
12052 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12053 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12054 //The following code has to be do after that.
12055 //For WDS station, use selfMac as the self BSSID
12056 if( CSR_IS_WDS_STA( pProfile ) )
12057 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012058 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12059 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 }
12061 }
12062 else
12063 {
12064 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012065 //Use the first SSID
12066 if(pProfile->SSIDs.numOfSSIDs)
12067 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012068 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12069 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 }
12071 //For WDS station, use selfMac as the self BSSID
12072 if( CSR_IS_WDS_STA( pProfile ) )
12073 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012074 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12075 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 }
12077 //Use the first BSSID
12078 else if( pProfile->BSSIDs.numOfBSSIDs )
12079 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012080 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12081 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 }
12083 else
12084 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012085 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 }
12087 }
12088 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 //Set operating channel in pProfile which will be used
12090 //in csrRoamSetBssConfigCfg() to determine channel bonding
12091 //mode and will be configured in CFG later
12092 pProfile->operationChannel = Channel;
12093
12094 if(Channel == 0)
12095 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012096 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 }
12098 else
12099 {
12100
12101 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012102 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012103 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012104 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012105 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012106#ifdef WLAN_FEATURE_AP_HT40_24G
12107 if (CSR_IS_INFRA_AP(pProfile))
12108 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12109 else
12110 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12111#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012112 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012113#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012114 }
12115 else
12116 {
12117 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12118 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012119 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012120 pBssConfig->cbMode = cbMode;
12121 pSession->bssParams.cbMode = cbMode;
12122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 }
12124}
12125
Jeff Johnson295189b2012-06-20 16:38:30 -070012126static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12127 tANI_BOOLEAN *pfSameIbss )
12128{
12129 eHalStatus status = eHAL_STATUS_SUCCESS;
12130 tANI_BOOLEAN fSameIbss = FALSE;
12131
12132 if ( csrIsConnStateIbss( pMac, sessionId ) )
12133 {
12134 // Check if any profile parameter has changed ? If any profile parameter
12135 // has changed then stop old BSS and start a new one with new parameters
12136 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12137 {
12138 fSameIbss = TRUE;
12139 }
12140 else
12141 {
12142 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12143 }
12144 }
12145 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12146 {
12147 // Disassociate from the connected Infrastructure network...
12148 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12149 }
12150 else
12151 {
12152 tBssConfigParam *pBssConfig;
12153
Kiet Lam64c1b492013-07-12 13:56:44 +053012154 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12155 if ( NULL == pBssConfig )
12156 status = eHAL_STATUS_FAILURE;
12157 else
12158 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 if(HAL_STATUS_SUCCESS(status))
12160 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012161 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012162 // there is no Bss description before we start an IBSS so we need to adopt
12163 // all Bss configuration parameters from the Profile.
12164 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12165 if(HAL_STATUS_SUCCESS(status))
12166 {
12167 //save dotMode
12168 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12169 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012170 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012171 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12172 NULL, pBssConfig,
12173 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012175
12176 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 }//Allocate memory
12178 }
12179
12180 if(pfSameIbss)
12181 {
12182 *pfSameIbss = fSameIbss;
12183 }
12184 return( status );
12185}
12186
Jeff Johnson295189b2012-06-20 16:38:30 -070012187static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12188 tSirSmeNewBssInfo *pNewBss )
12189{
12190 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012191
12192 if(!pSession)
12193 {
12194 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12195 return;
12196 }
12197
Jeff Johnson295189b2012-06-20 16:38:30 -070012198 if( pNewBss )
12199 {
12200 // Set the operating channel.
12201 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12202 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012203 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12204 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 return;
12207}
12208
Jeff Johnson295189b2012-06-20 16:38:30 -070012209#ifdef FEATURE_WLAN_WAPI
12210eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12211 tANI_U32 numItems )
12212{
12213 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12214 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012215 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012217 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 return status;
12219 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012220 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012221 pSession = CSR_GET_SESSION( pMac, sessionId );
12222 if(numItems <= CSR_MAX_BKID_ALLOWED)
12223 {
12224 status = eHAL_STATUS_SUCCESS;
12225 //numItems may be 0 to clear the cache
12226 pSession->NumBkidCache = (tANI_U16)numItems;
12227 if(numItems && pBKIDCache)
12228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012229 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12230 sizeof(tBkidCacheInfo) * numItems);
12231 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 }
12233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 return (status);
12235}
Jeff Johnson295189b2012-06-20 16:38:30 -070012236eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12237 tBkidCacheInfo *pBkidCache)
12238{
12239 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12240 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012243 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 return status;
12245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 pSession = CSR_GET_SESSION( pMac, sessionId );
12247 if(pNum && pBkidCache)
12248 {
12249 if(pSession->NumBkidCache == 0)
12250 {
12251 *pNum = 0;
12252 status = eHAL_STATUS_SUCCESS;
12253 }
12254 else if(*pNum >= pSession->NumBkidCache)
12255 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012256 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012257 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012258 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 -070012259 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012260 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012262 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12263 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012264 *pNum = pSession->NumBkidCache;
12265 status = eHAL_STATUS_SUCCESS;
12266 }
12267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012268 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012269}
Jeff Johnson295189b2012-06-20 16:38:30 -070012270tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12271{
12272 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012273}
12274#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012275eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012276 tPmkidCacheInfo *pPMKIDCache,
12277 tANI_U32 numItems,
12278 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012279{
12280 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12281 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012282
12283 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012284 {
12285 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12286 return eHAL_STATUS_FAILURE;
12287 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012288
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012289 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012290
12291 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 {
12293#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12294 {
12295 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012296 vos_mem_set(&secEvent,
12297 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012298 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12299 secEvent.encryptionModeMulticast =
12300 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12301 secEvent.encryptionModeUnicast =
12302 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012303 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 secEvent.authMode =
12305 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12306 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12307 }
12308#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012310 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012311 if (numItems && pPMKIDCache)
12312 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012313 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012314 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12315 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012316 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012317 }
12318 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012319 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012320 tPmkidCacheInfo *pmksa;
12321
12322 for (i = 0; i < numItems; i++) {
12323 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012324
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012325 /* Delete the entry if present */
12326 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12327
12328 /* Add entry to the cache */
12329 vos_mem_copy(
12330 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12331 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12332 vos_mem_copy(
12333 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12334 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12335
12336 /* Increment the CSR local cache index */
12337 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12338 pSession->CurCacheIndex++;
12339 else
12340 pSession->CurCacheIndex = 0;
12341
12342 pSession->NumPmkidCache++;
12343 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12344 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 }
12347 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012348 return (status);
12349}
12350
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012351eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012352 tANI_U8 *pBSSId,
12353 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012354{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012355 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12356 tANI_BOOLEAN fMatchFound = FALSE;
12357 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012358 tANI_U32 CurIndex;
12359 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012360
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012361 if(!pSession)
12362 {
12363 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12364 return eHAL_STATUS_FAILURE;
12365 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012366
12367 /* Check if there are no entries to delete */
12368 if (0 == pSession->NumPmkidCache) {
12369 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12370 return eHAL_STATUS_SUCCESS;
12371 }
12372
12373 if (!flush_cache) {
12374 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12375 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12376 pBSSId, VOS_MAC_ADDR_SIZE)) {
12377 fMatchFound = 1;
12378
12379 /* Clear this - the matched entry */
12380 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12381 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012382 break;
12383 }
12384 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012385
12386 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12387 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12388 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012389 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012390 else {
12391 /* Match Found */
12392 CurIndex = pSession->CurCacheIndex;
12393 if(Index < CurIndex) {
12394 for(i = Index; i < (CurIndex-1); i++) {
12395 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12396 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12397 }
12398 pSession->CurCacheIndex--;
12399 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12400 sizeof(tPmkidCacheInfo));
12401 } else if(Index > CurIndex) {
12402 for(i = Index; i > (CurIndex); i--) {
12403 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12404 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12405 }
12406 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12407 sizeof(tPmkidCacheInfo));
12408 }
12409 pSession->NumPmkidCache--;
12410 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012411 } else {
12412 /* Flush the entire cache */
12413 vos_mem_zero(pSession->PmkidCacheInfo,
12414 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12415 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012416 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012417 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012418
12419 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012420}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012421
Jeff Johnson295189b2012-06-20 16:38:30 -070012422tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12423{
12424 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12425}
12426
Jeff Johnson295189b2012-06-20 16:38:30 -070012427eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12428{
12429 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12430 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012431 tPmkidCacheInfo *pmksa;
12432 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012433
12434 if(!pSession)
12435 {
12436 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12437 return eHAL_STATUS_FAILURE;
12438 }
12439
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 if(pNum && pPmkidCache)
12441 {
12442 if(pSession->NumPmkidCache == 0)
12443 {
12444 *pNum = 0;
12445 status = eHAL_STATUS_SUCCESS;
12446 }
12447 else if(*pNum >= pSession->NumPmkidCache)
12448 {
12449 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012451 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 -070012452 pSession->NumPmkidCache);
12453 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12454 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012455
12456 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12457 pmksa = &pSession->PmkidCacheInfo[i];
12458 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12459 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
12460 pPmkidCache++;
12461 j++;
12462 }
12463 }
12464
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 *pNum = pSession->NumPmkidCache;
12466 status = eHAL_STATUS_SUCCESS;
12467 }
12468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 return (status);
12470}
12471
Jeff Johnson295189b2012-06-20 16:38:30 -070012472eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12473{
12474 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12475 tANI_U32 len;
12476 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012477
12478 if(!pSession)
12479 {
12480 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12481 return eHAL_STATUS_FAILURE;
12482 }
12483
Jeff Johnson295189b2012-06-20 16:38:30 -070012484 if(pLen)
12485 {
12486 len = *pLen;
12487 *pLen = pSession->nWpaRsnReqIeLength;
12488 if(pBuf)
12489 {
12490 if(len >= pSession->nWpaRsnReqIeLength)
12491 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012492 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12493 pSession->nWpaRsnReqIeLength);
12494 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012495 }
12496 }
12497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 return (status);
12499}
12500
Jeff Johnson295189b2012-06-20 16:38:30 -070012501eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12502{
12503 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12504 tANI_U32 len;
12505 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012506
12507 if(!pSession)
12508 {
12509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12510 return eHAL_STATUS_FAILURE;
12511 }
12512
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 if(pLen)
12514 {
12515 len = *pLen;
12516 *pLen = pSession->nWpaRsnRspIeLength;
12517 if(pBuf)
12518 {
12519 if(len >= pSession->nWpaRsnRspIeLength)
12520 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012521 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12522 pSession->nWpaRsnRspIeLength);
12523 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 }
12525 }
12526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 return (status);
12528}
Jeff Johnson295189b2012-06-20 16:38:30 -070012529#ifdef FEATURE_WLAN_WAPI
12530eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12531{
12532 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12533 tANI_U32 len;
12534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012535
12536 if(!pSession)
12537 {
12538 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12539 return eHAL_STATUS_FAILURE;
12540 }
12541
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 if(pLen)
12543 {
12544 len = *pLen;
12545 *pLen = pSession->nWapiReqIeLength;
12546 if(pBuf)
12547 {
12548 if(len >= pSession->nWapiReqIeLength)
12549 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012550 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12551 pSession->nWapiReqIeLength);
12552 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 }
12554 }
12555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 return (status);
12557}
Jeff Johnson295189b2012-06-20 16:38:30 -070012558eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12559{
12560 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12561 tANI_U32 len;
12562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012563
12564 if(!pSession)
12565 {
12566 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12567 return eHAL_STATUS_FAILURE;
12568 }
12569
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 if(pLen)
12571 {
12572 len = *pLen;
12573 *pLen = pSession->nWapiRspIeLength;
12574 if(pBuf)
12575 {
12576 if(len >= pSession->nWapiRspIeLength)
12577 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012578 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12579 pSession->nWapiRspIeLength);
12580 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 }
12582 }
12583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 return (status);
12585}
12586#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012587eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12588{
12589 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12590 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012591
12592 if(!pSession)
12593 {
12594 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12595 return (retStatus);
12596 }
12597
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 if(CSR_IS_ROAMING(pSession))
12599 {
12600 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12601 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12602 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 return (retStatus);
12604}
12605
Jeff Johnson295189b2012-06-20 16:38:30 -070012606//This function remove the connected BSS from te cached scan result
12607eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12608 tCsrRoamConnectedProfile *pConnProfile)
12609{
12610 eHalStatus status = eHAL_STATUS_FAILURE;
12611 tCsrScanResultFilter *pScanFilter = NULL;
12612 tListElem *pEntry;
12613 tCsrScanResult *pResult;
12614 tDot11fBeaconIEs *pIes;
12615 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12617 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12618 {
12619 do
12620 {
12621 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012622 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12623 if ( NULL == pScanFilter )
12624 status = eHAL_STATUS_FAILURE;
12625 else
12626 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012628 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12629 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12630 if ( NULL == pScanFilter->BSSIDs.bssid )
12631 status = eHAL_STATUS_FAILURE;
12632 else
12633 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012635 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12636 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12638 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12639 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012640 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12641 if ( NULL == pScanFilter->SSIDs.SSIDList )
12642 status = eHAL_STATUS_FAILURE;
12643 else
12644 status = eHAL_STATUS_SUCCESS;
12645 if (!HAL_STATUS_SUCCESS(status)) break;
12646 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12647 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 }
12649 pScanFilter->authType.numEntries = 1;
12650 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12651 pScanFilter->BSSType = pConnProfile->BSSType;
12652 pScanFilter->EncryptionType.numEntries = 1;
12653 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12654 pScanFilter->mcEncryptionType.numEntries = 1;
12655 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12656 //We ignore the channel for now, BSSID should be enough
12657 pScanFilter->ChannelInfo.numOfChannels = 0;
12658 //Also ignore the following fields
12659 pScanFilter->uapsd_mask = 0;
12660 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012661 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 pScanFilter->countryCode[0] = 0;
12663 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 csrLLLock(&pMac->scan.scanResultList);
12665 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12666 while( pEntry )
12667 {
12668 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12669 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12670 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12671 pScanFilter, NULL, NULL, NULL, &pIes);
12672 //Release the IEs allocated by csrMatchBSS is needed
12673 if( !pResult->Result.pvIes )
12674 {
12675 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012676 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 }
12678 if(fMatch)
12679 {
12680 //We found the one
12681 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12682 {
12683 //Free the memory
12684 csrFreeScanResultEntry( pMac, pResult );
12685 }
12686 break;
12687 }
12688 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12689 }//while
12690 csrLLUnlock(&pMac->scan.scanResultList);
12691 }while(0);
12692 if(pScanFilter)
12693 {
12694 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012695 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 }
12697 }
12698 return (status);
12699}
12700
Jeff Johnson295189b2012-06-20 16:38:30 -070012701//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012702eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12703{
12704 eHalStatus status = eHAL_STATUS_SUCCESS;
12705 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12707 {
12708 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12709 {
12710 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12711 {
12712 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012713 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012714 status = eHAL_STATUS_CSR_WRONG_STATE;
12715 break;
12716 }
12717 if( csrIsConnStateInfra( pMac, sessionId ) )
12718 {
12719 if( chnId &&
12720 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012722 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12724 status = eHAL_STATUS_CSR_WRONG_STATE;
12725 break;
12726 }
12727 }
12728 }
12729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 return ( status );
12731}
12732
Jeff Johnson295189b2012-06-20 16:38:30 -070012733static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12734{
12735 eHalStatus status = eHAL_STATUS_SUCCESS;
12736 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12737 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012738
12739 if(!pSession)
12740 {
12741 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12742 return eHAL_STATUS_FAILURE;
12743 }
12744
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 if ( csrIsConnStateIbss( pMac, sessionId ) )
12746 {
12747 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12748 }
12749 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12750 {
12751 // Disassociate from the connected Infrastructure network...
12752 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12753 }
12754 else
12755 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12757 //Otherwise we need to add code to handle the
12758 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12759 //send stop_bss to PE, before we can continue.
12760 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012761 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012763 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12764 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 // there is no Bss description before we start an WDS so we need
12766 // to adopt all Bss configuration parameters from the Profile.
12767 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12768 if(HAL_STATUS_SUCCESS(status))
12769 {
12770 //Save profile for late use
12771 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012772 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12773 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012775 vos_mem_set(pSession->pCurRoamProfile,
12776 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012780 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012781 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12782 NULL, &bssConfig,
12783 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 }
12785 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012786
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 return( status );
12788}
12789
Jeff Johnson295189b2012-06-20 16:38:30 -070012790////////////////////Mail box
12791
Jeff Johnson295189b2012-06-20 16:38:30 -070012792//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12793//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012794static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12795 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12797{
12798 tCsrChannelSet channelGroup;
12799 tSirMacCapabilityInfo *pAP_capabilityInfo;
12800 tAniBool fTmp;
12801 tANI_BOOLEAN found = FALSE;
12802 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012803 tANI_S8 pwrLimit = 0;
12804 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12806 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12807 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12808 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 // 802.11h
12810 //We can do this because it is in HOST CPU order for now.
12811 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012812 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12813 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12814 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 fTmp = (tAniBool)pal_cpu_to_be32(1);
12816 }
12817 else
12818 fTmp = (tAniBool)0;
12819
12820 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012821 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 pBuf += sizeof(tAniBool);
12823 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012824 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 // This is required for 11k test VoWiFi Ent: Test 2.
12826 // We need the power capabilities for Assoc Req.
12827 // This macro is provided by the halPhyCfg.h. We pick our
12828 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012829 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12830 if (0 != pwrLimit)
12831 {
12832 *pBuf++ = pwrLimit;
12833 }
12834 else
12835 {
12836 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 size = sizeof(pMac->roam.validChannelList);
12839 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12840 {
12841 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12842 for ( i = 0; i < size; i++)
12843 {
12844 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12845
12846 }
12847 }
12848 else
12849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012850 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 *pBuf++ = 0; //tSirSupChnl->numChnl
12852 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 //Check whether it is ok to enter UAPSD
12854#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12855 if( btcIsReadyForUapsd(pMac) )
12856#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12857 {
12858 *pBuf++ = uapsdMask;
12859 }
12860#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12861 else
12862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012863 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 *pBuf++ = 0;
12865 }
12866#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12867
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012869 vos_mem_copy(pBuf, pBssDescription,
12870 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12872}
12873
Jeff Johnson295189b2012-06-20 16:38:30 -070012874/*
12875 * The communication between HDD and LIM is thru mailbox (MB).
12876 * Both sides will access the data structure "tSirSmeJoinReq".
12877 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12878 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12879 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12880 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12881 */
12882eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012883 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012884{
12885 eHalStatus status = eHAL_STATUS_SUCCESS;
12886 tSirSmeJoinReq *pMsg;
12887 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012888 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012889 tANI_U16 msgLen, wTmp, ieLen;
12890 tSirMacRateSet OpRateSet;
12891 tSirMacRateSet ExRateSet;
12892 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12893 tANI_U32 dwTmp;
12894 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012895 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053012896 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053012897 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012898
12899 if(!pSession)
12900 {
12901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12902 return eHAL_STATUS_FAILURE;
12903 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012904 /* To satisfy klockworks */
12905 if (NULL == pBssDescription)
12906 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012907 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012908 return eHAL_STATUS_FAILURE;
12909 }
12910
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 do {
12912 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12913 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012914 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012915 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12916 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12917 // IE fields, but the length field in the bssDescription needs to be interpreted to
12918 // determine length of the IE fields.
12919 //
12920 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12921 // add in the length from the bssDescription (then add the size of the 'length' field
12922 // itself because that is NOT included in the length field).
12923 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12924 pBssDescription->length + sizeof( pBssDescription->length ) +
12925 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 +053012926 pMsg = vos_mem_malloc(msgLen);
12927 if (NULL == pMsg)
12928 status = eHAL_STATUS_FAILURE;
12929 else
12930 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012932 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012933 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 pMsg->length = pal_cpu_to_be16(msgLen);
12935 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 // sessionId
12937 *pBuf = (tANI_U8)sessionId;
12938 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 // transactionId
12940 *pBuf = 0;
12941 *( pBuf + 1 ) = 0;
12942 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012943 // ssId
12944 if( pIes->SSID.present && pIes->SSID.num_ssid )
12945 {
12946 // ssId len
12947 *pBuf = pIes->SSID.num_ssid;
12948 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012949 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 pBuf += pIes->SSID.num_ssid;
12951 }
12952 else
12953 {
12954 *pBuf = 0;
12955 pBuf++;
12956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012958 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12959 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 pBuf += sizeof(tSirMacAddr);
12961 // bsstype
12962 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12963 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012964 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012965 pBuf += sizeof(tSirBssType);
12966 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012967 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12968 if (pBssDescription->channelId <= 14 &&
12969 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12970 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12971 {
12972 //Need to disable VHT operation in 2.4 GHz band
12973 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12974 }
12975 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 //Persona
12978 *pBuf = (tANI_U8)pProfile->csrPersona;
12979 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012980 //CBMode
12981 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12982 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012983
12984 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012985 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12986
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 // uapsdPerAcBitmask
12988 *pBuf = pProfile->uapsd_mask;
12989 pBuf++;
12990
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012991
12992
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053012993 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012994 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 {
12996 // OperationalRateSet
12997 if (OpRateSet.numRates) {
12998 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012999 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 pBuf += OpRateSet.numRates;
13001 } else *pBuf++ = 0;
13002 // ExtendedRateSet
13003 if (ExRateSet.numRates) {
13004 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013005 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 pBuf += ExRateSet.numRates;
13007 } else *pBuf++ = 0;
13008 }
13009 else
13010 {
13011 *pBuf++ = 0;
13012 *pBuf++ = 0;
13013 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013014
13015 //rateBitmap
13016 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13017 pBuf += sizeof(tANI_U16);
13018
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 // rsnIE
13020 if ( csrIsProfileWpa( pProfile ) )
13021 {
13022 // Insert the Wpa IE into the join request
13023 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13024 (tCsrWpaIe *)( wpaRsnIE ) );
13025 }
13026 else if( csrIsProfileRSN( pProfile ) )
13027 {
13028 // Insert the RSN IE into the join request
13029 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13030 (tCsrRSNIe *)( wpaRsnIE ) );
13031 }
13032#ifdef FEATURE_WLAN_WAPI
13033 else if( csrIsProfileWapi( pProfile ) )
13034 {
13035 // Insert the WAPI IE into the join request
13036 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13037 (tCsrWapiIe *)( wpaRsnIE ) );
13038 }
13039#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 else
13041 {
13042 ieLen = 0;
13043 }
13044 //remember the IE for future use
13045 if( ieLen )
13046 {
13047 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013049 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 -070013050 ieLen = DOT11F_IE_RSN_MAX_LEN;
13051 }
13052#ifdef FEATURE_WLAN_WAPI
13053 if( csrIsProfileWapi( pProfile ) )
13054 {
13055 //Check whether we need to allocate more memory
13056 if(ieLen > pSession->nWapiReqIeLength)
13057 {
13058 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13059 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013060 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013061 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013062 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13063 if (NULL == pSession->pWapiReqIE)
13064 status = eHAL_STATUS_FAILURE;
13065 else
13066 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 if(!HAL_STATUS_SUCCESS(status)) break;
13068 }
13069 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013070 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013072 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013074 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 pBuf += ieLen;
13076 }
13077 else//should be WPA/WPA2 otherwise
13078#endif /* FEATURE_WLAN_WAPI */
13079 {
13080 //Check whether we need to allocate more memory
13081 if(ieLen > pSession->nWpaRsnReqIeLength)
13082 {
13083 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13084 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013085 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013087 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13088 if (NULL == pSession->pWpaRsnReqIE)
13089 status = eHAL_STATUS_FAILURE;
13090 else
13091 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 if(!HAL_STATUS_SUCCESS(status)) break;
13093 }
13094 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013095 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013097 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013099 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pBuf += ieLen;
13101 }
13102 }
13103 else
13104 {
13105 //free whatever old info
13106 pSession->nWpaRsnReqIeLength = 0;
13107 if(pSession->pWpaRsnReqIE)
13108 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013109 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 pSession->pWpaRsnReqIE = NULL;
13111 }
13112#ifdef FEATURE_WLAN_WAPI
13113 pSession->nWapiReqIeLength = 0;
13114 if(pSession->pWapiReqIE)
13115 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013116 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 pSession->pWapiReqIE = NULL;
13118 }
13119#endif /* FEATURE_WLAN_WAPI */
13120 //length is two bytes
13121 *pBuf = 0;
13122 *(pBuf + 1) = 0;
13123 pBuf += 2;
13124 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013125#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013126 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013128 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 //length is two bytes
13130 *pBuf = 0;
13131 *(pBuf + 1) = 0;
13132 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013133 }
13134 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013136 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013137 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013138 {
13139 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013140#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013141 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013142 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013143 pSession->suppCckmIeInfo.cckmIe, ieLen);
13144#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013145 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013146 pSession,
13147 pProfile,
13148 pBssDescription,
13149 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 pSession->nWpaRsnReqIeLength,
13151 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013152#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013153 }
13154 else
13155 {
13156 ieLen = 0;
13157 }
13158 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13159 if( ieLen )
13160 {
13161 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13162 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013163 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013164 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013165 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013166 pBuf += ieLen;
13167 }
13168 else
13169 {
13170 //Indicate you have no CCKM IE
13171 //length is two bytes
13172 *pBuf = 0;
13173 *(pBuf + 1) = 0;
13174 pBuf += 2;
13175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013177#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013179 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 {
13181 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013182 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013184 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013186 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013188 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 pBuf += ieLen;
13190 }
13191 else
13192 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013193 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 *pBuf = 0;
13196 *(pBuf + 1) = 0;
13197 pBuf += 2;
13198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 // addIEAssoc
13200 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13201 {
13202 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 if(ieLen > pSession->nAddIEAssocLength)
13204 {
13205 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013206 {
13207 vos_mem_free(pSession->pAddIEAssoc);
13208 }
13209 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13210 if (NULL == pSession->pAddIEAssoc)
13211 status = eHAL_STATUS_FAILURE;
13212 else
13213 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013217 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013218 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013219 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013220 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013221 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 pBuf += ieLen;
13223 }
13224 else
13225 {
13226 pSession->nAddIEAssocLength = 0;
13227 if(pSession->pAddIEAssoc)
13228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013229 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 pSession->pAddIEAssoc = NULL;
13231 }
13232 *pBuf = 0;
13233 *(pBuf + 1) = 0;
13234 pBuf += 2;
13235 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013236
13237 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013239 //Unmask any AC in reassoc that is ACM-set
13240 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13241 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013243 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13244 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013245#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013246 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013247#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013248 }
13249 else
13250 {
13251 uapsd_mask = 0;
13252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 }
13254 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013255
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013257 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013258 pBuf += sizeof(tANI_U32);
13259
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013261 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013262 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013263#ifdef WLAN_FEATURE_11W
13264 //MgmtEncryption
13265 if (pProfile->MFPEnabled)
13266 {
13267 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13268 }
13269 else
13270 {
13271 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13272 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013273 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013274 pBuf += sizeof(tANI_U32);
13275#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013276#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013277 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013278 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013279#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013280 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013281 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013282#endif
13283 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013284 {
13285 // is11Rconnection;
13286 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013287 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013288 pBuf += sizeof(tAniBool);
13289 }
13290 else
13291 {
13292 // is11Rconnection;
13293 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013294 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013295 pBuf += sizeof(tAniBool);
13296 }
13297#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013298#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013299
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013300 // isESEFeatureIniEnabled
13301 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013302 {
13303 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013304 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013305 pBuf += sizeof(tAniBool);
13306 }
13307 else
13308 {
13309 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013310 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013311 pBuf += sizeof(tAniBool);
13312 }
13313
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013314 /* A profile can not be both ESE and 11R. But an 802.11R AP
13315 * may be advertising support for ESE as well. So if we are
13316 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013317 * If we are associating explictly 11R only then we will get
13318 * 11R.
13319 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013320 if ((csrIsProfileESE(pProfile) ||
13321 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013322 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13323 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13324 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13325 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13326#ifdef WLAN_FEATURE_11W
13327 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013328 || (pProfile->negotiatedAuthType ==
13329 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013330#endif
13331 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013332 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013333 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013334 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013335 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013336 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013337 pBuf += sizeof(tAniBool);
13338 }
13339 else
13340 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013341 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013342 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013343 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013344 pBuf += sizeof(tAniBool);
13345 }
13346
13347 if (eWNI_SME_JOIN_REQ == messageType)
13348 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013349 tESETspecInfo eseTspec;
13350 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013351 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013352 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13353 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13354 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013355 }
13356 else if (eWNI_SME_REASSOC_REQ == messageType)
13357 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013358 if ((csrIsProfileESE(pProfile) ||
13359 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013360 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13361 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13362 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13363 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13364#ifdef WLAN_FEATURE_11W
13365 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013366 || (pProfile->negotiatedAuthType ==
13367 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013368#endif
13369 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013370 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013372 tESETspecInfo eseTspec;
13373 // ESE Tspec information
13374 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13375 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13376 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013379 if (eseTspec.numTspecs) {
13380 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13381 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013383 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013385 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013387 tESETspecInfo eseTspec;
13388 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013389 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013390 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13391 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13392 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 }
13394 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013395#endif // FEATURE_WLAN_ESE
13396#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013398 if (pMac->roam.configParam.isFastTransitionEnabled
13399#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013400 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013401#endif
13402 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013404 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013405 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013406 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 }
13408 else
13409 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013410 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013412 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013413 }
13414#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013415#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013416 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013417 {
13418 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013419 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013420 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013421 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013422 }
13423 else
13424 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013425 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013426 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013427 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013428 }
13429#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013430
13431 // txLdpcIniFeatureEnabled
13432 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13433 pBuf++;
13434
Kiran4a17ebe2013-01-31 10:43:43 -080013435 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13436 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13437 {
13438 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13439 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13440 csrApplyPower2Current(pMac);
13441 }
13442
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013443#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013444 // txBFIniFeatureEnabled
13445 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13446 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013447
13448 // txBFCsnValue
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013449 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13450 if (pIes->VHTCaps.present)
13451 {
13452 txBFCsnValue = CSR_ROAM_MIN(txBFCsnValue, pIes->VHTCaps.numSoundingDim);
13453 }
13454 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013455 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013456
13457 /* Only enable MuBf if no other MuBF session exist
13458 * and FW and HOST is MuBF capable.
13459 */
13460 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13461 {
13462 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13463 pBuf++;
13464 }
13465 else
13466 {
13467 *pBuf = 0;
13468 pBuf++;
13469 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013470#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013471 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13472 pBuf++;
13473
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013474 // WME
13475 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13476 {
13477 //WME enabled
13478 dwTmp = pal_cpu_to_be32(TRUE);
13479 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13480 pBuf += sizeof(tAniBool);
13481 }
13482 else
13483 {
13484 dwTmp = pal_cpu_to_be32(FALSE);
13485 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13486 pBuf += sizeof(tAniBool);
13487 }
13488
13489 // QOS
13490 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13491 {
13492 //QOS enabled
13493 dwTmp = pal_cpu_to_be32(TRUE);
13494 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13495 pBuf += sizeof(tAniBool);
13496 }
13497 else
13498 {
13499 dwTmp = pal_cpu_to_be32(FALSE);
13500 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13501 pBuf += sizeof(tAniBool);
13502 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013503 //BssDesc
13504 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13505 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013506
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013507 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013508 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13509 pMsg = NULL;
13510
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013511 if(!HAL_STATUS_SUCCESS(status))
13512 {
13513 break;
13514 }
13515 else
13516 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013517#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013518 if (eWNI_SME_JOIN_REQ == messageType)
13519 {
13520 //Tush-QoS: notify QoS module that join happening
13521 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13522 }
13523 else if (eWNI_SME_REASSOC_REQ == messageType)
13524 {
13525 //Tush-QoS: notify QoS module that reassoc happening
13526 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013528#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013531
13532 if (pMsg != NULL)
13533 {
13534 vos_mem_free( pMsg );
13535 }
13536
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013538}
13539
Jeff Johnson295189b2012-06-20 16:38:30 -070013540//
13541eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13542{
13543 eHalStatus status = eHAL_STATUS_SUCCESS;
13544 tSirSmeDisassocReq *pMsg;
13545 tANI_U8 *pBuf;
13546 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13548 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13549 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013551 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13552 if (NULL == pMsg)
13553 status = eHAL_STATUS_FAILURE;
13554 else
13555 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013557 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13559 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013560 pBuf = &pMsg->sessionId;
13561 // sessionId
13562 *pBuf++ = (tANI_U8)sessionId;
13563 // transactionId
13564 *pBuf = 0;
13565 *( pBuf + 1 ) = 0;
13566 pBuf += sizeof(tANI_U16);
13567
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013568 if ( (pSession->pCurRoamProfile != NULL) &&
13569 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13570 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 {
13572 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013573 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13574 sizeof( tSirMacAddr ));
13575 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013578 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13579 //perMacAddr is passed as bssId for softAP
13580 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 pBuf = pBuf + sizeof ( tSirMacAddr );
13582 }
13583 else
13584 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013586 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13587 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013589 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13590 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 if(!HAL_STATUS_SUCCESS(status))
13594 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013595 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 break;
13597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 // reasonCode
13599 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013600 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13601 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 if(!HAL_STATUS_SUCCESS(status))
13603 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013604 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 break;
13606 }
13607 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13609 Here we should not send the disassoc over the air to the AP */
13610 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13611#ifdef WLAN_FEATURE_VOWIFI_11R
13612 && csrRoamIs11rAssoc(pMac)
13613#endif
13614 )
13615 {
13616 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13617 }
13618 pBuf += sizeof(tANI_U8);
13619 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 return( status );
13622}
Jeff Johnson295189b2012-06-20 16:38:30 -070013623eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13624{
13625 eHalStatus status = eHAL_STATUS_SUCCESS;
13626 tSirSmeTkipCntrMeasReq *pMsg;
13627 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 do
13629 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013630 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13631 if ( NULL == pMsg )
13632 status = eHAL_STATUS_FAILURE;
13633 else
13634 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013636 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13638 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 pBuf = &pMsg->sessionId;
13640 // sessionId
13641 *pBuf++ = (tANI_U8)sessionId;
13642 // transactionId
13643 *pBuf = 0;
13644 *( pBuf + 1 ) = 0;
13645 pBuf += sizeof(tANI_U16);
13646 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013647 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13648 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 pBuf = pBuf + sizeof ( tSirMacAddr );
13650 // bEnable
13651 *pBuf = (tANI_BOOLEAN)bEnable;
13652 if(!HAL_STATUS_SUCCESS(status))
13653 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013654 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 break;
13656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 return( status );
13660}
Jeff Johnson295189b2012-06-20 16:38:30 -070013661eHalStatus
13662csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13663 VOS_MODULE_ID modId, tSirMacAddr bssId,
13664 void *pUsrContext, void *pfnSapEventCallback,
13665 tANI_U8 *pAssocStasBuf )
13666{
13667 eHalStatus status = eHAL_STATUS_SUCCESS;
13668 tSirSmeGetAssocSTAsReq *pMsg;
13669 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13670 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 do
13672 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013673 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13674 if ( NULL == pMsg )
13675 status = eHAL_STATUS_FAILURE;
13676 else
13677 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013679 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 pBuf = (tANI_U8 *)&pMsg->bssId;
13682 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013684 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 // modId
13687 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013688 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013691 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13692 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013694 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13695 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013697 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13698 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 status = palSendMBMessage( pMac->hHdd, pMsg );
13701 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 return( status );
13703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013704eHalStatus
13705csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13706 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13707 {
13708 eHalStatus status = eHAL_STATUS_SUCCESS;
13709 tSirSmeGetWPSPBCSessionsReq *pMsg;
13710 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013711
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 do
13713 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013714 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13715 if ( NULL == pMsg )
13716 status = eHAL_STATUS_FAILURE;
13717 else
13718 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013720 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013723 VOS_ASSERT(pBuf);
13724
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013727 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13728 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013730 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13731 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013733 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013736 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 return( status );
13742}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013743
13744eHalStatus
13745csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13746{
13747 tpSirChangeBIParams pMsg;
13748 tANI_U16 len = 0;
13749 eHalStatus status = eHAL_STATUS_SUCCESS;
13750 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13751
13752 if(!pSession)
13753 {
13754 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13755 return eHAL_STATUS_FAILURE;
13756 }
13757
13758 //NO need to update the Beacon Params if update beacon parameter flag is not set
13759 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13760 return eHAL_STATUS_SUCCESS;
13761
13762 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13763
13764 /* Create the message and send to lim */
13765 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013766 pMsg = vos_mem_malloc(len);
13767 if ( NULL == pMsg )
13768 status = eHAL_STATUS_FAILURE;
13769 else
13770 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013771 if(HAL_STATUS_SUCCESS(status))
13772 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013773 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013774 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13775 pMsg->length = len;
13776
13777 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13779 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013780 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13781 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013782 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013783 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013784 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13785 status = palSendMBMessage(pMac->hHdd, pMsg);
13786 }
13787 return status;
13788}
13789
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053013790#ifdef WLAN_FEATURE_AP_HT40_24G
13791eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
13792{
13793 tpSirSetHT2040Mode pMsg;
13794 tANI_U16 len = 0;
13795 eHalStatus status = eHAL_STATUS_SUCCESS;
13796 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13797
13798 if(!pSession)
13799 {
13800 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13801 return eHAL_STATUS_FAILURE;
13802 }
13803
13804 /* Create the message and send to lim */
13805 len = sizeof(tSirSetHT2040Mode);
13806 pMsg = vos_mem_malloc(len);
13807
13808 if ( NULL == pMsg )
13809 {
13810 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
13811 status = eHAL_STATUS_FAILURE;
13812 }
13813 else
13814 status = eHAL_STATUS_SUCCESS;
13815
13816 if(HAL_STATUS_SUCCESS(status))
13817 {
13818 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
13819 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
13820 pMsg->length = len;
13821
13822 // bssId
13823 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13824 sizeof(tSirMacAddr));
13825
13826 smsLog( pMac, LOGW, FL("CSR Attempting to set "
13827 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
13828 MAC_ADDR_ARRAY(pMsg->bssId));
13829
13830 pMsg->sessionId = sessionId;
13831 pMsg->cbMode = cbMode;
13832
13833 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
13834 sessionId, cbMode);
13835
13836 status = palSendMBMessage(pMac->hHdd, pMsg);
13837 }
13838 return status;
13839}
13840#endif
13841
Jeff Johnson295189b2012-06-20 16:38:30 -070013842eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13843{
13844 eHalStatus status = eHAL_STATUS_SUCCESS;
13845 tSirSmeDeauthReq *pMsg;
13846 tANI_U8 *pBuf;
13847 tANI_U16 wTmp;
13848 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13849 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13850 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013852 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13853 if ( NULL == pMsg )
13854 status = eHAL_STATUS_FAILURE;
13855 else
13856 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013858 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13860 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13861 //sessionId
13862 pBuf = &pMsg->sessionId;
13863 *pBuf++ = (tANI_U8)sessionId;
13864
13865 //tansactionId
13866 *pBuf = 0;
13867 *(pBuf + 1 ) = 0;
13868 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13872 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013873 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13874 sizeof( pMsg->peerMacAddr ) );
13875 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 pBuf = pBuf + sizeof(tSirMacAddr);
13877 }
13878 else
13879 {
13880 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013881 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13882 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 }
13885 if(!HAL_STATUS_SUCCESS(status))
13886 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013887 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 break;
13889 }
13890 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013891 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13892 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 pBuf = pBuf + sizeof(tSirMacAddr);
13894 if(!HAL_STATUS_SUCCESS(status))
13895 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013896 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 break;
13898 }
13899 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013900 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13901 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 if(!HAL_STATUS_SUCCESS(status))
13903 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013904 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 break;
13906 }
13907 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 return( status );
13910}
13911
Jeff Johnson295189b2012-06-20 16:38:30 -070013912eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13913{
13914 eHalStatus status = eHAL_STATUS_SUCCESS;
13915 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13918 if ( NULL == pMsg )
13919 status = eHAL_STATUS_FAILURE;
13920 else
13921 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013923 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13925 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13926 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013927 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13928 sizeof(pMsg->peerMacAddr));
13929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 if(!HAL_STATUS_SUCCESS(status))
13931 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013932 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 break;
13934 }
13935//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013936 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13937 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 if(!HAL_STATUS_SUCCESS(status))
13939 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013940 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 break;
13942 }
13943//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 return( status );
13947}
13948
Jeff Johnson295189b2012-06-20 16:38:30 -070013949eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13950{
13951 eHalStatus status = eHAL_STATUS_SUCCESS;
13952 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013954 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13955 if ( NULL == pMsg )
13956 status = eHAL_STATUS_FAILURE;
13957 else
13958 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013960 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13962 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13963 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013964 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13965 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 if(!HAL_STATUS_SUCCESS(status))
13967 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013968 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 break;
13970 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013971 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13972 sizeof(pMsg->peerMacAddr));
13973 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 if(!HAL_STATUS_SUCCESS(status))
13975 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013976 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 break;
13978 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 return( status );
13982}
Jeff Johnson295189b2012-06-20 16:38:30 -070013983eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13984{
13985 eHalStatus status = eHAL_STATUS_SUCCESS;
13986 tSirSmeAssocCnf *pMsg;
13987 tANI_U8 *pBuf;
13988 tSirResultCodes statusCode;
13989 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053013990
13991 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
13992 "HalStatus : %d"),
13993 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013995 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13996 if ( NULL == pMsg )
13997 status = eHAL_STATUS_FAILURE;
13998 else
13999 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014001 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
14003 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 pBuf = (tANI_U8 *)&pMsg->statusCode;
14005 if(HAL_STATUS_SUCCESS(Halstatus))
14006 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14007 else
14008 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014009 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 pBuf += sizeof(tSirResultCodes);
14011 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014012 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14013 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 pBuf += sizeof (tSirMacAddr);
14015 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014016 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14017 sizeof(tSirMacAddr));
14018 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 pBuf += sizeof (tSirMacAddr);
14020 // aid
14021 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053014022 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 pBuf += sizeof (tANI_U16);
14024 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014025 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14026 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pBuf += sizeof (tSirMacAddr);
14028 // alternateChannelId
14029 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070014030 status = palSendMBMessage( pMac->hHdd, pMsg );
14031 if(!HAL_STATUS_SUCCESS(status))
14032 {
14033 //pMsg is freed by palSendMBMessage
14034 break;
14035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 return( status );
14038}
Jeff Johnson295189b2012-06-20 16:38:30 -070014039eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
14040 tpSirSmeAssocInd pAssocInd,
14041 eHalStatus Halstatus,
14042 tANI_U8 sessionId)
14043{
14044 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014045 tSirSmeAssocIndToUpperLayerCnf *pMsg;
14046 tANI_U8 *pBuf;
14047 tSirResultCodes statusCode;
14048 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014050 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14051 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14052 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070014053
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
14055 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14056
14057 pMsg->sessionId = sessionId;
14058
14059 pBuf = (tANI_U8 *)&pMsg->statusCode;
14060 if(HAL_STATUS_SUCCESS(Halstatus))
14061 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14062 else
14063 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014064 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014065 pBuf += sizeof(tSirResultCodes);
14066 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014067 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 pBuf += sizeof (tSirMacAddr);
14069 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014070 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14071 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014072 pBuf += sizeof (tSirMacAddr);
14073 // StaId
14074 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014075 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 pBuf += sizeof (tANI_U16);
14077 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014078 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 pBuf += sizeof (tSirMacAddr);
14080 // alternateChannelId
14081 *pBuf = 11;
14082 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014083 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 //Wmm
14085 *pBuf = pAssocInd->wmmEnabledSta;
14086 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014088 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014091 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 //reassocReq
14094 *pBuf = pAssocInd->reassocReq;
14095 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053014096#ifdef WLAN_FEATURE_AP_HT40_24G
14097 // 40 MHz Intolerant
14098 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
14099 pBuf += sizeof (tANI_U8);
14100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14102 msgQ.bodyptr = pMsg;
14103 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053014106 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070014107}
Jeff Johnson295189b2012-06-20 16:38:30 -070014108
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014109eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
14111 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
14112 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
14113 tANI_U8 *pKeyRsc )
14114{
14115 tSirSmeSetContextReq *pMsg;
14116 tANI_U16 msgLen;
14117 eHalStatus status = eHAL_STATUS_FAILURE;
14118 tAniEdType tmpEdType;
14119 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053014120 tANI_U8 *pBuf = NULL;
14121 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053014123 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14124 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
14128 // key set. Since we only support upto one key, we always allocate memory for 1 key
14129 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
14130 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
14131 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
14132 ( sizeof( pMsg->keyMaterial.key ) );
14133
Kiet Lam64c1b492013-07-12 13:56:44 +053014134 pMsg = vos_mem_malloc(msgLen);
14135 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14136 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
14138 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014139 //sessionId
14140 pBuf = &pMsg->sessionId;
14141 *pBuf = (tANI_U8)sessionId;
14142 pBuf++;
14143 // transactionId
14144 *pBuf = 0;
14145 *(pBuf + 1) = 0;
14146 pBuf += sizeof(tANI_U16);
14147 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014148 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014149
14150 pBuf += sizeof(tSirMacAddr);
14151
14152 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014153 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14154 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014155
14156 pBuf += sizeof(tSirMacAddr);
14157
14158 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14160 // in the tSirKeyMaterial keyMaterial; field).
14161 //
14162 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14163 // shorter than this max size. Is LIM interpreting this ok ?
14164 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 -070014165 // set pMsg->keyMaterial.edType
14166 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014167 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014168 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 // set the pMsg->keyMaterial.numKeys field
14170 *p = numKeys;
14171 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 // set pSirKey->keyId = keyId;
14173 *p = keyId;
14174 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 // set pSirKey->unicast = (tANI_U8)fUnicast;
14176 *p = (tANI_U8)fUnicast;
14177 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014178 // set pSirKey->keyDirection = aniKeyDirection;
14179 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014180 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 p += sizeof(tAniKeyDirection);
14182 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014183 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 // set pSirKey->paeRole
14186 *p = paeRole; // 0 is Supplicant
14187 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 // set pSirKey->keyLength = keyLength;
14189 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 if ( keyLength && pKey )
14191 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014192 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 if(keyLength == 16)
14194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014195 smsLog(pMac, LOG1, " SME Set keyIdx (%d) encType(%d) key = %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X",
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14197 pKey[5], pKey[6], pKey[7], pKey[8],
14198 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14199 }
14200 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014203 return( status );
14204}
14205
Jeff Johnson295189b2012-06-20 16:38:30 -070014206eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14207 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14208{
14209 eHalStatus status;
14210 tSirSmeStartBssReq *pMsg;
14211 tANI_U8 *pBuf = NULL;
14212 tANI_U8 *wTmpBuf = NULL;
14213 tANI_U16 msgLen, wTmp;
14214 tANI_U32 dwTmp;
14215 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014216 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014219
14220 if(!pSession)
14221 {
14222 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14223 return eHAL_STATUS_FAILURE;
14224 }
14225
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 do {
14227 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14228 pSession->joinFailStatusCode.reasonCode = 0;
14229 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014230 pMsg = vos_mem_malloc(msgLen);
14231 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14232 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 //sessionId
14237 *pBuf = (tANI_U8)sessionId;
14238 pBuf++;
14239 // transactionId
14240 *pBuf = 0;
14241 *(pBuf + 1) = 0;
14242 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014243 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014244 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 pBuf += sizeof(tSirMacAddr);
14246 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014247 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 pBuf += sizeof(tSirMacAddr);
14249 // beaconInterval
14250 if( pBssDesc && pBssDesc->beaconInterval )
14251 {
14252 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014254 else if(pParam->beaconInterval)
14255 {
14256 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 else
14259 {
14260 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14261 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014262 if(csrIsconcurrentsessionValid (pMac, sessionId,
14263 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014264 == eHAL_STATUS_SUCCESS )
14265 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014266 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014267 pParam->bssPersona);
14268 //Update the beacon Interval
14269 pParam->beaconInterval = wTmp;
14270 }
14271 else
14272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014273 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014274 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014275 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014276 return status;
14277 }
14278
Kiet Lam64c1b492013-07-12 13:56:44 +053014279 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 pBuf += sizeof(tANI_U16);
14281 // dot11mode
14282 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14283 pBuf += 1;
14284 // bssType
14285 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014286 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 pBuf += sizeof(tSirBssType);
14288 // ssId
14289 if( pParam->ssId.length )
14290 {
14291 // ssId len
14292 *pBuf = pParam->ssId.length;
14293 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014294 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 pBuf += pParam->ssId.length;
14296 }
14297 else
14298 {
14299 *pBuf = 0;
14300 pBuf++;
14301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 // set the channel Id
14303 *pBuf = pParam->operationChn;
14304 pBuf++;
14305 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014306 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014307 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014308 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014309
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 // Set privacy
14311 *pBuf = pParam->privacy;
14312 pBuf++;
14313
14314 //Set Uapsd
14315 *pBuf = pParam->ApUapsdEnable;
14316 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 //Set SSID hidden
14318 *pBuf = pParam->ssidHidden;
14319 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14321 pBuf++;
14322
14323 //Ht protection Enable/Disable
14324 *pBuf = (tANI_U8)pParam->protEnabled;
14325 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 //Enable Beacons to Receive for OBSS protection Enable/Disable
14327 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14328 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 //set cfg related to protection
14330 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014331 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 // Set Auth type
14334 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014335 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 // Set DTIM
14338 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014339 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 // Set wps_state
14342 *pBuf = pParam->wps_state;
14343 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014344 // set isCoalesingInIBSSAllowed
14345 *pBuf = pMac->isCoalesingInIBSSAllowed;
14346 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 //Persona
14348 *pBuf = (tANI_U8)pParam->bssPersona;
14349 pBuf++;
14350
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014351 //txLdpcIniFeatureEnabled
14352 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14353 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014354
Chet Lanctot8cecea22014-02-11 19:09:36 -080014355#ifdef WLAN_FEATURE_11W
14356 // Set MFP capable/required
14357 *pBuf = (tANI_U8)pParam->mfpCapable;
14358 pBuf++;
14359 *pBuf = (tANI_U8)pParam->mfpRequired;
14360 pBuf++;
14361#endif
14362
krunal soni4f087d22013-07-29 16:32:26 -070014363 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14365 {
14366 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014367 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 break;
14369 }
14370 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014371 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 pBuf += sizeof(tANI_U16);
14373 if( wTmp )
14374 {
14375 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014376 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 pBuf += wTmp;
14378 }
14379 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014380 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014381 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14383 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014384 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14385 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 pBuf += pParam->operationalRateSet.numRates ;
14387 *pBuf++ = pParam->extendedRateSet.numRates;
14388 if(0 != pParam->extendedRateSet.numRates)
14389 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014390 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14391 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014392 pBuf += pParam->extendedRateSet.numRates;
14393 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014394#ifdef WLAN_FEATURE_AP_HT40_24G
14395 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14396#endif
krunal sonie9002db2013-11-25 14:24:17 -080014397
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14399 pMsg->length = pal_cpu_to_be16(msgLen);
14400
14401 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014402 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 return( status );
14404}
14405
Jeff Johnson295189b2012-06-20 16:38:30 -070014406eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14407{
14408 eHalStatus status = eHAL_STATUS_FAILURE;
14409 tSirSmeStopBssReq *pMsg;
14410 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14411 tANI_U8 *pBuf;
14412 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014413
14414 if(!pSession)
14415 {
14416 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14417 return eHAL_STATUS_FAILURE;
14418 }
14419
Jeff Johnson295189b2012-06-20 16:38:30 -070014420 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014421 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14422 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14423 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014424 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14425 pBuf = &pMsg->sessionId;
14426 //sessionId
14427 *pBuf = (tANI_U8)sessionId;
14428 pBuf++;
14429 // transactionId
14430 *pBuf = 0;
14431 pBuf += sizeof(tANI_U16);
14432 //reason code
14433 *pBuf = 0;
14434 pBuf += sizeof(tSirResultCodes);
14435 // bssid
14436 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14437 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14438 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014439 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14440 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 }
14442 else
14443 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014444 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14445 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 }
14447 pBuf += sizeof(tSirMacAddr);
14448 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14449 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014450 status = palSendMBMessage( pMac->hHdd, pMsg );
14451#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014452 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14453 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14454 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14456 pMsg->reasonCode = 0;
14457 // bssid
14458 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14459 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14460 {
14461 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14462 }
14463 else
14464 {
14465 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14466 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014467 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014468 pMsg->transactionId = 0;
14469 pMsg->sessionId = (tANI_U8)sessionId;
14470 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14471 status = palSendMBMessage( pMac->hHdd, pMsg );
14472#endif
14473 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014474 return( status );
14475}
14476
Jeff Johnson295189b2012-06-20 16:38:30 -070014477eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14478 tCsrRoamModifyProfileFields *pModProfileFields,
14479 tANI_U32 *pRoamId, v_BOOL_t fForce)
14480{
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 eHalStatus status = eHAL_STATUS_FAILURE;
14482 tANI_U32 roamId = 0;
14483 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014485 (fForce || (!vos_mem_compare( &pModProfileFields,
14486 &pSession->connectedProfile.modifyProfileFields,
14487 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 {
14489 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14490 if(pRoamId)
14491 {
14492 *pRoamId = roamId;
14493 }
14494
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14496 eCsrSmeIssuedReassocToSameAP, roamId,
14497 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 return status;
14500}
Jeff Johnson295189b2012-06-20 16:38:30 -070014501static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14502{
14503 eHalStatus status = eHAL_STATUS_SUCCESS;
14504 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014505 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14507 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14508 return (status);
14509}
Jeff Johnson295189b2012-06-20 16:38:30 -070014510eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14511{
14512 eHalStatus status = eHAL_STATUS_SUCCESS;
14513 tListElem *pEntry = NULL;
14514 tSmeCmd *pCommand = NULL;
14515 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014516 do
14517 {
14518 if(pMsg == NULL)
14519 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014520 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014521 status = eHAL_STATUS_FAILURE;
14522 break;
14523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014524 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14525 if(pEntry)
14526 {
14527 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14528 if(eSmeCommandAddStaSession == pCommand->command)
14529 {
14530 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014531 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014532 if (pRsp->status == eSIR_FAILURE) {
14533 VOS_ASSERT( 0 );
14534 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 //Remove this command out of the active list
14538 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14539 {
14540 //Now put this command back on the avilable command list
14541 csrReleaseCommand(pMac, pCommand);
14542 }
14543 smeProcessPendingQueue( pMac );
14544 }
14545 else
14546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014547 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 -070014548 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 status = eHAL_STATUS_FAILURE;
14550 break;
14551 }
14552 }
14553 else
14554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014555 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 -070014556 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014557 status = eHAL_STATUS_FAILURE;
14558 break;
14559 }
14560 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014562}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014563eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14564 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014565{
14566 tSirSmeAddStaSelfReq *pMsg;
14567 tANI_U16 msgLen;
14568 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014569 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014570 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014571 pMsg = vos_mem_malloc(msgLen);
14572 if ( NULL == pMsg ) break;
14573 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14575 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014577 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014578 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14579
14580 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14581
Arif Hussain24bafea2013-11-15 15:10:03 -080014582 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14583 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 return( status );
14587}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014588eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14589 tANI_U32 sessionId,
14590 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014591{
14592 eHalStatus status = eHAL_STATUS_SUCCESS;
14593 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 pCommand = csrGetCommandBuffer(pMac);
14595 if(NULL == pCommand)
14596 {
14597 status = eHAL_STATUS_RESOURCES;
14598 }
14599 else
14600 {
14601 pCommand->command = eSmeCommandAddStaSession;
14602 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014603 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14604 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014605 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14607 if( !HAL_STATUS_SUCCESS( status ) )
14608 {
14609 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014610 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014611 }
14612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 return (status);
14614}
Jeff Johnson295189b2012-06-20 16:38:30 -070014615eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14616{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014617 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014618}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014619eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14620 csrRoamCompleteCallback callback,
14621 void *pContext, tANI_U8 *pSelfMacAddr,
14622 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014623{
14624 eHalStatus status = eHAL_STATUS_SUCCESS;
14625 tANI_U32 i;
14626 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 *pbSessionId = CSR_SESSION_ID_INVALID;
14628 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14629 {
14630 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14631 {
14632 pSession = CSR_GET_SESSION( pMac, i );
14633 status = eHAL_STATUS_SUCCESS;
14634 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14635 pSession->sessionId = (tANI_U8)i;
14636 pSession->callback = callback;
14637 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014638 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014640 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14641 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014643 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014645 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014646 break;
14647 }
14648#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014649 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14650 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014652 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014654 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 break;
14656 }
14657#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014658 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014659 break;
14660 }
14661 }
14662 if( CSR_ROAM_SESSION_MAX == i )
14663 {
14664 //No session is available
14665 status = eHAL_STATUS_RESOURCES;
14666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014667 return ( status );
14668}
Jeff Johnson295189b2012-06-20 16:38:30 -070014669eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14670{
14671 eHalStatus status = eHAL_STATUS_SUCCESS;
14672 tListElem *pEntry = NULL;
14673 tSmeCmd *pCommand = NULL;
14674 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014675 do
14676 {
14677 if(pMsg == NULL)
14678 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014679 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 status = eHAL_STATUS_FAILURE;
14681 break;
14682 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14684 if(pEntry)
14685 {
14686 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14687 if(eSmeCommandDelStaSession == pCommand->command)
14688 {
14689 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014690 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014691 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014692 //This session is done.
14693 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 if(pCommand->u.delStaSessionCmd.callback)
14695 {
14696
14697 status = sme_ReleaseGlobalLock( &pMac->sme );
14698 if ( HAL_STATUS_SUCCESS( status ) )
14699 {
14700 pCommand->u.delStaSessionCmd.callback(
14701 pCommand->u.delStaSessionCmd.pContext);
14702 status = sme_AcquireGlobalLock( &pMac->sme );
14703 if (! HAL_STATUS_SUCCESS( status ) )
14704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014705 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 return status;
14707 }
14708 }
14709 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014710 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 }
14712 }
14713
14714 //Remove this command out of the active list
14715 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14716 {
14717 //Now put this command back on the avilable command list
14718 csrReleaseCommand(pMac, pCommand);
14719 }
14720 smeProcessPendingQueue( pMac );
14721 }
14722 else
14723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014724 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 -070014725 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 status = eHAL_STATUS_FAILURE;
14727 break;
14728 }
14729 }
14730 else
14731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014732 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 -070014733 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 status = eHAL_STATUS_FAILURE;
14735 break;
14736 }
14737 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014739}
Jeff Johnson295189b2012-06-20 16:38:30 -070014740eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14741{
14742 tSirSmeDelStaSelfReq *pMsg;
14743 tANI_U16 msgLen;
14744 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014745 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14747 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014748 pMsg = vos_mem_malloc(msgLen);
14749 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14750 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14752 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014754 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14755 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014757 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 return( status );
14759}
Jeff Johnson295189b2012-06-20 16:38:30 -070014760eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14761 tSirMacAddr sessionMacAddr,
14762 csrRoamSessionCloseCallback callback,
14763 void *pContext)
14764{
14765 eHalStatus status = eHAL_STATUS_SUCCESS;
14766 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 pCommand = csrGetCommandBuffer(pMac);
14768 if(NULL == pCommand)
14769 {
14770 status = eHAL_STATUS_RESOURCES;
14771 }
14772 else
14773 {
14774 pCommand->command = eSmeCommandDelStaSession;
14775 pCommand->sessionId = (tANI_U8)sessionId;
14776 pCommand->u.delStaSessionCmd.callback = callback;
14777 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014778 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14779 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014780 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14781 if( !HAL_STATUS_SUCCESS( status ) )
14782 {
14783 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014784 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014785 }
14786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 return (status);
14788}
Jeff Johnson295189b2012-06-20 16:38:30 -070014789eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14790{
14791 return csrSendMBDelSelfStaReqMsg( pMac,
14792 pCommand->u.delStaSessionCmd.selfMacAddr );
14793}
Jeff Johnson295189b2012-06-20 16:38:30 -070014794static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14795{
14796 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14797 tListElem *pEntry, *pNext;
14798 tSmeCmd *pCommand;
14799 tDblLinkList localList;
14800
14801 vos_mem_zero(&localList, sizeof(tDblLinkList));
14802 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14803 {
14804 smsLog(pMac, LOGE, FL(" failed to open list"));
14805 return;
14806 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014807 csrLLLock(pList);
14808 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14809 while(pEntry != NULL)
14810 {
14811 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14812 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14813 if(pCommand->sessionId == sessionId)
14814 {
14815 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14816 {
14817 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14818 }
14819 }
14820 pEntry = pNext;
14821 }
14822 csrLLUnlock(pList);
14823
14824 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14825 {
14826 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14827 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14828 }
14829 csrLLClose(&localList);
14830}
14831
Jeff Johnson295189b2012-06-20 16:38:30 -070014832void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14833{
14834 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14835 {
14836 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 csrRoamStop(pMac, sessionId);
14838 csrFreeConnectBssDesc(pMac, sessionId);
14839 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14840 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014841 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014842#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014843 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014844#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014845 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14846 if (pMac->fScanOffload)
14847 {
14848 purgeSmeSessionCmdList(pMac, sessionId,
14849 &pMac->sme.smeScanCmdPendingList);
14850 }
14851
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 purgeCsrSessionCmdList(pMac, sessionId);
14853 csrInitSession(pMac, sessionId);
14854 }
14855}
14856
Jeff Johnson295189b2012-06-20 16:38:30 -070014857eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14858 tANI_BOOLEAN fSync,
14859 csrRoamSessionCloseCallback callback,
14860 void *pContext )
14861{
14862 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014863 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14864 {
14865 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14866 if(fSync)
14867 {
14868 csrCleanupSession(pMac, sessionId);
14869 }
14870 else
14871 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014872 purgeSmeSessionCmdList(pMac, sessionId,
14873 &pMac->sme.smeCmdPendingList);
14874 if (pMac->fScanOffload)
14875 {
14876 purgeSmeSessionCmdList(pMac, sessionId,
14877 &pMac->sme.smeScanCmdPendingList);
14878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014879 purgeCsrSessionCmdList(pMac, sessionId);
14880 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14881 pSession->selfMacAddr, callback, pContext);
14882 }
14883 }
14884 else
14885 {
14886 status = eHAL_STATUS_INVALID_PARAMETER;
14887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 return ( status );
14889}
14890
Jeff Johnson295189b2012-06-20 16:38:30 -070014891static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14892{
14893 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014894
14895 if(!pSession)
14896 {
14897 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14898 return;
14899 }
14900
Jeff Johnson295189b2012-06-20 16:38:30 -070014901 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14902 pSession->sessionId = CSR_SESSION_ID_INVALID;
14903 pSession->callback = NULL;
14904 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14906 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14907 csrFreeRoamProfile( pMac, sessionId );
14908 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14909 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14910 csrFreeConnectBssDesc(pMac, sessionId);
14911 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014912 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14913 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014915 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 pSession->pWpaRsnReqIE = NULL;
14917 }
14918 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014919 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014921 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 pSession->pWpaRsnRspIE = NULL;
14923 }
14924 pSession->nWpaRsnRspIeLength = 0;
14925#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014926 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014928 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014929 pSession->pWapiReqIE = NULL;
14930 }
14931 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014932 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014934 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 pSession->pWapiRspIE = NULL;
14936 }
14937 pSession->nWapiRspIeLength = 0;
14938#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014939 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014941 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 }
14943 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014944
Kiet Lam64c1b492013-07-12 13:56:44 +053014945 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014947 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014951}
14952
Jeff Johnson295189b2012-06-20 16:38:30 -070014953eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14954{
14955 eHalStatus status = eHAL_STATUS_FAILURE;
14956 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14958 {
14959 if( CSR_IS_SESSION_VALID( pMac, i ) )
14960 {
14961 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14962 {
14963 //Found it
14964 status = eHAL_STATUS_SUCCESS;
14965 *pSessionId = i;
14966 break;
14967 }
14968 }
14969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 return( status );
14971}
14972
Jeff Johnson295189b2012-06-20 16:38:30 -070014973//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14974//session because for IBSS, the bssid changes.
14975static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14976{
14977 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14978 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14980 {
14981 if( CSR_IS_SESSION_VALID( pMac, i ) )
14982 {
14983 pSession = CSR_GET_SESSION( pMac, i );
14984 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14985 {
14986 //Found it
14987 nRet = i;
14988 break;
14989 }
14990 }
14991 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 return (nRet);
14993}
Jeff Johnson295189b2012-06-20 16:38:30 -070014994static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14995{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014996 VOS_STATUS status = VOS_STATUS_SUCCESS;
14997
14998 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 profile info from pmac global structure */
15000
Arif Hussain24bafea2013-11-15 15:10:03 -080015001 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
15002 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 /* Check for user misconfig of RSSI trigger threshold */
15004 pMac->roam.configParam.vccRssiThreshold =
15005 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
15006 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
15007 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 /* Check for user misconfig of UL MAC Loss trigger threshold */
15009 pMac->roam.configParam.vccUlMacLossThreshold =
15010 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
15011 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015012#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15013 {
15014 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015015 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 /* Indicate the neighbor roal algorithm about the connect indication */
15017 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
15018 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015019
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015020 /* Making sure we are roaming force fully to 5GHz AP only once and
15021 * only when we connected to 2.4GH AP only during initial association.
15022 */
15023 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
15024 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
15025 SIR_BAND_2_4_GHZ)
15026 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053015027 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015028 status = vos_timer_start(
15029 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
15030 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015031 if ( status != VOS_STATUS_SUCCESS )
15032 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015033 smsLog(pMac, LOGE,
15034 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
15035 status);
15036 //Send RSO start because in case 5G roaming
15037 //host have not enabled at initial connection
15038 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015039 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015040 else
15041 {
15042 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
15043 __func__);
15044 }
15045 }
15046 /*
15047 * Making ini value to false here only so we just roam to
15048 * only once for whole driver load to unload tenure
15049 * This feature is only applicable for first connection only
15050 */
15051 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
15052 {
15053 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
15054 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053015055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015056 }
15057#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015058}
15059
Jeff Johnson295189b2012-06-20 16:38:30 -070015060static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
15061{
15062 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015063
15064 if(!pSession)
15065 {
15066 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15067 return;
15068 }
15069
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 //Only to handle the case for Handover on infra link
15071 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15072 {
15073 return;
15074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
15076 csrRoamDeregStatisticsReq(pMac);
15077 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15078#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15079 /* Indicate the neighbor roal algorithm about the disconnect indication */
15080 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
15081#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070015082
15083 //Remove this code once SLM_Sessionization is supported
15084 //BMPS_WORKAROUND_NOT_NEEDED
15085 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070015086 csrIsInfraApStarted( pMac ) &&
15087 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070015088 {
15089 pMac->roam.configParam.doBMPSWorkaround = 0;
15090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015091}
15092
Jeff Johnson295189b2012-06-20 16:38:30 -070015093void csrRoamTlStatsTimerHandler(void *pv)
15094{
15095 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
15096 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15098
Jeff Johnsone7245742012-09-05 17:12:55 -070015099 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
15100
Jeff Johnson295189b2012-06-20 16:38:30 -070015101#if 0
15102 // TODO Persession .???
15103 //req TL for stats
15104 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
15105 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015106 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015107 }
15108 else
15109 {
15110 //save in SME
15111 csrRoamSaveStatsFromTl(pMac, tlStats);
15112 }
15113#endif
15114 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15115 {
15116 if(pMac->roam.tlStatsReqInfo.periodicity)
15117 {
15118 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015119 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15120 pMac->roam.tlStatsReqInfo.periodicity);
15121 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015123 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015124 return;
15125 }
15126 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15127 }
15128 }
15129}
Jeff Johnson295189b2012-06-20 16:38:30 -070015130void csrRoamPeStatsTimerHandler(void *pv)
15131{
15132 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
15133 eHalStatus status;
15134 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
15135 VOS_STATUS vosStatus;
15136 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 pPeStatsReqListEntry->timerRunning = FALSE;
15138 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
15139 {
15140 // If we entered here, meaning the timer could not be successfully
15141 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
15142
15143 /* Destroy the timer */
15144 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
15145 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015147 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 }
15149
15150 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015151 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 pPeStatsReqListEntry = NULL;
15153 }
15154 else
15155 {
15156 if(!pPeStatsReqListEntry->rspPending)
15157 {
15158 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
15159 pPeStatsReqListEntry->staId);
15160 if(!HAL_STATUS_SUCCESS(status))
15161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015162 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015163 }
15164 else
15165 {
15166 pPeStatsReqListEntry->rspPending = TRUE;
15167 }
15168 }
15169
15170 //send down a req
15171 if(pPeStatsReqListEntry->periodicity &&
15172 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15173 {
15174 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15175 if(ePMC_FULL_POWER == powerState)
15176 {
15177 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15178 {
15179 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15180 }
15181 }
15182 else
15183 {
15184 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15185 {
15186 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15187 }
15188 }
15189 //start timer
15190 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15191 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015193 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 return;
15195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 pPeStatsReqListEntry->timerRunning = TRUE;
15197
15198 }
15199
15200 }
15201}
Jeff Johnson295189b2012-06-20 16:38:30 -070015202void csrRoamStatsClientTimerHandler(void *pv)
15203{
15204 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15206 {
15207#if 0
15208 // TODO Stats fix for multisession
15209 //start the timer
15210 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15211
15212 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015214 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 }
15216#endif
15217 }
15218#if 0
15219 //send up the stats report
15220 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15221 pStaEntry->staId, pStaEntry->pContext);
15222#endif
15223}
15224
15225
15226
Jeff Johnson295189b2012-06-20 16:38:30 -070015227eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15228{
15229 tAniGetPEStatsReq *pMsg;
15230 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015231 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15232 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015234 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015235 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 }
15237 // need to initiate a stats request to PE
15238 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15239 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15240 pMsg->staId = staId;
15241 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 if(!HAL_STATUS_SUCCESS(status))
15244 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015245 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015247 return status;
15248}
Jeff Johnson295189b2012-06-20 16:38:30 -070015249void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15250{
15251 tAniGetPEStatsRsp *pSmeStatsRsp;
15252 eHalStatus status = eHAL_STATUS_FAILURE;
15253 tListElem *pEntry = NULL;
15254 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15255 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15256 tANI_U32 tempMask = 0;
15257 tANI_U8 counter = 0;
15258 tANI_U8 *pStats = NULL;
15259 tANI_U32 length = 0;
15260 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015261 v_S7_t rssi = 0, snr = 0;
15262 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015263 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015264 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15265 if(pSmeStatsRsp->rc)
15266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015267 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015268 goto post_update;
15269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 tempMask = pSmeStatsRsp->statsMask;
15271 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 /* subtract all statistics from this length, and after processing the entire
15273 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15274 * in this 'stats' message.
15275 */
15276 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 //new stats info from PE, fill up the stats strucutres in PMAC
15278 while(tempMask)
15279 {
15280 if(tempMask & 1)
15281 {
15282 switch(counter)
15283 {
15284 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015285 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015286 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15287 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 pStats += sizeof(tCsrSummaryStatsInfo);
15289 length -= sizeof(tCsrSummaryStatsInfo);
15290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015292 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015293 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15294 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015295 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15296 length -= sizeof(tCsrGlobalClassAStatsInfo);
15297 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015299 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015300 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15301 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15303 length -= sizeof(tCsrGlobalClassBStatsInfo);
15304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015306 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015307 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15308 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15310 length -= sizeof(tCsrGlobalClassCStatsInfo);
15311 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015313 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15315 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015316 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15317 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 }
15319 else
15320 {
15321 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015322 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 VOS_ASSERT( 0 );
15324 }
15325 if(!HAL_STATUS_SUCCESS(status))
15326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015327 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 }
15329 pStats += sizeof(tCsrPerStaStatsInfo);
15330 length -= sizeof(tCsrPerStaStatsInfo);
15331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015333 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 }
15336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 tempMask >>=1;
15338 counter++;
15339 }
15340 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15341 if (length != 0)
15342 {
15343 pRssi = (tANI_U32*)pStats;
15344 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015345 pStats += sizeof(tANI_U32);
15346 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 }
15348 else
15349 {
15350 /* If riva is not sending rssi, continue to use the hack */
15351 rssi = RSSI_HACK_BMPS;
15352 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015353
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015355
15356 if (length != 0)
15357 {
15358 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015359 pStats += sizeof(tANI_U32);
15360 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015361 }
15362 else
15363 {
15364 linkCapacity = 0;
15365 }
15366
15367 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015368
15369 if (length != 0)
15370 {
15371 pSnr = (tANI_U32*)pStats;
15372 snr = (v_S7_t)*pSnr;
15373 }
15374 else
15375 {
15376 snr = SNR_HACK_BMPS;
15377 }
15378
15379 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015380post_update:
15381 //make sure to update the pe stats req list
15382 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15383 if(pEntry)
15384 {
15385 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15386 pPeStaEntry->rspPending = FALSE;
15387
15388 }
15389 //check the one timer cases
15390 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15391 if(pEntry)
15392 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015394 if(pTempStaEntry->timerExpired)
15395 {
15396 //send up the stats report
15397 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15398 pTempStaEntry->staId, pTempStaEntry->pContext);
15399 //also remove from the client list
15400 csrRoamRemoveStatListEntry(pMac, pEntry);
15401 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015402 }
15403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015404}
Jeff Johnson295189b2012-06-20 16:38:30 -070015405tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15406{
15407 tListElem *pEntry = NULL;
15408 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 if(!pEntry)
15411 {
15412 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015413 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 return NULL;
15415 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015416 while( pEntry )
15417 {
15418 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 if(pTempStaEntry->statsMask == statsMask)
15420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015421 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 break;
15423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015424 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 return pEntry;
15427}
15428
Jeff Johnson295189b2012-06-20 16:38:30 -070015429tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15430 tANI_BOOLEAN update)
15431{
15432 tListElem *pEntry;
15433 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015434 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015435 if(!pEntry)
15436 {
15437 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015438 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015439 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 return NULL;
15441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 while( pEntry )
15443 {
15444 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15446 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15447 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015448 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 if(update)
15450 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015451 pTempStaEntry->periodicity = pStaEntry->periodicity;
15452 pTempStaEntry->callback = pStaEntry->callback;
15453 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 }
15455 break;
15456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 return pEntry;
15460}
Jeff Johnson295189b2012-06-20 16:38:30 -070015461tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15462{
15463 tListElem *pEntry;
15464 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015465 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 if(!pEntry)
15467 {
15468 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015469 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015470 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 return NULL;
15472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015473 while( pEntry )
15474 {
15475 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015478 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015479 break;
15480 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015483 return pEntry;
15484}
Jeff Johnson295189b2012-06-20 16:38:30 -070015485eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15486 csrRoamLinkQualityIndCallback callback,
15487 void *pContext)
15488{
15489 pMac->roam.linkQualityIndInfo.callback = callback;
15490 pMac->roam.linkQualityIndInfo.context = pContext;
15491 if( NULL == callback )
15492 {
15493 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15494 }
15495 else
15496 {
15497 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015498 /* do we need to invoke the callback to notify client of initial value ?? */
15499 }
15500 return eHAL_STATUS_SUCCESS;
15501}
Jeff Johnson295189b2012-06-20 16:38:30 -070015502void csrRoamVccTrigger(tpAniSirGlobal pMac)
15503{
15504 eCsrRoamLinkQualityInd newVccLinkQuality;
15505 tANI_U32 ul_mac_loss = 0;
15506 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015507 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15508 /*-------------------------------------------------------------------------
15509 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015510 Check for a change in link quality and notify client if necessary
15511 -------------------------------------------------------------------------*/
15512 ul_mac_loss_trigger_threshold =
15513 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015515 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015516 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015517 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015519 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015520 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15521 }
15522 else
15523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015524 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015525 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015527 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15528 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015529 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015531 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015532 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015534 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015535 newVccLinkQuality );
15536
15537 /* we now invoke the callback once to notify client of initial value */
15538 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15539 pMac->roam.linkQualityIndInfo.context );
15540 //event: EVENT_WLAN_VCC
15541 }
15542 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 pMac->roam.vccLinkQuality = newVccLinkQuality;
15544
Jeff Johnson295189b2012-06-20 16:38:30 -070015545}
Jeff Johnson295189b2012-06-20 16:38:30 -070015546VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15547 v_U8_t rssiNotification,
15548 void * context)
15549{
15550 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15551 eCsrRoamLinkQualityInd newVccLinkQuality;
15552 // TODO : Session info unavailable
15553 tANI_U32 sessionId = 0;
15554 VOS_STATUS status = VOS_STATUS_SUCCESS;
15555 /*-------------------------------------------------------------------------
15556 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 Check for a change in link quality and notify client if necessary
15558 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015559 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015560 pMac->roam.configParam.vccRssiThreshold);
15561 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015563 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 return VOS_STATUS_SUCCESS;
15565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015566 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015568 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15570 }
15571 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015573 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015574 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15575 }
15576 else
15577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015578 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 //Set to this so the code below won't do anything
15580 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 VOS_ASSERT(0);
15582 }
15583
Jeff Johnson295189b2012-06-20 16:38:30 -070015584 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015586 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015587 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015589 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015591 /* we now invoke the callback once to notify client of initial value */
15592 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15593 pMac->roam.linkQualityIndInfo.context );
15594 //event: EVENT_WLAN_VCC
15595 }
15596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015597 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 return status;
15599}
Jeff Johnson295189b2012-06-20 16:38:30 -070015600tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15601 tDblLinkList *pStaList,
15602 tCsrStatsClientReqInfo *pStaEntry)
15603{
15604 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015605 //if same entity requested for same set of stats with different periodicity &
15606 // callback update it
15607 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15608 {
15609
Kiet Lam64c1b492013-07-12 13:56:44 +053015610 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15611 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 {
15613 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015614 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015615 return NULL;
15616 }
15617
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 pNewStaEntry->callback = pStaEntry->callback;
15619 pNewStaEntry->pContext = pStaEntry->pContext;
15620 pNewStaEntry->periodicity = pStaEntry->periodicity;
15621 pNewStaEntry->requesterId = pStaEntry->requesterId;
15622 pNewStaEntry->statsMask = pStaEntry->statsMask;
15623 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15624 pNewStaEntry->pMac = pStaEntry->pMac;
15625 pNewStaEntry->staId = pStaEntry->staId;
15626 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15627
15628 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15629 }
15630 return pNewStaEntry;
15631}
15632
Jeff Johnson295189b2012-06-20 16:38:30 -070015633tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15634 tDblLinkList *pStaList,
15635 tCsrPeStatsReqInfo *pStaEntry)
15636{
15637 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015638 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15639 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 {
15641 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015642 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015643 return NULL;
15644 }
15645
Jeff Johnson295189b2012-06-20 16:38:30 -070015646 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15647 pNewStaEntry->numClient = pStaEntry->numClient;
15648 pNewStaEntry->periodicity = pStaEntry->periodicity;
15649 pNewStaEntry->statsMask = pStaEntry->statsMask;
15650 pNewStaEntry->pMac = pStaEntry->pMac;
15651 pNewStaEntry->staId = pStaEntry->staId;
15652 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15653 pNewStaEntry->rspPending = pStaEntry->rspPending;
15654
15655 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015656 return pNewStaEntry;
15657}
Jeff Johnson295189b2012-06-20 16:38:30 -070015658eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15659 tCsrRssiCallback callback,
15660 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15661{
15662 eHalStatus status = eHAL_STATUS_SUCCESS;
15663 vos_msg_t msg;
15664 tANI_U32 sessionId;
15665
15666 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015667 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015668 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15669 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015671 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015672 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015674 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15675
15676 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15677 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15678 pMsg->sessionId = sessionId;
15679 pMsg->staId = staId;
15680 pMsg->rssiCallback = callback;
15681 pMsg->pDevContext = pContext;
15682 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015683 msg.type = eWNI_SME_GET_RSSI_REQ;
15684 msg.bodyptr = pMsg;
15685 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015688 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015689 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015690 status = eHAL_STATUS_FAILURE;
15691 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015692 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015693 return status;
15694}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015695
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015696eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15697 tCsrSnrCallback callback,
15698 tANI_U8 staId, tCsrBssid bssId,
15699 void *pContext)
15700{
15701 eHalStatus status = eHAL_STATUS_SUCCESS;
15702 vos_msg_t msg;
15703 tANI_U32 sessionId;
15704
15705 tAniGetSnrReq *pMsg;
15706
15707 smsLog(pMac, LOG2, FL("called"));
15708
15709 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15710 if (NULL == pMsg )
15711 {
15712 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15713 return status;
15714 }
15715
15716 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15717
15718 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15719 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15720 pMsg->sessionId = sessionId;
15721 pMsg->staId = staId;
15722 pMsg->snrCallback = callback;
15723 pMsg->pDevContext = pContext;
15724 msg.type = eWNI_SME_GET_SNR_REQ;
15725 msg.bodyptr = pMsg;
15726 msg.reserved = 0;
15727
15728 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15729 {
15730 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15731 vos_mem_free((v_VOID_t *)pMsg);
15732 status = eHAL_STATUS_FAILURE;
15733 }
15734
15735 smsLog(pMac, LOG2, FL("returned"));
15736 return status;
15737}
15738
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015739#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015740eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15741 tCsrRssiCallback callback,
15742 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15743{
15744 eHalStatus status = eHAL_STATUS_SUCCESS;
15745 tAniGetRssiReq *pMsg;
15746
Kiet Lam64c1b492013-07-12 13:56:44 +053015747 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15748 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015749 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015750 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015751 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015752 }
15753 // need to initiate a stats request to PE
15754 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15755 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15756 pMsg->staId = staId;
15757 pMsg->rssiCallback = callback;
15758 pMsg->pDevContext = pContext;
15759 pMsg->pVosContext = pVosContext;
15760 status = palSendMBMessage(pMac->hHdd, pMsg );
15761 if(!HAL_STATUS_SUCCESS(status))
15762 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015763 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015764 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015765 status = eHAL_STATUS_FAILURE;
15766 }
15767 return status;
15768}
15769#endif
15770
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015771
15772
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015773#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015774eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15775 tCsrTsmStatsCallback callback,
15776 tANI_U8 staId,
15777 tCsrBssid bssId,
15778 void *pContext,
15779 void* pVosContext,
15780 tANI_U8 tid)
15781{
15782 eHalStatus status = eHAL_STATUS_SUCCESS;
15783 tAniGetTsmStatsReq *pMsg = NULL;
15784
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015785 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15786 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015787 {
15788 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015789 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015790 }
15791 // need to initiate a stats request to PE
15792 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15793 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15794 pMsg->staId = staId;
15795 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015796 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015797 pMsg->tsmStatsCallback = callback;
15798 pMsg->pDevContext = pContext;
15799 pMsg->pVosContext = pVosContext;
15800 status = palSendMBMessage(pMac->hHdd, pMsg );
15801 if(!HAL_STATUS_SUCCESS(status))
15802 {
15803 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15804 //pMsg is freed by palSendMBMessage
15805 status = eHAL_STATUS_FAILURE;
15806 }
15807 return status;
15808}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015809#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015810
15811
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015812/* ---------------------------------------------------------------------------
15813 \fn csrGetTLSTAState
15814 \helper function to get teh TL STA State whenever the function is called.
15815
15816 \param staId - The staID to be passed to the TL
15817 to get the relevant TL STA State
15818 \return the state as tANI_U16
15819 ---------------------------------------------------------------------------*/
15820tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15821{
15822 WLANTL_STAStateType tlSTAState;
15823 tlSTAState = WLANTL_STA_INIT;
15824
15825 //request TL for STA State
15826 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15827 {
15828 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15829 }
15830
15831 return tlSTAState;
15832}
15833
Jeff Johnson295189b2012-06-20 16:38:30 -070015834eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15835 tANI_U32 statsMask,
15836 tCsrStatsCallback callback,
15837 tANI_U32 periodicity, tANI_BOOLEAN cache,
15838 tANI_U8 staId, void *pContext)
15839{
15840 tCsrStatsClientReqInfo staEntry;
15841 tCsrStatsClientReqInfo *pStaEntry = NULL;
15842 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15843 tListElem *pEntry = NULL;
15844 tANI_BOOLEAN found = FALSE;
15845 eHalStatus status = eHAL_STATUS_SUCCESS;
15846 tANI_BOOLEAN insertInClientList = FALSE;
15847 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015848 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015849
15850 if( csrIsAllSessionDisconnected(pMac) )
15851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015852 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015853 return eHAL_STATUS_FAILURE;
15854 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015855
15856 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15857 {
15858 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15859 return eHAL_STATUS_FAILURE;
15860 }
15861
Jeff Johnson295189b2012-06-20 16:38:30 -070015862 if((!statsMask) && (!callback))
15863 {
15864 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015865 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015866 return eHAL_STATUS_FAILURE;
15867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015868 //for the search list method for deregister
15869 staEntry.requesterId = requesterId;
15870 staEntry.statsMask = statsMask;
15871 //requester wants to deregister or just an error
15872 if((statsMask) && (!callback))
15873 {
15874 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15875 if(!pEntry)
15876 {
15877 //msg
15878 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015879 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 return eHAL_STATUS_FAILURE;
15881 }
15882 else
15883 {
15884 //clean up & return
15885 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015886 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015887 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015888 pStaEntry->pPeStaEntry->numClient--;
15889 //check if we need to delete the entry from peStatsReqList too
15890 if(!pStaEntry->pPeStaEntry->numClient)
15891 {
15892 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15893 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015895
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 //check if we need to stop the tl stats timer too
15897 pMac->roam.tlStatsReqInfo.numClient--;
15898 if(!pMac->roam.tlStatsReqInfo.numClient)
15899 {
15900 if(pMac->roam.tlStatsReqInfo.timerRunning)
15901 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015902 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15903 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015905 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015906 return eHAL_STATUS_FAILURE;
15907 }
15908 }
15909 pMac->roam.tlStatsReqInfo.periodicity = 0;
15910 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15911 }
15912 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015913 // Destroy the vos timer...
15914 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15915 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015917 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 csrRoamRemoveStatListEntry(pMac, pEntry);
15920 pStaEntry = NULL;
15921 return eHAL_STATUS_SUCCESS;
15922 }
15923 }
15924
15925 if(cache && !periodicity)
15926 {
15927 //return the cached stats
15928 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15929 }
15930 else
15931 {
15932 //add the request in the client req list
15933 staEntry.callback = callback;
15934 staEntry.pContext = pContext;
15935 staEntry.periodicity = periodicity;
15936 staEntry.pPeStaEntry = NULL;
15937 staEntry.staId = staId;
15938 staEntry.pMac = pMac;
15939 staEntry.timerExpired = FALSE;
15940
15941
Jeff Johnson295189b2012-06-20 16:38:30 -070015942 //if periodic report requested with non cached result from PE/TL
15943 if(periodicity)
15944 {
15945
15946 //if looking for stats from PE
15947 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15948 {
15949
15950 //check if same request made already & waiting for rsp
15951 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15952 periodicity, &found, staId);
15953 if(!pPeStaEntry)
15954 {
15955 //bail out, maxed out on number of req for PE
15956 return eHAL_STATUS_FAILURE;
15957 }
15958 else
15959 {
15960 staEntry.pPeStaEntry = pPeStaEntry;
15961 }
15962
15963 }
15964 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15965 if(statsMask & (1 << eCsrGlobalClassDStats))
15966 {
15967 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015969 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015970 }
15971 else
15972 {
15973
15974 //update periodicity
15975 if(pMac->roam.tlStatsReqInfo.periodicity)
15976 {
15977 pMac->roam.tlStatsReqInfo.periodicity =
15978 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15979 }
15980 else
15981 {
15982 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15983 }
15984 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15985 {
15986 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15987 }
15988
15989 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15990 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015991 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015992 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015994 //req TL for class D stats
15995 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015997 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015998 }
15999 else
16000 {
16001 //save in SME
16002 csrRoamSaveStatsFromTl(pMac, pTlStats);
16003 }
16004 vos_mem_free(pTlStats);
16005 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016006 }
16007 else
16008 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016009 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016010 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016011
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 if(pMac->roam.tlStatsReqInfo.periodicity)
16013 {
16014 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016015 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16016 pMac->roam.tlStatsReqInfo.periodicity);
16017 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016018 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016019 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 return eHAL_STATUS_FAILURE;
16021 }
16022 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16023 }
16024 }
16025 }
16026 pMac->roam.tlStatsReqInfo.numClient++;
16027 }
16028
16029 insertInClientList = TRUE;
16030 }
16031 //if one time report requested with non cached result from PE/TL
16032 else if(!cache && !periodicity)
16033 {
16034 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16035 {
16036 //send down a req
16037 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16038 if(!HAL_STATUS_SUCCESS(status))
16039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016040 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 }
16042 //so that when the stats rsp comes back from PE we respond to upper layer
16043 //right away
16044 staEntry.timerExpired = TRUE;
16045 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 }
16047 if(statsMask & (1 << eCsrGlobalClassDStats))
16048 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016049 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016050 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016052 //req TL for class D stats
16053 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
16054 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016055 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016056 }
16057 else
16058 {
16059 //save in SME
16060 csrRoamSaveStatsFromTl(pMac, pTlStats);
16061 }
16062 vos_mem_free(pTlStats);
16063 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016064 }
16065 else
16066 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016067 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016069
16070 }
16071 //if looking for stats from TL only
16072 if(!insertInClientList)
16073 {
16074 //return the stats
16075 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
16076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016078 if(insertInClientList)
16079 {
16080 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
16081 if(!pStaEntry)
16082 {
16083 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016084 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016085 return eHAL_STATUS_FAILURE;
16086 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016087 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016088 //Init & start timer if needed
16089 if(periodicity)
16090 {
16091 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
16092 csrRoamStatsClientTimerHandler, pStaEntry );
16093 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016095 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016096 return eHAL_STATUS_FAILURE;
16097 }
16098 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
16099 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16100 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016101 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016102 return eHAL_STATUS_FAILURE;
16103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016106 }
16107 return eHAL_STATUS_SUCCESS;
16108}
16109
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016110#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16111
16112static tSirRetStatus
16113csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
16114 tANI_U8* pBD,
16115 tANI_U8 type,
16116 tANI_U8 subType,
16117 tSirMacAddr peerAddr,
16118 tSirMacAddr selfMacAddr)
16119{
16120 tSirRetStatus statusCode = eSIR_SUCCESS;
16121 tpSirMacMgmtHdr pMacHdr;
16122
16123 /* Prepare MAC management header */
16124 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16125
16126 /* Prepare FC */
16127 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16128 pMacHdr->fc.type = type;
16129 pMacHdr->fc.subType = subType;
16130
16131 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016132 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
16133 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016134
16135 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
16136
16137 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016138 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
16139 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016140 return statusCode;
16141} /*** csrRoamScanOffloadPopulateMacHeader() ***/
16142
16143static tSirRetStatus
16144csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
16145 tANI_U8 nChannelNum,
16146 tANI_U32 dot11mode,
16147 tSirMacAddr selfMacAddr,
16148 tANI_U8 *pFrame,
16149 tANI_U16 *pusLen)
16150{
16151 tDot11fProbeRequest pr;
16152 tANI_U32 nStatus, nBytes, nPayload;
16153 tSirRetStatus nSirStatus;
16154 /*Bcast tx*/
16155 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
16156 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16157
16158
Kiet Lam64c1b492013-07-12 13:56:44 +053016159 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016160
16161 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
16162
16163 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
16164 {
16165 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
16166 }
16167
16168
16169 if (IS_DOT11_MODE_HT(dot11mode))
16170 {
16171 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16172 }
16173
16174
16175 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16176 if ( DOT11F_FAILED( nStatus ) )
16177 {
16178 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16179 "Failed to calculate the packed size f"
16180 "or a Probe Request (0x%08x).\n", nStatus );
16181
16182
16183 nPayload = sizeof( tDot11fProbeRequest );
16184 }
16185 else if ( DOT11F_WARNED( nStatus ) )
16186 {
16187 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16188 "There were warnings while calculating"
16189 "the packed size for a Probe Request ("
16190 "0x%08x).\n", nStatus );
16191 }
16192
16193 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16194
16195 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016196 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016197
16198
16199 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016200 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016201
16202 if ( eSIR_SUCCESS != nSirStatus )
16203 {
16204 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16205 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16206 nSirStatus );
16207 return nSirStatus;
16208 }
16209
16210
16211 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16212 sizeof( tSirMacMgmtHdr ),
16213 nPayload, &nPayload );
16214 if ( DOT11F_FAILED( nStatus ) )
16215 {
16216 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16217 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16218 return eSIR_FAILURE;
16219 }
16220 else if ( DOT11F_WARNED( nStatus ) )
16221 {
16222 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016223 "There were warnings while packing a Probe Request (0x%08x).\n",
16224 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016225 }
16226
16227 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16228 return eSIR_SUCCESS;
16229}
16230
16231eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16232{
16233 vos_msg_t msg;
16234 tSirRoamOffloadScanReq *pRequestBuf;
16235 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16236 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016237 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016238 tANI_U8 *ChannelList = NULL;
16239 tANI_U32 sessionId;
16240 eHalStatus status = eHAL_STATUS_SUCCESS;
16241 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016242 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016243 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016244 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016245 tSirBssDescription *pBssDesc = NULL;
16246 tDot11fBeaconIEs *pIes = NULL;
16247 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016248 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016249
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016250 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16251
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016252 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016253 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016254 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016255 return eHAL_STATUS_FAILURE;
16256 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016257
16258 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16259 {
16260 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16261 return eHAL_STATUS_FAILURE;
16262 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016263
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016264 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16265 * It is important to ensure that the command is passed down to the FW only
16266 * if the Infra Station is in a connected state.A connected station could also be
16267 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16268 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16269 * irrespective of whichever state we are in.*/
16270 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16271 (command != ROAM_SCAN_OFFLOAD_STOP))
16272 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16274 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16275 macTraceGetNeighbourRoamState(
16276 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016277 return eHAL_STATUS_FAILURE;
16278 }
16279
Abhishek Singh3e915632014-11-01 17:14:50 +053016280 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16281 * Also there are cases where pNeighborRoamInfo->currAPbssid
16282 * is set to 0 during disconnect and so we might return without stopping
16283 * the roam scan. So no need to find the session if command is
16284 * ROAM_SCAN_OFFLOAD_STOP.
16285 */
16286 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016287 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016288 status = csrRoamGetSessionIdFromBSSID(pMac,
16289 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16290 &sessionId);
16291
16292 if ( !HAL_STATUS_SUCCESS( status ) )
16293 {
16294 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16295 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16296 return eHAL_STATUS_FAILURE;
16297 }
16298 pSession = CSR_GET_SESSION( pMac, sessionId );
16299 if (NULL == pSession)
16300 {
16301 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016302 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016303 return eHAL_STATUS_FAILURE;
16304 }
16305 pBssDesc = pSession->pConnectBssDesc;
16306 if (pBssDesc == NULL)
16307 {
16308 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16309 "%s: pBssDesc not found for current session", __func__);
16310 return eHAL_STATUS_FAILURE;
16311 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016312 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016313 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16314 if (NULL == pRequestBuf)
16315 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016316 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16317 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16318 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016319 }
16320
Abhishek Singh3e915632014-11-01 17:14:50 +053016321 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16322 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16323 * host driver reloads, but Riva still up and running*/
16324 pRequestBuf->Command = command;
16325 if(command == ROAM_SCAN_OFFLOAD_STOP)
16326 {
16327 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053016328 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053016329 /*For a STOP Command, there is no need to
16330 * go through filling up all the below parameters
16331 * since they are not required for the STOP command*/
16332 goto send_roam_scan_offload_cmd;
16333 }
16334 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016335 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016336 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16337 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016338 sizeof(tCsrBssid));
16339 pRequestBuf->ConnectedNetwork.ssId.length =
16340 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16341 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16342 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16343 pRequestBuf->ConnectedNetwork.ssId.length);
16344 pRequestBuf->ConnectedNetwork.authentication =
16345 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16346 pRequestBuf->ConnectedNetwork.encryption =
16347 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16348 pRequestBuf->ConnectedNetwork.mcencryption =
16349 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016350 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16351 {
16352 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016353 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016354 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16355 }
16356 else
16357 {
16358 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16359 operationChannel = pSession->connectedProfile.operationChannel;
16360
16361 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16362 {
16363 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16364 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16365 vos_mem_free(pRequestBuf);
16366 return eHAL_STATUS_FAILURE;
16367 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016368 if(NULL == pIes)
16369 {
16370 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16371 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016372 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016373 return eHAL_STATUS_FAILURE;
16374 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016375 if (pIes->SuppRates.present)
16376 {
16377 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16378 /*Check for both basic rates and extended rates.*/
16379 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16380 {
16381 /*Check if the Rate is Mandatory or Not*/
16382 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16383 && (pIes->SuppRates.rates[i] & 0x80))
16384 {
16385 /*Retrieve the actual data rate*/
16386 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16387 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16388 if (minRate == 0)
16389 minRate = dataRate;
16390 else
16391 minRate = (minRate < dataRate) ? minRate:dataRate;
16392 }
16393 }
16394
16395 if (pIes->ExtSuppRates.present)
16396 {
16397 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16398 {
16399 /*Check if the Rate is Mandatory or Not*/
16400 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16401 && (pIes->ExtSuppRates.rates[i] & 0x80))
16402 {
16403 /*Retrieve the actual data rate*/
16404 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16405 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16406 if (minRate == 0)
16407 minRate = dataRate;
16408 else
16409 minRate = (minRate < dataRate) ? minRate:dataRate;
16410 }
16411 }
16412 }
16413 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16414 }
16415 else
16416 {
16417 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16418 "%s: Supp Rates not present in pIes", __func__);
16419 vos_mem_free(pRequestBuf);
16420 return eHAL_STATUS_FAILURE;
16421 }
16422 if (NULL != pIes)
16423 {
16424 vos_mem_free(pIes);
16425 pIes = NULL;
16426 }
16427 switch (minRate)
16428 {
16429 case 1:
16430 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16431 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16432 break;
16433 case 2:
16434 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16435 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16436 break;
16437 case 5:
16438 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16439 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16440 break;
16441 case 6:
16442 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16443 {
16444 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16445 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16446 }
16447 else
16448 {
16449 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16450 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16451 }
16452 break;
16453 case 11:
16454 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16455 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16456 break;
16457 case 12:
16458 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16459 {
16460 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16461 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16462 }
16463 else
16464 {
16465 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16466 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16467 }
16468 break;
16469 case 24:
16470 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16471 {
16472 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16473 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16474 }
16475 else
16476 {
16477 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16478 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16479 }
16480 break;
16481 default:
16482 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16483 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16484 break;
16485 }
16486 }
16487 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16488 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16489 operationChannel, minRate,
16490 pRequestBuf->RxSensitivityThreshold,
16491 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016492 pRequestBuf->RoamRssiDiff =
16493 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016494 pRequestBuf->StartScanReason = reason;
16495 pRequestBuf->NeighborScanTimerPeriod =
16496 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16497 pRequestBuf->NeighborRoamScanRefreshPeriod =
16498 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16499 pRequestBuf->NeighborScanChannelMinTime =
16500 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16501 pRequestBuf->NeighborScanChannelMaxTime =
16502 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16503 pRequestBuf->EmptyRefreshScanPeriod =
16504 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016505 /* MAWC feature */
16506 pRequestBuf->MAWCEnabled =
16507 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016508#ifdef FEATURE_WLAN_ESE
16509 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016510#endif
16511 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016512#ifdef FEATURE_WLAN_ESE
16513 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016514 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16515 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016516 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16517#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016518 currChannelListInfo->numOfChannels == 0)
16519 {
16520
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016521 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16522 * Give Preference to INI Channels.*/
16523 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16524 {
16525 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16526 /*The INI channels need to be filtered with respect to the current
16527 * band that is supported.*/
16528 eBand = pMac->roam.configParam.bandCapability;
16529 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016530 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016531 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16532 "Invalid band, No operation carried out (Band %d)", eBand);
16533 vos_mem_free(pRequestBuf);
16534 return eHAL_STATUS_FAILURE;
16535 }
16536 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16537 {
16538 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16539 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16540 (eCSR_BAND_ALL == eBand))
16541 {
16542 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16543 csrRoamIsChannelValid(pMac, *ChannelList) &&
16544 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16545 {
16546 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16547 }
16548 }
16549 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016550 }
16551 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16552 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016553 }
16554 else
16555 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016556 ChannelList = pMac->scan.occupiedChannels.channelList;
16557 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16558 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016559 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16560 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16561 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016562 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16563 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016564 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016565 }
16566 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016567 }
16568 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16569 /* If the profile changes as to what it was earlier, inform the FW through
16570 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16571 * for the earlier profile and try to learn them afresh.*/
16572 if (reason == REASON_FLUSH_CHANNEL_LIST)
16573 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16574 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016575 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16576 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16577 else
16578 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016579 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016580 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016581 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016582#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016583 else
16584 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016585 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016586 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016587 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016588 if (currChannelListInfo->numOfChannels != 0)
16589 {
16590 ChannelList = currChannelListInfo->ChannelList;
16591 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016592 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016593 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16594 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016595 {
16596 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16597 }
16598 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016599 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016600 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16601 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16602 }
16603 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016604#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016605 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016606 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016607 if (j < sizeof(ChannelCacheStr))
16608 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016609 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16610 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016611 }
16612 else
16613 {
16614 break;
16615 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016616 }
16617 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16618 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16619 pRequestBuf->ChannelCacheType,
16620 pRequestBuf->ConnectedNetwork.ChannelCount,
16621 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016622 num_channels = 0;
16623 ChannelList = NULL;
16624
16625 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016626 host_channels = sizeof(pMac->roam.validChannelList);
16627 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016628 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016629 ChannelList = pMac->roam.validChannelList;
16630 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016631 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016632 else
16633 {
16634 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16635 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016636 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016637 return eHAL_STATUS_FAILURE;
16638 }
16639 for(i=0; i<pMac->roam.numValidChannels; i++)
16640 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016641 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16642 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016643 {
16644 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16645 }
16646 ChannelList++;
16647 }
16648 pRequestBuf->ValidChannelCount = num_channels;
16649
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016650 pRequestBuf->MDID.mdiePresent =
16651 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16652 pRequestBuf->MDID.mobilityDomain =
16653 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016654 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16655
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016656 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016657 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16658 * where RFS is the RF Switching time. It is twice RFS to consider the
16659 * time to go off channel and return to the home channel. */
16660 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16661 {
16662 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16663 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16664 " Hence enforcing home away time to disable (0)",
16665 __func__, pRequestBuf->HomeAwayTime,
16666 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16667 pRequestBuf->HomeAwayTime = 0;
16668 }
16669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016670
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016671 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16672 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16673 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16674 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16675 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16676
16677 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16678 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016679send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016680 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016681 msg.reserved = 0;
16682 msg.bodyptr = pRequestBuf;
16683 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16684 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016685 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16686 vos_mem_free(pRequestBuf);
16687 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016688 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016689 else
16690 {
16691 if (ROAM_SCAN_OFFLOAD_START == command)
16692 bRoamScanOffloadStarted = VOS_TRUE;
16693 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16694 bRoamScanOffloadStarted = VOS_FALSE;
16695 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016696
16697 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16698 return status;
16699}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016700
16701eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16702{
16703 switch(reason)
16704 {
16705 case 0:
16706 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16707 break;
16708 case REASON_OS_REQUESTED_ROAMING_NOW:
16709 csrNeighborRoamProceedWithHandoffReq(pMac);
16710 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016711 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16712 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16713 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016714 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016715 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 -070016716 }
16717 return eHAL_STATUS_SUCCESS;
16718}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016719#endif
16720
Jeff Johnson295189b2012-06-20 16:38:30 -070016721tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16722 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16723{
16724 tANI_BOOLEAN found = FALSE;
16725 eHalStatus status = eHAL_STATUS_SUCCESS;
16726 tCsrPeStatsReqInfo staEntry;
16727 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16728 tListElem *pStaEntry = NULL;
16729 VOS_STATUS vosStatus;
16730 tPmcPowerState powerState;
16731 *pFound = FALSE;
16732
16733 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16734 if(pStaEntry)
16735 {
16736 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16737 if(pTempStaEntry->periodicity)
16738 {
16739 pTempStaEntry->periodicity =
16740 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16741 }
16742 else
16743 {
16744 pTempStaEntry->periodicity = periodicity;
16745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 pTempStaEntry->numClient++;
16747 found = TRUE;
16748 }
16749 else
16750 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016751 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 staEntry.numClient = 1;
16753 staEntry.periodicity = periodicity;
16754 staEntry.pMac = pMac;
16755 staEntry.rspPending = FALSE;
16756 staEntry.staId = staId;
16757 staEntry.statsMask = statsMask;
16758 staEntry.timerRunning = FALSE;
16759 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16760 if(!pTempStaEntry)
16761 {
16762 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016763 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 return NULL;
16765 }
16766 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016767 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16768 if(ePMC_FULL_POWER == powerState)
16769 {
16770 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16771 {
16772 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16773 }
16774 }
16775 else
16776 {
16777 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16778 {
16779 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16780 }
16781 }
16782 if(!pTempStaEntry->timerRunning)
16783 {
16784 //send down a req in case of one time req, for periodic ones wait for timer to expire
16785 if(!pTempStaEntry->rspPending &&
16786 !pTempStaEntry->periodicity)
16787 {
16788 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16789 if(!HAL_STATUS_SUCCESS(status))
16790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016791 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016792 }
16793 else
16794 {
16795 pTempStaEntry->rspPending = TRUE;
16796 }
16797 }
16798 if(pTempStaEntry->periodicity)
16799 {
16800 if(!found)
16801 {
16802
16803 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16804 csrRoamPeStatsTimerHandler, pTempStaEntry );
16805 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016807 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016808 return NULL;
16809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016810 }
16811 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016812 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016813 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16814 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016816 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 return NULL;
16818 }
16819 pTempStaEntry->timerRunning = TRUE;
16820 }
16821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016822 *pFound = found;
16823 return pTempStaEntry;
16824}
16825
Jeff Johnson295189b2012-06-20 16:38:30 -070016826/*
16827 pStaEntry is no longer invalid upon the return of this function.
16828*/
16829static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16830{
16831 if(pEntry)
16832 {
16833 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16834 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016835 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016837 }
16838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016839
16840void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16841{
16842 tListElem *pEntry;
16843 tCsrPeStatsReqInfo *pTempStaEntry;
16844 VOS_STATUS vosStatus;
16845 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016846 if(!pEntry)
16847 {
16848 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016849 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 return;
16851 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 while( pEntry )
16853 {
16854 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16856 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016857 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 if(pTempStaEntry->timerRunning)
16859 {
16860 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16861 /* If we are not able to stop the timer here, just remove
16862 * the entry from the linked list. Destroy the timer object
16863 * and free the memory in the timer CB
16864 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016865 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 {
16867 /* the timer is successfully stopped */
16868 pTempStaEntry->timerRunning = FALSE;
16869
16870 /* Destroy the timer */
16871 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16872 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016874 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 }
16876 }
16877 else
16878 {
16879 // the timer could not be stopped. Hence destroy and free the
16880 // memory for the PE stat entry in the timer CB.
16881 pTempStaEntry->timerStopFailed = TRUE;
16882 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016884
16885 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16886 {
16887 // Only free the memory if we could stop the timer successfully
16888 if(!pTempStaEntry->timerStopFailed)
16889 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016890 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016891 pTempStaEntry = NULL;
16892 }
16893 break;
16894 }
16895
16896 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16897 }
16898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016899 return;
16900}
16901
16902
Jeff Johnsone7245742012-09-05 17:12:55 -070016903void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016904{
16905
Jeff Johnsone7245742012-09-05 17:12:55 -070016906 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16907 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16908 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16909 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16910 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16911 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16912 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016913 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016914 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16915 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16916 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16917 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16918 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16919 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016921 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16922 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016923
16924}
16925
Jeff Johnson295189b2012-06-20 16:38:30 -070016926void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16927 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16928{
16929 tANI_U8 stats[500];
16930 tANI_U8 *pStats = NULL;
16931 tANI_U32 tempMask = 0;
16932 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 if(!callback)
16934 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016935 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016936 return;
16937 }
16938 if(!statsMask)
16939 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016940 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 return;
16942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016944 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016945 while(tempMask)
16946 {
16947 if(tempMask & 1)
16948 {
16949 //new stats info from PE, fill up the stats strucutres in PMAC
16950 switch(counter)
16951 {
16952 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016953 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016954 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16955 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016956 pStats += sizeof(tCsrSummaryStatsInfo);
16957 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016958 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016959 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016960 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16961 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016962 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016964 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016965 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016966 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16967 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016968 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016969 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016970 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016971 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016972 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16973 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016974 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016975 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016976 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016977 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016978 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16979 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016980 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016981 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016983 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016984 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16985 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016986 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016987 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016988 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016989 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016990 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016991 }
16992 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016993 tempMask >>=1;
16994 counter++;
16995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016996 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016997}
16998
Jeff Johnson295189b2012-06-20 16:38:30 -070016999eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
17000{
17001 tListElem *pEntry = NULL;
17002 tListElem *pPrevEntry = NULL;
17003 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
17004 eHalStatus status = eHAL_STATUS_SUCCESS;
17005 VOS_STATUS vosStatus;
17006 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017007 if(!pEntry)
17008 {
17009 //list empty
17010 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017011 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070017012 return status;
17013 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017014 while( pEntry )
17015 {
17016 if(pPrevEntry)
17017 {
17018 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17019 //send up the stats report
17020 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17021 pTempStaEntry->staId, pTempStaEntry->pContext);
17022 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017024 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070017025 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
17026 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017027 pTempStaEntry->pPeStaEntry->numClient--;
17028 //check if we need to delete the entry from peStatsReqList too
17029 if(!pTempStaEntry->pPeStaEntry->numClient)
17030 {
17031 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
17032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017034 //check if we need to stop the tl stats timer too
17035 pMac->roam.tlStatsReqInfo.numClient--;
17036 if(!pMac->roam.tlStatsReqInfo.numClient)
17037 {
17038 if(pMac->roam.tlStatsReqInfo.timerRunning)
17039 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017040 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17041 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017043 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017044 //we will continue
17045 }
17046 }
17047 pMac->roam.tlStatsReqInfo.periodicity = 0;
17048 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17049 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017050 if (pTempStaEntry->periodicity)
17051 {
17052 //While creating StaEntry in csrGetStatistics,
17053 //Initializing and starting timer only when periodicity is set.
17054 //So Stop and Destroy timer only when periodicity is set.
17055
Jeff Johnsone7245742012-09-05 17:12:55 -070017056 vos_timer_stop( &pTempStaEntry->timer );
17057 // Destroy the vos timer...
17058 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
17059 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017061 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017063 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017064
Jeff Johnson295189b2012-06-20 16:38:30 -070017065
17066 pPrevEntry = pEntry;
17067 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
17068 }
17069 //the last one
17070 if(pPrevEntry)
17071 {
17072 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17073 //send up the stats report
17074 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17075 pTempStaEntry->staId, pTempStaEntry->pContext);
17076 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017078 return status;
17079
17080}
17081
Jeff Johnson295189b2012-06-20 16:38:30 -070017082eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
17083 tRequestFullPowerReason *pReason,
17084 tANI_BOOLEAN *pfNeedPower )
17085{
17086 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17087 tRequestFullPowerReason reason = eSME_REASON_OTHER;
17088 tPmcState pmcState;
17089 eHalStatus status = eHAL_STATUS_SUCCESS;
17090 // TODO : Session info unavailable
17091 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017092 if( pfNeedPower )
17093 {
17094 *pfNeedPower = eANI_BOOLEAN_FALSE;
17095 }
17096 //We only handle CSR commands
17097 if( !(eSmeCsrCommandMask & pCommand->command) )
17098 {
17099 return eHAL_STATUS_SUCCESS;
17100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017101 //Check PMC state first
17102 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017103 switch( pmcState )
17104 {
17105 case REQUEST_IMPS:
17106 case IMPS:
17107 if( eSmeCommandScan == pCommand->command )
17108 {
17109 switch( pCommand->u.scanCmd.reason )
17110 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017111#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17112 case eCsrScanGetLfrResult:
17113#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017114 case eCsrScanGetResult:
17115 case eCsrScanBGScanAbort:
17116 case eCsrScanBGScanEnable:
17117 case eCsrScanGetScanChnInfo:
17118 //Internal process, no need for full power
17119 fNeedFullPower = eANI_BOOLEAN_FALSE;
17120 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017121 default:
17122 //Other scans are real scan, ask for power
17123 fNeedFullPower = eANI_BOOLEAN_TRUE;
17124 break;
17125 } //switch
17126 }
17127 else
17128 {
17129 //ask for power for roam and status change
17130 fNeedFullPower = eANI_BOOLEAN_TRUE;
17131 }
17132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017133 case REQUEST_BMPS:
17134 case BMPS:
17135 case REQUEST_START_UAPSD:
17136 case UAPSD:
17137 //We treat WOWL same as BMPS
17138 case REQUEST_ENTER_WOWL:
17139 case WOWL:
17140 if( eSmeCommandRoam == pCommand->command )
17141 {
17142 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
17143 tCsrScanResult *pScanResult;
17144 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070017145 switch ( pCommand->u.roamCmd.roamReason )
17146 {
17147 case eCsrForcedDisassoc:
17148 case eCsrForcedDisassocMICFailure:
17149 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17150 fNeedFullPower = eANI_BOOLEAN_TRUE;
17151 break;
17152 case eCsrSmeIssuedDisassocForHandoff:
17153 case eCsrForcedDeauth:
17154 case eCsrHddIssuedReassocToSameAP:
17155 case eCsrSmeIssuedReassocToSameAP:
17156 fNeedFullPower = eANI_BOOLEAN_TRUE;
17157 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017158 case eCsrCapsChange:
17159 fNeedFullPower = eANI_BOOLEAN_TRUE;
17160 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017161 default:
17162 //Check whether the profile is already connected. If so, no need for full power
17163 //Note: IBSS is ignored for now because we don't support powersave in IBSS
17164 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
17165 {
17166 //Only need to check the first one
17167 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
17168 if( pEntry )
17169 {
17170 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17171#if 0
17172 // TODO : Session Specific info pConnectBssDesc
17173 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17174 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17175 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17176 {
17177 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17178 // with Authenticating first. To force this, stop the current association (Disassociate) and
17179 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17180 // a new Association.
17181 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17182 {
17183 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17184 {
17185 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17186 //No need for full power
17187 //Set the flag so the code later can avoid to do the above
17188 //check again.
17189 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17190 break;
17191 }
17192 }
17193 }
17194#endif
17195 }
17196 }
17197 //If we are here, full power is needed
17198 fNeedFullPower = eANI_BOOLEAN_TRUE;
17199 break;
17200 }
17201 }
17202 else if( eSmeCommandWmStatusChange == pCommand->command )
17203 {
17204 //need full power for all
17205 fNeedFullPower = eANI_BOOLEAN_TRUE;
17206 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17207 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017208#ifdef FEATURE_WLAN_TDLS
17209 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17210 {
17211 //TDLS link is getting established. need full power
17212 fNeedFullPower = eANI_BOOLEAN_TRUE;
17213 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17214 }
17215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 case REQUEST_STOP_UAPSD:
17218 case REQUEST_EXIT_WOWL:
17219 if( eSmeCommandRoam == pCommand->command )
17220 {
17221 fNeedFullPower = eANI_BOOLEAN_TRUE;
17222 switch ( pCommand->u.roamCmd.roamReason )
17223 {
17224 case eCsrForcedDisassoc:
17225 case eCsrForcedDisassocMICFailure:
17226 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17227 break;
17228 default:
17229 break;
17230 }
17231 }
17232 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017233 case STOPPED:
17234 case REQUEST_STANDBY:
17235 case STANDBY:
17236 case LOW_POWER:
17237 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017238 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17239 " stopped/standby state %s (%d)" ),
17240 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017241 status = eHAL_STATUS_FAILURE;
17242 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017243 case FULL_POWER:
17244 case REQUEST_FULL_POWER:
17245 default:
17246 //No need to ask for full power. This has to be FULL_POWER state
17247 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017248 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017249 if( pReason )
17250 {
17251 *pReason = reason;
17252 }
17253 if( pfNeedPower )
17254 {
17255 *pfNeedPower = fNeedFullPower;
17256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017257 return ( status );
17258}
17259
Jeff Johnson295189b2012-06-20 16:38:30 -070017260static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17261{
17262 eHalStatus status = eHAL_STATUS_SUCCESS;
17263 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17264 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017265 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017266 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17267 {
17268 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017270 return ( status );
17271}
17272
Jeff Johnson295189b2012-06-20 16:38:30 -070017273tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17274{
17275 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017276 if( pCmd )
17277 {
17278 pMac->roam.sPendingCommands++;
17279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017280 return ( pCmd );
17281}
17282
Jeff Johnson295189b2012-06-20 16:38:30 -070017283void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17284{
17285 if (pMac->roam.sPendingCommands > 0)
17286 {
17287 //All command allocated through csrGetCommandBuffer need to
17288 //decrement the pending count when releasing.
17289 pMac->roam.sPendingCommands--;
17290 smeReleaseCommand( pMac, pCommand );
17291 }
17292 else
17293 {
17294 smsLog(pMac, LOGE, FL( "no pending commands"));
17295 VOS_ASSERT(0);
17296 }
17297}
17298
Jeff Johnson295189b2012-06-20 16:38:30 -070017299//Return SUCCESS is the command is queued, failed
17300eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17301{
17302 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053017303
17304 if (!SME_IS_START(pMac))
17305 {
17306 smsLog( pMac, LOGE, FL("Sme in stop state"));
17307 return eHAL_STATUS_FAILURE;
17308 }
17309
Jeff Johnson295189b2012-06-20 16:38:30 -070017310 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17311 {
17312 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17313 pCommand->u.scanCmd.reason);
17314 return eHAL_STATUS_CSR_WRONG_STATE;
17315 }
17316
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017317 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17318 {
17319 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17320 &pCommand->Link, LL_ACCESS_LOCK);
17321 // process the command queue...
17322 smeProcessPendingQueue(pMac);
17323 status = eHAL_STATUS_SUCCESS;
17324 goto end;
17325 }
17326
Jeff Johnson295189b2012-06-20 16:38:30 -070017327 //We can call request full power first before putting the command into pending Q
17328 //because we are holding SME lock at this point.
17329 status = csrRequestFullPower( pMac, pCommand );
17330 if( HAL_STATUS_SUCCESS( status ) )
17331 {
17332 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017333 //make sure roamCmdPendingList is not empty first
17334 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17335 if( fNoCmdPending )
17336 {
17337 smePushCommand( pMac, pCommand, fHighPriority );
17338 }
17339 else
17340 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017341 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017342 //no list lock is needed since SME lock is held
17343 if( !fHighPriority )
17344 {
17345 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17346 }
17347 else {
17348 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17349 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017351 }
17352 else if( eHAL_STATUS_PMC_PENDING == status )
17353 {
17354 //no list lock is needed since SME lock is held
17355 if( !fHighPriority )
17356 {
17357 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17358 }
17359 else {
17360 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17361 }
17362 //Let caller know the command is queue
17363 status = eHAL_STATUS_SUCCESS;
17364 }
17365 else
17366 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017367 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017368 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017369 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017370 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017371end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017372 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017373}
Jeff Johnson295189b2012-06-20 16:38:30 -070017374eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17375{
17376 eHalStatus status = eHAL_STATUS_SUCCESS;
17377 tSirUpdateAPWPSIEsReq *pMsg;
17378 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17379
17380 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17381 if (NULL == pSession)
17382 {
17383 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17384 return eHAL_STATUS_FAILURE;
17385 }
17386
Jeff Johnson295189b2012-06-20 16:38:30 -070017387 do
17388 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017389 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17390 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17391 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017392 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17393
17394 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017395 VOS_ASSERT(pBuf);
17396
Jeff Johnson295189b2012-06-20 16:38:30 -070017397 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017398 // transactionId
17399 *pBuf = 0;
17400 *( pBuf + 1 ) = 0;
17401 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017402 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017403 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17404 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017405 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017406 //sessionId
17407 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017408 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017409 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017410 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017411 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017412 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017413 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017414 return ( status );
17415}
Jeff Johnson295189b2012-06-20 16:38:30 -070017416eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17417{
17418 eHalStatus status = eHAL_STATUS_SUCCESS;
17419 tSirUpdateAPWPARSNIEsReq *pMsg;
17420 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017421 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17422 if (NULL == pSession)
17423 {
17424 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17425 return eHAL_STATUS_FAILURE;
17426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017427 do
17428 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017429 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17430 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17431 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017432 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017433 pBuf = (tANI_U8 *)&pMsg->transactionId;
17434 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017435 // transactionId
17436 *pBuf = 0;
17437 *( pBuf + 1 ) = 0;
17438 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017439 VOS_ASSERT(pBuf);
17440
Jeff Johnson295189b2012-06-20 16:38:30 -070017441 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017442 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17443 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017444 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017445 // sessionId
17446 *pBuf++ = (tANI_U8)sessionId;
17447
17448 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017449 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017450 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017451 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017452 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017453 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017454 return ( status );
17455}
Jeff Johnson295189b2012-06-20 16:38:30 -070017456
17457#ifdef WLAN_FEATURE_VOWIFI_11R
17458//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17459eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17460{
17461 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17462 tpSirFTPreAuthReq pftPreAuthReq;
17463 tANI_U16 auth_req_len = 0;
17464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017465 auth_req_len = sizeof(tSirFTPreAuthReq);
17466 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017467 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017468 {
17469 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17470 return eHAL_STATUS_RESOURCES;
17471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017472 // Save the SME Session ID here. We need it while processing the preauth response
17473 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017474 vos_mem_zero(pftPreAuthReq, auth_req_len);
17475
17476 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17477 sizeof(pBssDescription->length) + pBssDescription->length);
17478
17479 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17480
17481 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17482
Kiet Lam64c1b492013-07-12 13:56:44 +053017483 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17484 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17485 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17486 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017487
Jeff Johnson295189b2012-06-20 16:38:30 -070017488#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017489 if (csrRoamIs11rAssoc(pMac) &&
17490 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017491 {
17492 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017493 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17494 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017495 }
17496 else
17497#endif
17498 {
17499 pftPreAuthReq->ft_ies_length = 0;
17500 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017501 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17502 sizeof(pBssDescription->length) + pBssDescription->length);
17503 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017504 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17505}
Jeff Johnson295189b2012-06-20 16:38:30 -070017506/*--------------------------------------------------------------------------
17507 * This will receive and process the FT Pre Auth Rsp from the current
17508 * associated ap.
17509 *
17510 * This will invoke the hdd call back. This is so that hdd can now
17511 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17512 ------------------------------------------------------------------------*/
17513void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17514{
17515 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17516 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017517#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017518 tCsrRoamInfo roamInfo;
17519#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017520 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017521
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017522#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017523 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017524 if (status != eHAL_STATUS_SUCCESS) {
17525 /*
17526 * Bail out if pre-auth was not even processed.
17527 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017528 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17529 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017530 return;
17531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017532#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017533 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17534 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17535 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017536 // Implies a success
17537 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017538 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17539 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017540 /* No need to notify qos module if this is a non 11r & ESE roam*/
17541 if (csrRoamIs11rAssoc(pMac)
17542#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17543 || csrRoamIsESEAssoc(pMac)
17544#endif
17545 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017546 {
17547 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17548 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017549#ifdef DEBUG_ROAM_DELAY
17550 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17551#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017552 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17553 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017554 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17555 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017556#ifdef DEBUG_ROAM_DELAY
17557 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17558#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017559 if (eHAL_STATUS_SUCCESS != status)
17560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017561 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017562 return;
17563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017564 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017565 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17566 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017567 if (csrRoamIs11rAssoc(pMac))
17568 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17569 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17570
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017571#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17572 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017573 {
17574 /* read TSF */
17575 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17576
17577 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017578 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017579 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17580 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017581#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017582#ifdef FEATURE_WLAN_LFR
17583 // If Legacy Fast Roaming is enabled, signal the supplicant
17584 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017585 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017586 {
17587 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017588 vos_mem_copy((void *)&roamInfo.bssid,
17589 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017590 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17591 }
17592
17593#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017594
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017595 // If its an Open Auth, FT IEs are not provided by supplicant
17596 // Hence populate them here
17597 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17598 pMac->ft.ftSmeContext.addMDIE = FALSE;
17599 if( csrRoamIs11rAssoc(pMac) &&
17600 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17601 {
17602 tANI_U16 ft_ies_length;
17603 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17604
17605 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17606 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17607 {
17608 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17609 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17610 }
17611
17612 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17613 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17614 {
17615 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17616 }
17617 else
17618 {
17619 // Copy the RIC IEs to reassoc IEs
17620 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17621 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17622 pFTPreAuthRsp->ric_ies_length);
17623 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17624 pMac->ft.ftSmeContext.addMDIE = TRUE;
17625 }
17626 }
17627
Jeff Johnson295189b2012-06-20 16:38:30 -070017628 // Done with it, init it.
17629 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17630}
17631#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017632
Jeff Johnson295189b2012-06-20 16:38:30 -070017633#ifdef FEATURE_WLAN_BTAMP_UT_RF
17634void csrRoamJoinRetryTimerHandler(void *pv)
17635{
17636 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17637 tpAniSirGlobal pMac = pInfo->pMac;
17638 tANI_U32 sessionId = pInfo->sessionId;
17639 tCsrRoamSession *pSession;
17640
17641 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017643 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017644 pSession = CSR_GET_SESSION( pMac, sessionId );
17645 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17646 {
17647 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017649 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017650 }
17651 }
17652 }
17653}
Jeff Johnson295189b2012-06-20 16:38:30 -070017654eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17655{
17656 eHalStatus status = eHAL_STATUS_FAILURE;
17657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17658
17659 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017661 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017662 pSession->maxRetryCount--;
17663 pSession->joinRetryTimerInfo.pMac = pMac;
17664 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017665 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17666 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017667 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017668 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017669 }
17670 }
17671 else
17672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017673 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017674 pSession->maxRetryCount);
17675 }
17676
17677 return (status);
17678}
Jeff Johnson295189b2012-06-20 16:38:30 -070017679eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17680{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017681 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017682 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17683 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017684 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017685 }
17686
17687 return eHAL_STATUS_SUCCESS;
17688}
17689#endif
17690
17691
17692/*
17693 pBuf points to the beginning of the message
17694 LIM packs disassoc rsp as below,
17695 messageType - 2 bytes
17696 messageLength - 2 bytes
17697 sessionId - 1 byte
17698 transactionId - 2 bytes (tANI_U16)
17699 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17700 peerMacAddr - 6 bytes
17701 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17702*/
17703static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17704{
17705 if(pBuf && pRsp)
17706 {
17707 pBuf += 4; //skip type and length
17708 pRsp->sessionId = *pBuf++;
17709 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17710 pBuf += 2;
17711 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17712 pBuf += 4;
17713 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17714 }
17715}
17716
Jeff Johnsond13512a2012-07-17 11:42:19 -070017717eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17718{
17719 static uNvTables nvTables;
17720 eHalStatus status = eHAL_STATUS_SUCCESS;
17721 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17722
17723 /* read the country code from NV and use it */
17724 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17725 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017726 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17727 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017728 return status;
17729 }
17730 else
17731 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017732 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017733 status = eHAL_STATUS_FAILURE;
17734 return status;
17735 }
17736}
17737
17738eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17739{
Kiet Lam64c1b492013-07-12 13:56:44 +053017740 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017741 return eHAL_STATUS_SUCCESS;
17742}
schang86c22c42013-03-13 18:41:24 -070017743
17744eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17745{
17746 tSirSetTxPowerReq *pMsg = NULL;
17747 eHalStatus status = eHAL_STATUS_SUCCESS;
17748 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17749
17750 if (!pSession)
17751 {
17752 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17753 return eHAL_STATUS_FAILURE;
17754 }
17755
Kiet Lam64c1b492013-07-12 13:56:44 +053017756 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17757 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17758 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17759 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17760 pMsg->length = sizeof(tSirSetTxPowerReq);
17761 pMsg->mwPower = mW;
17762 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17763 sizeof(tSirMacAddr));
17764 status = palSendMBMessage(pMac->hHdd, pMsg);
17765 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017766 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017767 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17768 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017769 }
17770 return status;
17771}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017772
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017773eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17774{
17775 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17776 eHalStatus status = eHAL_STATUS_SUCCESS;
17777 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17778
17779 if (!pSession)
17780 {
17781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17782 return eHAL_STATUS_FAILURE;
17783 }
17784 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17785 {
17786 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017787
17788 if( NULL == pMsg )
17789 {
17790 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17791 return eHAL_STATUS_FAILURE;
17792 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017793 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17794 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17795 pMsg->length = sizeof(tANI_U8);
17796 pMsg->seesionId = sessionId;
17797 status = palSendMBMessage(pMac->hHdd, pMsg);
17798 if (!HAL_STATUS_SUCCESS(status))
17799 {
17800 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17801 //pMsg is freed by palSendMBMessage
17802 }
17803 }
17804 else
17805 {
17806 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17807 status = eHAL_STATUS_FAILURE;
17808 }
17809 return status;
17810}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017811/* Returns whether a session is in VOS_STA_MODE...or not */
17812tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17813{
17814 tCsrRoamSession *pSession = NULL;
17815 pSession = CSR_GET_SESSION ( pMac, sessionId );
17816 if(!pSession)
17817 {
17818 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17819 return eANI_BOOLEAN_FALSE;
17820 }
17821 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17822 {
17823 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17824 return eANI_BOOLEAN_FALSE;
17825 }
17826 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17827 {
17828 return eANI_BOOLEAN_FALSE;
17829 }
17830 /* There is a possibility that the above check may fail,because
17831 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17832 * when it is connected.So,we may sneak through the above check even
17833 * if we are not a STA mode INFRA station. So, if we sneak through
17834 * the above condition, we can use the following check if we are
17835 * really in STA Mode.*/
17836
17837 if ( NULL != pSession->pCurRoamProfile )
17838 {
17839 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17840 {
17841 return eANI_BOOLEAN_TRUE;
17842 } else {
17843 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17844 return eANI_BOOLEAN_FALSE;
17845 }
17846 }
17847
17848 return eANI_BOOLEAN_FALSE;
17849}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017850
17851#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17852eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17853 tCsrHandoffRequest *pHandoffInfo)
17854{
17855 eHalStatus status = eHAL_STATUS_SUCCESS;
17856 vos_msg_t msg;
17857
17858 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017859 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17860 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017861 {
17862 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017863 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017864 }
17865 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17866 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17867 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17868 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017869 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017870 pHandoffInfo->bssid,
17871 6);
17872 msg.type = eWNI_SME_HANDOFF_REQ;
17873 msg.bodyptr = pMsg;
17874 msg.reserved = 0;
17875 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17876 {
17877 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017878 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017879 status = eHAL_STATUS_FAILURE;
17880 }
17881 return status;
17882}
17883#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017884
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017885
17886#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017887/* ---------------------------------------------------------------------------
17888 \fn csrSetCCKMIe
17889 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17890 data structure and this IE will be packed inside reassociation request
17891 \param pMac - pMac global structure
17892 \param sessionId - Current session id
17893 \param pCckmIe - pointer to CCKM IE data
17894 \param ccKmIeLen - length of the CCKM IE
17895 \- return Success or failure
17896 -------------------------------------------------------------------------*/
17897VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17898 const tANI_U8 *pCckmIe,
17899 const tANI_U8 ccKmIeLen)
17900{
17901 eHalStatus status = eHAL_STATUS_SUCCESS;
17902 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17903
17904 if (!pSession)
17905 {
17906 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17907 return eHAL_STATUS_FAILURE;
17908 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017909 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017910 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17911 return status;
17912}
17913
17914/* ---------------------------------------------------------------------------
17915 \fn csrRoamReadTSF
17916 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17917 probe response reception from the hand off AP to arrive at the latest TSF value.
17918 \param pMac - pMac global structure
17919 \param pTimestamp - output TSF timestamp
17920 \- return Success or failure
17921 -------------------------------------------------------------------------*/
17922VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17923{
17924 eHalStatus status = eHAL_STATUS_SUCCESS;
17925 tCsrNeighborRoamBSSInfo handoffNode;
17926 tANI_U32 timer_diff = 0;
17927 tANI_U32 timeStamp[2];
17928 tpSirBssDescription pBssDescription = NULL;
17929
17930 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17931 pBssDescription = handoffNode.pBssDescription;
17932
17933 // Get the time diff in milli seconds
17934 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17935 // Convert msec to micro sec timer
17936 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17937
17938 timeStamp[0] = pBssDescription->timeStamp[0];
17939 timeStamp[1] = pBssDescription->timeStamp[1];
17940
17941 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17942
Kiet Lamf2f201e2013-11-16 21:24:16 +053017943 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017944 sizeof (tANI_U32) * 2);
17945 return status;
17946}
17947
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017948#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017949
Agarwal Ashish738843c2014-09-25 12:27:56 +053017950/* ---------------------------------------------------------------------------
17951 \fn csrDisableDfsChannel
17952 \brief This function will call csrApplyChannelPowerCountryInfo to
17953 \ to trim the list on basis of NO_DFS flag.
17954 \param pMac - pMac global structure
17955 \- return void
17956 -------------------------------------------------------------------------*/
17957void csrDisableDfsChannel(tpAniSirGlobal pMac)
17958{
17959 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
17960 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
17961}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053017962
17963/* ---------------------------------------------------------------------------
17964 \fn csrGetStaticUapsdMask
17965 \brief This function will get the static uapsd settings for an existing
17966 \ Infra session.
17967 \param pMac - pMac global structure
17968 \- return void
17969 -------------------------------------------------------------------------*/
17970void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
17971{
17972 tANI_S8 sessionId;
17973 tCsrRoamSession *pSession = NULL;
17974
17975 *staticUapsdMask = 0;
17976 sessionId = csrGetInfraSessionId(pMac);
17977 if(sessionId == -1)
17978 smsLog(pMac, LOGE, FL("Valid session not present."));
17979 else
17980 pSession = CSR_GET_SESSION(pMac, sessionId);
17981
17982 if(!pSession || !pSession->pCurRoamProfile)
17983 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
17984 " pSession:%p"), pSession);
17985 else
17986 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
17987}
17988